From 7961e59925b84bf1c6e5339e116d88418d2326aa Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 7 May 2020 14:44:41 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20simplify=20button=20?= =?UTF-8?q?icon=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addon/styles/rose/utilities/_button.scss | 22 +++++++++---------- .../templates/components/rose/button.hbs | 4 +--- .../components/rose/button-test.js | 7 +++--- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/addons/rose/addon/styles/rose/utilities/_button.scss b/addons/rose/addon/styles/rose/utilities/_button.scss index f07bd5cb5..3bb506024 100644 --- a/addons/rose/addon/styles/rose/utilities/_button.scss +++ b/addons/rose/addon/styles/rose/utilities/_button.scss @@ -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 { diff --git a/addons/rose/addon/templates/components/rose/button.hbs b/addons/rose/addon/templates/components/rose/button.hbs index bb940e89c..f109c1407 100644 --- a/addons/rose/addon/templates/components/rose/button.hbs +++ b/addons/rose/addon/templates/components/rose/button.hbs @@ -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}} {{/if}} @@ -28,7 +27,6 @@ {{/if}} diff --git a/addons/rose/tests/integration/components/rose/button-test.js b/addons/rose/tests/integration/components/rose/button-test.js index 2a717f01f..be532a65f 100644 --- a/addons/rose/tests/integration/components/rose/button-test.js +++ b/addons/rose/tests/integration/components/rose/button-test.js @@ -35,14 +35,13 @@ module('Integration | Component | rose/button', function (hooks) { test('it supports left and right icons', async function (assert) { await render(hbs``); - assert.ok(find('.rose-button-icon-left')); + assert.ok(find('.has-icon-left .rose-icon')); await render(hbs``); - 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``); - assert.ok(find('.rose-button-icon-only')); - assert.ok(find('.rose-button-icon-only .rose-icon')); + assert.ok(find('.has-icon-only .rose-icon')); }); });