Skip to content

Commit 2c13f7f

Browse files
author
Luke Bowerman
authored
Extended palette (#1695)
* Initial take at exposing "highlight" colors * Add additional accent colors * Update color swatch stories * Removed actionlist aliases
1 parent e04dfaa commit 2c13f7f

File tree

9 files changed

+100
-58
lines changed

9 files changed

+100
-58
lines changed

packages/components/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4848

4949
- `useTooltip` no longer supports `surfaceStyles` property
5050
- `Heading` & `Paragraph`, `Span`, `Text` no longer support `variant` (use `color` instead)
51+
- `ActionList` aliases to `DataTable`
5152

5253
## [0.9.25]
5354

packages/components/src/DataTable/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,7 @@
2424
2525
*/
2626

27-
import { DataTable } from './DataTable'
28-
import { DataTableAction, DataTableItem } from './Item'
29-
import { DataTableCell, DataTableColumns } from './Column'
30-
3127
export * from './DataTable'
3228
export * from './Column'
3329
export * from './Item'
3430
export * from './utils'
35-
36-
/**
37-
* Legacy exports
38-
* NOTE: These will be removed in the not-too-distant future
39-
*/
40-
export const ActionList = DataTable
41-
export const ActionListItem = DataTableItem
42-
export const ActionListItemAction = DataTableAction
43-
export const ActionListItemColumn = DataTableCell
44-
45-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
46-
export interface ActionListColumns extends DataTableColumns {}

packages/design-tokens/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- `AliasColor` to support color aliases previously used via `variant` property
13+
- Added colors: `secondary` & `subdued`
14+
- Added colors: `informAccent`, `positiveAccent`, & `warnAccent`
1315

1416
## [0.9.20]
1517

49.4 KB
Loading
-106 KB
Binary file not shown.

packages/design-tokens/src/colors.story.tsx

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,78 @@
2424
2525
*/
2626

27-
import React, { useContext } from 'react'
28-
import styled, { ThemeContext } from 'styled-components'
27+
import React, { Fragment, ReactNode } from 'react'
28+
import styled from 'styled-components'
2929
import sortBy from 'lodash/sortBy'
30+
3031
/**
3132
* IMPORTANT: It is only acceptable to reach across package boundaries like this
3233
* because this is a Story and will never be run in a "production" environment.
3334
*
3435
* In this case we don't want to create a dependency loop between @looker/design-tokens
3536
* and @looker/components
3637
*/
37-
import { Code, Flex, Heading } from '../../components/src'
38+
import { Tooltip } from '../../components/src'
39+
import { theme } from './theme'
40+
41+
const CELL_SIZE = '3rem'
42+
43+
const sortedColorsArray = sortBy(Object.entries(theme.colors), 0)
3844

39-
const CELL_SIZE = '6rem'
45+
export const AllColors = () => {
46+
const colors = sortedColorsArray.map(([name, color]) => {
47+
return { color, label: `${name} - ${color}` }
48+
})
4049

41-
export const Complete = () => (
42-
<GridLayout>
43-
<ColorSlots />
44-
</GridLayout>
45-
)
50+
return <MiniSwatches>{colors}</MiniSwatches>
51+
}
52+
53+
export const GroupedByOutput = () => {
54+
const grouped: { [key: string]: string[] } = {}
55+
56+
sortedColorsArray.forEach(([name, color]) => {
57+
if (grouped[color]) {
58+
grouped[color] = [...grouped[color], name]
59+
} else {
60+
grouped[String(color)] = [name]
61+
}
62+
})
63+
64+
const colors = Object.entries(grouped).map(([color, entries]) => {
65+
const labels = entries.map((label, index) => (
66+
<Fragment key={index}>
67+
{label} <br />
68+
</Fragment>
69+
))
70+
71+
return {
72+
color,
73+
label: (
74+
<>
75+
<strong>{color}</strong>
76+
<br />
77+
{labels}
78+
</>
79+
),
80+
}
81+
})
82+
83+
return <MiniSwatches>{colors}</MiniSwatches>
84+
}
85+
86+
GroupedByOutput.parameters = {
87+
storyshots: { disable: true },
88+
}
4689

4790
export default {
48-
component: Complete,
4991
title: 'Colors',
5092
}
5193

5294
const GridLayout = styled.div`
5395
display: grid;
5496
grid-gap: 1rem;
5597
grid-template-columns: repeat(auto-fill, minmax(${CELL_SIZE}, 1fr));
98+
padding: 1rem;
5699
`
57100

58101
/**
@@ -74,31 +117,16 @@ const CircleSwatch = styled.div<SwatchProps>`
74117
width: 3rem;
75118
`
76119

77-
const ColorSlots = () => {
78-
const { colors } = useContext(ThemeContext)
79-
80-
const colorSwatches = sortBy(Object.entries(colors), 0).map(
81-
([name, color]) => (
82-
<Flex
83-
flexDirection="column"
84-
key={name}
85-
alignItems="center"
86-
width={CELL_SIZE}
87-
>
88-
<CircleSwatch color={color}></CircleSwatch>
89-
<Heading
90-
truncate
91-
fontSize="small"
92-
pt="xsmall"
93-
fontWeight="semiBold"
94-
fontFamily="body"
95-
>
96-
{name}
97-
</Heading>
98-
<Code fontSize="xsmall">{color.toUpperCase()}</Code>
99-
</Flex>
100-
)
101-
)
102-
103-
return <>{colorSwatches}</>
120+
interface MiniSwatchesProps {
121+
children: { color: string; label: ReactNode }[]
122+
}
123+
124+
const MiniSwatches = ({ children }: MiniSwatchesProps) => {
125+
const colorSwatches = children.map(({ label, color }, index) => (
126+
<Tooltip key={index} content={label} textAlign="left">
127+
<CircleSwatch color={color}></CircleSwatch>
128+
</Tooltip>
129+
))
130+
131+
return <GridLayout>{colorSwatches}</GridLayout>
104132
}

packages/design-tokens/src/system/color/derivative.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@
2424
2525
*/
2626

27-
export interface DerivativeColors {
27+
interface HighlightColors {
28+
/**
29+
* Used to highlight / accent content
30+
*/
31+
informAccent: string
32+
/**
33+
* Used to highlight / accent content
34+
*/
35+
positiveAccent: string
36+
/**
37+
* Used to highlight / accent content
38+
*/
39+
warnAccent: string
40+
}
41+
42+
export interface DerivativeColors extends HighlightColors {
2843
/**
2944
* Default input background
3045
* Text input, select input

packages/design-tokens/src/utils/color/derivatives.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,29 @@
2525
*/
2626

2727
import { DerivativeColors, SpecifiableColors } from '../../system'
28-
import { generateInteractive } from './stateful'
29-
import { mixColors, textBlends } from './blend'
28+
import { accentBlendScale, generateInteractive } from './stateful'
29+
import { mixColors, mixScaledColors, textBlends } from './blend'
3030

3131
export const generateDerivativeColors = ({
32+
background,
33+
inform,
3234
link,
35+
positive,
3336
text,
34-
background,
37+
warn,
3538
}: SpecifiableColors): DerivativeColors => {
39+
const accents = {
40+
informAccent: mixScaledColors(accentBlendScale, inform, background),
41+
positiveAccent: mixScaledColors(accentBlendScale, positive, background),
42+
warnAccent: mixScaledColors(accentBlendScale, warn, background),
43+
}
44+
3645
return {
3746
field: background,
3847
inverse: text,
3948
inverseOn: background,
4049
linkInteractive: generateInteractive(link),
4150
neutral: mixColors(textBlends[1], text, background),
51+
...accents,
4252
}
4353
}

packages/design-tokens/src/utils/color/stateful.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ import { mixScaledColors } from './blend'
3939
export const generateInteractive = (color: string) => lighten(0.04, color)
4040
export const generatePressed = (color: string) => darken(0.07, color)
4141

42+
export const accentBlendScale = 16
43+
4244
const generateStatefulColor = (
4345
background: string,
4446
color: string
4547
): StatefulColorChoices => {
4648
return {
4749
subtle: mixScaledColors(10, color, background),
48-
accent: mixScaledColors(16, color, background),
50+
accent: mixScaledColors(accentBlendScale, color, background),
4951
focus: mixScaledColors(60, color, background),
5052
interactive: generateInteractive(color),
5153
pressed: generatePressed(color),

0 commit comments

Comments
 (0)