(props: {
children: ReactNode;
staticColor?: StaticColor;
hideColorPicker?: boolean;
})
| 33 | } |
| 34 | |
| 35 | export 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 | |
| 69 | export const StaticColorDecorator = (Story: any, {args}: any): ReactElement => ( |
| 70 | <StaticColorProvider staticColor={args.staticColor}> |
nothing calls this directly
no test coverage detected