import * as React from 'react'; import Container from '@mui/joy/Container'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import { CssVarsProvider, useColorScheme, useTheme, TypographySystem, createGetCssVar, } from '@mui/joy/styles'; const getCssVar = createGetCssVar(); const rgb2hex = (rgb: string) => `#${(rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/) || []) .slice(1) .map((n) => parseInt(n, 10).toString(16).padStart(2, '0')) .join('')}`; function ColorSchemePicker() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return ( ({ position: 'relative', display: 'inline-flex', alignItems: 'center', border: '1px solid', borderRadius: theme.vars.radius.md, ...theme.variants.outlined.neutral, })} > {(['light', 'dark'] as const).map((modeId) => { return ( ); })} ); } function ColorToken({ name, value }: { name: string; value: string }) { const [color, setColor] = React.useState(''); const ref = React.useRef(null); React.useEffect(() => { if (ref.current && typeof window !== 'undefined') { const style = window.getComputedStyle(ref.current); setColor(rgb2hex(style.backgroundColor)); } }, []); return (
{name} {color}
); } function PaletteTokens() { const { colorScheme } = useColorScheme(); const { palette } = useTheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); return ( {mounted && ( Palette ({colorScheme}) )}
{Object.entries(palette).map(([key, nestedObj]) => { if (typeof nestedObj === 'string' && mounted) { return ; } return (
{key} {key !== 'mode' && key !== 'colorScheme' && ( {Object.entries(nestedObj).map(([nestedKey, value]) => ( ))} )}
); })}
); } function TypographyScale() { const { typography } = useTheme(); return ( Typography {(Object.keys(typography) as Array).map((level) => { return ( {level} ); })} ); } export default function JoyStyleGuide() { return (
UI Patterns
List item title Secondary text.

List item title Secondary text. metadata
List item title Secondary text. metadata
); }