This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
CategoryColorSchemes.tsx
68 lines (60 loc) · 1.69 KB
/
CategoryColorSchemes.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as React from 'react'
import * as _ from 'lodash'
import {
createComponent,
ComponentSlotStylesInput,
ThemePrepared,
Grid,
Header,
HeaderProps,
ShorthandCollection,
} from '@fluentui/react'
import ColorBox from './ColorBox'
type ColorVariantsProps = {
name?: string
themes?: ThemePrepared[]
headers?: ShorthandCollection<HeaderProps>
}
export const colorVariantsStyles: ComponentSlotStylesInput<ColorVariantsProps> = {
root: {
border: '1px solid transparent',
borderRadius: '.25rem',
overflow: 'hidden',
},
}
const CategoryColorSchemes = createComponent<ColorVariantsProps>({
displayName: 'ColorVariants',
render: ({ name, themes, headers, stardust: { classes } }) => {
if (themes.length === 0) return <></>
const colorSchemes = _.map(themes, theme => theme.siteVariables.categoryColorScheme[name])
const elements = _.flatMap(_.head(colorSchemes), (i, token) => [
<ColorBox
copyToClipboardIcon={false}
showColorValue={false}
name={token}
key={`${token}schema`}
size="small"
value={undefined}
styles={{ backgroundColor: '#f2f2f2' }}
/>,
..._.map(colorSchemes, (colorScheme, i) => (
<ColorBox
key={`${token}${i}`}
size="small"
value={colorScheme[token]}
copyToClipboardIcon={false}
/>
)),
])
const columns = `auto ${_.times(themes.length, () => '180px').join(' ')}`
return (
<div className={classes.root}>
<Grid columns={columns}>
{headers && headers.map(header => Header.create(header))}
{elements}
</Grid>
</div>
)
},
})
export default CategoryColorSchemes