Skip to content

Commit 74a0aff

Browse files
fix(web): keep color picker styling in shared controls
1 parent bcb9030 commit 74a0aff

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎apps/web/src/components/settings/ProviderAccentColorPicker.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function ProviderCustomColorPanel(props: {
3636
label="Accent color saturation and brightness"
3737
value={hsv}
3838
onChange={commitHsv}
39-
className="h-36 rounded-none"
39+
variant="edge"
4040
/>
4141
<div className="grid gap-3 p-3">
4242
<ColorHueSlider
@@ -56,7 +56,7 @@ function ProviderCustomColorPanel(props: {
5656
props.onCommit(nextColor);
5757
}}
5858
onBlur={() => setHexDraft(null)}
59-
className="rounded-md font-mono text-xs"
59+
className="font-mono text-xs"
6060
aria-label="Custom hex accent color"
6161
spellCheck={false}
6262
/>

‎apps/web/src/components/ui/color-picker.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useState, type KeyboardEvent, type PointerEvent } from "react";
1+
import { useId, useRef, useState, type KeyboardEvent, type PointerEvent } from "react";
22

33
import type { HsvColor } from "../../lib/color";
44
import { cn } from "../../lib/utils";
@@ -60,7 +60,9 @@ export function ColorSaturationValuePlane({
6060
onChange,
6161
onInteractionEnd,
6262
className,
63-
}: ColorControlProps<HsvColor>) {
63+
variant = "inset",
64+
}: ColorControlProps<HsvColor> & { variant?: "inset" | "edge" }) {
65+
const instructionsId = useId();
6466
const { handlers, thumbTransition } = useColorDrag((event) => {
6567
const bounds = event.currentTarget.getBoundingClientRect();
6668
if (!bounds.width || !bounds.height) return;
@@ -86,24 +88,28 @@ export function ColorSaturationValuePlane({
8688
return (
8789
<div
8890
aria-label={label}
91+
aria-describedby={instructionsId}
8992
aria-valuemin={0}
9093
aria-valuemax={100}
9194
aria-valuenow={Math.round(value.s * 100)}
9295
aria-valuetext={`saturation ${Math.round(value.s * 100)}%, brightness ${Math.round(value.v * 100)}%`}
9396
className={cn(
94-
"relative h-32 cursor-crosshair touch-none overflow-hidden rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-popover",
97+
"relative cursor-crosshair touch-none overflow-hidden bg-[linear-gradient(to_top,#000,transparent),linear-gradient(to_right,#fff,transparent)] outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-popover",
98+
variant === "edge" ? "h-36 rounded-none" : "h-32 rounded-lg",
9599
className,
96100
)}
97101
role="slider"
98102
style={{
99103
backgroundColor: `hsl(${value.h} 100% 50%)`,
100-
backgroundImage:
101-
"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",
102104
}}
103105
tabIndex={0}
104106
onKeyDown={handleKeyDown}
105107
{...handlers}
106108
>
109+
<span id={instructionsId} className="sr-only">
110+
Use Left and Right arrows to adjust saturation, and Up and Down arrows to adjust brightness.
111+
Hold Shift for larger steps.
112+
</span>
107113
<span
108114
className="pointer-events-none absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.4)]"
109115
style={{
@@ -154,10 +160,7 @@ export function ColorHueSlider({
154160
>
155161
<span
156162
aria-hidden
157-
className="h-2.5 w-full rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0_/_12%)]"
158-
style={{
159-
background: "linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)",
160-
}}
163+
className="h-2.5 w-full rounded-full bg-[linear-gradient(to_right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)] shadow-[inset_0_0_0_1px_rgb(0_0_0_/_12%)]"
161164
/>
162165
<span
163166
className="pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.4)]"

0 commit comments

Comments
 (0)