-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3f9157
commit 9e76204
Showing
10 changed files
with
241 additions
and
18 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
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
74 changes: 74 additions & 0 deletions
74
ui/design-tokens/src/Colors/CedarColor/CedarColor.stories.tsx
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,74 @@ | ||
import React from 'react'; | ||
import { CedarColor, CedarColorPalette } from './CedarColor'; | ||
import { ColorProps } from '../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/CedarColor', | ||
component: CedarColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<CedarColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: { type: 'text', value: 'cobalt400' }, | ||
color: { | ||
type: 'object', | ||
value: { | ||
value: { type: 'color', value: '#225c4e' }, | ||
name: { type: 'text', value: 'cdr-color-text-button-primary-hover' }, | ||
description: { | ||
type: 'text', | ||
value: 'Text color for the hover state of primary buttons', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const palette = () => ( | ||
<CedarColorPalette | ||
palette={{ | ||
primary: { | ||
name: 'cdr-color-text-primary', | ||
value: 'rgba(12, 11, 8, 0.75)', | ||
description: 'The default, primary text color', | ||
}, | ||
secondary: { | ||
name: 'cdr-color-text-secondary', | ||
value: 'rgba(66, 59, 47, 0.75)', | ||
description: 'The secondary text color', | ||
}, | ||
brand: { | ||
name: 'cdr-color-text-brand', | ||
value: '#113731', | ||
description: 'Text set in our primary brand color', | ||
}, | ||
sale: { | ||
name: 'cdr-color-text-sale', | ||
value: '#cc0000', | ||
description: 'The color of sale text', | ||
}, | ||
inverse: { | ||
name: 'cdr-color-text-inverse', | ||
value: '#f9f8f6', | ||
description: 'Text color on dark background', | ||
}, | ||
disabled: { | ||
name: 'cdr-color-text-disabled', | ||
value: '#d1cbbd', | ||
description: 'The color of text when it is disabled', | ||
}, | ||
success: { | ||
name: 'cdr-color-text-success', | ||
value: '#2e6b34', | ||
description: 'Color of success messages', | ||
}, | ||
warning: { | ||
name: 'cdr-color-text-warning', | ||
value: '#854714', | ||
description: 'Color of warning messages', | ||
}, | ||
}} | ||
/> | ||
); |
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,84 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Box } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import { colorToStr, mostReadable } from '../utils'; | ||
import { ColorBlockProps, ColorValue } from '../types'; | ||
import { FlexContainerProps, FlexContainer } from '../FlexContainer'; | ||
|
||
/** | ||
* Color item displaying as a row, with color, name, description and hex value | ||
* Design inspired from REI's [Cedar](https://rei.github.io/rei-cedar-docs/foundation/color/). | ||
*/ | ||
|
||
export const CedarColor: FC<ColorBlockProps & { index?: number }> = ({ | ||
name, | ||
color, | ||
index = 0, | ||
}) => { | ||
const colorObj: ColorValue = | ||
typeof color === 'string' ? { value: color } : color; | ||
const { value: colorValue, name: colorName, description } = colorObj; | ||
|
||
const { hex } = colorToStr(colorValue); | ||
const textColor = mostReadable(hex); | ||
return ( | ||
<Box sx={{ display: 'flex', flex: '1' }}> | ||
<Box | ||
sx={{ | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
fontSize: 1, | ||
p: 2, | ||
bg: index % 2 ? 'background' : 'gray', | ||
}} | ||
> | ||
<CopyContainer value={hex} name={name}> | ||
<Box | ||
sx={{ | ||
width: 50, | ||
height: 50, | ||
bg: colorValue, | ||
color: textColor, | ||
mr: 3, | ||
}} | ||
/> | ||
</CopyContainer> | ||
<Box | ||
sx={{ | ||
flex: 1, | ||
}} | ||
> | ||
<div sx={{ display: 'flex', flexDirection: 'column' }}> | ||
<div sx={{ fontWeight: 'bold' }}>{colorName}</div> | ||
<div> {description}</div> | ||
</div> | ||
</Box> | ||
<div sx={{ mr: 3, fontSize: 0 }}>{hex}</div> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with CedarColor items | ||
* using a css flex display direction column | ||
*/ | ||
export const CedarColorPalette: FC<Omit< | ||
FlexContainerProps, | ||
'children' | 'direction' | ||
>> = props => ( | ||
<FlexContainer direction="column" {...props}> | ||
{({ name, value, index }) => ( | ||
<CedarColor | ||
key={`color_item_${name}}`} | ||
name={name} | ||
color={value} | ||
index={index} | ||
/> | ||
)} | ||
</FlexContainer> | ||
); |
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 * from './CedarColor'; |
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