-
Notifications
You must be signed in to change notification settings - Fork 683
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
Add color section to styleguide #2030
Merged
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b70e3f7
Add color page
jimbo f2cbec7
Add new tones
jimbo 6552d20
Update colors
jimbo ab2f6a8
Add tokens for new tones
jimbo 80b34df
Add sections
jimbo b7e0928
Adjust break styles
jimbo a3cefd2
Adjust heading size
jimbo 3d6e090
Merge branch 'develop' into jimbo/styleguide-color
supernova-at 3744970
Merge branch 'develop' into jimbo/styleguide-color
jimbo 43176ee
Merge branch 'develop' into jimbo/styleguide-color
jimbo 5ff24f7
Merge branch 'develop' into jimbo/styleguide-color
jimbo ee11af7
Extract contrast utils
jimbo 01ce8b0
Merge branch 'develop' into jimbo/styleguide-color
jimbo 03d4953
Distribute colors into sections
jimbo 26ddce2
Merge branch 'develop' into jimbo/styleguide-color
jimbo 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 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,8 @@ | ||
.root { | ||
display: grid; | ||
gap: 1.5rem; | ||
grid-template-columns: repeat(auto-fill, 12rem); | ||
justify-content: center; | ||
max-width: 52.5rem; | ||
min-width: 12rem; | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
|
||
import Tone from './Tone'; | ||
import classes from './Hue.css'; | ||
|
||
const Hue = props => { | ||
const { hue, tones } = props; | ||
|
||
const toneElements = Array.from(tones, ([tone, value]) => ( | ||
<Tone key={tone} hue={hue} tone={tone} value={value} /> | ||
)); | ||
|
||
return <div className={classes.root}>{toneElements}</div>; | ||
}; | ||
|
||
export default Hue; |
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 @@ | ||
.root { | ||
background-color: rgb(var(--venia-global-color-gray-100)); | ||
border-radius: 4px; | ||
display: grid; | ||
gap: 4.5rem; | ||
justify-content: center; | ||
margin-bottom: 5rem; | ||
padding: 3rem 1.5rem; | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/venia-styleguide/src/components/Palette/Palette.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,17 @@ | ||
import React from 'react'; | ||
|
||
import Hue from './Hue'; | ||
import classes from './Palette.css'; | ||
|
||
const Palette = props => { | ||
const { colors } = props; | ||
const { hues } = colors; | ||
|
||
const hueElements = Array.from(hues, ([hue, tones]) => ( | ||
<Hue key={hue} hue={hue} tones={tones} /> | ||
)); | ||
|
||
return <figure className={classes.root}>{hueElements}</figure>; | ||
}; | ||
|
||
export default Palette; |
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,31 @@ | ||
.root { | ||
composes: detail from '../../styles/typography.css'; | ||
align-content: start; | ||
background-color: rgb(var(--tone)); | ||
border: 1px solid rgb(var(--venia-global-color-gray-300)); | ||
border-radius: 4px; | ||
display: grid; | ||
font-weight: var(--venia-global-text-fontWeight-bold); | ||
height: 6.75rem; | ||
padding: 1rem; | ||
text-transform: uppercase; | ||
width: 12rem; | ||
} | ||
|
||
.root--balance-light { | ||
composes: root; | ||
} | ||
|
||
.root--balance-dark { | ||
composes: root; | ||
color: white; | ||
} | ||
|
||
.label { | ||
font-size: var(--venia-typography-detail-S-fontSize); | ||
letter-spacing: 0.5px; | ||
} | ||
|
||
.value { | ||
font-size: var(--venia-typography-detail-L-fontSize); | ||
} |
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,44 @@ | ||
import React, { useMemo } from 'react'; | ||
|
||
import finalizeClasses from '../../util/finalizeClasses'; | ||
import classes from './Tone.css'; | ||
|
||
const getHex = channel => parseInt(channel).toString(16); | ||
|
||
const getSRGB = channel => { | ||
const factor = channel / 255; | ||
|
||
return factor <= 0.03928 | ||
? factor / 12.92 | ||
: Math.pow((factor + 0.055) / 1.055, 2.4); | ||
}; | ||
|
||
const getLightness = channels => { | ||
const [r, g, b] = channels.map(getSRGB); | ||
|
||
return r * 0.2126 + g * 0.7152 + b * 0.0722; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you drop a comment about these numbers? |
||
}; | ||
|
||
const WHITE = getLightness([255, 255, 255]); | ||
|
||
const Tone = props => { | ||
const { hue, tone, value } = props; | ||
const style = { '--tone': value }; | ||
|
||
const channels = useMemo(() => value.split(' '), [value]); | ||
const lightness = getLightness(channels); | ||
const ratio = WHITE / (lightness + 0.05); | ||
const balance = ratio < 3 ? 'light' : 'dark'; | ||
|
||
const finalClasses = finalizeClasses(classes, { balance }); | ||
const hex = channels.map(channel => getHex(channel)).join(''); | ||
|
||
return ( | ||
<div className={finalClasses.get('root')} style={style}> | ||
<span className={classes.label}>{`${hue} ${tone}`}</span> | ||
<span className={classes.value}>{`#${hex}`}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Tone; |
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 './Palette'; |
2 changes: 1 addition & 1 deletion
2
packages/venia-styleguide/src/components/ThematicBreak/ThematicBreak.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.root { | ||
border: none; | ||
height: 1rem; | ||
height: 2rem; | ||
margin: 1rem; | ||
} |
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,30 @@ | ||
import Article from "../../components/Article" | ||
import Palette from "../../components/Palette" | ||
import Section from "../../components/Section" | ||
import TableOfContents from "../../components/TableOfContents" | ||
|
||
import Grays from "./sections/Grays" | ||
import data from "./colors.yml" | ||
|
||
export const colors = data | ||
|
||
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. | ||
|
||
*** | ||
|
||
<Palette colors={colors} /> | ||
<Section title="Table of contents"> | ||
<TableOfContents /> | ||
</Section> | ||
<Section title="Grays"> | ||
<Grays /> | ||
</Section> | ||
|
||
export const title = "Color" | ||
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,30 @@ | ||
--- | ||
|
||
hues: !!pairs | ||
- gray: !!pairs | ||
- 50: "255 255 255" | ||
- 75: "250 250 250" | ||
- 100: "245 245 245" | ||
- 200: "235 235 235" | ||
- 300: "224 224 224" | ||
- 400: "204 204 204" | ||
- 500: "163 163 163" | ||
- 600: "122 122 122" | ||
- 700: "82 82 82" | ||
- 800: "61 61 61" | ||
- 900: "31 31 31" | ||
- red: !!pairs | ||
- 400: "197 27 72" | ||
- 500: "188 16 62" | ||
- 600: "176 7 52" | ||
- 700: "163 0 44" | ||
- sea: !!pairs | ||
- 400: 224 246 242 | ||
- 500: 215 244 239 | ||
- 600: 206 243 236 | ||
- 700: 197 242 234 | ||
- teal: !!pairs | ||
- 400: "22 155 162" | ||
- 500: "13 143 150" | ||
- 600: "6 131 137" | ||
- 700: "0 115 120" |
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,5 +1 @@ | ||
import React from 'react'; | ||
|
||
const Page = () => <span>Color</span>; | ||
|
||
export default Page; | ||
export { default } from './Color'; |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/color/sections/Grays/Methodology.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 @@ | ||
#### Generating the grays | ||
|
||
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. |
3 changes: 3 additions & 0 deletions
3
packages/venia-styleguide/src/pages/color/sections/Grays/Usage.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 @@ | ||
#### Using the gray system | ||
|
||
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. |
14 changes: 14 additions & 0 deletions
14
packages/venia-styleguide/src/pages/color/sections/Grays/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,14 @@ | ||
import Columns from "../../../../components/Columns" | ||
import Methodology from "./Methodology" | ||
import Usage from "./Usage" | ||
|
||
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. | ||
|
||
*** | ||
|
||
<Columns> | ||
<Usage /> | ||
</Columns> | ||
<Columns> | ||
<Methodology /> | ||
</Columns> |
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
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.
Can you drop a comment about these numbers?