2019-05-13 19:05:25 +00:00
|
|
|
/**
|
|
|
|
* @module Icon
|
|
|
|
* `Icon` components are glyphs used to indicate important information.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* <Icon @glyph="cancel-square-outline" />
|
|
|
|
* ```
|
|
|
|
* @param glyph=null {String} - The name of the SVG to render inline.
|
2019-10-25 18:16:45 +00:00
|
|
|
* @param [size='m'] {String} - The size of the Icon, can be one of 's', 'm', 'l', 'xlm', 'xl', 'xxl'. The default is 'm'.
|
2019-05-13 19:05:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
import Component from '@ember/component';
|
2019-05-16 19:49:38 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { assert } from '@ember/debug';
|
2019-05-13 19:05:25 +00:00
|
|
|
import layout from '../templates/components/icon';
|
|
|
|
|
2019-10-25 18:16:45 +00:00
|
|
|
const SIZES = ['s', 'm', 'l', 'xlm', 'xl', 'xxl'];
|
2019-05-16 19:49:38 +00:00
|
|
|
|
2019-05-13 19:05:25 +00:00
|
|
|
export default Component.extend({
|
|
|
|
tagName: '',
|
|
|
|
layout,
|
|
|
|
glyph: null,
|
2019-05-16 19:49:38 +00:00
|
|
|
size: 'm',
|
|
|
|
sizeClass: computed('size', function() {
|
|
|
|
let { size } = this;
|
|
|
|
assert(
|
|
|
|
`The size property of ${this.toString()} must be one of the following: ${SIZES.join(', ')}`,
|
|
|
|
SIZES.includes(size)
|
|
|
|
);
|
|
|
|
if (size === 'm') {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return `hs-icon-${size}`;
|
|
|
|
}),
|
2019-05-13 19:05:25 +00:00
|
|
|
});
|