refactor: 💡 simplify button icon classes
This commit is contained in:
3 files changed
+15
-18
No files matched your search
@@ -10,7 +10,17 @@
|
||||
border-radius: sizing.rems(xxxs);
|
||||
border: sizing.rems(xxxxs) solid;
|
||||
|
||||
&.rose-button-icon-only {
|
||||
&.has-icon-left > .rose-icon:first-child {
|
||||
margin-left: -(sizing.rems(xs));
|
||||
margin-right: sizing.rems(xxs);
|
||||
}
|
||||
|
||||
&.has-icon-right > .rose-icon:last-child {
|
||||
margin-left: sizing.rems(xxs);
|
||||
margin-right: -(sizing.rems(xs));
|
||||
}
|
||||
|
||||
&.has-icon-only {
|
||||
padding-right: sizing.rems(s);
|
||||
padding-left: sizing.rems(s);
|
||||
.rose-button-body {
|
||||
@@ -37,16 +47,6 @@
|
||||
text-shadow: map.get($default, 'text-shadow');
|
||||
}
|
||||
|
||||
> .rose-button-icon-left {
|
||||
margin-left: -(sizing.rems(xs));
|
||||
margin-right: sizing.rems(xxs);
|
||||
}
|
||||
|
||||
> .rose-button-icon-right {
|
||||
margin-left: sizing.rems(xxs);
|
||||
margin-right: -(sizing.rems(xs));
|
||||
}
|
||||
|
||||
&:not(:disabled) {
|
||||
@if $hover {
|
||||
&:hover {
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
...attributes
|
||||
type={{if @submit "submit" "button"}}
|
||||
disabled={{if @disabled "disabled"}}
|
||||
class="{{if @style (concat "rose-button-" @style)}} {{if @iconOnly "rose-button-icon-only"}}"
|
||||
class="{{if @style (concat "rose-button-" @style)}} {{if @iconLeft "has-icon-left"}} {{if @iconRight "has-icon-right"}} {{if @iconOnly "has-icon-only"}}"
|
||||
>
|
||||
|
||||
{{#if @iconLeft}}
|
||||
<Rose::Icon
|
||||
@name={{@iconLeft}}
|
||||
@size="medium"
|
||||
class="rose-button-icon-left"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
@@ -28,7 +27,6 @@
|
||||
<Rose::Icon
|
||||
@name={{@iconRight}}
|
||||
@size="medium"
|
||||
class="rose-button-icon-right"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -35,14 +35,13 @@ module('Integration | Component | rose/button', function (hooks) {
|
||||
|
||||
test('it supports left and right icons', async function (assert) {
|
||||
await render(hbs`<Rose::Button @iconLeft="chevron-left" />`);
|
||||
assert.ok(find('.rose-button-icon-left'));
|
||||
assert.ok(find('.has-icon-left .rose-icon'));
|
||||
await render(hbs`<Rose::Button @iconRight="chevron-left" />`);
|
||||
assert.ok(find('.rose-button-icon-right'));
|
||||
assert.ok(find('.has-icon-right .rose-icon'));
|
||||
});
|
||||
|
||||
test('it supports an icon-only type', async function (assert) {
|
||||
await render(hbs`<Rose::Button @iconOnly="chevron-left" />`);
|
||||
assert.ok(find('.rose-button-icon-only'));
|
||||
assert.ok(find('.rose-button-icon-only .rose-icon'));
|
||||
assert.ok(find('.has-icon-only .rose-icon'));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user