Skip to content

Commit b3f29d4

Browse files
authored
Merge pull request #2324 from braaar/develop
fix: show color hex value as swatch title
2 parents 35a8bb7 + c1e4f7f commit b3f29d4

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/style-guide/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"scripts": {},
1212
"dependencies": {
1313
"@theme-ui/presets": "workspace:^",
14+
"@theme-ui/color": "workspace:^",
1415
"@types/color": "^3.0.3",
1516
"color": "^3.1.2",
1617
"lodash.get": "^4.4.2"

packages/style-guide/src/ColorSwatch.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx jsx */
2+
import { getColor } from '@theme-ui/color'
23
import { ComponentProps } from 'react'
3-
import { jsx, get, ResponsiveStyleValue } from 'theme-ui'
4+
import { jsx, ResponsiveStyleValue } from 'theme-ui'
45
import { toHex } from './color'
56
import { useTheme } from './context'
67

@@ -17,8 +18,8 @@ export const ColorSwatch = ({
1718
label = true,
1819
...props
1920
}: ColorSwatchProps) => {
20-
const { colors } = useTheme()!
21-
const value = get(colors!, color)
21+
const theme = useTheme()!
22+
const value = getColor(theme, color)
2223
return (
2324
<div {...props} title={`${toHex(value)}`}>
2425
<div

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)