-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next-major' of github.com:primer/react into mp/deprecat…
…e-legacy-label
- Loading branch information
Showing
61 changed files
with
1,664 additions
and
1,512 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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.