Skip to content

Commit 9698f5d

Browse files
fix(button): update button kind prop type (#7212)
* refactor(button): update class names to double dash convention * fix(button): update button kind prop type * chore: update snapshots Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent d4ae38f commit 9698f5d

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@
283283
color: $text-04;
284284
}
285285

286-
&-tertiary {
286+
// TODO: deprecate single dash tertiary
287+
&-tertiary,
288+
&--tertiary {
287289
@include button-theme(
288290
transparent,
289291
$danger-02,
@@ -309,7 +311,9 @@
309311
}
310312
}
311313

312-
&-ghost {
314+
// TODO: deprecate single dash ghost
315+
&-ghost,
316+
&--ghost {
313317
@include button-theme(
314318
transparent,
315319
transparent,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ Map {
190190
"danger",
191191
"ghost",
192192
"danger--primary",
193+
"danger--ghost",
194+
"danger--tertiary",
193195
"tertiary",
194196
],
195197
],
@@ -2450,6 +2452,8 @@ Map {
24502452
"danger",
24512453
"ghost",
24522454
"danger--primary",
2455+
"danger--ghost",
2456+
"danger--tertiary",
24532457
"tertiary",
24542458
],
24552459
],
@@ -2554,6 +2558,8 @@ Map {
25542558
"danger",
25552559
"ghost",
25562560
"danger--primary",
2561+
"danger--ghost",
2562+
"danger--tertiary",
25572563
"tertiary",
25582564
],
25592565
],
@@ -3366,6 +3372,8 @@ Map {
33663372
"danger",
33673373
"ghost",
33683374
"danger--primary",
3375+
"danger--ghost",
3376+
"danger--tertiary",
33693377
"tertiary",
33703378
],
33713379
],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ export const Danger = () => {
159159
<>
160160
<Button kind="danger">Button</Button>
161161
&nbsp;
162-
<Button kind="danger-tertiary">Tertiary Danger Button</Button>
162+
<Button kind="danger--tertiary">Tertiary Danger Button</Button>
163163
&nbsp;
164-
<Button kind="danger-ghost">Ghost Danger Button</Button>
164+
<Button kind="danger--ghost">Ghost Danger Button</Button>
165165
</>
166166
);
167167
};

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,20 @@ describe('DangerButton', () => {
277277
});
278278

279279
describe('Renders tertiary variation as expected', () => {
280-
const wrapper = shallow(<Button kind="danger-tertiary" />);
280+
const wrapper = shallow(<Button kind="danger--tertiary" />);
281281

282282
it('has the expected classes', () => {
283-
expect(wrapper.hasClass(`${prefix}--btn--danger-tertiary`)).toEqual(true);
283+
expect(wrapper.hasClass(`${prefix}--btn--danger--tertiary`)).toEqual(
284+
true
285+
);
284286
});
285287
});
286288

287289
describe('Renders ghost variation as expected', () => {
288-
const wrapper = shallow(<Button kind="danger-ghost" />);
290+
const wrapper = shallow(<Button kind="danger--ghost" />);
289291

290292
it('has the expected classes', () => {
291-
expect(wrapper.hasClass(`${prefix}--btn--danger-ghost`)).toEqual(true);
293+
expect(wrapper.hasClass(`${prefix}--btn--danger--ghost`)).toEqual(true);
292294
});
293295
});
294296
});

packages/react/src/components/Button/Button.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ user interacts with it.
5959

6060
Icon buttons allow users to take actions, and make choices, with a single tap.
6161
Icon buttons can take the form of any of the seven types (Primary, Secondary,
62-
Tertiary, Danger, Danger tertiary, Danger ghost and Ghost) but most commonly will be styled as primary or ghost
63-
buttons.
62+
Tertiary, Danger, Danger tertiary, Danger ghost and Ghost) but most commonly
63+
will be styled as primary or ghost buttons.
6464

6565
<Preview>
6666
<Story id="button--icon-button" />
@@ -162,24 +162,25 @@ button is interacted with.
162162
### Button `kind`
163163
164164
Carbon has seven types of buttons, `primary`, `secondary`, `tertiary`, `ghost`,
165-
`danger`, `danger-tertiary`, and `danger-ghost`. If no `kind` is specified, a `primary` button will be rendered.
166-
For more information on when to use each variant, check out the
165+
`danger`, `danger--tertiary`, and `danger--ghost`. If no `kind` is specified, a
166+
`primary` button will be rendered. For more information on when to use each
167+
variant, check out the
167168
[design documentation](https://www.carbondesignsystem.com/components/button/usage#overview)
168169
169170
<Button>Primary</Button> <Button kind="secondary">Secondary</Button> <Button kind="tertiary">
170171
Tertiary{' '}
171-
</Button> <Button kind="danger">Danger</Button> <Button kind="danger-tertiary">Danger Tertiary</Button>
172-
<Button kind="danger-ghost">Danger Ghost</Button> <Button kind="ghost">
173-
Ghost
172+
</Button> <Button kind="danger">Danger</Button> <Button kind="danger--tertiary">
173+
Danger Tertiary
174174
</Button>
175+
<Button kind="danger--ghost">Danger Ghost</Button> <Button kind="ghost">Ghost</Button>
175176
176177
```jsx
177178
<Button>Primary</Button>
178179
<Button kind="secondary">Secondary</Button>
179180
<Button kind="tertiary">Tertiary</Button>
180181
<Button kind="danger">Danger</Button>
181-
<Button kind="danger-tertiary">Danger Tertiary</Button>
182-
<Button kind="danger-ghost">Danger Ghost</Button>
182+
<Button kind="danger--tertiary">Danger Tertiary</Button>
183+
<Button kind="danger--ghost">Danger Ghost</Button>
183184
<Button kind="ghost">Ghost</Button>
184185
```
185186

packages/react/src/prop-types/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ export const ButtonKinds = [
1111
'danger',
1212
'ghost',
1313
'danger--primary',
14+
'danger--ghost',
15+
'danger--tertiary',
1416
'tertiary',
1517
];

0 commit comments

Comments
 (0)