Skip to content

Commit 2b9d44d

Browse files
authored
Merge pull request #568 from components-ai/colors
Improve color display
2 parents 0c2668a + 8114b4c commit 2b9d44d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@compai/css-gui': patch
3+
---
4+
5+
Improve color display

packages/gui/src/components/primitives/ColorPicker/PalettePicker.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Popover from '@radix-ui/react-popover'
22
import { themeGet } from '../../../lib'
33
import { useTheme } from '../../providers/ThemeContext'
4+
import { joinPath } from '../../providers/util'
45
import Checkerboard from './Checkerboard'
56
import { hasAlpha, withFallback } from './util'
67

@@ -20,6 +21,15 @@ export default function PalettePopover({
2021
// swatch,
2122
...props
2223
}: Props) {
24+
const theme = useTheme()
25+
const rawValue = themeGet({
26+
property: 'color',
27+
path: value.path,
28+
theme,
29+
})
30+
31+
const labelMeta = value.path === rawValue ? null : `(${rawValue})`
32+
2333
return (
2434
<Popover.Root>
2535
<Popover.Trigger
@@ -46,6 +56,7 @@ export default function PalettePopover({
4656
{/* swatch */}
4757
<Popover.Anchor>{<Swatch value={value} />}</Popover.Anchor>
4858
{value.path}
59+
<span sx={{ fontSize: 0, color: 'muted' }}>{labelMeta}</span>
4960
</Popover.Trigger>
5061
<Popover.Content
5162
sx={{
@@ -114,12 +125,18 @@ export function PalettePicker({ value, onChange }: Props) {
114125
return (
115126
<div key={name} sx={{ display: 'flex', gap: '.125rem' }}>
116127
{(colorGroup as any).map((color: any, i: number) => {
128+
const colorPath = `${name}.${i}`
117129
const selected = valueColor === color
130+
const rawColor = themeGet({
131+
theme,
132+
property: 'color',
133+
path: colorPath,
134+
})
118135

119136
return (
120137
<button
121138
key={color.id}
122-
title={`${name}.${i}`}
139+
title={`${colorPath} (${rawColor})`}
123140
sx={{
124141
appearance: 'none',
125142
WebkitAppearance: 'none',

0 commit comments

Comments
 (0)