Skip to content

Commit e4bb101

Browse files
feat(button): add selected state to icon only ghost button (#7784)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 1551b04 commit e4bb101

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

packages/components/src/components/button/_button.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
}
213213
}
214214

215+
.#{$prefix}--btn--icon-only.#{$prefix}--btn--selected {
216+
background: $selected-ui;
217+
}
218+
215219
.#{$prefix}--btn path[data-icon-path='inner-path'] {
216220
fill: none;
217221
}

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ Map {
188188
"type": "string",
189189
},
190190
"iconDescription": [Function],
191+
"isSelected": Object {
192+
"type": "bool",
193+
},
191194
"kind": Object {
192195
"args": Array [
193196
Array [

packages/react/src/components/Button/Button-story.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const props = {
7777
className: 'some-class',
7878
kind: select('Button kind (kind)', kinds, 'primary'),
7979
disabled: boolean('Disabled (disabled)', false),
80+
isSelected: boolean('Selected (isSelected)', false),
8081
size: select('Button size (size)', sizes, 'default'),
8182
renderIcon: !iconToUse || iconToUse.svgData ? undefined : iconToUse,
8283
iconDescription: text(

packages/react/src/components/Button/Button.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const Button = React.forwardRef(function Button(
2323
size,
2424
kind,
2525
href,
26+
isSelected,
2627
tabIndex,
2728
type,
2829
renderIcon: ButtonImageElement,
@@ -43,6 +44,7 @@ const Button = React.forwardRef(function Button(
4344
[`${prefix}--btn--${kind}`]: kind,
4445
[`${prefix}--btn--disabled`]: disabled,
4546
[`${prefix}--btn--icon-only`]: hasIconOnly,
47+
[`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost',
4648
[`${prefix}--tooltip__trigger`]: hasIconOnly,
4749
[`${prefix}--tooltip--a11y`]: hasIconOnly,
4850
[`${prefix}--tooltip--${tooltipPosition}`]: hasIconOnly && tooltipPosition,
@@ -148,6 +150,11 @@ Button.propTypes = {
148150
return undefined;
149151
},
150152

153+
/**
154+
* Specify whether the Button is currently selected
155+
*/
156+
isSelected: PropTypes.bool,
157+
151158
/**
152159
* Specify the kind of Button you want to create
153160
*/

0 commit comments

Comments
 (0)