757 B28 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8import type {ReactNode} from 'react';
9
10import * as stylex from '@stylexjs/stylex';
11import {light} from './theme/tokens.stylex';
12
13type Writable<T> = {-readonly [P in keyof T]: T[P]};
14export function ThemedComponentsRoot({
15 theme,
16 className,
17 children,
18}: {
19 theme: 'light' | 'dark';
20 className?: string;
21 children: ReactNode;
22}) {
23 const props = stylex.props(theme === 'light' && light);
24 // stylex would overwrite className
25 (props as Writable<typeof props>).className += ` ${className ?? ''} ${theme}-theme`;
26 return <div {...props}>{children}</div>;
27}
28