diff --git a/addons/rose/addon/styles/rose/utilities/_button.scss b/addons/rose/addon/styles/rose/utilities/_button.scss index ea1e9b539..f07bd5cb5 100644 --- a/addons/rose/addon/styles/rose/utilities/_button.scss +++ b/addons/rose/addon/styles/rose/utilities/_button.scss @@ -9,6 +9,19 @@ padding: sizing.rems(off-xs) sizing.rems(l); border-radius: sizing.rems(xxxs); border: sizing.rems(xxxxs) solid; + + &.rose-button-icon-only { + padding-right: sizing.rems(s); + padding-left: sizing.rems(s); + .rose-button-body { + position: absolute; + top: -1000px; + left: -1000px; + width: 1px; + height: 1px; + opacity: 0; + } + } } @mixin button-style($name, $default, $hover: &, $active: &, $disabled: &) { diff --git a/addons/rose/addon/templates/components/rose/button.hbs b/addons/rose/addon/templates/components/rose/button.hbs index c9ff41a6b..19f28bca1 100644 --- a/addons/rose/addon/templates/components/rose/button.hbs +++ b/addons/rose/addon/templates/components/rose/button.hbs @@ -2,7 +2,7 @@ ...attributes type={{if @submit "submit" "button"}} disabled={{if @disabled "disabled"}} - class={{if @style (concat "rose-button-" @style)}} + class="{{if @style (concat "rose-button-" @style)}} {{if @iconOnly "rose-button-icon-only"}}" > {{#if @iconLeft}} @@ -17,6 +17,14 @@ {{yield}} + {{#if @iconOnly}} + + {{/if}} + {{#if @iconRight}} ({ onClick: action('clicked'), } }); + +export const IconOnly = () => ({ + template: hbs` +

Icon-only buttons visually hide their text, revealing just an icon. + It's still important to include meaningful text in the body of the + button for accessibility purposes.

+ + + {{text}} + + `, + context: { + text: text('text', 'Button'), + iconOnly: select('iconOnly', icons, 'copy-action'), + } +});