Skip to content

Commit

Permalink
Adds chroma-js. Adds new accessibility documentation to color table.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmrs committed May 20, 2019
1 parent 79ef8a2 commit f6fe539
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@emotion/core": "^10.0.10",
"@emotion/styled": "^10.0.10",
"@styled-system/should-forward-prop": "^1.0.0",
"chroma-js": "^2.0.3",
"emotion-theming": "^10.0.10",
"react": "^16.8.6",
"react-dom": "^16.8.6",
Expand Down
4 changes: 4 additions & 0 deletions src/elements/Span.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
textAlign,
textStyle,
color,
borders,
borderRadius,
} from 'styled-system'

const Span = styled('span', { shouldForwardProp })(
Expand All @@ -22,6 +24,8 @@ const Span = styled('span', { shouldForwardProp })(
textAlign,
textStyle,
color,
borders,
borderRadius,
{},
)

Expand Down
27 changes: 19 additions & 8 deletions src/pages/Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import jsx from '../jsx'
import React from 'react'
import theme from '../theme'
import chroma from 'chroma-js'

import Logo from '../components/Logo'
import Container from '../components/Container'
Expand Down Expand Up @@ -91,14 +92,24 @@ function Styles() {
<h3 px={[4,0]}>Colors</h3>
<table>
{Object.keys(theme.colors).map((keyName, i) => (
<tr>
<td maxWidth={64} borderBottom='1px solid' borderColor={theme.colors[keyName]} py={1}>
<div bg={theme.colors[keyName]} px={[3,4,5]} height='100%' pt={3} pb={4}> </div>
</td>
<td borderBottom='1px solid' borderColor={theme.colors[keyName]} bg='white' color={theme.colors[keyName]} fontWeight={700} px={[2,3,4]} fontSize={[2,5,5]}>Aa</td>
<td borderBottom='1px solid' borderColor={theme.colors[keyName]} px={[0,3]} fontWeight={700} fontSize={[1,2,3]}>{keyName}</td>
<td borderBottom='1px solid' borderColor={theme.colors[keyName]} px={[0,3]} textAlign='right' bg='white' width='auto' fontSize={[0,1,1]}>{theme.colors[keyName]}</td>
</tr>
<tr>
<td py={3} width={24} borderBottom='1px solid' bg={theme.colors[keyName]} color='white' borderColor={theme.colors[keyName]} pl={3} fontWeight={700} fontSize={0}>
<span color='black'>
{chroma.contrast(theme.colors[keyName], 'black').toFixed(2)}
</span>
</td>
<td borderBottom='1px solid' bg={theme.colors[keyName]} color='white' borderColor={theme.colors[keyName]} fontWeight={700} fontSize={0}>
<span px={2} py={1} borderBottom='1px solid' borderColor={theme.colors[keyName]} width={48} bg='black' color={theme.colors[keyName]} fontWeight={700}>Aa</span>
</td>
<td width={24} borderBottom='1px solid' bg={theme.colors[keyName]} color='white' borderColor={theme.colors[keyName]} fontWeight={700} fontSize={0}>
{chroma.contrast(theme.colors[keyName], 'white').toFixed(2)}
</td>
<td borderBottom='1px solid' bg={theme.colors[keyName]} color='white' borderColor={theme.colors[keyName]} fontWeight={700} fontSize={0}>
<span px={2} py={1} borderBottom='1px solid' borderColor={theme.colors[keyName]} width={48} bg='white' color={theme.colors[keyName]} fontWeight={700}>Aa</span>
</td>
<td borderBottom='1px solid' borderColor={theme.colors[keyName]} px={[0,3]} fontWeight={700} fontSize={[1,2,3]}>{keyName}</td>
<td borderBottom='1px solid' borderColor={theme.colors[keyName]} px={[0,3]} textAlign='right' bg='white' width='auto' fontSize={[0,1,1]}>{theme.colors[keyName]}</td>
</tr>
))}
</table>
</section>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2844,6 +2844,11 @@ chownr@^1.1.1:
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494"
integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==

chroma-js@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/chroma-js/-/chroma-js-2.0.3.tgz#2521d4f80c4e786e00064c4a62824e38ff6557c4"
integrity sha512-2kTvZZOFSV1O81/rm99t9vmkh9jQxsHqsRRoZevDVz/VCC3yKMyPuMK8M5yHG+UMg2tV6cRoqtZtgcD92udcBw==

chrome-trace-event@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz#45a91bd2c20c9411f0963b5aaeb9a1b95e09cc48"
Expand Down

0 comments on commit f6fe539

Please sign in to comment.