Skip to content

Commit 4d99527

Browse files
committed
Add migration docs
1 parent 8b5e4ce commit 4d99527

File tree

3 files changed

+106
-2
lines changed

3 files changed

+106
-2
lines changed

docs/content/drafts/Button2.mdx renamed to docs/content/Button.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ storybook: '/react/storybook?path=/story/composite-components-button2'
77
description: Use button for the main actions on a page or form.
88
---
99

10-
import {Props} from '../../src/props'
11-
import {ComponentChecklist} from '../../src/component-checklist'
1210
import {Button, IconButton, LinkButton} from '@primer/react/drafts'
1311

1412
## Usage

docs/content/Buttons.mdx renamed to docs/content/deprecated/Buttons.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ source: https://github.com/primer/react/blob/main/src/Button
66
storybook: '/react/storybook?path=/story/composite-components-button--default-button'
77
---
88

9+
## Deprecation
10+
11+
Use [Button](/Button) instead.
12+
13+
For more info on the changes, have a look at the migration guide.
14+
[Button migration guide](/migration-guide/Button)
15+
916
`Button` is used for actions, like in forms, while `Link` is used for destinations, or moving from one page to another.
1017

1118
In special cases where you'd like to use a `<a>` styled like a Button, use `<Button as='a'>` and provide an `href`.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Button migration guide
3+
---
4+
5+
## Summary
6+
7+
The new set of Button components brings a much needed update.
8+
The older version was a set of seven different components. Each variant of the component had a separate component.
9+
The guidelines to put in icons inside the buttons was also vague. With the new components, we now have a great guidance for common button usage.
10+
11+
## Change list
12+
13+
### Button variants
14+
15+
We now support a variant property which takes values `primary`, `invisible`, `outline` and `danger`
16+
17+
#### Before
18+
19+
```jsx
20+
import {ButtonPrimary, ButtonInvisible, ButtonOutline, ButtonDanger} from '@primer/react'
21+
22+
<ButtonPrimary>Primary Button</ButtonPrimary>
23+
24+
<ButtonInvisible>Invisible Button</ButtonInvisible>
25+
26+
<ButtonOutline>Outline Button</ButtonOutline>
27+
28+
<ButtonDanger>Danger Button</ButtonDanger>
29+
30+
```
31+
32+
#### After
33+
34+
```jsx
35+
import {Button} from '@primer/react'
36+
37+
<Button variant="primary">Primary Button</Button>
38+
39+
<Button variant="invisible">Invisible Button</Button>
40+
41+
<Button variant="outline">Outline Button</Button>
42+
43+
<Button variant="danger">Danger Button</Button>
44+
45+
```
46+
47+
### Leading and Trailing icons
48+
49+
In the previous component, we allowed icon components to be direct children. This results in a lot of custom styling for the icon components.
50+
In the new one, we now have `leadinIcon` and `trailingIcon` properties.
51+
52+
#### Before
53+
54+
```jsx
55+
<Button>
56+
<SearchIcon />
57+
Search
58+
</Button>
59+
```
60+
61+
#### After
62+
63+
```jsx
64+
<Button leadingIcon={SearchIcon}>Search</Button>
65+
```
66+
67+
### Icon buttons
68+
69+
Icon only buttons are common usages in products. So we now have a component for the specific usecase
70+
71+
#### Before
72+
73+
```jsx
74+
<Button>
75+
<XIcon />
76+
</Button>
77+
```
78+
79+
#### After
80+
81+
```jsx
82+
<IconButton aria-label="Close button" icon={XIcon} />
83+
```
84+
85+
### Size property
86+
87+
Earlier we used `variant` to mean size property. Now we have a new property called `size` which is more semantically correct.
88+
89+
#### Before
90+
91+
```jsx
92+
<Button variant="small">Small button</Button>
93+
```
94+
95+
#### After
96+
97+
```jsx
98+
<Button size="small">Small button</Button>
99+
```

0 commit comments

Comments
 (0)