-
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
460532d
commit 8331000
Showing
6 changed files
with
172 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
41 changes: 41 additions & 0 deletions
41
ui/design-tokens/src/Colors/HelpScoutColor/HelpScoutColor.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,41 @@ | ||
import React from 'react'; | ||
import { HelpScoutColor, HelpScoutColorPalette } from './HelpScoutColor'; | ||
import { ColorProps } from '../../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/HelpScoutColor', | ||
component: HelpScoutColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<HelpScoutColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: 'Lavender', | ||
color: { | ||
type: 'object', | ||
value: { | ||
value: { type: 'color', value: '#9FA6FF' }, | ||
name: '500', | ||
primary: { type: 'boolean', value: true }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const palette = () => ( | ||
<HelpScoutColorPalette | ||
palette={{ | ||
lavender: { value: '#9FA6FF', name: '500', primary: true }, | ||
'lavender-100': { value: '#F9F9FF', name: '100' }, | ||
'lavender-200': { value: '#EBECFF', name: '200' }, | ||
'lavender-300': { value: '#D9DCFD', name: '300' }, | ||
'lavender-400': { value: '#B9BEFF', name: '400' }, | ||
'lavender-500': { value: '#9FA6FF', name: '500' }, | ||
'lavender-600': { value: '#818AEC', name: '600' }, | ||
'lavender-700': { value: '#6269C5', name: '700' }, | ||
'lavender-800': { value: '#404996', name: '800' }, | ||
'lavender-900': { value: '#232A5C', name: '900' }, | ||
}} | ||
/> | ||
); |
94 changes: 94 additions & 0 deletions
94
ui/design-tokens/src/Colors/HelpScoutColor/HelpScoutColor.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,94 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Theme } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import { colorToStr, mostReadable } from '../utils'; | ||
import { ColorBlockProps, ColorValue } from '../../types'; | ||
import { FlexContainerProps, FlexContainer } from '../../components'; | ||
|
||
/** | ||
* Color item displaying the color as a row, expanding on hover. Separate visualization (header) for primary color. | ||
* Design inspired from [HelpScout](https://style.helpscout.com/visual-elements/#color). | ||
*/ | ||
|
||
export const HelpScoutColor: FC<ColorBlockProps> = ({ name, color }) => { | ||
const colorObj: ColorValue = | ||
typeof color === 'string' ? { value: color } : color; | ||
const { value: colorValue, primary, name: colorName } = colorObj; | ||
|
||
const { hex } = colorToStr(colorValue); | ||
const textColor = mostReadable(hex); | ||
|
||
return ( | ||
<div sx={{ display: 'flex', flex: '1', width: 250 }}> | ||
<CopyContainer value={hex} name={name} sxStyle={{ width: '100%' }}> | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
bg: colorValue, | ||
color: textColor, | ||
height: primary ? 100 : 50, | ||
justifyContent: primary ? 'space-between' : 'center', | ||
fontSize: 0, | ||
borderTopRightRadius: primary ? 6 : 0, | ||
borderTopLeftRadius: primary ? 6 : 0, | ||
transition: 'all .2s', | ||
':hover': { | ||
mx: -2, | ||
borderRadius: 3, | ||
boxShadow: (t: Theme) => `0 2px 10px 3px ${t.colors?.shadow}`, | ||
}, | ||
}} | ||
> | ||
{primary && ( | ||
<div sx={{ p: 3, fontSize: 1, fontWeight: 'heading' }}> | ||
{name ? name.toUpperCase() : ''} | ||
</div> | ||
)} | ||
<div | ||
sx={{ | ||
px: 3, | ||
display: 'flex', | ||
height: 50, | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
}} | ||
> | ||
<div | ||
sx={{ | ||
mr: 4, | ||
}} | ||
> | ||
{colorName} | ||
</div> | ||
<div | ||
sx={{ | ||
pointerEvents: 'none', | ||
}} | ||
> | ||
{hex} | ||
</div> | ||
</div> | ||
</div> | ||
</CopyContainer> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with HelpScoutColor items | ||
* using a css flex display direction column | ||
*/ | ||
export const HelpScoutColorPalette: FC<Omit< | ||
FlexContainerProps, | ||
'children' | 'direction' | ||
>> = props => ( | ||
<FlexContainer direction="column" sx={{ width: 250 }} {...props}> | ||
{({ name, value }) => ( | ||
<HelpScoutColor key={`color_item_${name}}`} name={name} color={value} /> | ||
)} | ||
</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 './HelpScoutColor'; |
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