-
Notifications
You must be signed in to change notification settings - Fork 616
Button deprecation #1908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Button deprecation #1908
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dd11ad5
Move old button to deprecated
pksjce eaec908
Move Button2 to main bundle
pksjce 6084fa0
Add migration docs
pksjce f096f3a
More changes from the checklist
pksjce 5660989
More deprecation
pksjce 222dddb
Update tests
pksjce e81a242
Add deprecated details
pksjce 0c286b7
Create many-roses-hammer.md
pksjce 0489b6a
Update .changeset/many-roses-hammer.md
pksjce b11a858
Update many-roses-hammer.md
pksjce c97fd6e
Update many-roses-hammer.md
pksjce d8c962e
Update many-roses-hammer.md
pksjce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
--- | ||
'@primer/react': major | ||
--- | ||
### Button deprecation | ||
|
||
A new set of `Button` components brings a much needed update. Previously to `v35`, `Button` was a set of seven independent components. In `v35`, we now have common `Button` usage guidelines and more convenient API. | ||
|
||
#### Button variants | ||
We now support a variant property which takes values `primary`, `invisible`, `outline` and `danger` | ||
|
||
<table> | ||
<tr> | ||
<th> Before (v34)</th> <th> After (v35)</th> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
|
||
import { ButtonPrimary, ButtonInvisible, | ||
ButtonOutline, ButtonDanger } | ||
from '@primer/react' | ||
|
||
<ButtonPrimary> | ||
Primary Button | ||
</ButtonPrimary> | ||
<ButtonInvisible> | ||
Invisible Button | ||
</ButtonInvisible> | ||
<ButtonOutline> | ||
Outline Button | ||
</ButtonOutline> | ||
<ButtonDanger> | ||
Danger Button | ||
</ButtonDanger> | ||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
|
||
import { Button } from '@primer/react' | ||
|
||
<Button variant="primary"> | ||
Primary Button | ||
</Button> | ||
<Button variant="invisible"> | ||
Invisible Button | ||
</Button> | ||
<Button variant="outline"> | ||
Outline Button | ||
</Button> | ||
<Button variant="danger"> | ||
Danger Button | ||
</Button> | ||
``` | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
### Leading and Trailing icons | ||
|
||
In the previous component, we allowed icon components to be direct children. This results in a lot of custom styling for the icon components. | ||
In the new one, we now have `leadinIcon` and `trailingIcon` properties. | ||
|
||
<table> | ||
<tr> | ||
<th> Before (v34)</th> <th> After (v35)</th> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<Button> | ||
<SearchIcon /> | ||
Search | ||
</Button> | ||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<Button leadingIcon={SearchIcon}>Search</Button> | ||
``` | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
### Icon buttons | ||
|
||
Icon only buttons are common usages in products. So we now have a component for the specific usecase | ||
|
||
<table> | ||
<tr> | ||
<th> Before (v34)</th> <th> After (v35)</th> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<Button> | ||
<XIcon /> | ||
</Button> | ||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<IconButton aria-label="Close button" icon={XIcon} /> | ||
``` | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
|
||
### Size property | ||
|
||
Earlier we used `variant` to mean size property. Now we have a new property called `size` which is more semantically correct. | ||
|
||
<table> | ||
<tr> | ||
<th> Before (v34)</th> <th> After (v35)</th> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<Button variant="small">Small button</Button> | ||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
<Button size="small">Small button</Button> | ||
``` | ||
|
||
</td> | ||
</tr> | ||
</table> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
import styled from 'styled-components' | ||
import {get} from '../constants' | ||
import sx, {SxProp} from '../sx' | ||
import {ComponentProps} from '../utils/types' | ||
import ButtonBase, {ButtonBaseProps} from './ButtonBase' | ||
import React, {forwardRef} from 'react' | ||
import {ButtonProps} from './types' | ||
import {ButtonBase} from './ButtonBase' | ||
|
||
const Button = styled(ButtonBase)<ButtonBaseProps & SxProp>` | ||
color: ${get('colors.btn.text')}; | ||
background-color: ${get('colors.btn.bg')}; | ||
border: 1px solid ${get('colors.btn.border')}; | ||
box-shadow: ${get('shadows.btn.shadow')}, ${get('shadows.btn.insetShadow')}}; | ||
|
||
&:hover { | ||
background-color: ${get('colors.btn.hoverBg')}; | ||
border-color: ${get('colors.btn.hoverBorder')}; | ||
} | ||
|
||
// focus must come before :active so that the active box shadow overrides | ||
&:focus { | ||
border-color: ${get('colors.btn.focusBorder')}; | ||
box-shadow: ${get('shadows.btn.focusShadow')}; | ||
} | ||
|
||
&:active { | ||
background-color: ${get('colors.btn.selectedBg')}; | ||
box-shadow: ${get('shadows.btn.shadowActive')}; | ||
} | ||
|
||
&:disabled { | ||
color: ${get('colors.primer.fg.disabled')}; | ||
background-color: ${get('colors.btn.bg')}; | ||
border-color: ${get('colors.btn.border')}; | ||
const ButtonComponent = forwardRef<HTMLButtonElement, ButtonProps>( | ||
({children, ...props}, forwardedRef): JSX.Element => { | ||
return ( | ||
<ButtonBase ref={forwardedRef} {...props} as="button"> | ||
{children} | ||
</ButtonBase> | ||
) | ||
} | ||
) | ||
|
||
${sx}; | ||
` | ||
ButtonComponent.displayName = 'Button' | ||
|
||
export type ButtonProps = ComponentProps<typeof Button> | ||
export default Button | ||
export {ButtonComponent} |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo for later.. we'd want to make these tables, but we can do this in a follow up PR