chore: 🤖 add size option to icon component
This commit is contained in:
5 files changed
+32
-5
No files matched your search
@@ -1,9 +1,19 @@
|
||||
@use 'variables/sizing';
|
||||
|
||||
.rose-icon {
|
||||
--size: #{sizing.rems(l)};
|
||||
|
||||
&.medium {
|
||||
--size: #{sizing.rems(m)};
|
||||
}
|
||||
|
||||
&.small {
|
||||
--size: #{sizing.rems(s)};
|
||||
}
|
||||
|
||||
> svg {
|
||||
width: sizing.rems(l);
|
||||
height: sizing.rems(l);
|
||||
vertical-align: top;
|
||||
width: var(--size);
|
||||
height: var(--size);
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
<span class="rose-icon">
|
||||
<span class="rose-icon {{@size}}">
|
||||
{{inline-svg @name}}
|
||||
</span>
|
||||
@@ -2,6 +2,8 @@ Dummy app index template
|
||||
|
||||
<h2>Icon</h2>
|
||||
<Rose::Icon @name="alert-circle-fill" />
|
||||
<Rose::Icon @name="alert-circle-fill" @size="medium" />
|
||||
<Rose::Icon @name="alert-circle-fill" @size="small" />
|
||||
|
||||
<h2>Button</h2>
|
||||
<Rose::Button @style="primary">Primary</Rose::Button>
|
||||
|
||||
@@ -7,7 +7,7 @@ export default {
|
||||
|
||||
export const Normal = () => ({
|
||||
template: hbs`
|
||||
<Rose::Icon @name={{name}} />
|
||||
<Rose::Icon @name={{name}} @size={{size}} />
|
||||
|
||||
<br>
|
||||
|
||||
@@ -25,5 +25,15 @@ export const Normal = () => ({
|
||||
},
|
||||
'check-circle-outline'
|
||||
),
|
||||
|
||||
size: select(
|
||||
'size',
|
||||
{
|
||||
'large (24px / default)': 'large',
|
||||
'medium (16px)': 'medium',
|
||||
'small (12px)': 'small',
|
||||
},
|
||||
'large'
|
||||
),
|
||||
},
|
||||
});
|
||||
@@ -10,4 +10,9 @@ module('Integration | Component | rose/icon', function (hooks) {
|
||||
await render(hbs`<Rose::Icon @name="unfold-more" />`);
|
||||
assert.ok(find('svg'));
|
||||
});
|
||||
|
||||
test('it supports optional @size', async function (assert) {
|
||||
await render(hbs`<Rose::Icon @name="unfold-more" @size="small" />`);
|
||||
assert.ok(find('.small'));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user