MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ColorArea

Function ColorArea

starters/hooks/src/ColorArea.tsx:14–50  ·  view source on GitHub ↗
(props: ColorAreaProps)

Source from the content-addressed store, hash-verified

12}
13
14export function ColorArea(props: ColorAreaProps) {
15 let inputXRef = useRef<HTMLInputElement>(null);
16 let inputYRef = useRef<HTMLInputElement>(null);
17 let containerRef = useRef<HTMLDivElement>(null);
18 // useColorAreaState manages the two channel values behind the 2D gradient.
19 let state = useColorAreaState(props);
20 /*- begin highlight -*/
21 let {colorAreaProps, xInputProps, yInputProps, thumbProps} = useColorArea(
22 {...props, inputXRef, inputYRef, containerRef},
23 state
24 );
25 /*- end highlight -*/
26 let {focusProps, isFocusVisible} = useFocusRing();
27
28 return (
29 <div
30 {...colorAreaProps}
31 ref={containerRef}
32 className="react-aria-ColorArea"
33 data-disabled={props.isDisabled || undefined}
34 style={{...colorAreaProps.style, ...props.style}}>
35 <div
36 {...thumbProps}
37 className="react-aria-ColorThumb"
38 data-focus-visible={isFocusVisible || undefined}
39 data-disabled={props.isDisabled || undefined}
40 style={{
41 ...thumbProps.style,
42 background: state.getDisplayColor().toString('css')
43 }}>
44 {/* Two hidden range inputs drive the X and Y color channels. */}
45 <input ref={inputXRef} {...xInputProps} {...focusProps} />
46 <input ref={inputYRef} {...yInputProps} {...focusProps} />
47 </div>
48 </div>
49 );
50}

Callers

nothing calls this directly

Calls 5

useColorAreaStateFunction · 0.90
useColorAreaFunction · 0.90
useFocusRingFunction · 0.90
toStringMethod · 0.65
getDisplayColorMethod · 0.65

Tested by

no test coverage detected