Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Load icons from sprite file #3642

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
- "@formatjs/intl-locale"
- "@formatjs/intl-pluralrules"
- "@formatjs/intl-relativetimeformat"
- "@fortawesome"
- "@percy/cli"
- "@percy/ember"
- "broccoli-file-creator"
Expand Down
2 changes: 1 addition & 1 deletion addon/components/editable-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{/if}}
</button>
{{#if isTruncated}}
<FaIcon @icon="ellipsis" @transform="down-6" />
<EllipsisIcon />
<button
class="expand-text-button"
type="button"
Expand Down
14 changes: 14 additions & 0 deletions addon/components/ellipsis-icon.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<svg
class="fa-ellipsis awesome-icon"
aria-hidden="true"
focusable="false"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<g transform="translate(224 256)">
<g transform="translate(0, 192)">
<use xlink:href="/fontawesome/solid.svg#ellipsis" transform="translate(-224 -256)"></use>
</g>
</g>
</svg>
21 changes: 21 additions & 0 deletions addon/components/fa-icon.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{! template-lint-disable eol-last }}
<svg
class="awesome-icon fa-{{@icon}} {{if @spin "spin"}} {{this.flip}} {{if @listItem "list-item"}}"
data-icon={{@icon}}
aria-hidden={{this.ariaHidden}}
focusable={{this.focusable}}
role="img"
fill="currentColor"
aria-labelledby={{this.titleId}}
...attributes
>
{{#if @title}}
<title id={{this.titleId}}>{{@title}}</title>
{{/if}}

{{#if (eq @prefix "brands")}}
<use xlink:href="/fontawesome/brands.svg#{{@icon}}"></use>
{{else}}
<use xlink:href="/fontawesome/solid.svg#{{@icon}}"></use>
{{/if}}
</svg>
40 changes: 40 additions & 0 deletions addon/components/fa-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Component from '@glimmer/component';
import { guidFor } from '@ember/object/internals';

export default class FaIconComponent extends Component {
get uniqueId() {
return guidFor(this);
}

get titleId() {
if (!this.args.title) {
return null;
}

return `inline-title-${this.uniqueId}`;
}

get ariaHidden() {
return this.args.title ? 'false' : 'true';
}

get focusable() {
return this.args.title ? 'true' : 'false';
}

get flip() {
if (this.args.flip === 'horizontal') {
return 'flip-horizontal';
}

if (this.args.flip === 'vertical') {
return 'flip-vertical';
}

if (this.args.flip === 'both') {
return 'flip-horizontal flip-vertical';
}

return '';
}
}
4 changes: 2 additions & 2 deletions addon/components/lm-type-icon.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<FaIcon
<FaIcon
class="lm-type-icon"
@icon={{this.icon}}
@listItem={{@listItem}}
@fixedWidth={{@fixedWidth}}
@title={{t this.title}}
data-test-lm-type-icon
data-test-lm-type-icon
/>
2 changes: 1 addition & 1 deletion addon/components/truncate-text.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span class="truncate-text" data-test-truncate-text ...attributes>
{{this.displayText}}
{{#if this.isTruncated}}
<FaIcon @icon="ellipsis" @transform="down-6"/>
<EllipsisIcon />
<button
class="expand-buttons"
aria-label={{t "general.expand"}}
Expand Down
1 change: 1 addition & 0 deletions app/components/ellipsis-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ilios-common/components/ellipsis-icon';
1 change: 1 addition & 0 deletions app/components/fa-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ilios-common/components/fa-icon';
2 changes: 2 additions & 0 deletions app/styles/ilios-common/components.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "components/api-version-notice";
@import "components/awesome-icon";
@import "components/back-link";
@import "components/body";
@import "components/breadcrumbs";
Expand Down Expand Up @@ -48,6 +49,7 @@
@import "components/detail-taxonomies";
@import "components/detail-terms-list";
@import "components/editinplace";
@import "components/ellipsis-icon";
@import "components/event-not-found";
@import "components/flatpickr";
@import "components/html-editor";
Expand Down
63 changes: 63 additions & 0 deletions app/styles/ilios-common/components/awesome-icon.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*!
* Copied and Modified from https://fontawesome.com/license/free [MIT]
*/

.awesome-icon {
width: 1em;
height: 1em;
vertical-align: -0.125em;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: inline-block;
font-style: normal;
font-variant: normal;
line-height: 1; /* stylelint-disable-line property-disallowed-list */
text-rendering: auto;

&.spin {
animation-name: awesome-spin;
animation-delay: 0s;
animation-direction: normal;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-timing-function: linear;

@media (prefers-reduced-motion: reduce) {
animation-delay: -1ms;
animation-duration: 1ms;
animation-iteration-count: 1;
transition-delay: 0s;
transition-duration: 0s;
}
}

&.fixed-width {
text-align: center;
width: 1.25em;
}

&.list-item {
left: calc(var(--fa-li-width, 2em) * -1);
position: absolute;
text-align: center;
width: var(--fa-li-width, 2em);
line-height: inherit; /* stylelint-disable-line property-disallowed-list */
}

&.flip-horizontal {
transform: scale(-1, 1);
}

&.flip-vertical {
transform: scale(1, -1);
}

@keyframes awesome-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
}
3 changes: 3 additions & 0 deletions app/styles/ilios-common/components/ellipsis-icon.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ellipsis-icon {
transform-origin: 0.4375em 0.875em;
}
4 changes: 4 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint camelcase: 0 */

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
const broccoliAssetRevDefaults = require('broccoli-asset-rev/lib/default-options');

module.exports = function (defaults) {
const app = new EmberAddon(defaults, {
Expand All @@ -18,6 +19,9 @@ module.exports = function (defaults) {
'ember-simple-auth': {
useSessionSetupMethod: true, //can be removed in ESA v5.x
},
fingerprint: {
extensions: broccoliAssetRevDefaults.extensions.concat(['svg']),
},
});

/*
Expand Down
Loading
Loading