-
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
4d71cb9
commit 170ff4c
Showing
7 changed files
with
241 additions
and
1 deletion.
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
54 changes: 54 additions & 0 deletions
54
ui/design-tokens/src/Colors/FinestraColor/FinestraColor.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,54 @@ | ||
import React from 'react'; | ||
import { FinestraColor, FinestraColorPalette } from './FinestraColor'; | ||
import { ColorProps } from '../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/FinestraColor', | ||
component: FinestraColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<FinestraColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: 'V 100', | ||
color: { | ||
type: 'object', | ||
value: { | ||
name: 'V', | ||
value: { type: 'color', value: '#cf1322' }, | ||
primary: { type: 'boolean', value: true }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const palette = () => ( | ||
<FinestraColorPalette | ||
palette={{ | ||
'C 100 - dark': { | ||
value: '#2D2D2D', | ||
}, | ||
'C 100': { | ||
value: '#414141', | ||
name: 'C', | ||
primary: true, | ||
}, | ||
'C 75': { | ||
value: '#707070', | ||
}, | ||
'C 50': { | ||
value: '#9F9F9F', | ||
}, | ||
'C 25': { | ||
value: '#CECECE', | ||
}, | ||
'C 10': { | ||
value: '#EAEAEA', | ||
}, | ||
'C 2': { | ||
value: '#FAFAFA', | ||
}, | ||
}} | ||
/> | ||
); |
98 changes: 98 additions & 0 deletions
98
ui/design-tokens/src/Colors/FinestraColor/FinestraColor.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,98 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import { CheckIcon } from '@primer/octicons-react'; | ||
import { colorToStr, mostReadable } from '../utils'; | ||
import { ColorBlockProps, ColorValue } from '../types'; | ||
import { FlexContainerProps, FlexContainer } from '../FlexContainer'; | ||
|
||
/** | ||
* Color item displaying the color as a small block, with name and hex color on the side. If the color is a primary color, will display as a circle. | ||
* Design inspired from [Finestra](https://design.fusionfabric.cloud/foundations/colors). | ||
*/ | ||
|
||
export const FinestraColor: FC<ColorBlockProps> = ({ name, color }) => { | ||
const colorObj: ColorValue = | ||
typeof color === 'string' ? { value: color } : color; | ||
const { value: colorValue, name: colorName, primary } = colorObj; | ||
|
||
const { hex } = colorToStr(colorValue); | ||
const textColor = mostReadable(hex); | ||
return ( | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flex: '1', | ||
width: 250, | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<CopyContainer | ||
value={hex} | ||
name={name} | ||
sxStyle={{ p: primary ? 0 : 2, width: 80 }} | ||
> | ||
<div | ||
sx={{ | ||
bg: colorValue, | ||
color: textColor, | ||
position: 'relative', | ||
|
||
borderRadius: primary ? '50%' : undefined, | ||
':after': { | ||
content: '""', | ||
display: 'block', | ||
paddingBottom: '100%', | ||
}, | ||
}} | ||
> | ||
<div | ||
sx={{ | ||
position: 'absolute', | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
}} | ||
> | ||
{primary ? colorName : <CheckIcon />} | ||
</div> | ||
</div> | ||
</CopyContainer> | ||
|
||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
ml: 4, | ||
lineHeight: '1.4rem', | ||
}} | ||
> | ||
<div>{name}</div> | ||
<div sx={{ opacity: 0.5 }}>{hex}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with FinestraColor items | ||
* using a css flex display direction column | ||
*/ | ||
export const FinestraColorPalette: FC<Omit< | ||
FlexContainerProps, | ||
'children' | 'direction' | ||
>> = props => ( | ||
<FlexContainer direction="column" sx={{ width: 250 }} {...props}> | ||
{({ name, value, hover }) => ( | ||
<FinestraColor | ||
key={`color_item_${name}}`} | ||
name={name} | ||
color={value} | ||
hover={hover} | ||
/> | ||
)} | ||
</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 './FinestraColor'; |
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