-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a button section to the styleguide (#2088)
- Loading branch information
Showing
21 changed files
with
215 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/venia-styleguide/src/components/Button/Button.css
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,47 @@ | ||
.root { | ||
--color: var(--venia-global-color-gray-900); | ||
background: none; | ||
border-color: rgb(var(--color)); | ||
border-radius: 1.5rem; | ||
border-style: solid; | ||
border-width: 1px; | ||
color: rgb(var(--color)); | ||
font-size: var(--venia-global-text-fontSize-100); | ||
font-weight: var(--venia-global-text-fontWeight-bold); | ||
height: 2rem; | ||
line-height: var(--venia-global-text-lineHeight-300); | ||
max-width: 100%; | ||
min-width: 7.5rem; | ||
outline: none; | ||
padding: 0 1rem; | ||
transition-duration: 384ms; | ||
transition-property: background-color, border-color, color; | ||
transition-timing-function: var(--venia-global-anim-standard); | ||
} | ||
|
||
.root:hover { | ||
--color: var(--venia-brand-color-1-700); | ||
} | ||
|
||
.root:focus { | ||
box-shadow: 0 0 0 2px rgb(var(--venia-pattern-glow-color)), | ||
0 0 0.5rem 2px rgb(var(--color) / 0.2); | ||
--color: var(--venia-brand-color-1-700); | ||
} | ||
|
||
.root--priority-high { | ||
composes: root; | ||
background-color: rgb(var(--color)); | ||
color: rgb(var(--venia-global-color-gray-50)); | ||
} | ||
|
||
.root--priority-normal { | ||
composes: root; | ||
} | ||
|
||
.content { | ||
min-width: 0; | ||
overflow: hidden; | ||
text-overflow: clip; | ||
white-space: nowrap; | ||
} |
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,25 @@ | ||
import React, { useMemo } from 'react'; | ||
|
||
import finalizeClasses from '../../util/finalizeClasses'; | ||
import classes from './Button.css'; | ||
|
||
const Button = props => { | ||
const { children, priority, ...rest } = props; | ||
|
||
const finalClasses = useMemo(() => { | ||
return finalizeClasses(classes, { priority }); | ||
}, [priority]); | ||
|
||
return ( | ||
<button {...rest} className={finalClasses.get('root')}> | ||
<span className={classes.content}>{children}</span> | ||
</button> | ||
); | ||
}; | ||
|
||
export default Button; | ||
|
||
Button.defaultProps = { | ||
priority: 'normal', | ||
type: 'button' | ||
}; |
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 @@ | ||
export { default } from './Button'; |
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
6 changes: 6 additions & 0 deletions
6
packages/venia-styleguide/src/components/ExampleGroup/ExampleGroup.css
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,6 @@ | ||
.root { | ||
align-items: center; | ||
display: grid; | ||
gap: 2rem; | ||
justify-items: center; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/venia-styleguide/src/components/ExampleGroup/ExampleGroup.js
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,7 @@ | ||
import React from 'react'; | ||
|
||
import classes from './ExampleGroup.css'; | ||
|
||
const ExampleGroup = props => <div {...props} className={classes.root} />; | ||
|
||
export default ExampleGroup; |
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 @@ | ||
export { default } from './ExampleGroup'; |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Article from "../../components/Article" | ||
import Section from "../../components/Section" | ||
import TableOfContents from "../../components/TableOfContents" | ||
|
||
import Behaviors from "./sections/Behaviors" | ||
import Options from "./sections/Options" | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce | ||
quis euismod nisi. Morbi metus mauris, volutpat ac aliquet eget, | ||
laoreet vel tortor. Pellentesque commodo tellus nibh, vitae | ||
varius lectus pharetra in. Aliquam quis nisi ligula. Proin sit | ||
amet mauris ac lacus efficitur varius eget in urna. Ut sagittis | ||
feugiat ex et dictum. Nam ut tempor urna, at dapibus erat. | ||
Aenean ac dui a tellus venenatis accumsan. | ||
|
||
*** | ||
|
||
<Section title="Table of contents"> | ||
<TableOfContents /> | ||
</Section> | ||
<Section title="Options"> | ||
<Options /> | ||
</Section> | ||
<Section title="Behaviors"> | ||
<Behaviors /> | ||
</Section> | ||
|
||
export const title = "Button" | ||
export default Article |
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 @@ | ||
export { default } from './Button'; |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/button/sections/Behaviors/FlexibleWidth.md
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,3 @@ | ||
#### Flexible width | ||
|
||
A button derives its width from the text. |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/button/sections/Behaviors/MinimumWidth.md
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,3 @@ | ||
#### Minimum width | ||
|
||
Standard buttons have a minimum width of `7.5rem`, ensuring their shape is easily identifiable even when the text is short. Quiet buttons have no minimum width. |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/button/sections/Behaviors/TextOverflow.md
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,3 @@ | ||
#### Text overflow | ||
|
||
If the text overflows, it will clip, not wrap to a second line. To avoid clipping, keep the text as concise as possible. |
27 changes: 27 additions & 0 deletions
27
packages/venia-styleguide/src/pages/button/sections/Behaviors/index.md
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,27 @@ | ||
import Button from "../../../../components/Button" | ||
import Columns from "../../../../components/Columns" | ||
import ExampleGroup from "../../../../components/ExampleGroup" | ||
import FlexibleWidth from "./FlexibleWidth" | ||
import MinimumWidth from "./MinimumWidth" | ||
import TextOverflow from "./TextOverflow" | ||
|
||
<Columns reverse> | ||
<FlexibleWidth /> | ||
<ExampleGroup> | ||
<Button>Send</Button> | ||
<Button>Create Account</Button> | ||
<Button>Enter Registration Code</Button> | ||
</ExampleGroup> | ||
</Columns> | ||
<Columns reverse> | ||
<MinimumWidth /> | ||
<ExampleGroup> | ||
<Button>Go</Button> | ||
</ExampleGroup> | ||
</Columns> | ||
<Columns reverse> | ||
<TextOverflow /> | ||
<ExampleGroup> | ||
<Button>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis euismod nisi</Button> | ||
</ExampleGroup> | ||
</Columns> |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/button/sections/Options/HighPriority.md
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,3 @@ | ||
#### High priority | ||
|
||
A high priority button is more prominent than other buttons, attracting the user's attention and inviting them to consider taking a particular action. Avoid having more than one high priority button on the screen at once. |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/button/sections/Options/NormalPriority.md
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,3 @@ | ||
#### Normal priority | ||
|
||
A normal button presents the user with an optional or less preferable action. |
9 changes: 9 additions & 0 deletions
9
packages/venia-styleguide/src/pages/button/sections/Options/OptionsTable.md
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,9 @@ | ||
#### Table of options | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce | ||
quis euismod nisi. | ||
|
||
Property | Values | Default Value | ||
:--- | :--- | :--- | ||
priority | high / normal | normal | ||
quiet | true / false | false |
24 changes: 24 additions & 0 deletions
24
packages/venia-styleguide/src/pages/button/sections/Options/index.md
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,24 @@ | ||
import Button from "../../../../components/Button" | ||
import Columns from "../../../../components/Columns" | ||
import ExampleGroup from "../../../../components/ExampleGroup" | ||
import HighPriority from "./HighPriority" | ||
import NormalPriority from "./NormalPriority" | ||
import OptionsTable from "./OptionsTable" | ||
|
||
<Columns reverse> | ||
<HighPriority /> | ||
<ExampleGroup> | ||
<Button priority="high"> | ||
Submit | ||
</Button> | ||
</ExampleGroup> | ||
</Columns> | ||
<Columns reverse> | ||
<NormalPriority /> | ||
<ExampleGroup> | ||
<Button priority="normal"> | ||
Cancel | ||
</Button> | ||
</ExampleGroup> | ||
</Columns> | ||
<OptionsTable /> |
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