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

Function StaticColorProvider

packages/@react-spectrum/s2/stories/utils.tsx:35–67  ·  view source on GitHub ↗
(props: {
  children: ReactNode;
  staticColor?: StaticColor;
  hideColorPicker?: boolean;
})

Source from the content-addressed store, hash-verified

33}
34
35export function StaticColorProvider(props: {
36 children: ReactNode;
37 staticColor?: StaticColor;
38 hideColorPicker?: boolean;
39}): ReactElement {
40 let [autoBg, setAutoBg] = useState('#5131c4');
41 return (
42 <>
43 <div
44 style={{
45 padding: 8,
46 // @ts-ignore
47 '--s2-container-bg': props.staticColor === 'auto' ? autoBg : undefined,
48 background: props.staticColor === 'auto' ? autoBg : getBackgroundColor(props.staticColor)
49 }}>
50 {props.children}
51 </div>
52 {props.staticColor === 'auto' && !props.hideColorPicker && (
53 <label
54 className={style({
55 display: 'flex',
56 alignItems: 'center',
57 gap: 8,
58 marginTop: 16,
59 font: 'ui'
60 })}>
61 Background:
62 <input type="color" value={autoBg} onChange={e => setAutoBg(e.target.value)} />
63 </label>
64 )}
65 </>
66 );
67}
68
69export const StaticColorDecorator = (Story: any, {args}: any): ReactElement => (
70 <StaticColorProvider staticColor={args.staticColor}>

Callers

nothing calls this directly

Calls 1

getBackgroundColorFunction · 0.70

Tested by

no test coverage detected