polished#parseToHsl TypeScript Examples
The following examples show how to use
polished#parseToHsl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Colors.stories.tsx From kodiak-ui with MIT License | 5 votes |
function ColorSwatches({ colorsArray, colorName }: ColorSwatchesProps) {
const borderLeftColor = [...colorsArray].sort(function darkestColorForSort(
color1,
color2,
) {
try {
const color1Hsl = parseToHsl(color1)
const color2Hsl = parseToHsl(color2)
return color1Hsl.lightness - color2Hsl.lightness
} catch (error) {
return -1
}
})[0]
return (
<Flex sx={{ flexDirection: 'column', width: '100%' }} key={colorName}>
<Box sx={{ borderLeft: '2px solid', borderLeftColor, mt: 8 }}>
<Text
variant="text.heading"
sx={{ ml: 3, textTransform: 'capitalize' }}
>
{colorName}
</Text>
</Box>
<Grid sx={{ gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr)' }}>
{colorsArray.map((value, index) => {
if (colorsArray[index] === null) {
return null
}
return (
<ColorSwatch
key={`${colorName}.${index}`}
color={value}
colorName={`${colorName}.${index}`}
sx={{ pt: 4 }}
/>
)
})}
</Grid>
</Flex>
)
}