index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/approaches.md
# Approaches <p class="description">Learn which approach is recommended, depending on the situation, to customize Joy UI components.</p> - For customizing only a specific instance of a given component, [_use the `sx` prop_](#sx-prop). - To ensure every instance of a given component looks the same across you app, [_use theming_](#theming). - To create something that Joy UI doesn't support out of the box but still has design consistency, create a [_reusable component_](#reusable-component) that uses Joy UI's theme design tokens. ## `sx` prop The `sx` prop provides a superset of CSS (contains all CSS properties/selectors, in addition to custom ones) that maps values directly from the theme, depending on the CSS property used. Every Joy UI component supports it and it's a tool that allows you to quickly customize components on the spot. Visit [the `sx` prop documentation](/system/getting-started/the-sx-prop/) to learn more about it. {{"demo": "SxProp.js"}} ## Theming The theme is an object where you define both your design language with foundational tokens such as color schemes, typography and spacing scales, and how each component, and their different variants and states, uses them. Here are some examples that reproduce popular designs (only the light mode, though): {{"demo": "ButtonThemes.js", "hideToolbar": true}} ### Customizing theme tokens Theme tokens refer to both _low-level_ and _global variant_ design tokens. For example, instead of assigning the same hex code every time you want to change a given component's background color, you assign a theme token instead. If, at any point, you want to change that, you'd change in one place only, ensuring you consistency across all the components that use that theme token. To print your own design language into Joy UI components, start by customizing these tokens first, as every component uses them. To do that, always use the `extendTheme` function as the customized tokens will be deeply merged into the default theme. Under the hood, Joy UI will convert the tokens to CSS variables, enabling you to get them through `theme.vars.*`, which is very convenient as you can use any styling solution to read those CSS vars. ```js import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ colorSchemes: { light: { palette: { // affects all Joy components that has `color="primary"` prop. primary: { 50: '#fffbeb', 100: '#fef3c7', 200: '#fde68a', // 300, 400, ..., 800, 900: '#78350f', }, }, }, }, fontFamily: { display: 'Inter, var(--joy-fontFamily-fallback)', body: 'Inter, var(--joy-fontFamily-fallback)', }, }); function App() { return <CssVarsProvider theme={theme}>...</CssVarsProvider>; } ``` ### Customizing components Each Joy UI component uses a pre-defined set of theme tokens. For example, the default small [`Button`](/joy-ui/react-button/) comes with `fontSize: sm` by default. To change that while ensuring that every instance of it has the same styles, do it [targeting the component directly from the theme](/joy-ui/customization/themed-components/). Here's a preview of how you'd change the button's font size to large: ```js import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Button from '@mui/joy/Button'; const theme = extendTheme({ components: { // The component identifier always start with `Joy${ComponentName}`. JoyButton: { styleOverrides: { root: ({ theme }) => { // theme.vars.* return the CSS variables. fontSize: theme.vars.fontSize.lg, // 'var(--joy-fontSize-lg)' }, }, }, }, }); function MyApp() { return ( <CssVarsProvider theme={theme}> <Button>Text</Button> </CssVarsProvider> ); } ``` ## Reusable component Creating new and custom components is always an option when you don't find exactly what you're looking for. You can, however, ensure design consistency with other Joy UI components by pulling styles from the theme through the `styled` function. You also gain the ability to use the `sx` prop, which also accepts theme tokens, to customize this newly created component. {{"demo": "StyledComponent.js"}}
1,800
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/StatComponent.js
import * as React from 'react'; import { styled } from '@mui/joy/styles'; const StatRoot = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.vars.palette.background.surface, borderRadius: theme.vars.radius.sm, boxShadow: theme.vars.shadow.md, })); const StatValue = styled('div')(({ theme }) => ({ ...theme.typography.h2, })); const StatUnit = styled('div')(({ theme }) => ({ ...theme.typography['body-sm'], color: theme.vars.palette.text.tertiary, })); export default function StatComponent() { return ( <StatRoot> <StatValue>19,267</StatValue> <StatUnit>Active users / month</StatUnit> </StatRoot> ); }
1,801
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/StatFullTemplate.js
import * as React from 'react'; import PropTypes from 'prop-types'; import Stack from '@mui/joy/Stack'; import { styled, useThemeProps } from '@mui/joy/styles'; const StatRoot = styled('div', { name: 'JoyStat', slot: 'root', })(({ theme, ownerState }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.vars.palette.background.surface, borderRadius: theme.vars.radius.sm, boxShadow: theme.vars.shadow.md, ...(ownerState.variant === 'outlined' && { border: `2px solid ${theme.palette.divider}`, boxShadow: 'none', }), })); const StatValue = styled('div', { name: 'JoyStat', slot: 'value', })(({ theme }) => ({ ...theme.typography.h2, })); const StatUnit = styled('div', { name: 'JoyStat', slot: 'unit', })(({ theme }) => ({ ...theme.typography['body-sm'], color: theme.vars.palette.text.tertiary, })); const Stat = React.forwardRef(function Stat(inProps, ref) { const props = useThemeProps({ props: inProps, name: 'JoyStat' }); const { value, unit, variant, ...other } = props; const ownerState = { ...props, variant }; return ( <StatRoot ref={ref} ownerState={ownerState} {...other}> <StatValue ownerState={ownerState}>{value}</StatValue> <StatUnit ownerState={ownerState}>{unit}</StatUnit> </StatRoot> ); }); Stat.propTypes = { unit: PropTypes.string.isRequired, value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, variant: PropTypes.oneOf(['outlined']), }; export default function StatFullTemplate() { return ( <Stack direction="row" spacing={2}> <Stat value="1.9M" unit="Favorites" /> <Stat value="5.1M" unit="Views" variant="outlined" /> </Stack> ); }
1,802
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/StatFullTemplate.tsx
import * as React from 'react'; import Stack from '@mui/joy/Stack'; import { styled, useThemeProps } from '@mui/joy/styles'; export interface StatProps { value: number | string; unit: string; variant?: 'outlined'; } interface StatOwnerState extends StatProps { // …key value pairs for the internal state that you want to style the slot // but don't want to expose to the users } const StatRoot = styled('div', { name: 'JoyStat', slot: 'root', })<{ ownerState: StatOwnerState }>(({ theme, ownerState }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.vars.palette.background.surface, borderRadius: theme.vars.radius.sm, boxShadow: theme.vars.shadow.md, ...(ownerState.variant === 'outlined' && { border: `2px solid ${theme.palette.divider}`, boxShadow: 'none', }), })); const StatValue = styled('div', { name: 'JoyStat', slot: 'value', })<{ ownerState: StatOwnerState }>(({ theme }) => ({ ...theme.typography.h2, })); const StatUnit = styled('div', { name: 'JoyStat', slot: 'unit', })<{ ownerState: StatOwnerState }>(({ theme }) => ({ ...theme.typography['body-sm'], color: theme.vars.palette.text.tertiary, })); const Stat = React.forwardRef<HTMLDivElement, StatProps>(function Stat( inProps, ref, ) { const props = useThemeProps({ props: inProps, name: 'JoyStat' }); const { value, unit, variant, ...other } = props; const ownerState = { ...props, variant }; return ( <StatRoot ref={ref} ownerState={ownerState} {...other}> <StatValue ownerState={ownerState}>{value}</StatValue> <StatUnit ownerState={ownerState}>{unit}</StatUnit> </StatRoot> ); }); export default function StatFullTemplate() { return ( <Stack direction="row" spacing={2}> <Stat value="1.9M" unit="Favorites" /> <Stat value="5.1M" unit="Views" variant="outlined" /> </Stack> ); }
1,803
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/StatFullTemplate.tsx.preview
<Stat value="1.9M" unit="Favorites" /> <Stat value="5.1M" unit="Views" variant="outlined" />
1,804
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/StatSlots.js
import * as React from 'react'; import { styled } from '@mui/material/styles'; const StatRoot = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.vars.palette.background.surface, borderRadius: theme.vars.radius.sm, boxShadow: theme.vars.shadow.md, })); const StatValue = styled('div')(({ theme }) => ({ ...theme.typography.h2, })); const StatUnit = styled('div')(({ theme }) => ({ ...theme.typography['body-sm'], color: theme.vars.palette.text.tertiary, })); const Label = styled('div')(({ theme }) => ({ ...theme.typography['body-sm'], borderRadius: '2px', padding: theme.spacing(0, 1), position: 'absolute', color: '#fff', fontSize: '0.75rem', fontWeight: 500, backgroundColor: '#ff5252', })); export default function StatSlots() { return ( <StatRoot sx={{ outline: '1px solid #ff5252', outlineOffset: 4, position: 'relative' }} > <StatValue sx={{ outline: '1px solid #ff5252', position: 'relative' }}> 19,267 <Label sx={{ right: 0, top: 4, transform: 'translateX(100%)', }} > value </Label> </StatValue> <StatUnit sx={{ outline: '1px solid #ff5252', position: 'relative' }}> Active users / month <Label sx={{ right: 0, top: 2, transform: 'translateX(100%)', }} > unit </Label> </StatUnit> <Label sx={{ left: -4, top: 4, transform: 'translateX(-100%)', }} > root </Label> </StatRoot> ); }
1,805
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/creating-themed-components/creating-themed-components.md
# Creating themed components <p class="description">Learn how to create fully custom components that accept your app's theme.</p> ## Introduction Joy UI provides a powerful theming feature that lets you add your own components to the theme and treat them as if they're built-in components. If you are building a component library on top of Joy UI, you can follow the step-by-step guide below to create a custom component that is themeable across multiple projects. Alternatively, you can use the provided [template](#template) as a starting point for your component. :::info You don't need to connect your component to the theme if you are only using it in a single project. ::: ## Step-by-step guide This guide will walk you through how to build this statistics component, which accepts the app's theme as though it were a built-in Joy UI component: {{"demo": "StatComponent.js", "hideToolbar": true}} ### 1. Create the component slots Slots let you customize each individual element of the component by targeting its respective name in the [theme's styleOverrides](/joy-ui/customization/themed-components/#theme-style-overrides). This statistics component is composed of three slots: - `root`: the container of the component - `value`: the number of the statistics - `unit`: the unit or description of the statistics :::success Though you can give these slots any names you prefer, we recommend using `root` for the outermost container element for consistency with the rest of the library. ::: {{"demo": "StatSlots.js", "hideToolbar": true}} Use the `styled` API with `name` and `slot` parameters to create the slots, as shown below: ```js import * as React from 'react'; import { styled } from '@mui/joy/styles'; const StatRoot = styled('div', { name: 'JoyStat', // The component name slot: 'root', // The slot name })(({ theme }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.vars.palette.background.surface, borderRadius: theme.vars.radius.sm, boxShadow: theme.vars.shadow.md, })); const StatValue = styled('div', { name: 'JoyStat', slot: 'value', })(({ theme }) => ({ ...theme.typography.h2, })); const StatUnit = styled('div', { name: 'JoyStat', slot: 'unit', })(({ theme }) => ({ ...theme.typography['body-sm'], color: theme.vars.palette.text.tertiary, })); ``` ### 2. Create the component Assemble the component using the slots created in the previous step: ```js // /path/to/Stat.js import * as React from 'react'; const StatRoot = styled('div', { name: 'JoyStat', slot: 'root', })(…); const StatValue = styled('div', { name: 'JoyStat', slot: 'value', })(…); const StatUnit = styled('div', { name: 'JoyStat', slot: 'unit', })(…); const Stat = React.forwardRef(function Stat(props, ref) { const { value, unit, ...other } = props; return ( <StatRoot ref={ref} {...other}> <StatValue>{value}</StatValue> <StatUnit>{unit}</StatUnit> </StatRoot> ); }); export default Stat; ``` At this point, you'll be able to apply the theme to the `Stat` component like this: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ components: { // the component name defined in the `name` parameter // of the `styled` API JoyStat: { styleOverrides: { // the slot name defined in the `slot` and `overridesResolver` parameters // of the `styled` API root: { backgroundColor: '#121212', }, value: { color: '#fff', }, unit: { color: '#888', }, }, }, }, }); ``` ### 3. Style the slot with ownerState When you need to style the slot-based props or internal state, wrap them in the `ownerState` object and pass it to each slot as a prop. The `ownerState` is a special name that will not spread to the DOM via the `styled` API. Add a `variant` prop to the `Stat` component and use it to style the `root` slot, as shown below: ```diff const Stat = React.forwardRef(function Stat(props, ref) { + const { value, unit, variant, ...other } = props; + + const ownerState = { ...props, variant }; return ( - <StatRoot ref={ref} {...other}> - <StatValue>{value}</StatValue> - <StatUnit>{unit}</StatUnit> - </StatRoot> + <StatRoot ref={ref} ownerState={ownerState} {...other}> + <StatValue ownerState={ownerState}>{value}</StatValue> + <StatUnit ownerState={ownerState}>{unit}</StatUnit> + </StatRoot> ); }); ``` Then you can read `ownerState` in the slot to style it based on the `variant` prop. ```diff const StatRoot = styled('div', { name: 'JoyStat', slot: 'root', - })(({ theme }) => ({ + })(({ theme, ownerState }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.palette.background.paper, borderRadius: theme.shape.borderRadius, boxShadow: theme.shadows[2], letterSpacing: '-0.025em', fontWeight: 600, + ...ownerState.variant === 'outlined' && { + border: `2px solid ${theme.palette.divider}`, + }, })); ``` ### 4. Support theme default props To customize your component's default props for different projects, you need to use the `useThemeProps` API. ```diff + import { useThemeProps } from '@mui/joy/styles'; - const Stat = React.forwardRef(function Stat(props, ref) { + const Stat = React.forwardRef(function Stat(inProps, ref) { + const props = useThemeProps({ props: inProps, name: 'JoyStat' }); const { value, unit, ...other } = props; return ( <StatRoot ref={ref} {...other}> <StatValue>{value}</StatValue> <StatUnit>{unit}</StatUnit> </StatRoot> ); }); ``` Then you can customize the default props of your component like this: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ components: { JoyStat: { defaultProps: { variant: 'outlined', }, }, }, }); ``` ## TypeScript If you use TypeScript, you must create interfaces for the component props and ownerState: ```js interface StatProps { value: number | string; unit: string; variant?: 'outlined'; } interface StatOwnerState extends StatProps { // …key value pairs for the internal state that you want to style the slot // but don't want to expose to the users } ``` Then you can use them in the component and slots. ```js const StatRoot = styled('div', { name: 'JoyStat', slot: 'root', })<{ ownerState: StatOwnerState }>(({ theme, ownerState }) => ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.palette.background.paper, borderRadius: theme.shape.borderRadius, boxShadow: theme.shadows[2], letterSpacing: '-0.025em', fontWeight: 600, // typed-safe access to the `variant` prop ...(ownerState.variant === 'outlined' && { border: `2px solid ${theme.palette.divider}`, boxShadow: 'none', }), })); // …do the same for other slots const Stat = React.forwardRef<HTMLDivElement, StatProps>(function Stat(inProps, ref) { const props = useThemeProps({ props: inProps, name: 'JoyStat' }); const { value, unit, variant, ...other } = props; const ownerState = { ...props, variant }; return ( <StatRoot ref={ref} ownerState={ownerState} {...other}> <StatValue ownerState={ownerState}>{value}</StatValue> <StatUnit ownerState={ownerState}>{unit}</StatUnit> </StatRoot> ); }); ``` Finally, add the Stat component to the theme types. ```ts import { Theme, StyleOverrides } from '@mui/joy/styles'; import { StatProps, StatOwnerState } from '/path/to/Stat'; declare module '@mui/joy/styles' { interface Components { JoyStat?: { defaultProps?: Partial<StatProps>; styleOverrides?: StyleOverrides<StatProps, StatOwnerState, Theme>; }; } } ``` --- ## Template This template is the final product of the step-by-step guide above, demonstrating how to build a custom component that can be styled with the theme as if it was a built-in component. {{"demo": "StatFullTemplate.js", "defaultCodeOpen": true}}
1,806
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/DarkModeByDefault.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Sheet from '@mui/joy/Sheet'; import Chip from '@mui/joy/Chip'; import Typography from '@mui/joy/Typography'; const theme = extendTheme({ cssVarPrefix: 'demo' }); export default function DarkModeByDefault() { return ( <CssVarsProvider defaultMode="dark" // the props below are specific to this demo, // you might not need them in your app. // theme={theme} // the selector to apply CSS theme variables stylesheet. colorSchemeSelector="#demo_dark-mode-by-default" // // the local storage key to use modeStorageKey="demo_dark-mode-by-default" // // set as root provider disableNestedContext > <div id="demo_dark-mode-by-default"> <Sheet sx={{ px: 3, py: 1.5, borderRadius: 'sm' }}> <Typography component="div" endDecorator={ <Chip variant="outlined" color="primary" size="sm"> Default </Chip> } fontSize="lg" > Dark mode </Typography> </Sheet> </div> </CssVarsProvider> ); }
1,807
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/DarkModeByDefault.tsx
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Sheet from '@mui/joy/Sheet'; import Chip from '@mui/joy/Chip'; import Typography from '@mui/joy/Typography'; const theme = extendTheme({ cssVarPrefix: 'demo' }); export default function DarkModeByDefault() { return ( <CssVarsProvider defaultMode="dark" // the props below are specific to this demo, // you might not need them in your app. // theme={theme} // the selector to apply CSS theme variables stylesheet. colorSchemeSelector="#demo_dark-mode-by-default" // // the local storage key to use modeStorageKey="demo_dark-mode-by-default" // // set as root provider disableNestedContext > <div id="demo_dark-mode-by-default"> <Sheet sx={{ px: 3, py: 1.5, borderRadius: 'sm' }}> <Typography component="div" endDecorator={ <Chip variant="outlined" color="primary" size="sm"> Default </Chip> } fontSize="lg" > Dark mode </Typography> </Sheet> </div> </CssVarsProvider> ); }
1,808
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/IdentifySystemMode.js
import * as React from 'react'; import { CssVarsProvider, useColorScheme, extendTheme } from '@mui/joy/styles'; import Typography from '@mui/joy/Typography'; const theme = extendTheme({ cssVarPrefix: 'demo' }); function Identifier() { const { systemMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return ( <Typography component="div" fontSize="lg" sx={{ opacity: 0 }}> Calculating… </Typography> ); } return ( <Typography component="div" fontSize="lg"> Your system is in{' '} <Typography variant="outlined" fontSize="md" sx={{ boxShadow: 'sm', fontFamily: 'code', bgcolor: 'background.level1', }} > {systemMode} </Typography>{' '} mode. </Typography> ); } export default function IdentifySystemMode() { return ( <CssVarsProvider defaultMode="system" // The props below are specific to this demo, // you might not need them in your app. // theme={theme} // the local storage key to use. modeStorageKey="demo_identify-system-mode" // set as root provider disableNestedContext > <Identifier /> </CssVarsProvider> ); }
1,809
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/IdentifySystemMode.tsx
import * as React from 'react'; import { CssVarsProvider, useColorScheme, extendTheme } from '@mui/joy/styles'; import Typography from '@mui/joy/Typography'; const theme = extendTheme({ cssVarPrefix: 'demo' }); function Identifier() { const { systemMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return ( <Typography component="div" fontSize="lg" sx={{ opacity: 0 }}> Calculating… </Typography> ); } return ( <Typography component="div" fontSize="lg"> Your system is in{' '} <Typography variant="outlined" fontSize="md" sx={{ boxShadow: 'sm', fontFamily: 'code', bgcolor: 'background.level1', }} > {systemMode} </Typography>{' '} mode. </Typography> ); } export default function IdentifySystemMode() { return ( <CssVarsProvider defaultMode="system" // The props below are specific to this demo, // you might not need them in your app. // theme={theme} // the local storage key to use. modeStorageKey="demo_identify-system-mode" // set as root provider disableNestedContext > <Identifier /> </CssVarsProvider> ); }
1,810
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/IdentifySystemMode.tsx.preview
<CssVarsProvider defaultMode="system" // The props below are specific to this demo, // you might not need them in your app. // theme={theme} // the local storage key to use. modeStorageKey="demo_identify-system-mode" // set as root provider disableNestedContext > <Identifier /> </CssVarsProvider>
1,811
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/ModeToggle.js
import * as React from 'react'; import { CssVarsProvider, useColorScheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; function ModeSwitcher() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return ( <Button variant="soft" color="neutral" onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')} > {mode === 'dark' ? 'Turn light' : 'Turn dark'} </Button> ); } export default function ModeToggle() { // the `node` is used for attaching CSS variables to this demo, // you might not need it in your application. const [node, setNode] = React.useState(null); useEnhancedEffect(() => { setNode(document.getElementById('mode-toggle')); }, []); return ( <CssVarsProvider // the props below are specific to this demo, // you might not need them in your app. // // the element to apply [data-joy-color-scheme] attribute. colorSchemeNode={node || null} // // the selector to apply the CSS theme variables stylesheet. colorSchemeSelector="#mode-toggle" // // the local storage key to use. modeStorageKey="mode-toggle-demo" > <Box id="mode-toggle" sx={{ textAlign: 'center', flexGrow: 1, p: 2, m: -3, borderRadius: [0, 'sm'], }} > <ModeSwitcher /> </Box> </CssVarsProvider> ); }
1,812
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/ModeToggle.tsx
import * as React from 'react'; import { CssVarsProvider, useColorScheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; function ModeSwitcher() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return ( <Button variant="soft" color="neutral" onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')} > {mode === 'dark' ? 'Turn light' : 'Turn dark'} </Button> ); } export default function ModeToggle() { // the `node` is used for attaching CSS variables to this demo, // you might not need it in your application. const [node, setNode] = React.useState<HTMLElement | null>(null); useEnhancedEffect(() => { setNode(document.getElementById('mode-toggle')); }, []); return ( <CssVarsProvider // the props below are specific to this demo, // you might not need them in your app. // // the element to apply [data-joy-color-scheme] attribute. colorSchemeNode={node || null} // // the selector to apply the CSS theme variables stylesheet. colorSchemeSelector="#mode-toggle" // // the local storage key to use. modeStorageKey="mode-toggle-demo" > <Box id="mode-toggle" sx={{ textAlign: 'center', flexGrow: 1, p: 2, m: -3, borderRadius: [0, 'sm'], }} > <ModeSwitcher /> </Box> </CssVarsProvider> ); }
1,813
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/dark-mode/dark-mode.md
# Dark mode <p class="description">Learn about the different methods for applying dark mode to a Joy UI app.</p> ## Set as default To set dark mode as the default for your app, add `defaultMode: 'dark'` to your `<CssVarsProvider>` wrapper component: :::warning When you change the `defaultMode` to another value, you must clear the local storage for it to take effect. ::: {{"demo": "DarkModeByDefault.js"}} For server-side applications, check out the framework setup in [the section below](#server-side-rendering) and provide the same value to the `getInitColorSchemeScript` function: ```js getInitColorSchemeScript({ defaultMode: 'dark' }); ``` ## Matching device's preference Use `defaultMode: 'system'` to set your app's default mode to match the user's chosen preference on their device. ```jsx import { CssVarsProvider } from '@mui/joy/styles'; <CssVarsProvider defaultMode="system">...</CssVarsProvider>; ``` For server-side applications, check out the framework setup in [the section below](#server-side-rendering) and provide the same value to the `getInitColorSchemeScript` function: ```js getInitColorSchemeScript({ defaultMode: 'system' }); ``` ### Identify the system mode Use the `useColorScheme` React hook to check if the user's preference is in light or dark mode: ```js import { useColorScheme } from '@mui/joy/styles'; function SomeComponent() { const { mode, systemMode } = useColorScheme(); console.log(mode); // "system" console.log(systemMode); // "light" | "dark" based on the user's preference. } ``` {{"demo": "IdentifySystemMode.js"}} :::warning The `useColorScheme()` hook only works with components nested inside of `<CssVarsProvider>`—otherwise it will throw an error. ::: ## Creating a mode-toggle component You can create a toggle component to give users the option to select between modes. In the example below, we're using a `Button` component that calls `setMode` from the `useColorSchemes()` hook to handle the mode toggling. ```js import { useColorScheme } from '@mui/joy/styles'; import Button from '@mui/joy/Button'; function ModeToggle() { const { mode, setMode } = useColorScheme(); return ( <Button variant="outlined" color="neutral" onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')} > {mode === 'dark' ? 'Turn light' : 'Turn dark'} </Button> ); } ``` {{"demo": "ModeToggle.js"}} :::warning The `useColorScheme()` hook only works with components nested inside of `<CssVarsProvider>`—otherwise it will throw an error. ::: ## Server-side rendering notes ### Avoid hydration mismatch Make sure to render the UI when the page is mounted on the client. This is because the `mode` will only be available to the client-side (it is `undefined` on the server). If you try to render your UI based on the server, before mounting on the client, you'll see a hydration mismatch error. ```diff function ModeToggle() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + + if (!mounted) { + // to avoid layout shift, render a placeholder button + return <Button variant="outlined" color="neutral" sx={{ width: 120 }} />; + } return ( <Button variant="outlined" color="neutral" onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')} > {mode === 'dark' ? 'Turn light' : 'Turn dark'} </Button> ); }; ``` ### Avoiding screen flickering To [prevent the UI from flickering](/joy-ui/main-features/dark-mode-optimization/#the-problem-flickering-on-first-load), apply `getInitColorSchemeScript()` before the main application script-it varies across frameworks: ### Next.js Pages Router To use the Joy UI API with a Next.js project, add the following code to the custom [`pages/_document.js`](https://nextjs.org/docs/pages/building-your-application/routing/custom-document) file: ```jsx import Document, { Html, Head, Main, NextScript } from 'next/document'; import { getInitColorSchemeScript } from '@mui/joy/styles'; export default class MyDocument extends Document { render() { return ( <Html data-color-scheme="light"> <Head>...</Head> <body> {getInitColorSchemeScript()} <Main /> <NextScript /> </body> </Html> ); } } ```
1,814
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/default-theme-viewer/JoyDefaultTheme.js
import * as React from 'react'; import { extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import { ThemeProvider, createTheme } from '@mui/material/styles'; import ThemeViewer, { useNodeIdsLazy, } from 'docs/src/modules/components/ThemeViewer'; const defaultTheme = extendTheme(); export default function JoyDefaultTheme() { const [expandPaths, setExpandPaths] = React.useState(null); React.useEffect(() => { let expandPath; decodeURI(document.location.search.slice(1)) .split('&') .forEach((param) => { const [name, value] = param.split('='); if (name === 'expand-path') { expandPath = value; } }); if (!expandPath) { return; } setExpandPaths( expandPath .replace('$.', '') .split('.') .reduce((acc, path) => { const last = acc.length > 0 ? `${acc[acc.length - 1]}.` : ''; acc.push(last + path); return acc; }, []), ); }, []); const data = defaultTheme; const allNodeIds = useNodeIdsLazy(data); React.useDebugValue(allNodeIds); return ( <Box sx={{ width: '100%' }}> <ThemeProvider theme={() => createTheme()}> <ThemeViewer data={data} expandPaths={expandPaths} /> </ThemeProvider> </Box> ); }
1,815
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/default-theme-viewer/default-theme-viewer.md
# Default theme viewer <p class="description">Check out how the theme object looks like with the default values.</p> :::warning This is a work in progress. We're still iterating on Joy UI's default theme. ::: :::info To create your own theme, start by customizing the [theme colors](/joy-ui/customization/theme-colors/). ::: {{"demo": "JoyDefaultTheme.js", "hideToolbar": true, "bg": "inline"}}
1,816
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingInternalSlot.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Autocomplete from '@mui/joy/Autocomplete'; import AutocompleteListbox from '@mui/joy/AutocompleteListbox'; export default function OverridingInternalSlot() { return ( <Box sx={{ display: 'flex', flexDirection: 'column', width: 320 }}> <Autocomplete open multiple disableClearable placeholder="Type to search" options={[ { label: '🆘 Need help' }, { label: '✨ Improvement' }, { label: '🚀 New feature' }, { label: '🐛 Bug fix' }, ]} slots={{ listbox: AutocompleteListbox, }} /> </Box> ); }
1,817
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingInternalSlot.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Autocomplete from '@mui/joy/Autocomplete'; import AutocompleteListbox from '@mui/joy/AutocompleteListbox'; export default function OverridingInternalSlot() { return ( <Box sx={{ display: 'flex', flexDirection: 'column', width: 320 }}> <Autocomplete open multiple disableClearable placeholder="Type to search" options={[ { label: '🆘 Need help' }, { label: '✨ Improvement' }, { label: '🚀 New feature' }, { label: '🐛 Bug fix' }, ]} slots={{ listbox: AutocompleteListbox, }} /> </Box> ); }
1,818
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingInternalSlot.tsx.preview
<Autocomplete open multiple disableClearable placeholder="Type to search" options={[ { label: '🆘 Need help' }, { label: '✨ Improvement' }, { label: '🚀 New feature' }, { label: '🐛 Bug fix' }, ]} slots={{ listbox: AutocompleteListbox, }} />
1,819
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingRootSlot.js
import * as React from 'react'; import Button from '@mui/joy/Button'; export default function OverridingRootSlot() { return ( <Button component="a" href="https://mui.com/about/" target="_blank" rel="noopener noreferrer" > About us </Button> ); }
1,820
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingRootSlot.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; export default function OverridingRootSlot() { return ( <Button component="a" href="https://mui.com/about/" target="_blank" rel="noopener noreferrer" > About us </Button> ); }
1,821
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/OverridingRootSlot.tsx.preview
<Button component="a" href="https://mui.com/about/" target="_blank" rel="noopener noreferrer" > About us </Button>
1,822
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/overriding-component-structure/overriding-component-structure.md
# Overriding component structure <p class="description">Learn how to override the default DOM structure of Joy UI components.</p> Joy UI components are designed to suit the widest possible range of use cases, but you may occasionally need to change how a component's structure is rendered in the DOM. To understand how to do this, it helps to have an accurate mental model of MUI components. ## The mental model A component's structure is determined by the elements that fill that component's **slots**. Slots are most commonly filled by HTML tags, but may also be filled by React components. All components contain a root slot that defines their primary node in the DOM tree; more complex components also contain additional interior slots named after the elements they represent. All _non-utility_ Joy UI components accept two props for overriding their rendered HTML structure: - `component`—to override the root slot - `slots`—to replace any interior slots (when present) as well as the root Additionally, you can pass custom props to interior slots using `slotProps`. ## The root slot The root slot represents the component's outermost element. It is filled by a styled component with an appropriate HTML element. For example, the [Button's](/joy-ui/react-button/) root slot is a `<button>` element. This component _only_ has a root slot; more complex components may have additional [interior slots](#interior-slots). ### The component prop Use the `component` prop to override a component's root slot. The demo below shows how to replace the Button's `<button>` tag with a `<a>` to create a link button: {{"demo": "OverridingRootSlot.js"}} :::info The props `href`, `target`, and `rel` are specific to `<a>` tag. Be sure to use the appropriate attributes when you provide a custom `component` prop. ::: ## Interior slots Complex components are composed of one or more interior slots in addition to the root. These slots are often (but not necessarily) nested within the root. For example, the [Autocomplete](/joy-ui/react-autocomplete/) is composed of a root `<div>` that houses several interior slots named for the elements they represent: input, startDecorator, endDecorator, clearIndicator, popupIndicator and so on. ### The slots prop Use the `slots` prop to replace a component's interior slots. The example below shows how to replace the listbox slot in the [Autocomplete](/joy-ui/react-autocomplete/) component to remove the popup functionality: {{"demo": "OverridingInternalSlot.js"}} ### The slotProps prop The `slotProps` prop is an object that contains the props for all slots within a component. You can use it to define additional custom props to pass to a component's interior slots. For example, the code snippet below shows how to add a custom `data-testid` to the listbox slot of the [Autocomplete](/joy-ui/react-autocomplete/) component: ```jsx <Autocomplete slotProps={{ listbox: { 'data-testid': 'my-listbox' } }} /> ``` All additional props placed on the primary component are also propagated into the root slot (just as if they were placed in `slotProps.root`). These two examples are equivalent: ```jsx <Autocomplete id="badge1"> ``` ```jsx <Autocomplete slotProps={{ root: { id: 'badge1' } }}> ``` :::warning If both `slotProps.root` and additional props have the same keys but different values, the `slotProps.root` props will take precedence. This does not apply to classes or the `style` prop—they will be merged instead. ::: ## Best practices Use `component` or `slotProps.{slot}.component` prop to override the element by preserving the styles of the slot. Use `slots` prop to replace the slot's styles and functionality with your custom component. Overriding with `component` lets you apply the attributes of that element directly to the root. For instance, if you override the Button's root with an `<li>` tag, you can add the `<li>` attribute `value` directly to the component. If you did the same with `slots.root`, you would need to place this attribute on the `slotProps.root` object in order to avoid a TypeScript error. Be mindful of your rendered DOM structure when overriding the slots of more complex components. You can easily break the rules of semantic and accessible HTML if you deviate too far from the default structure—for instance, by unintentionally nesting block-level elements inside of inline elements. Joy UI components automatically correct semantically incorrect HTML—see [Automatic adjustment](/joy-ui/main-features/automatic-adjustment/) for details.
1,823
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-builder/theme-builder.md
# Theme builder <p class="description">Tools for tailoring your custom Joy UI theme.</p> ## Colors Use the visual color palette builder below to construct a custom theme. Click the **< >** icon in the top right corner when you're ready to copy and paste the code into your app. Read [the Theme colors page](/joy-ui/customization/theme-colors/) for details on working with colors in Joy UI. {{"component": "modules/components/JoyThemeBuilder.tsx"}}
1,824
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-colors/BootstrapVariantTokens.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; const palette = { primary: { solidBg: '#0d6efd', solidBorder: '#0d6efd', solidHoverBg: '#0b5ed7', solidHoverBorder: '#0a58ca', solidActiveBg: '#0a58ca', solidActiveBorder: '#0a53be', solidDisabledBg: '#0d6efd', solidDisabledBorder: '#0d6efd', }, neutral: { solidBg: '#6c757d', solidBorder: '#6c757d', solidHoverBg: '#5c636a', solidHoverBorder: '#565e64', solidActiveBg: '#565e64', solidActiveBorder: '#51585e', solidDisabledBg: '#6c757d', solidDisabledBorder: '#6c757d', // btn-light softColor: '#000', softBg: '#f8f9fa', softBorder: '#f8f9fa', softHoverBg: '#f9fafb', softHoverBorder: '#f9fafb', softActiveBg: '#f9fafb', softActiveBorder: '#f9fafb', softDisabledBg: '#f8f9fa', softDisabledBorder: '#f8f9fa', }, success: { solidBg: '#198754', solidBorder: '#198754', solidHoverBg: '#157347', solidHoverBorder: '#146c43', solidActiveBg: '#146c43', solidActiveBorder: '#13653f', solidDisabledBg: '#198754', solidDisabledBorder: '#198754', }, danger: { solidBg: '#dc3545', solidBorder: '#dc3545', solidHoverBg: '#bb2d3b', solidHoverBorder: '#b02a37', solidActiveBg: '#b02a37', solidActiveBorder: '#a52834', solidDisabledBg: '#dc3545', solidDisabledBorder: '#dc3545', }, warning: { solidColor: '#000', solidBg: '#ffc107', solidBorder: '#ffc107', solidHoverBg: '#ffca2c', solidHoverBorder: '#ffc720', solidActiveBg: '#ffcd39', solidActiveBorder: '#ffc720', solidDisabledBg: '#ffc107', solidDisabledBorder: '#ffc107', }, info: { solidColor: '#000', solidBg: '#0dcaf0', solidBorder: '#0dcaf0', solidHoverBg: '#31d2f2', solidHoverBorder: '#25cff2', solidActiveBg: '#3dd5f3', solidActiveBorder: '#25cff2', solidDisabledBg: '#0dcaf0', solidDisabledBorder: '#0dcaf0', }, }; const bootstrapTheme = extendTheme({ cssVarPrefix: 'bs', colorSchemes: { light: { palette }, dark: { palette }, }, components: { JoyButton: { styleOverrides: { root: ({ ownerState, theme }) => ({ letterSpacing: 'normal', fontWeight: theme.vars.fontWeight.md, fontFamily: theme.vars.fontFamily.fallback, outlineWidth: 0, borderRadius: '0.375rem', transition: 'color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out', ...(ownerState.size === 'md' && { paddingInline: '0.75rem', minHeight: 38, }), }), }, }, }, }); const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; export default function BootstrapVariantTokens() { // the `node` is used for attaching CSS variables to this demo, you might not need it in your application. const [node, setNode] = React.useState(null); useEnhancedEffect(() => { setNode(document.getElementById('bootstrap-buttons-demo')); }, []); return ( <CssVarsProvider theme={bootstrapTheme} colorSchemeNode={node || null} colorSchemeSelector="#bootstrap-buttons-demo" > <Box id="bootstrap-buttons-demo" sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }} > <Button>Primary</Button> <Button color="neutral">Secondary</Button> <Button color="success">Success</Button> <Button color="danger">Danger</Button> <Button color="warning">Warning</Button> <Button variant="soft" color="neutral"> Light </Button> </Box> </CssVarsProvider> ); }
1,825
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-colors/PaletteThemeViewer.js
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import { extendTheme, styled } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Link from '@mui/joy/Link'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import LightMode from '@mui/icons-material/LightModeOutlined'; import DarkMode from '@mui/icons-material/DarkModeOutlined'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded'; import useClipboardCopy from 'docs/src/modules/utils/useClipboardCopy'; const defaultTheme = extendTheme(); const traverseObject = (palette) => { const result = {}; const traverse = (object, parts = []) => { if (object && typeof object === 'object') { // eslint-disable-next-line no-restricted-syntax for (const key of Object.keys(object)) { traverse(object[key], [...parts, key]); } } else { result[parts.join('.')] = object; } }; traverse(palette); return result; }; // https://stackoverflow.com/a/38641281/559913 const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base', }); const Table = styled('table')(({ theme }) => ({ borderCollapse: 'separate', borderSpacing: 0, display: 'block', height: 500, overflowY: 'scroll', th: { textAlign: 'left', padding: 8, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '3px 6px', }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); export default function PaletteThemeViewer() { const { copy, isCopied } = useClipboardCopy(); const light = traverseObject(defaultTheme.colorSchemes.light.palette); const dark = traverseObject(defaultTheme.colorSchemes.dark.palette); const paletteTokens = Array.from( new Set([...Object.keys(dark), ...Object.keys(light)]), ).sort(collator.compare); const renderSwatch = (colorScheme, token) => ( <Box component="span" data-joy-color-scheme={colorScheme} sx={{ position: 'relative', width: '1em', height: '1em', fontSize: 'var(--Icon-fontSize)', borderRadius: '2px', backgroundImage: `linear-gradient(90deg, var(--joy-palette-text-tertiary) 50%, transparent 50%), linear-gradient(90deg, transparent 50%, var(--joy-palette-text-tertiary) 50%)`, backgroundRepeat: 'repeat-x', backgroundSize: '100% 50%, 100% 50%', backgroundPosition: '0 0, 0 100%', '&::after': { content: '""', position: 'absolute', display: 'block', inset: 0, bgcolor: token, borderRadius: 'inherit', boxShadow: 'inset 0 0 0 1px #bababa', }, }} /> ); return ( <Box sx={{ marginBottom: '-9px', width: '100%', overflow: 'hidden', position: 'relative', border: '1px solid', borderColor: 'divider', borderTopLeftRadius: '12px', borderTopRightRadius: '12px', }} > <Sheet variant="solid" color="success" sx={{ position: 'absolute', left: '50%', bottom: 0, transform: `translateX(-50%) translateY(${ isCopied ? '-0.5rem' : 'calc(100% + 0.5rem)' })`, transition: '0.3s', p: 0.5, pl: 0.5, pr: 1, borderRadius: 'xl', boxShadow: 'md', zIndex: 1, }} > <Typography level="body-xs" textColor="inherit" startDecorator={<CheckCircleRoundedIcon fontSize="small" />} > Copied </Typography> </Sheet> <Table> <thead> <tr> <th> <Typography fontSize="sm" textColor="inherit"> Token </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<LightMode />} textColor="inherit" > Light </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<DarkMode />} textColor="inherit" > Dark </Typography> </th> </tr> </thead> <tbody> {paletteTokens .filter((token) => token !== 'mode') .map((token) => ( <tr key={token}> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="sm" fontWeight="md" textAlign="left" onClick={() => copy(token)} endDecorator={ light[token].match(/^[0-9]+\s[0-9]+\s[0-9]+$/) ? ( <Tooltip size="sm" arrow title={ <Typography> Translucent color usage: <br /> <Typography fontFamily="code" component="code" sx={{ py: 1, display: 'block' }} > rgba(var(--joy-palette-{token.replace('.', '-')}) / 0.6) </Typography> </Typography> } sx={{ pointerEvents: 'none' }} > <InfoOutlined sx={{ cursor: 'initial' }} /> </Tooltip> ) : null } sx={{ cursor: 'copy' }} > {token} </Link> </td> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="xs" startDecorator={renderSwatch('light', token)} fontFamily="code" textAlign="left" sx={{ alignItems: 'flex-start', cursor: 'copy' }} onClick={() => copy(light[token])} > {light[token]} </Link> </td> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="xs" startDecorator={renderSwatch('dark', token)} fontFamily="code" textAlign="left" sx={{ alignItems: 'flex-start', cursor: 'copy' }} onClick={() => copy(dark[token])} > {dark[token]} </Link> </td> </tr> ))} </tbody> </Table> </Box> ); }
1,826
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-colors/PaletteThemeViewer.tsx
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import { extendTheme, Palette, styled } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Link from '@mui/joy/Link'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import LightMode from '@mui/icons-material/LightModeOutlined'; import DarkMode from '@mui/icons-material/DarkModeOutlined'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded'; import useClipboardCopy from 'docs/src/modules/utils/useClipboardCopy'; const defaultTheme = extendTheme(); const traverseObject = (palette: Palette) => { const result: Record<string, any> = {}; const traverse = (object: any, parts: string[] = []) => { if (object && typeof object === 'object') { // eslint-disable-next-line no-restricted-syntax for (const key of Object.keys(object)) { traverse(object[key], [...parts, key]); } } else { result[parts.join('.')] = object; } }; traverse(palette); return result; }; // https://stackoverflow.com/a/38641281/559913 const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base', }); const Table = styled('table')(({ theme }) => ({ borderCollapse: 'separate', borderSpacing: 0, display: 'block', height: 500, overflowY: 'scroll', th: { textAlign: 'left', padding: 8, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '3px 6px', }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); export default function PaletteThemeViewer() { const { copy, isCopied } = useClipboardCopy(); const light = traverseObject(defaultTheme.colorSchemes.light.palette); const dark = traverseObject(defaultTheme.colorSchemes.dark.palette); const paletteTokens = Array.from( new Set([...Object.keys(dark), ...Object.keys(light)]), ).sort(collator.compare); const renderSwatch = (colorScheme: 'light' | 'dark', token: string) => ( <Box component="span" data-joy-color-scheme={colorScheme} sx={{ position: 'relative', width: '1em', height: '1em', fontSize: 'var(--Icon-fontSize)', borderRadius: '2px', backgroundImage: `linear-gradient(90deg, var(--joy-palette-text-tertiary) 50%, transparent 50%), linear-gradient(90deg, transparent 50%, var(--joy-palette-text-tertiary) 50%)`, backgroundRepeat: 'repeat-x', backgroundSize: '100% 50%, 100% 50%', backgroundPosition: '0 0, 0 100%', '&::after': { content: '""', position: 'absolute', display: 'block', inset: 0, bgcolor: token, borderRadius: 'inherit', boxShadow: 'inset 0 0 0 1px #bababa', }, }} /> ); return ( <Box sx={{ marginBottom: '-9px', width: '100%', overflow: 'hidden', position: 'relative', border: '1px solid', borderColor: 'divider', borderTopLeftRadius: '12px', borderTopRightRadius: '12px', }} > <Sheet variant="solid" color="success" sx={{ position: 'absolute', left: '50%', bottom: 0, transform: `translateX(-50%) translateY(${ isCopied ? '-0.5rem' : 'calc(100% + 0.5rem)' })`, transition: '0.3s', p: 0.5, pl: 0.5, pr: 1, borderRadius: 'xl', boxShadow: 'md', zIndex: 1, }} > <Typography level="body-xs" textColor="inherit" startDecorator={<CheckCircleRoundedIcon fontSize="small" />} > Copied </Typography> </Sheet> <Table> <thead> <tr> <th> <Typography fontSize="sm" textColor="inherit"> Token </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<LightMode />} textColor="inherit" > Light </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<DarkMode />} textColor="inherit" > Dark </Typography> </th> </tr> </thead> <tbody> {paletteTokens .filter((token) => token !== 'mode') .map((token) => ( <tr key={token}> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="sm" fontWeight="md" textAlign="left" onClick={() => copy(token)} endDecorator={ light[token].match(/^[0-9]+\s[0-9]+\s[0-9]+$/) ? ( <Tooltip size="sm" arrow title={ <Typography> Translucent color usage: <br /> <Typography fontFamily="code" component="code" sx={{ py: 1, display: 'block' }} > rgba(var(--joy-palette-{token.replace('.', '-')}) / 0.6) </Typography> </Typography> } sx={{ pointerEvents: 'none' }} > <InfoOutlined sx={{ cursor: 'initial' }} /> </Tooltip> ) : null } sx={{ cursor: 'copy' }} > {token} </Link> </td> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="xs" startDecorator={renderSwatch('light', token)} fontFamily="code" textAlign="left" sx={{ alignItems: 'flex-start', cursor: 'copy' }} onClick={() => copy(light[token])} > {light[token]} </Link> </td> <td> <Link component="button" color="neutral" textColor="inherit" fontSize="xs" startDecorator={renderSwatch('dark', token)} fontFamily="code" textAlign="left" sx={{ alignItems: 'flex-start', cursor: 'copy' }} onClick={() => copy(dark[token])} > {dark[token]} </Link> </td> </tr> ))} </tbody> </Table> </Box> ); }
1,827
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-colors/RemoveActiveTokens.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; // ⚠️ If the value is `undefined`, it should be `undefined` for other color schemes as well. const theme = extendTheme({ colorSchemes: { light: { palette: { primary: { solidActiveBg: undefined, }, }, }, dark: { palette: { primary: { solidActiveBg: undefined, }, }, }, }, }); const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; export default function RemoveActiveTokens() { // the `node` is used for attaching CSS variables to this demo, you might not need it in your application. const [node, setNode] = React.useState(null); useEnhancedEffect(() => { setNode(document.getElementById('remove-active-tokens-demo')); }, []); return ( <CssVarsProvider theme={theme} colorSchemeNode={node || null} colorSchemeSelector="#remove-active-tokens-demo" > <Box id="remove-active-tokens-demo" sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }} > <Button>Button</Button> </Box> </CssVarsProvider> ); }
1,828
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-colors/theme-colors.md
# Theme colors <p class="description">Learn about the default theme's color palette and how to customize it.</p> ## Default color tokens Joy UI's default theme includes 5 built-in semantic color palettes, with light and dark mapping, to help you build great looking UIs quickly. {{"demo": "PaletteThemeViewer.js", "bg": "inline"}} :::info Some tokens reuse color values from others using the [`var(--*)`](https://developer.mozilla.org/en-US/docs/Web/CSS/var) syntax. ::: ### Global variant tokens One of Joy UI's main features is the four [global variants](/joy-ui/main-features/global-variants/) that are available in every component. They use the built-in color palettes following the format of **variant type | state | CSS property**. For example: - `solidBg` refers to the solid variant's background color in its initial state. - `outlinedHoverBorder` refers to the outlined variant's border color in its hover state. ### Channel tokens The channel tokens helps creating translucent colors using (`rgba`). The ones ending with `Channel` are automatically generated for each palette. - `lightChannel`: is generated from the palette's `200` token. - `mainChannel`: is generated from the palette's `500` token. - `darkChannel`: is generated from the palette's `800` token. The code snippet below shows how to use them: ```js import Typography from '@mui/joy/Typography'; <Typography sx={theme => ({ color: `rgba(${theme.vars.palette.primary.mainChannel} / 0.72)`, })} > ``` ## Customizations ### Changing the default values To change the HEX code for each color while still following the palette pattern, extend the theme by accessing them through the `palette` node on the target mode (light or dark): ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ colorSchemes: { dark: { palette: { primary: { 50: '#C0CCD9', 100: '#A5B8CF', 200: '#6A96CA', 300: '#4886D0', 400: '#2178DD', 500: '#096BDE', 600: '#1B62B5', 700: '#265995', 800: '#2F4968', 900: '#2F3C4C', }, }, }, }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` ### Changing the global variant tokens A good way to start changing how color looks like with the built-in variants is by using the Button component as a jumping-off point. For example, here's how you'd make the Joy UI Button match the colors of another system, such as [Bootstrap](https://getbootstrap.com/docs/5.2/components/buttons/#examples): {{"demo": "BootstrapVariantTokens.js"}} - Bootstrap's default buttons are comparable to Joy UI's `solid` variant. - Bootstrap's `secondary` variant uses a grey color, similar to Joy UI's `neutral`. - Bootstrap's `btn-light` is similar to Joy UI's button using the `soft` variant and `neutral` color palette. - Joy UI's defaults don't include anything similar to Bootstrap's `btn-dark`. - We can recreate it using one of the three main customization approaches. ### Adding color tokens To make any new color available through the `color` prop, insert them in the `colorSchemes` key of the extended theme. You'll also be able to access them with both the `styled` and `sx` APIs. ```js extendTheme({ colorSchemes: { light: { palette: { // `gradient` is a new color token gradient: { primary: 'linear-gradient(to top, var(--joy-palette-primary-main), #000)', }, }, }, }, }); // `sx` prop usage example: <Button sx={{ background: (theme) => theme.vars.palette.gradient.primary }} />; ``` :::success We recommend to limit them to 3 levels deep-in this case: `palette.gradient.primary`. ::: #### TypeScript Augment the theme's `Palette` interface, when working in TypeScript, to include the new tokens. ```ts // You can put this to any file that's included in your tsconfig declare module '@mui/joy/styles' { interface Palette { gradient: { primary: string; }; } } ``` :::success Adding custom tokens increases your stylesheet's bundle size, and adds an extra set of maintenance costs to your app. These tradeoffs mean that adding new tokens is usually only worthwhile when you know that they'll be used by many components. As an alternative, consider using [the `sx` prop](/joy-ui/customization/approaches/#sx-prop) for one-off customizations. ::: ### Adding new palettes To add entirely new color palettes, with any type of scale, and make them available through the `color` prop, insert them in the `colorSchemes` key of the extended theme. The snippet below adds a custom `secondary` palette to the theme. ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ colorSchemes: { light: { palette: { secondary: { // Credit: // https://github.com/tailwindlabs/tailwindcss/blob/master/src/public/colors.js 50: '#fdf2f8', 100: '#fce7f3', 200: '#fbcfe8', 300: '#f9a8d4', 400: '#f472b6', 500: '#ec4899', 600: '#db2777', 700: '#be185d', 800: '#9d174d', 900: '#831843', // Adjust the global variant tokens as you'd like. // The tokens should be the same for all color schemes. solidBg: 'var(--joy-palette-secondary-400)', solidActiveBg: 'var(--joy-palette-secondary-500)', outlinedBorder: 'var(--joy-palette-secondary-500)', outlinedColor: 'var(--joy-palette-secondary-700)', outlinedActiveBg: 'var(--joy-palette-secondary-100)', softColor: 'var(--joy-palette-secondary-800)', softBg: 'var(--joy-palette-secondary-200)', softActiveBg: 'var(--joy-palette-secondary-300)', plainColor: 'var(--joy-palette-secondary-700)', plainActiveBg: 'var(--joy-palette-secondary-100)', }, }, }, dark: { palette: { secondary: { // Credit: // https://github.com/tailwindlabs/tailwindcss/blob/master/src/public/colors.js 50: '#fdf2f8', 100: '#fce7f3', 200: '#fbcfe8', 300: '#f9a8d4', 400: '#f472b6', 500: '#ec4899', 600: '#db2777', 700: '#be185d', 800: '#9d174d', 900: '#831843', // Adjust the global variant tokens as you'd like. // The tokens should be the same for all color schemes. solidBg: 'var(--joy-palette-secondary-400)', solidActiveBg: 'var(--joy-palette-secondary-500)', outlinedBorder: 'var(--joy-palette-secondary-700)', outlinedColor: 'var(--joy-palette-secondary-600)', outlinedActiveBg: 'var(--joy-palette-secondary-900)', softColor: 'var(--joy-palette-secondary-500)', softBg: 'var(--joy-palette-secondary-900)', softActiveBg: 'var(--joy-palette-secondary-800)', plainColor: 'var(--joy-palette-secondary-500)', plainActiveBg: 'var(--joy-palette-secondary-900)', }, }, }, }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` Then, you will be able to use `secondary` color on Joy UI components: ```js <Button color="secondary"> <IconButton variant="outlined" color="secondary"> <Chip variant="soft" color="secondary"> ``` #### TypeScript When working in TypeScript, you must augment the theme's interfaces to include the new palette. ```ts // You can put this to any file that's included in your tsconfig import type { PaletteRange } from '@mui/joy/styles'; declare module '@mui/joy/styles' { interface ColorPalettePropOverrides { // apply to all Joy UI components that support `color` prop secondary: true; } interface Palette { // this will make the node `secondary` configurable in `extendTheme` // and add `secondary` to the theme's palette. secondary: PaletteRange; } } ``` :::warning Note that adding new palettes increases the HTML bundle size. ::: ### Removing the default tokens To remove any default token, use `undefined` as a value within the extended theme. This removes them from the `theme` object and prevents the corresponding CSS variable from being generated. For example, all default global variant color tokens comes with styles for the `:active` pseudo class. Here's how you'd remove it from the solid variant. ```jsx // ⚠️ If the value is `undefined`, it should be `undefined` for all color schemes. const theme = extendTheme({ colorSchemes: { light: { palette: { primary: { solidActiveBg: undefined, }, }, }, dark: { palette: { primary: { solidActiveBg: undefined, }, }, }, }, }); ``` {{"demo": "RemoveActiveTokens.js"}}
1,829
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-shadow/CustomShadowOnElement.js
import * as React from 'react'; import Button from '@mui/joy/Button'; export default function CustomShadowOnElement() { return ( <Button size="lg" sx={(theme) => ({ boxShadow: theme.shadow.md, transition: '0.2s', '--joy-shadowChannel': theme.vars.palette.primary.mainChannel, '--joy-shadowRing': 'inset 0 -3px 0 rgba(0 0 0 / 0.24)', '&:hover': { boxShadow: theme.shadow.lg, transform: 'translateY(-3px)', }, '&:active': { boxShadow: theme.shadow.md, transform: 'translateY(0px)', '--joy-shadowRing': '0 0 #000', }, })} > Buy </Button> ); }
1,830
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-shadow/CustomShadowOnElement.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; export default function CustomShadowOnElement() { return ( <Button size="lg" sx={(theme) => ({ boxShadow: theme.shadow.md, transition: '0.2s', '--joy-shadowChannel': theme.vars.palette.primary.mainChannel, '--joy-shadowRing': 'inset 0 -3px 0 rgba(0 0 0 / 0.24)', '&:hover': { boxShadow: theme.shadow.lg, transform: 'translateY(-3px)', }, '&:active': { boxShadow: theme.shadow.md, transform: 'translateY(0px)', '--joy-shadowRing': '0 0 #000', }, })} > Buy </Button> ); }
1,831
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-shadow/ShadowThemeViewer.js
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import { styled, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import LightMode from '@mui/icons-material/LightModeOutlined'; import DarkMode from '@mui/icons-material/DarkModeOutlined'; import Check from '@mui/icons-material/CheckCircle'; import useClipboardCopy from 'docs/src/modules/utils/useClipboardCopy'; const Table = styled('table')(({ theme }) => ({ border: '1px solid', borderColor: theme.vars.palette.divider, borderRadius: theme.vars.radius.md, borderCollapse: 'separate', borderSpacing: 0, width: '100%', overflowY: 'scroll', th: { textAlign: 'left', padding: 12, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '8px 12px', }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); const defaultTheme = extendTheme(); export default function ShadowThemeViewer() { const { copy, isCopied } = useClipboardCopy(); const tokens = Object.keys(defaultTheme.shadow); const formatShadowLayers = (shadow) => React.Children.toArray( shadow .split(', ') .reduce( (result, curr, index, array) => array.length - 1 !== index ? [...result, `${curr},`, <br />] : [...result, curr], [], ), ); return ( <Box sx={{ width: '100%', overflow: 'hidden', position: 'relative' }}> <Sheet variant="solid" color="success" sx={{ position: 'absolute', left: '50%', bottom: 0, transform: `translateX(-50%) translateY(${ isCopied ? '-0.5rem' : 'calc(100% + 0.5rem)' })`, transition: '0.3s', p: 0.5, px: 0.75, borderRadius: 'xs', boxShadow: 'sm', zIndex: 1, }} > <Typography level="body-xs" textColor="inherit" startDecorator={<Check />}> Copied </Typography> </Sheet> <Table> <thead> <tr> <th> <Typography fontSize="sm">Token</Typography> </th> <th> <Typography fontSize="sm">Value</Typography> </th> <th> <Typography fontSize="sm" startDecorator={<LightMode />}> Light </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<DarkMode />}> Dark </Typography> </th> </tr> </thead> <tbody> {tokens.map((token) => ( <tr key={token}> <td> <Typography fontSize="sm">{token}</Typography> </td> <td> <Link component="button" color="neutral" textColor="inherit" textAlign="left" fontSize="xs" fontFamily="code" onClick={() => copy(token)} > {formatShadowLayers(defaultTheme.shadow[token])} </Link> </td> <td data-joy-color-scheme="light"> <Sheet variant="outlined" sx={{ width: 64, height: 64, boxShadow: (theme) => theme.shadow[token], borderRadius: 'xs', mr: 2, }} /> </td> <td data-joy-color-scheme="dark"> <Sheet variant="outlined" sx={{ width: 64, height: 64, boxShadow: (theme) => theme.shadow[token], borderRadius: 'xs', }} /> </td> </tr> ))} </tbody> </Table> </Box> ); }
1,832
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-shadow/ShadowThemeViewer.tsx
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import { styled, extendTheme, Shadow } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import LightMode from '@mui/icons-material/LightModeOutlined'; import DarkMode from '@mui/icons-material/DarkModeOutlined'; import Check from '@mui/icons-material/CheckCircle'; import useClipboardCopy from 'docs/src/modules/utils/useClipboardCopy'; const Table = styled('table')(({ theme }) => ({ border: '1px solid', borderColor: theme.vars.palette.divider, borderRadius: theme.vars.radius.md, borderCollapse: 'separate', borderSpacing: 0, width: '100%', overflowY: 'scroll', th: { textAlign: 'left', padding: 12, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '8px 12px', }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); const defaultTheme = extendTheme(); export default function ShadowThemeViewer() { const { copy, isCopied } = useClipboardCopy(); const tokens = Object.keys(defaultTheme.shadow) as Array<keyof Shadow>; const formatShadowLayers = (shadow: string) => React.Children.toArray( shadow .split(', ') .reduce<Array<React.ReactNode>>( (result, curr, index, array) => array.length - 1 !== index ? [...result, `${curr},`, <br />] : [...result, curr], [], ), ); return ( <Box sx={{ width: '100%', overflow: 'hidden', position: 'relative' }}> <Sheet variant="solid" color="success" sx={{ position: 'absolute', left: '50%', bottom: 0, transform: `translateX(-50%) translateY(${ isCopied ? '-0.5rem' : 'calc(100% + 0.5rem)' })`, transition: '0.3s', p: 0.5, px: 0.75, borderRadius: 'xs', boxShadow: 'sm', zIndex: 1, }} > <Typography level="body-xs" textColor="inherit" startDecorator={<Check />}> Copied </Typography> </Sheet> <Table> <thead> <tr> <th> <Typography fontSize="sm">Token</Typography> </th> <th> <Typography fontSize="sm">Value</Typography> </th> <th> <Typography fontSize="sm" startDecorator={<LightMode />}> Light </Typography> </th> <th> <Typography fontSize="sm" startDecorator={<DarkMode />}> Dark </Typography> </th> </tr> </thead> <tbody> {tokens.map((token) => ( <tr key={token}> <td> <Typography fontSize="sm">{token}</Typography> </td> <td> <Link component="button" color="neutral" textColor="inherit" textAlign="left" fontSize="xs" fontFamily="code" onClick={() => copy(token)} > {formatShadowLayers(defaultTheme.shadow[token])} </Link> </td> <td data-joy-color-scheme="light"> <Sheet variant="outlined" sx={{ width: 64, height: 64, boxShadow: (theme) => theme.shadow[token], borderRadius: 'xs', mr: 2, }} /> </td> <td data-joy-color-scheme="dark"> <Sheet variant="outlined" sx={{ width: 64, height: 64, boxShadow: (theme) => theme.shadow[token], borderRadius: 'xs', }} /> </td> </tr> ))} </tbody> </Table> </Box> ); }
1,833
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-shadow/theme-shadow.md
# Theme shadow <p class="description">Learn about the default theme's shadow scale and how to customize it.</p> ## Default tokens Joy UI uses a T-shirt scale (sm, md, lg, etc.) for defining shadows used by components such as [Card](/joy-ui/react-card/), [Menu](/joy-ui/react-menu/), and more. These tokens are grouped inside the `theme.shadow` node: {{"demo": "ShadowThemeViewer.js", "bg": "inline"}} ## Customizing the default shadow Provide key-values to the `shadow` node to override the default shadows: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ shadow: { xs: '{CSS box-shadow}', sm: '{CSS box-shadow}', md: '{CSS box-shadow}', lg: '{CSS box-shadow}', xl: '{CSS box-shadow}', }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` :::success We recommend using `var(--joy-shadowRing)` and `var(--joy-shadowChannel)` for shadow values, similar to the [default token value](#default-tokens). ::: ## Adding new shadows You can add any custom keys to the `shadow` node: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ shadow: { subtle: '{CSS box-shadow}', strong: '{CSS box-shadow}', }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` ### TypeScript When working in TypeScript, you need to augment the theme's `Shadow` interface with the new keys: ```ts // You can put this to any file that's included in your tsconfig declare module '@mui/joy/styles' { interface Shadow { subtle: string; strong: string; } } ``` ## Shadow ring The shadow ring can be configured for both light and dark color schemes. To create a shadow ring, provide a valid CSS box-shadow value to the `shadowRing` node: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ colorSchemes: { light: { // This creates a 1px box-shadow. shadowRing: '0 0 0 1px rgba(0 0 0 / 0.1)', }, dark: { shadowChannel: '0 0 0 1px rgba(255 255 255 / 0.1)', }, }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` :::warning Customizing the theme's shadow ring will affect all Joy UI components that consume the theme's shadows. If you want to create a shadow ring for a specific element, see [Customizing shadows on an element](#customizing-shadows-on-an-element). ::: ## Shadow colors The color of the shadow comes from the theme token named `var(--joy-shadowChannel)`. You can customize the value for both light and dark color schemes: ```js import { extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ colorSchemes: { light: { shadowChannel: '12 12 12', }, dark: { shadowChannel: '0 0 0', }, }, }); // Then, pass it to `<CssVarsProvider theme={theme}>`. ``` :::warning The `shadowChannel` value must be rgb channels, e.g. `187 187 187`. ::: ## Customizing shadows on an element To customize a shadow color or shadow ring on a specific instance, use the raw value from the `theme.shadow.*`. :::error **Don't** use shadows from `theme.vars` or the shorthand syntax `{ shadow: '{key}' }` because the value points to the global CSS variable which does not work with the custom `shadowChannel` and `shadowRing` on the instance. ::: ```js // ✅ <Button sx={(theme) => ({ boxShadow: theme.shadow.md, '--joy-shadowChannel': theme.vars.palette.primary.mainChannel, '--joy-shadowRing': 'inset 0 -3px 0 rgba(0 0 0 / 0.24)', })} > // ❌ Both of these do not work <Button sx={(theme) => ({ boxShadow: 'md', '--joy-shadowChannel': theme.vars.palette.primary.mainChannel, '--joy-shadowRing': 'inset 0 -3px 0 rgba(0 0 0 / 0.24)', })} > <Button sx={(theme) => ({ boxShadow: theme.vars.shadow.md, '--joy-shadowChannel': theme.vars.palette.primary.mainChannel, '--joy-shadowRing': 'inset 0 -3px 0 rgba(0 0 0 / 0.24)', })} > ``` {{"demo": "CustomShadowOnElement.js"}}
1,834
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/CustomTypographyLevel.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; const customTheme = extendTheme({ typography: { h1: { // `--joy` is the default CSS variable prefix. // If you have a custom prefix, you have to use it instead. // For more details about the custom prefix, go to https://mui.com/joy-ui/customization/using-css-variables/#custom-prefix background: 'linear-gradient(-30deg, var(--joy-palette-primary-700), var(--joy-palette-primary-400))', // `Webkit*` properties must come later. WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent', }, }, }); export default function CustomTypographyLevel() { return ( <CssVarsProvider theme={customTheme}> <Box sx={(theme) => theme.typography.h1}>This is a gradient h1</Box> </CssVarsProvider> ); }
1,835
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/CustomTypographyLevel.tsx
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; const customTheme = extendTheme({ typography: { h1: { // `--joy` is the default CSS variable prefix. // If you have a custom prefix, you have to use it instead. // For more details about the custom prefix, go to https://mui.com/joy-ui/customization/using-css-variables/#custom-prefix background: 'linear-gradient(-30deg, var(--joy-palette-primary-700), var(--joy-palette-primary-400))', // `Webkit*` properties must come later. WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent', }, }, }); export default function CustomTypographyLevel() { return ( <CssVarsProvider theme={customTheme}> <Box sx={(theme) => theme.typography.h1}>This is a gradient h1</Box> </CssVarsProvider> ); }
1,836
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/CustomTypographyLevel.tsx.preview
<CssVarsProvider theme={customTheme}> <Box sx={(theme) => theme.typography.h1}>This is a gradient h1</Box> </CssVarsProvider>
1,837
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/NewTypographyLevel.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Typography from '@mui/joy/Typography'; const customTheme = extendTheme({ typography: { kbd: { background: 'linear-gradient(to top, var(--joy-palette-background-level2), var(--joy-palette-background-surface))', border: '1px solid var(--joy-palette-neutral-outlinedBorder)', borderRadius: 'var(--joy-radius-xs)', boxShadow: 'var(--joy-shadow-sm)', padding: '0.125em 0.375em', }, }, }); export default function NewTypographyLevel() { return ( <CssVarsProvider theme={customTheme}> <div> <Typography> Press <Typography level="kbd">⌘</Typography> +{' '} <Typography level="kbd">k</Typography> to search the documentation. </Typography> </div> </CssVarsProvider> ); }
1,838
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/NewTypographyLevel.tsx
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Typography from '@mui/joy/Typography'; declare module '@mui/joy/styles' { interface TypographySystemOverrides { kbd: true; } } const customTheme = extendTheme({ typography: { kbd: { background: 'linear-gradient(to top, var(--joy-palette-background-level2), var(--joy-palette-background-surface))', border: '1px solid var(--joy-palette-neutral-outlinedBorder)', borderRadius: 'var(--joy-radius-xs)', boxShadow: 'var(--joy-shadow-sm)', padding: '0.125em 0.375em', }, }, }); export default function NewTypographyLevel() { return ( <CssVarsProvider theme={customTheme}> <div> <Typography> Press <Typography level="kbd">⌘</Typography> +{' '} <Typography level="kbd">k</Typography> to search the documentation. </Typography> </div> </CssVarsProvider> ); }
1,839
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/NewTypographyLevel.tsx.preview
<CssVarsProvider theme={customTheme}> <div> <Typography> Press <Typography level="kbd">⌘</Typography> +{' '} <Typography level="kbd">k</Typography> to search the documentation. </Typography> </div> </CssVarsProvider>
1,840
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/TypographyThemeViewer.js
import * as React from 'react'; import { extendTheme, styled } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; const defaultTheme = extendTheme(); const Table = styled('table')(({ theme }) => ({ borderCollapse: 'separate', borderSpacing: 0, display: 'block', width: 'max-content', overflow: 'auto', th: { textAlign: 'left', padding: 12, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '8px 12px', '& > *': { padding: '8px 12px', margin: '-8px -12px', }, }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); const extractFromVar = (value, field) => (value || '').replace(`var(--joy-${field}-`, '').replace(')', ''); export default function TypographyThemeViewer() { const levels = Object.keys(defaultTheme.typography); const renderSwatch = (colorScheme, token) => token ? ( <Box component="span" data-joy-color-scheme={colorScheme} sx={{ display: 'inline-block', width: '16px', height: '16px', borderRadius: '2px', bgcolor: token, boxShadow: 'inset 0 0 0 1px #bababa', }} /> ) : null; return ( <Box sx={{ marginBottom: '-9px', maxWidth: '100%', overflowX: 'scroll', border: '1px solid', borderColor: 'divider', borderTopLeftRadius: '12px', borderTopRightRadius: '12px', }} > <Table> <thead> <tr> <th> <Typography fontSize="sm">Level</Typography> </th> <th> <Typography fontSize="sm" noWrap> Color </Typography> </th> <th> <Typography fontSize="sm" noWrap> Font size </Typography> </th> <th> <Typography fontSize="sm" noWrap> Font weight </Typography> </th> <th> <Typography fontSize="sm" noWrap> Line height </Typography> </th> </tr> </thead> <tbody> {levels.map((level) => ( <tr key={level}> <td> <Tooltip title={<Typography level={level}>Preview</Typography>} size="sm" arrow variant="outlined" placement="bottom-start" sx={{ pointerEvents: 'none' }} > <Typography fontSize="sm" sx={{ cursor: 'zoom-in' }}> {level} </Typography> </Tooltip> </td> <td> <Tooltip size="sm" arrow variant="outlined" title={ <Box sx={{ display: 'flex', gap: 3 }}> <Typography fontSize="xs" startDecorator={renderSwatch( 'light', defaultTheme.typography[level].color, )} > (light) </Typography> <Typography fontSize="xs" startDecorator={renderSwatch( 'dark', defaultTheme.typography[level].color, )} > (dark) </Typography> </Box> } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level].color || '-'} </Typography> </Tooltip> </td> <td> <Tooltip size="sm" arrow title={ defaultTheme.fontSize[ extractFromVar( defaultTheme.typography[level].fontSize, 'fontSize', ) ] } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level].fontSize || '-'} </Typography> </Tooltip> </td> {['fontWeight', 'lineHeight'].map((field) => ( <td key={field}> <Tooltip size="sm" arrow title={ defaultTheme[field][ extractFromVar(defaultTheme.typography[level][field], field) ] || '' } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" textAlign="center" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level][field] || '-'} </Typography> </Tooltip> </td> ))} </tr> ))} </tbody> </Table> </Box> ); }
1,841
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/TypographyThemeViewer.tsx
import * as React from 'react'; import { extendTheme, styled, TypographySystem, FontSize } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; const defaultTheme = extendTheme(); const Table = styled('table')(({ theme }) => ({ borderCollapse: 'separate', borderSpacing: 0, display: 'block', width: 'max-content', overflow: 'auto', th: { textAlign: 'left', padding: 12, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '8px 12px', '& > *': { padding: '8px 12px', margin: '-8px -12px', }, }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); const extractFromVar = (value: string, field: string) => (value || '').replace(`var(--joy-${field}-`, '').replace(')', ''); export default function TypographyThemeViewer() { const levels = Object.keys(defaultTheme.typography) as Array< keyof TypographySystem >; const renderSwatch = (colorScheme: 'light' | 'dark', token: string) => token ? ( <Box component="span" data-joy-color-scheme={colorScheme} sx={{ display: 'inline-block', width: '16px', height: '16px', borderRadius: '2px', bgcolor: token, boxShadow: 'inset 0 0 0 1px #bababa', }} /> ) : null; return ( <Box sx={{ marginBottom: '-9px', maxWidth: '100%', overflowX: 'scroll', border: '1px solid', borderColor: 'divider', borderTopLeftRadius: '12px', borderTopRightRadius: '12px', }} > <Table> <thead> <tr> <th> <Typography fontSize="sm">Level</Typography> </th> <th> <Typography fontSize="sm" noWrap> Color </Typography> </th> <th> <Typography fontSize="sm" noWrap> Font size </Typography> </th> <th> <Typography fontSize="sm" noWrap> Font weight </Typography> </th> <th> <Typography fontSize="sm" noWrap> Line height </Typography> </th> </tr> </thead> <tbody> {levels.map((level) => ( <tr key={level}> <td> <Tooltip title={<Typography level={level}>Preview</Typography>} size="sm" arrow variant="outlined" placement="bottom-start" sx={{ pointerEvents: 'none' }} > <Typography fontSize="sm" sx={{ cursor: 'zoom-in' }}> {level} </Typography> </Tooltip> </td> <td> <Tooltip size="sm" arrow variant="outlined" title={ <Box sx={{ display: 'flex', gap: 3 }}> <Typography fontSize="xs" startDecorator={renderSwatch( 'light', defaultTheme.typography[level].color as string, )} > (light) </Typography> <Typography fontSize="xs" startDecorator={renderSwatch( 'dark', defaultTheme.typography[level].color as string, )} > (dark) </Typography> </Box> } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level].color || '-'} </Typography> </Tooltip> </td> <td> <Tooltip size="sm" arrow title={ defaultTheme.fontSize[ extractFromVar( defaultTheme.typography[level].fontSize as string, 'fontSize', ) as keyof FontSize ] } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level].fontSize || '-'} </Typography> </Tooltip> </td> {(['fontWeight', 'lineHeight'] as const).map((field) => ( <td key={field}> <Tooltip size="sm" arrow title={ (defaultTheme[field] as Record<string, any>)[ extractFromVar( defaultTheme.typography[level][field] as string, field, ) ] || '' } sx={{ pointerEvents: 'none' }} > <Typography fontSize="xs" fontFamily="code" textAlign="center" sx={{ cursor: 'zoom-in' }} > {defaultTheme.typography[level][field] || '-'} </Typography> </Tooltip> </td> ))} </tr> ))} </tbody> </Table> </Box> ); }
1,842
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/theme-typography/theme-typography.md
# Theme typography <p class="description">Learn about the default theme's typography system and how to customize it.</p> ## Default system Joy UI's default theme includes a built-in typography system of 11 distinct levels—including semantic HTML headers as well as a comparable system for body text—to help you ensure consistency across your interface. {{"demo": "TypographyThemeViewer.js", "bg": "inline"}} :::info [CSS Baseline](/joy-ui/react-css-baseline/), [Scoped CSS Baseline](/joy-ui/react-css-baseline/#scoping-on-children), and [Typography](/joy-ui/react-typography/) are the only components that consume the theme typography directly, ensuring you can customize or even remove the default typography system without affecting other components. ::: ### Usage There are several ways that you can use the theme typography in your application: #### Typography component Use the `level` prop in the [Typography](/joy-ui/react-typography/) component: ```jsx // use the `theme.typography['body-sm']` styles <Typography level="body-sm">Secondary info</Typography> ``` #### CSS Baseline The [CSS Baseline](/joy-ui/react-css-baseline/) component applies `body-md` as the default level on the global stylesheet: ```jsx <CssBaseline /> // inherits the `theme.typography['body-md']` styles <p>Hello World</p> ``` #### sx prop Customize the typographic styles via the `sx` prop using `typography: 'some-level'`: ```jsx // to apply the `theme.typography['body-sm']` styles: <Box sx={{ typography: 'body-sm' }}>Small text</Box> ``` #### Applying theme styles to custom components Use the [`styled`](/joy-ui/customization/approaches/#reusable-component) function to create a custom component and apply styles from `theme.typography.*`: ```jsx import { styled } from '@mui/joy/styles'; const Tag = styled('span')((theme) => ({ ...theme.typography['body-sm'], color: 'inherit', borderRadius: theme.vars.radius.xs, boxShadow: theme.vars.shadow.sm, padding: '0.125em 0.375em', })); ``` ## Customizations To customize a default level, provide its name as a key along with an object containing the CSS rules as a value to the `theme.typography` node. The example below illustrates the customization of the `h1` level: {{"demo": "CustomTypographyLevel.js"}} ### Removing the default system Use `undefined` as a value to remove any unwanted levels: ```js const customTheme = extendTheme({ typography: { 'title-sm': undefined, 'title-xs': undefined, }, }); ``` For TypeScript, you must augment the theme structure to exclude the default levels: ```ts // You can put this to any file that's included in your tsconfig declare module '@mui/joy/styles' { interface TypographySystemOverrides { 'title-sm': false; 'title-xs': false; } } ``` ### Adding more levels To add a new level, define it as a key-value pair in the `theme.typography` node, where the key is the name of the new level and the value is an object containing the CSS rules. The demo below shows how to add a new level called `kbd`: {{"demo": "NewTypographyLevel.js"}} For TypeScript, you must augment the theme structure to include the new level: ```ts // You can put this to any file that's included in your tsconfig declare module '@mui/joy/styles' { interface TypographySystemOverrides { kbd: true; } } ``` ### Changing the default font Joy UI uses the [Inter](https://rsms.me/inter/) font by default. To change it, override the theme's `fontFamily` property: ```js extendTheme({ fontFamily: { display: 'Noto Sans', // applies to `h1`–`h4` body: 'Noto Sans', // applies to `title-*` and `body-*` }, }); ``` ## Common examples Here is a collection of well-known typography systems that you can use with Joy UI. Feel free to [submit a PR](https://github.com/mui/material-ui/compare) to add your favorite if it's not here. ❤️ ### Microsoft's Fluent - Design resource: [Figma](https://www.figma.com/community/file/836828295772957889) - Font: [Segoe UI](https://learn.microsoft.com/en-us/typography/font-list/segoe-ui) <iframe src="https://codesandbox.io/embed/joy-ui-fluent-typography-system-j86fct?module=%2Fdemo.tsx&fontsize=14&hidenavigation=1&theme=dark&view=preview" style="width:100%; height:360px; border:0; border-radius: 12px; overflow:hidden;" title="Joy UI - Fluent Typography System" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" ></iframe> ### Apple's Human Interface Guidelines - Design resource: [Sketch library](https://developer.apple.com/design/resources/) - Font: [San Francisco (SF)](https://developer.apple.com/fonts/) <iframe src="https://codesandbox.io/embed/joy-ui-human-interface-guidelines-typography-system-lkuz4d?module=%2Fdemo.tsx&fontsize=14&hidenavigation=1&theme=dark&view=preview" style="width:100%; height:320px; border:0; border-radius: 12px; overflow:hidden;" title="Joy UI - Human Interface Guidelines Typography System" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" ></iframe> ### Google's Material Design 3 - Design resource: [Figma](https://www.figma.com/community/file/1035203688168086460) - Font: [Roboto](https://fonts.google.com/specimen/Roboto) <iframe src="https://codesandbox.io/embed/joy-ui-material-3-typography-system-lx044f?module=%2Fdemo.tsx&fontsize=14&hidenavigation=1&theme=dark&view=preview" style="width:100%; height:500px; border:0; border-radius: 12px; overflow:hidden;" title="Joy UI - Joy UI - Material 3 Typography System" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" ></iframe>
1,843
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/themed-components/themed-components.md
# Themed components <p class="description">Learn how to apply custom styles to components at the theme level.</p> <!-- This page should answer: --> <!-- How to customize a component --> <!-- How to target specific prop --> ## Component identifier If you've used [Material UI](/material-ui/customization/theme-components/) before, you are probably familiar with this technique. To customize a specific component in the theme, specify the component identifier (`Joy{ComponentImportName}`) inside the `components` node. - Use `defaultProps` to change the default React props of the component. - Use `styleOverrides` to apply styles to each component slots. - Every Joy UI component contains the `root` slot. Visit the [`components.d.ts`](https://github.com/mui/material-ui/blob/-/packages/mui-joy/src/styles/components.d.ts) file to see all component identifiers. ```js import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; const theme = extendTheme({ components: { JoyChip: { defaultProps: { size: 'sm', }, styleOverrides: { root: { borderRadius: '4px', }, }, }, }, }); function App() { return <CssVarsProvider theme={theme}>...</CssVarsProvider>; } ``` ## Theme default props The values specified in the theme as `defaultProps` affect all instances of the component: ```js extendTheme({ components: { JoyIconButton: { defaultProps: { variant: 'outlined', color: 'neutral', }, }, }, }); // This is the same as: // <IconButton variant="outlined" color="neutral"> <IconButton>...</IconButton>; ``` ## Theme style overrides ### Change styles based on props To change the styles of a given prop, use a callback as value to the style overrides. The argument contains `theme` and `ownerState` (props). ```js extendTheme({ components: { JoyChip: { styleOverrides: { // `ownerState` contains the component props and internal state root: ({ ownerState, theme }) => ({ ...(ownerState.size === 'sm' && { borderRadius: theme.vars.radius.xs, }), }), }, }, }, }); ``` We recommend to use CSS variables from `theme.vars.*` because it has a better debugging experience and also is more performant in some cases. The styles can also contain any CSS selectors (support nested selectors), as such: ```js extendTheme({ components: { JoyChip: { styleOverrides: { root: ({ ownerState, theme }) => ({ ...(ownerState.variant === 'solid' && ownerState.clickable && { color: 'rgba(255 255 255 / 0.72)', '&:hover': { color: '#fff', }, }), }), }, }, }, }); ``` ### Change styles based on state Joy UI components increase the CSS specificity of the styles when they are in a given state such as `selected`, `disabled`, `focusVisible`, etc. To override styles of a specific state, import the component's class selector using its name in camel-case followed by `Classes`. ```js import { listItemButtonClasses } from '@mui/joy/ListItemButton'; extendTheme({ components: { JoyListItemButton: { styleOverrides: { root: { [`&.${listItemButtonClasses.selected}`]: { color: 'rgba(255 255 255 / 0.7)', }, }, }, }, }, }); ``` The available states are: `active`, `checked`, `completed`, `disabled`, `error`, `expanded`, `focused`, `focusVisible`, `readOnly`, `required`, `selected`. ### Extend colors The following code snippet illustrates how to provide additional colors to a component beyond `primary`, `success`, `info`, `danger`, `neutral`, and `warning`. Note that by creating new colors, you're automatically opting out of the [global variant feature](/joy-ui/main-features/global-variants/), which gives you fine-grained control over CSS properties like `color`, `background`, and `border`. The example below extends the Button colors to include `secondary` value: ```js extendTheme({ components: { JoyButton: { styleOverrides: { root: ({ ownerState, theme }) => ({ ...(ownerState.color === 'secondary' && { color: theme.vars.palette.text.secondary, backgroundColor: theme.vars.palette.background.level1, }), }), }, }, }, }); ``` Once these values are defined as above, you can make use of them directly on instances of the Button component: ```jsx <Button color="secondary">Secondary color</Button> <Button color="tertiary">Tertiary color</Button> ``` #### TypeScript Module augmentation is required to pass the values to the `color` prop of the component. The interface format is `{ComponentName}PropsColorOverrides`, which is the same for all Joy UI components: ```tsx // This part could be declared in your theme file declare module '@mui/joy/Button' { interface ButtonPropsColorOverrides { secondary: true; tertiary: true; } } // typed-safe <Button color="secondary" /> <Button color="tertiary" /> ``` ### Extend sizes The following code snippet illustrates how to provide additional sizes to a component beyond `sm`, `md`, and `lg`. We recommend following the established "t-shirt size" naming convention (e.g. `xs`, `xl`, `xxl`, etc.) to maintain consistency with all the other props. The example below extends the Button sizes to include `xs` and `xl` values: ```js extendTheme({ components: { JoyButton: { styleOverrides: { root: ({ ownerState, theme }) => ({ ...(ownerState.size === 'xs' && { '--Icon-fontSize': '1rem', '--Button-gap': '0.25rem', minHeight: 'var(--Button-minHeight, 1.75rem)', fontSize: theme.vars.fontSize.xs, paddingBlock: '2px', paddingInline: '0.5rem', }), ...(ownerState.size === 'xl' && { '--Icon-fontSize': '2rem', '--Button-gap': '1rem', minHeight: 'var(--Button-minHeight, 4rem)', fontSize: theme.vars.fontSize.xl, paddingBlock: '0.5rem', paddingInline: '2rem', }), }), }, }, }, }); ``` Once these values are defined as above, you can make use of them directly on instances of the Button component: ```jsx <Button size="xs">Extra small</Button> <Button size="xl">Extra large</Button> ``` The properties used for extending sizes should only relate to the density or the dimensions of the component. To learn how to extend variant properties, check out the [Extend variants](#extend-variants) section in this document. #### TypeScript Module augmentation is required to pass the values to the `size` prop of the component. The interface format is `{ComponentName}PropsSizeOverrides`, which is the same for all Joy UI components: ```tsx // This part could be declared in your theme file declare module '@mui/joy/Button' { interface ButtonPropsSizeOverrides { xs: true; xl: true; } } // typed-safe <Button size="xs" /> <Button size="xl" /> ``` ### Extend variants The following code snippet shows how to extend component variants for color properties. Note that by creating new variants, you're automatically opting out of the [global variant feature](/joy-ui/main-features/global-variants/), which gives you fine-grained control over CSS properties like `color`, `background`, and `border`. This example extends the Sheet variant to include a custom value named `glass`: ```js extendTheme({ components: { JoySheet: { styleOverrides: { root: ({ ownerState, theme }) => ({ ...(ownerState.variant === 'glass' && { color: theme.vars.palette.text.primary, background: 'rgba(255, 255, 255, 0.14)', backdropFilter: 'blur(5px)', border: '1px solid rgba(255, 255, 255, 0.3)', boxShadow: '0 4px 30px rgba(0, 0, 0, 0.1)', }), }), }, }, }, }); ``` Once the value is defined as above, you can make use of it directly on instances of the Sheet component: ```jsx <Sheet variant="glass">Glassmorphism</Sheet> ``` #### TypeScript Module augmentation is required to pass the values to the `variant` prop of the component. The interface format is `{ComponentName}PropsSizeOverrides`, which is the same for all Joy UI components: ```tsx // This part could be declared in your theme file declare module '@mui/joy/Sheet' { interface SheetPropsVariantOverrides { glass: true; } } // typed-safe <Sheet variant="glass" />; ``` ### Different styles per mode To specify different values than the ones defined in the default theme for each mode (light and dark), use the CSS attribute selector. Joy UI attaches a `data-*` attribute with the current color scheme to the DOM (HTML by default). You can use the `theme.getColorSchemeSelector` utility to change the component styles. The example below illustrate how you'd change the intensity of the `boxShadow` token in the light mode while removing it completely in the dark mode: ```js extendTheme({ components: { JoyChip: { styleOverrides: { root: ({ ownerState, theme }) => ({ // for the default color scheme (light) boxShadow: theme.vars.shadow.sm, // the result is `[data-joy-color-scheme="dark"] &` [theme.getColorSchemeSelector('dark')]: { boxShadow: 'none', }, }), }, }, }, }); ``` If you have custom color schemes defined, this approach also works. However, note that it creates additional CSS specificity which might be cumbersome when the parent component wants to override their children styles. :::error We don't recommend using the conditional operator to switch between values as it is not performant. ```js // 🚫 Don't do this extendTheme({ components: { JoyChip: { styleOverrides: { root: ({ ownerState, theme }) => ({ // styles will be created for both color schemes which is not performant boxShadow: theme.palette.mode === 'dark' ? 'none' : theme.vars.shadow.sm, }), }, }, }, }); ``` ::: <!-- ## Examples -->
1,844
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/using-css-variables/using-css-variables.md
# Using CSS variables <p class="description">Learn how to use CSS variables to customize Joy UI components.</p> ## Introduction To use CSS variables, you must wrap your app with the `<CssVarsProvider />` utility. ```jsx import { CssVarsProvider } from '@mui/joy/styles'; function App() { return <CssVarsProvider>...</CssVarsProvider>; } ``` Then you can apply styles based on CSS variables using the `theme.vars.*` notation. This notation is available to all styling APIs that Joy UI supports, including the `styled()` function and the `sx` prop. ## Styling APIs Use the `theme.vars.*` notation with any styling APIs supported by Joy UI: :::success Visit [the Approaches page](/joy-ui/customization/approaches/) to understand how to use the supported styling APIs. ::: ### styled function ```js const Div = styled('div')(({ theme }) => ({ // Outputs 'var(--joy-palette-primary-500)' color: theme.vars.palette.primary[500], })); ``` ### sx prop ```jsx // Outputs 'var(--joy-shadow-sm)' <Chip sx={(theme) => ({ boxShadow: theme.vars.shadow.sm })} /> ``` You can also use a short-hand syntax to resolve the values from the `theme.vars.*` the same way the example above does. ```js <Chip sx={{ border: '1px solid', // For color properties, lookup from `theme.vars.palette` color: 'neutral.800', // 'var(--joy-palette-neutral-800)' borderColor: 'neutral.400', // 'var(--joy-palette-neutral-400)' // lookup from `theme.vars.shadow` shadow: 'sm', // 'var(--joy-shadow-sm)' // lookup from `theme.vars.fontSize` fontSize: 'sm', // 'var(--joy-fontSize-sm)' }} /> ``` ### Themed components ```jsx extendTheme({ components: { JoyButton: { root: ({ theme }) => ({ // Outputs 'var(--joy-fontFamily-display)' fontFamily: theme.vars.fontFamily.display, }), }, }, }); ``` ### useTheme hook ```jsx import { useTheme } from '@mui/joy/styles'; const SomeComponent = () => { const theme = useTheme(); // The runtime theme. return ( <div> <p style={{ color: {theme.vars.palette.primary[500]} }}>Some text here.</p> </div> ); }; ``` ## Creating new variables To create new CSS variables, use raw theme values (`theme.*` as opposed to `theme.vars.*`). The code below shows an example of how to create a new shadow theme value: ```js const Div = styled('div')(({ theme }) => ({ // Note that it's using `theme.shadow`, not `theme.vars.shadow` boxShadow: theme.shadow.sm.replace(/,/g, ', inset'), })); ``` :::warning You can't use `theme.vars` to create an inset shadow because the value refers to the CSS variable, not the actual shadow. - `theme.vars.shadow.sm` returns `'var(--joy-shadow-sm)'` - `theme.shadow.sm` returns `'var(--joy-shadowRing), 0 1px 2px 0 rgba(var(--joy-shadowChannel) / 0.2)'` ::: ## Adjust color opacity Use the automatically generated opacity channel tokens (`mainChannel`, `lightChannel` and `darkChannel`), together with the `rgba` color notation, to adjust color opacity in all [available palettes](/joy-ui/customization/theme-colors/#default-color-tokens) in Joy UI. ```js const Div = styled('div')(({ theme }) => ({ backgroundColor: `rgba(${theme.vars.palette.primary.mainChannel} / 0.2)`, })); ``` :::warning The format of the channel tokens uses a space as a separator (e.g., `61 131 246`), which means you have to use `/` to combine the channel token with an opacity value. ```js `rgba(${theme.vars.palette.primary.mainChannel} / 0.2)`, // ✅ correct `rgba(${theme.vars.palette.primary.mainChannel}, 0.2)`, // 🚫 incorrect ``` ::: ## Custom prefixes Every Joy UI CSS variable is prefixed with `joy` by default. To change this prefix, use the `cssVarPrefix` property inside an `extendTheme` function on the `<CssVarsProvider />` component. ```jsx import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; function App() { return ( <CssVarsProvider theme={extendTheme({ cssVarPrefix: 'company' })}> ... </CssVarsProvider> ); } ``` The generated CSS variables will then be: ```diff - --joy-fontSize-md: 1rem; + --company-fontSize-md: 1rem; ``` ### Removing the default prefix Use an empty value (`''`) in the `cssVarPrefix` property to remove the default `joy` prefix from the generated CSS variables: ```jsx import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; function App() { return ( <CssVarsProvider theme={extendTheme({ cssVarPrefix: '' })}>...</CssVarsProvider> ); } ``` ```diff - --joy-fontSize-md: 1rem; + --fontSize-md: 1rem; ```
1,845
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started
petrpan-code/mui/material-ui/docs/data/joy/getting-started/installation/installation.md
# Installation <p class="description">Install Joy UI, a library of beautifully designed React UI components.</p> Run one of the following commands to add Joy UI to your project: <codeblock storageKey="package-manager"> ```bash npm npm install @mui/joy @emotion/react @emotion/styled ``` ```bash yarn yarn add @mui/joy @emotion/react @emotion/styled ``` ```bash pnpm pnpm add @mui/joy @emotion/react @emotion/styled ``` </codeblock> ## Peer dependencies <!-- #react-peer-version --> Please note that [react](https://www.npmjs.com/package/react) and [react-dom](https://www.npmjs.com/package/react-dom) are peer dependencies too: ```json "peerDependencies": { "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0" }, ``` ## Inter font Joy UI uses the [Inter](https://rsms.me/inter/) font by default. Add it to your project via [Fontsource](https://fontsource.org/), or with the Google Fonts CDN. ### Fontsource Run one of the following commands to add Inter through Fontsource to your Joy UI project: <codeblock storageKey="package-manager"> ```bash npm npm install @fontsource/inter ``` ```bash yarn yarn add @fontsource/inter ``` ```bash pnpm pnpm add @fontsource/inter ``` </codeblock> Then you can import it in your entry point like this: ```tsx import '@fontsource/inter'; ``` ### Google Web Fonts To install Inter through the Google Web Fonts CDN, add the following code inside your project's `<head />` tag: ```html <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" /> ```
1,846
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started
petrpan-code/mui/material-ui/docs/data/joy/getting-started/overview/overview.md
--- title: Overview --- # Joy UI - Overview <p class="description">Joy UI is a library of beautifully designed React UI components built to spark joy in the development process.</p> ## Introduction Joy UI is an open-source React component library that follows a lightly opinionated design direction, for a clean and modern UI that gives you plenty of room to customize the look and feel. :::warning Joy UI is currently in active development, and breaking changes are to be expected. We're adding new components and features regularly, and you're welcome to contribute! Look for the [`package: joy-ui`](https://github.com/mui/material-ui/labels/package%3A%20joy-ui) label on open issues and pull requests in the `mui/material-ui` repository on GitHub to see what other community members are working on, and feel free to submit your own. ::: ## Why use Joy UI Maintained by MUI, **Joy UI is an alternative to Material UI** for projects that **don't adhere to Material Design** guidelines as a design system starting point. These two sister libraries feature many of the same components, with similarly designed component APIs and customization features. Joy UI applies the decade of lessons learned in building and maintaining Material UI, for developers looking for sleek design, next-gen DX, and extensible components. Learn more about why you should use Joy UI for your next project below. ### Beautiful out of the box Joy UI follows a lightly opinionated design direction called Joy Design. Simple and functional, it offers a thoughtfully crafted set of defaults to ensure that your next project looks and feels great before you even begin customizing. For example, the [Order Dashboard template](/joy-ui/getting-started/templates/order-dashboard/) (pictured below) is minimally customized beyond defaults, to demonstrate how meticulously we've designed each component for consistency and cohesion across the UI: <img src="/static/joy-ui/overview/order-dashboard.png" style="width: 814px; margin-top: 4px; margin-bottom: 8px;" alt="The Order Dashboard template, inspired by Untitled UI and built by the MUI team using Joy UI with very little customizations." width="1628" height="400" /> ### Highly customizable You should feel inspired and empowered to change, extend, and revamp Joy UI's appearance and behavior with ease. Drawing from many years of experience maintaining Material UI, Joy UI applies new approaches to customization, enabling you to customize every piece of the components to match your unique design. For example, the demo below shows how to customize the [List](/joy-ui/react-list/) component using built-in CSS variables to match the design of the [Gatsby documentation side nav](https://www.gatsbyjs.com/docs/): {{"demo": "../../components/list/ExampleCollapsibleList.js"}} ### Developer experience Joy UI draws its name from the idea that it should spark joy in the creative process of building apps. Providing an unrivaled developer experience is at the heart of this. For example, observe how each element of the [Input](/joy-ui/react-input/) component automatically calculates and adjusts its own dimensions relative to the border radius, saving you from the tedium of doing it yourself: {{"demo": "../../main-features/automatic-adjustment/InputVariables.js"}} ### Accessibility Joy UI components are built on top of [Base UI's unstyled components and low-level hooks](/base-ui/getting-started/), giving you many accessibility features out of the box. We strive to make all components accessible to end users who require assistive technology, and offer suggestions for optimizing accessibility throughout our documentation. Joy UI's Form Control component automatically generates a unique ID that links the Input that it wraps with the Form Label and Form Helper Text components, ensuring that your app complies with this guideline: {{"demo": "../../components/input/InputField.js"}} ## Start now Get started with Joy UI today through some of these useful resources: {{"component": "modules/components/JoyStartingLinksCollection.js"}}
1,847
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started
petrpan-code/mui/material-ui/docs/data/joy/getting-started/roadmap/roadmap.md
# Roadmap <p class="description">Keep up with ongoing projects and help shape the future of Joy UI.</p> ## Priorization method Joy UI is a community-driven project, meaning we usually pick the issues and suggestions that resonate the most with the community. Therefore, make sure to leave an upvote 👍 on [the GitHub issues](https://github.com/mui/material-ui/issues?q=is:open+is:issue+label:%22package:+joy-ui%22) you are most interested in. Additionally, the MUI team conducts yearly [developer surveys](/blog/?tags=Developer+survey/), which also serve as key inputs for Joy UI's roadmap. Your participation is invaluable—keep an eye on MUI's social media to catch the next survey and help shape the future of this product! ## Keeping track of the roadmap ### Public GitHub project We use a GitHub project to track initiative prioritization across all MUI Core products, including Joy UI. We typically add tasks to the project board after discussing them internally. **[Visit the Joy UI project board 👉](https://github.com/orgs/mui/projects/18/views/8)** <img src="/static/joy-ui/roadmap/github-projects.png" style="width: 814px; margin-top: 4px; margin-bottom: 8px;" alt="A screenshot of the MUI Core GitHub project." width="1628" height="400" /> ### Milestones We also create milestones within the MUI Core repository (where Joy UI's code base is hosted) to keep track of larger cycles. Check it out to keep up with ongoing progress and see which issues have been picked up for the stable release. **[Visit the Joy UI milestones page 👉](https://github.com/mui/material-ui/milestone/47)** <img src="/static/joy-ui/roadmap/milestone.png" style="width: 814px; margin-top: 4px; margin-bottom: 8px;" alt="A screenshot from GitHub of the Joy UI stable release milestone." width="1628" height="400" />
1,848
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/TemplateCollection.js
import * as React from 'react'; import startCase from 'lodash/startCase'; import NextLink from 'next/link'; import AspectRatio from '@mui/joy/AspectRatio'; import Box from '@mui/joy/Box'; import Card from '@mui/joy/Card'; import CardContent from '@mui/joy/CardContent'; import CardOverflow from '@mui/joy/CardOverflow'; import Link from '@mui/joy/Link'; import List from '@mui/joy/List'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import SvgIcon from '@mui/joy/SvgIcon'; import Visibility from '@mui/icons-material/Visibility'; import CodeRoundedIcon from '@mui/icons-material/CodeRounded'; import codeSandbox from 'docs/src/modules/sandbox/CodeSandbox'; import sourceJoyTemplates from 'docs/src/modules/joy/sourceJoyTemplates'; /** * To display a template on the site: * - Create a folder next to this file. * - The folder should have `App.(js|tsx)` * - The name of the folder will be used as the url and title */ const authors = { MUI: { name: 'MUI', link: 'https://twitter.com/MUI_hq', }, SteveEberger: { name: 'Steve Ernstberger', link: 'https://twitter.com/SteveEberger', }, }; const templates = [ { name: 'order-dashboard', author: authors.MUI, design: { name: 'Untitled UI', link: 'https://www.figma.com/community/file/1020079203222518115/%E2%9D%96-Untitled-UI-%E2%80%93-FREE-Figma-UI-kit-and-design-system', }, }, { name: 'profile-dashboard', author: authors.MUI, design: { name: 'Untitled UI', link: 'https://www.figma.com/community/file/1020079203222518115/%E2%9D%96-Untitled-UI-%E2%80%93-FREE-Figma-UI-kit-and-design-system', }, }, { name: 'messages', author: authors.SteveEberger, design: { name: 'Untitled UI', link: 'https://www.figma.com/community/file/1020079203222518115/%E2%9D%96-Untitled-UI-%E2%80%93-FREE-Figma-UI-kit-and-design-system', }, }, { name: 'sign-in-side', author: authors.MUI, }, { name: 'rental-dashboard', author: authors.SteveEberger, design: { name: 'Untitled UI', link: 'https://www.figma.com/community/file/1020079203222518115/%E2%9D%96-Untitled-UI-%E2%80%93-FREE-Figma-UI-kit-and-design-system', }, }, { name: 'team', author: authors.MUI, }, { name: 'files', author: authors.MUI, }, { name: 'email', author: authors.MUI, }, { name: 'framesx-web-blocks', author: authors.MUI, design: { name: 'Frames X', link: 'https://framesxfigma.buninux.com/', }, }, ]; export default function TemplateCollection() { const joyTemplates = sourceJoyTemplates(); return ( <List sx={{ px: { xs: 2, sm: 0 }, flexGrow: 1, gap: 3, display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(300px, 1fr))', }} > {templates.map((template) => { const item = joyTemplates.map.get(template.name); return ( <Card component="li" variant="outlined" key={template.name} sx={{ bgcolor: 'initial', overflow: 'auto', borderRadius: 12 }} > <CardOverflow> <AspectRatio ratio="2" variant="plain" sx={{ borderRadius: 0, borderBottom: '1px solid', borderColor: 'divider', }} > <Box sx={(theme) => ({ background: `center/cover no-repeat url(/static/screenshots/joy-ui/getting-started/templates/${template.name}.jpg)`, [theme.getColorSchemeSelector('dark')]: { background: `center/cover no-repeat url(/static/screenshots/joy-ui/getting-started/templates/${template.name}-dark.jpg)`, }, })} /> <NextLink href={`/joy-ui/getting-started/templates/${template.name}/`} passHref legacyBehavior > {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} <Link tabIndex={-1} overlay aria-hidden data-ga-event-category="joy-template" data-ga-event-label={template.name} data-ga-event-action="preview-img" sx={[ (theme) => ({ display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column', gap: 1, transition: '0.15s', position: 'absolute', width: '100%', height: '100%', opacity: 0, top: 0, left: 0, bgcolor: `rgba(${theme.vars.palette.primary.lightChannel} / 0.3)`, backdropFilter: 'blur(4px)', '&:hover, &:focus': { opacity: 1, }, [theme.getColorSchemeSelector('dark')]: { bgcolor: `rgba(${theme.vars.palette.primary.darkChannel} / 0.3)`, }, }), ]} > <Visibility /> <Typography fontWeight="bold" fontFamily="IBM Plex Sans" textColor="text.primary" > View live preview </Typography> </Link> </NextLink> </AspectRatio> </CardOverflow> <CardContent sx={{ display: 'flex', flexDirection: 'column', }} > <Typography component="h3" fontFamily="IBM Plex Sans" fontSize="lg" fontWeight="xl" > {startCase(template.name)} </Typography> <Box sx={{ width: '100%', display: 'flex', alignItems: 'center', flexWrap: 'wrap', mb: 2, }} > {template.author && ( <Typography level="body-sm" fontWeight="md" fontFamily="IBM Plex Sans" > Built by{' '} <Link href={template.author.link} target="_blank" rel="noopener noreferrer" > <b>{template.author.name}</b> </Link> </Typography> )} {template.design && ( <React.Fragment> <Typography level="caption" fontWeight="md" textColor="text.tertiary" sx={{ mx: 0.5 }} > • </Typography> <Typography level="body-sm" fontWeight="md" fontFamily="IBM Plex Sans" > Designed by{' '} <Link href={template.design.link} target="_blank" rel="noopener noreferrer" > <b>{template.design.name}</b> </Link> </Typography> </React.Fragment> )} </Box> <Box sx={{ mt: 'auto', width: '100%', display: 'flex', flexDirection: { xs: 'column', sm: 'row' }, gap: 1.5, }} > <NextLink href={`https://github.com/mui/material-ui/tree/master/docs/data/joy/getting-started/templates/${template.name}`} passHref legacyBehavior > <Button component="a" variant="outlined" color="neutral" fullWidth startDecorator={<CodeRoundedIcon />} aria-label="Source code" data-ga-event-category="joy-template" data-ga-event-label={template.name} data-ga-event-action="preview" sx={{ fontFamily: 'IBM Plex Sans' }} > Source </Button> </NextLink> <Button variant="outlined" color="neutral" fullWidth startDecorator={ <SvgIcon viewBox="0 0 1080 1080"> <path d="M755 140.3l0.5-0.3h0.3L512 0 268.3 140h-0.3l0.8 0.4L68.6 256v512L512 1024l443.4-256V256L755 140.3z m-30 506.4v171.2L548 920.1V534.7L883.4 341v215.7l-158.4 90z m-584.4-90.6V340.8L476 534.4v385.7L300 818.5V646.7l-159.4-90.6zM511.7 280l171.1-98.3 166.3 96-336.9 194.5-337-194.6 165.7-95.7L511.7 280z" /> </SvgIcon> } aria-label="CodeSandbox playground" data-ga-event-category="joy-template" data-ga-event-label={template.name} data-ga-event-action="codesandbox" onClick={() => codeSandbox .createJoyTemplate({ ...item, title: `${startCase(template.name)} Template - Joy UI`, githubLocation: `${process.env.SOURCE_CODE_REPO}/blob/v${ process.env.LIB_VERSION }/docs/data/joy/templates/${template.name}/App.${ item.codeVariant === 'TS' ? 'tsx' : 'js' }`, }) .openSandbox() } sx={{ fontFamily: 'IBM Plex Sans' }} > CodeSandbox </Button> </Box> </CardContent> </Card> ); })} </List> ); }
1,849
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/index.md
# Joy UI templates <p class="description">A selection of free application templates to help you get started building your app with Joy UI.</p> If while using these examples you make changes or enhancements that could improve the developer experience, or if you would like to contribute with an additional example, please consider creating a [pull request on GitHub](https://github.com/mui/material-ui/blob/master/CONTRIBUTING.md). {{"demo": "TemplateCollection.js", "hideToolbar": true, "bg": "inline"}}
1,850
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/App.tsx
import * as React from 'react'; import { CssVarsProvider } from '@mui/joy/styles'; import { FocusTrap } from '@mui/base/FocusTrap'; import CssBaseline from '@mui/joy/CssBaseline'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import Button from '@mui/joy/Button'; import Stack from '@mui/joy/Stack'; // Icons import import CreateRoundedIcon from '@mui/icons-material/CreateRounded'; import EmailRoundedIcon from '@mui/icons-material/EmailRounded'; import PeopleAltRoundedIcon from '@mui/icons-material/PeopleAltRounded'; import FolderRoundedIcon from '@mui/icons-material/FolderRounded'; // custom import Layout from './components/Layout'; import Navigation from './components/Navigation'; import Mails from './components/Mails'; import EmailContent from './components/EmailContent'; import WriteEmail from './components/WriteEmail'; import Header from './components/Header'; export default function EmailExample() { const [drawerOpen, setDrawerOpen] = React.useState(false); const [open, setOpen] = React.useState(false); return ( <CssVarsProvider disableTransitionOnChange> <CssBaseline /> {drawerOpen && ( <Layout.SideDrawer onClose={() => setDrawerOpen(false)}> <Navigation /> </Layout.SideDrawer> )} <Stack id="tab-bar" direction="row" justifyContent="space-around" spacing={1} sx={{ display: { xs: 'flex', sm: 'none' }, zIndex: '999', bottom: 0, position: 'fixed', width: '100dvw', py: 2, backgroundColor: 'background.body', borderTop: '1px solid', borderColor: 'divider', }} > <Button variant="plain" color="neutral" aria-pressed="true" component="a" href="/joy-ui/getting-started/templates/email/" size="sm" startDecorator={<EmailRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Email </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/team/" size="sm" startDecorator={<PeopleAltRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Team </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/files/" size="sm" startDecorator={<FolderRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Files </Button> </Stack> <Layout.Root sx={{ ...(drawerOpen && { height: '100vh', overflow: 'hidden', }), }} > <Layout.Header> <Header /> </Layout.Header> <Layout.SideNav> <Navigation /> </Layout.SideNav> <Layout.SidePane> <Box sx={{ p: 2, display: 'flex', alignItems: 'center', justifyContent: 'space-between', }} > <Box sx={{ alignItems: 'center', gap: 1, }} > <Typography level="title-lg" textColor="text.secondary"> My inbox </Typography> <Typography level="title-sm" textColor="text.tertiary"> 5 emails </Typography> </Box> <Button size="sm" startDecorator={<CreateRoundedIcon />} onClick={() => setOpen(true)} sx={{ ml: 'auto' }} > Compose email </Button> <FocusTrap open={open} disableAutoFocus disableEnforceFocus> <WriteEmail open={open} onClose={() => setOpen(false)} /> </FocusTrap> </Box> <Mails /> </Layout.SidePane> <Layout.Main> <EmailContent /> </Layout.Main> </Layout.Root> </CssVarsProvider> ); }
1,851
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/EmailContent.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Chip from '@mui/joy/Chip'; import Card from '@mui/joy/Card'; import CardOverflow from '@mui/joy/CardOverflow'; import Sheet from '@mui/joy/Sheet'; import Typography from '@mui/joy/Typography'; import Button from '@mui/joy/Button'; import Snackbar from '@mui/joy/Snackbar'; import AspectRatio from '@mui/joy/AspectRatio'; import Divider from '@mui/joy/Divider'; import Avatar from '@mui/joy/Avatar'; import Tooltip from '@mui/joy/Tooltip'; // Icons import import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; import ForwardToInboxRoundedIcon from '@mui/icons-material/ForwardToInboxRounded'; import FolderIcon from '@mui/icons-material/Folder'; import ReplyRoundedIcon from '@mui/icons-material/ReplyRounded'; import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded'; export default function EmailContent() { const [open, setOpen] = React.useState([false, false, false]); const handleSnackbarOpen = (index: number) => { const updatedOpen = [...open]; updatedOpen[index] = true; setOpen(updatedOpen); }; const handleSnackbarClose = (index: number) => { const updatedOpen = [...open]; updatedOpen[index] = false; setOpen(updatedOpen); }; return ( <Sheet variant="outlined" sx={{ minHeight: 500, borderRadius: 'sm', p: 2, mb: 3, }} > <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 2, }} > <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> <Avatar src="https://i.pravatar.cc/40?img=3" srcSet="https://i.pravatar.cc/80?img=3" /> <Box sx={{ ml: 2 }}> <Typography level="title-sm" textColor="text.primary" mb={0.5}> Alex Jonnold </Typography> <Typography level="body-xs" textColor="text.tertiary"> 21 Oct 2022 </Typography> </Box> </Box> <Box sx={{ display: 'flex', height: '32px', flexDirection: 'row', gap: 1.5 }} > <Button size="sm" variant="plain" color="neutral" startDecorator={<ReplyRoundedIcon />} onClick={() => handleSnackbarOpen(0)} > Reply </Button> <Snackbar color="success" open={open[0]} onClose={() => handleSnackbarClose(0)} anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} startDecorator={<CheckCircleRoundedIcon />} endDecorator={ <Button onClick={() => handleSnackbarClose(0)} size="sm" variant="soft" color="neutral" > Dismiss </Button> } > Your message has been sent. </Snackbar> <Button size="sm" variant="plain" color="neutral" startDecorator={<ForwardToInboxRoundedIcon />} onClick={() => handleSnackbarOpen(1)} > Forward </Button> <Snackbar color="success" open={open[1]} onClose={() => handleSnackbarClose(1)} anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} startDecorator={<CheckCircleRoundedIcon />} endDecorator={ <Button onClick={() => handleSnackbarClose(1)} size="sm" variant="soft" color="neutral" > Dismiss </Button> } > Your message has been forwarded. </Snackbar> <Button size="sm" variant="plain" color="danger" startDecorator={<DeleteRoundedIcon />} onClick={() => handleSnackbarOpen(2)} > Delete </Button> <Snackbar color="danger" open={open[2]} onClose={() => handleSnackbarClose(2)} anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} startDecorator={<CheckCircleRoundedIcon />} endDecorator={ <Button onClick={() => handleSnackbarClose(2)} size="sm" variant="soft" color="neutral" > Dismiss </Button> } > Your message has been deleted. </Snackbar> </Box> </Box> <Divider sx={{ mt: 2 }} /> <Box sx={{ py: 2, display: 'flex', flexDirection: 'column', alignItems: 'start' }} > <Typography level="title-lg" textColor="text.primary" endDecorator={ <Chip component="span" size="sm" variant="outlined" color="warning"> Personal </Chip> } > Details for our Yosemite Park hike </Typography> <Box sx={{ mt: 1, display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap', }} > <div> <Typography component="span" level="body-sm" sx={{ mr: 1, display: 'inline-block' }} > From </Typography> <Tooltip size="sm" title="Copy email" variant="outlined"> <Chip size="sm" variant="soft" color="primary" onClick={() => {}}> [email protected] </Chip> </Tooltip> </div> <div> <Typography component="span" level="body-sm" sx={{ mr: 1, display: 'inline-block' }} > to </Typography> <Tooltip size="sm" title="Copy email" variant="outlined"> <Chip size="sm" variant="soft" color="primary" onClick={() => {}}> [email protected] </Chip> </Tooltip> </div> </Box> </Box> <Divider /> <Typography level="body-sm" mt={2} mb={2}> Hello, my friend! <br /> <br /> So, it seems we are getting there! Our trip is finally here. As you know, I love Yosemite National Park, a lot of great climbers and explorers have made history there, so I&apos;m very excited to bring you with me in this journey. <br /> <br /> There are plenty of amazing things to see there, from internationally recognized granite cliffs, waterfalls, clear streams, giant sequoia groves, lakes, mountains, meadows, glaciers, and a lot o biological diversity. It is amazing that almost 95 percent of the park is designated wilderness. Yosemite is one of the largest and least fragmented habitat blocks in the Serra Nevada, and the park supports a fantastic diversity of plants and animals. <br /> <br /> I really hope you love coming along with me, we will have an awesome time! I&apos;m attaching a few pics I took on the last time I went there-get excited! <br /> <br /> See you soon, Alex Jonnold </Typography> <Divider /> <Typography level="title-sm" mt={2} mb={2}> Attachments </Typography> <Box sx={(theme) => ({ display: 'flex', flexWrap: 'wrap', gap: 2, '& > div': { boxShadow: 'none', '--Card-padding': '0px', '--Card-radius': theme.vars.radius.sm, }, })} > <Card variant="outlined"> <AspectRatio ratio="1" sx={{ minWidth: 80 }}> <img src="https://images.unsplash.com/photo-1527549993586-dff825b37782?auto=format&h=80" srcSet="https://images.unsplash.com/photo-1527549993586-dff825b37782?auto=format&h=160 2x" alt="Yosemite National Park" /> </AspectRatio> </Card> <Card variant="outlined"> <AspectRatio ratio="1" sx={{ minWidth: 80 }}> <img src="https://images.unsplash.com/photo-1532614338840-ab30cf10ed36?auto=format&h=80" srcSet="https://images.unsplash.com/photo-1532614338840-ab30cf10ed36?auto=format&h=160 2x" alt="Yosemite National Park" /> </AspectRatio> </Card> <Card variant="outlined" orientation="horizontal"> <CardOverflow> <AspectRatio ratio="1" sx={{ minWidth: 80 }}> <div> <FolderIcon /> </div> </AspectRatio> </CardOverflow> <Box sx={{ py: { xs: 1, sm: 2 }, pr: 2 }}> <Typography level="title-sm" color="primary"> videos-hike.zip </Typography> <Typography level="body-xs">100 MB</Typography> </Box> </Card> </Box> </Sheet> ); }
1,852
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/Header.tsx
import * as React from 'react'; import { useColorScheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import Avatar from '@mui/joy/Avatar'; import Input from '@mui/joy/Input'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; import Dropdown from '@mui/joy/Dropdown'; import Menu from '@mui/joy/Menu'; import MenuButton from '@mui/joy/MenuButton'; import MenuItem from '@mui/joy/MenuItem'; import ListDivider from '@mui/joy/ListDivider'; import Drawer from '@mui/joy/Drawer'; import ModalClose from '@mui/joy/ModalClose'; import DialogTitle from '@mui/joy/DialogTitle'; // Icons import import SearchRoundedIcon from '@mui/icons-material/SearchRounded'; import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded'; import LightModeRoundedIcon from '@mui/icons-material/LightModeRounded'; import BookRoundedIcon from '@mui/icons-material/BookRounded'; import LanguageRoundedIcon from '@mui/icons-material/LanguageRounded'; import SettingsRoundedIcon from '@mui/icons-material/SettingsRounded'; import HelpRoundedIcon from '@mui/icons-material/HelpRounded'; import OpenInNewRoundedIcon from '@mui/icons-material/OpenInNewRounded'; import LogoutRoundedIcon from '@mui/icons-material/LogoutRounded'; import MenuRoundedIcon from '@mui/icons-material/MenuRounded'; // Custom import Navigation from './Navigation'; function ColorSchemeToggle() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return <IconButton size="sm" variant="outlined" color="primary" />; } return ( <Tooltip title="Change theme" variant="outlined"> <IconButton id="toggle-mode" size="sm" variant="plain" color="neutral" sx={{ alignSelf: 'center' }} onClick={() => { if (mode === 'light') { setMode('dark'); } else { setMode('light'); } }} > {mode === 'light' ? <DarkModeRoundedIcon /> : <LightModeRoundedIcon />} </IconButton> </Tooltip> ); } export default function Header() { const [open, setOpen] = React.useState(false); return ( <Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'space-between', }} > <Stack direction="row" justifyContent="center" alignItems="center" spacing={1} sx={{ display: { xs: 'none', sm: 'flex' } }} > <IconButton size="md" variant="outlined" color="neutral" sx={{ display: { xs: 'none', sm: 'inline-flex' }, borderRadius: '50%', }} > <LanguageRoundedIcon /> </IconButton> <Button variant="plain" color="neutral" aria-pressed="true" component="a" href="/joy-ui/getting-started/templates/email/" size="sm" sx={{ alignSelf: 'center' }} > Email </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/team/" size="sm" sx={{ alignSelf: 'center' }} > Team </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/files/" size="sm" sx={{ alignSelf: 'center' }} > Files </Button> </Stack> <Box sx={{ display: { xs: 'inline-flex', sm: 'none' } }}> <IconButton variant="plain" color="neutral" onClick={() => setOpen(true)}> <MenuRoundedIcon /> </IconButton> <Drawer sx={{ display: { xs: 'inline-flex', sm: 'none' } }} open={open} onClose={() => setOpen(false)} > <ModalClose /> <DialogTitle>Acme Co.</DialogTitle> <Box sx={{ px: 1 }}> <Navigation /> </Box> </Drawer> </Box> <Box sx={{ display: 'flex', flexDirection: 'row', gap: 1.5, alignItems: 'center', }} > <Input size="sm" variant="outlined" placeholder="Search anything…" startDecorator={<SearchRoundedIcon color="primary" />} endDecorator={ <IconButton variant="outlined" color="neutral" sx={{ bgcolor: 'background.level1' }} > <Typography level="title-sm" textColor="text.icon"> ⌘ K </Typography> </IconButton> } sx={{ alignSelf: 'center', display: { xs: 'none', sm: 'flex', }, }} /> <IconButton size="sm" variant="outlined" color="neutral" sx={{ display: { xs: 'inline-flex', sm: 'none' }, alignSelf: 'center' }} > <SearchRoundedIcon /> </IconButton> <Tooltip title="Joy UI overview" variant="outlined"> <IconButton size="sm" variant="plain" color="neutral" component="a" href="/blog/first-look-at-joy/" sx={{ alignSelf: 'center' }} > <BookRoundedIcon /> </IconButton> </Tooltip> <ColorSchemeToggle /> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', borderRadius: '9999999px' }} > <Avatar src="https://i.pravatar.cc/40?img=2" srcSet="https://i.pravatar.cc/80?img=2" sx={{ maxWidth: '32px', maxHeight: '32px' }} /> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <Box sx={{ display: 'flex', alignItems: 'center', }} > <Avatar src="https://i.pravatar.cc/40?img=2" srcSet="https://i.pravatar.cc/80?img=2" sx={{ borderRadius: '50%' }} /> <Box sx={{ ml: 1.5 }}> <Typography level="title-sm" textColor="text.primary"> Rick Sanchez </Typography> <Typography level="body-xs" textColor="text.tertiary"> [email protected] </Typography> </Box> </Box> </MenuItem> <ListDivider /> <MenuItem> <HelpRoundedIcon /> Help </MenuItem> <MenuItem> <SettingsRoundedIcon /> Settings </MenuItem> <ListDivider /> <MenuItem component="a" href="/blog/first-look-at-joy/"> First look at Joy UI <OpenInNewRoundedIcon /> </MenuItem> <MenuItem component="a" href="https://github.com/mui/material-ui/tree/master/docs/data/joy/getting-started/templates/email" > Sourcecode <OpenInNewRoundedIcon /> </MenuItem> <ListDivider /> <MenuItem> <LogoutRoundedIcon /> Log out </MenuItem> </Menu> </Dropdown> </Box> </Box> ); }
1,853
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/Layout.tsx
import * as React from 'react'; import Box, { BoxProps } from '@mui/joy/Box'; import Sheet from '@mui/joy/Sheet'; function Root(props: BoxProps) { return ( <Box {...props} sx={[ { display: 'grid', gridTemplateColumns: { xs: '1fr', sm: 'minmax(64px, 200px) minmax(450px, 1fr)', md: 'minmax(160px, 300px) minmax(300px, 500px) minmax(500px, 1fr)', }, gridTemplateRows: '64px 1fr', minHeight: '100vh', }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function Header(props: BoxProps) { return ( <Box component="header" className="Header" {...props} sx={[ { p: 2, gap: 2, bgcolor: 'background.surface', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gridColumn: '1 / -1', borderBottom: '1px solid', borderColor: 'divider', position: 'sticky', top: 0, zIndex: 1100, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function SideNav(props: BoxProps) { return ( <Box component="nav" className="Navigation" {...props} sx={[ { p: 2, bgcolor: 'background.surface', borderRight: '1px solid', borderColor: 'divider', display: { xs: 'none', sm: 'initial', }, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function SidePane(props: BoxProps) { return ( <Box className="Inbox" {...props} sx={[ { bgcolor: 'background.surface', borderRight: '1px solid', borderColor: 'divider', display: { xs: 'none', md: 'initial', }, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function Main(props: BoxProps) { return ( <Box component="main" className="Main" {...props} sx={[{ p: 2 }, ...(Array.isArray(props.sx) ? props.sx : [props.sx])]} /> ); } function SideDrawer({ onClose, ...props }: BoxProps & { onClose: React.MouseEventHandler<HTMLDivElement> }) { return ( <Box {...props} sx={[ { position: 'fixed', zIndex: 1200, width: '100%', height: '100%' }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} > <Box role="button" onClick={onClose} sx={{ position: 'absolute', inset: 0, bgcolor: (theme) => `rgba(${theme.vars.palette.neutral.darkChannel} / 0.8)`, }} /> <Sheet sx={{ minWidth: 256, width: 'max-content', height: '100%', p: 2, boxShadow: 'lg', bgcolor: 'background.surface', }} > {props.children} </Sheet> </Box> ); } export default { Root, Header, SideNav, SidePane, SideDrawer, Main, };
1,854
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/Mails.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import Avatar from '@mui/joy/Avatar'; import List from '@mui/joy/List'; import ListDivider from '@mui/joy/ListDivider'; import ListItem from '@mui/joy/ListItem'; import ListItemButton, { listItemButtonClasses } from '@mui/joy/ListItemButton'; import ListItemDecorator from '@mui/joy/ListItemDecorator'; const data = [ { name: 'Alex Jonnold', avatar: 'https://i.pravatar.cc/40?img=3', avatar2x: 'https://i.pravatar.cc/80?img=3', date: '21 Oct 2022', title: 'Details for our Yosemite Park hike', body: 'Hello, my friend! So, it seems that we are getting there…', color: 'warning.400', }, { name: 'Pete Sand', avatar: 'https://i.pravatar.cc/40?img=4', avatar2x: 'https://i.pravatar.cc/80?img=4', date: '06 Jul 2022', title: 'Tickets for our upcoming trip', body: 'Good day, mate! It seems that our tickets just arrived…', color: 'success.400', }, { name: 'Kate Gates', avatar: 'https://i.pravatar.cc/40?img=5', avatar2x: 'https://i.pravatar.cc/80?img=5', date: '16 May 2022', title: 'Brunch this Saturday?', body: "Hey! I'll be around the city this weekend, how about a…", color: 'primary.500', }, { name: 'John Snow', avatar: 'https://i.pravatar.cc/40?img=7', avatar2x: 'https://i.pravatar.cc/80?img=7', date: '10 May 2022', title: 'Exciting News!', body: 'Hello there! I have some exciting news to share with you...', color: 'danger.500', }, { name: 'Michael Scott', avatar: 'https://i.pravatar.cc/40?img=8', avatar2x: 'https://i.pravatar.cc/80?img=8', date: '13 Apr 2022', title: 'Upcoming Product Launch', body: 'Dear customers and supporters, I am thrilled to announc...', color: 'danger.500', }, ]; export default function EmailList() { return ( <List sx={{ [`& .${listItemButtonClasses.root}.${listItemButtonClasses.selected}`]: { borderLeft: '2px solid', borderLeftColor: 'var(--joy-palette-primary-outlinedBorder)', }, }} > {data.map((item, index) => ( <React.Fragment key={index}> <ListItem> <ListItemButton {...(index === 0 && { selected: true, color: 'neutral', })} sx={{ p: 2 }} > <ListItemDecorator sx={{ alignSelf: 'flex-start' }}> <Avatar alt="" srcSet={item.avatar2x} src={item.avatar} /> </ListItemDecorator> <Box sx={{ pl: 2, width: '100%' }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.5, }} > <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}> <Typography level="body-xs">{item.name}</Typography> <Box sx={{ width: '8px', height: '8px', borderRadius: '99px', bgcolor: item.color, }} /> </Box> <Typography level="body-xs" textColor="text.tertiary"> {item.date} </Typography> </Box> <div> <Typography level="title-sm" sx={{ mb: 0.5 }}> {item.title} </Typography> <Typography level="body-sm">{item.body}</Typography> </div> </Box> </ListItemButton> </ListItem> <ListDivider sx={{ m: 0 }} /> </React.Fragment> ))} </List> ); }
1,855
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/Navigation.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import List from '@mui/joy/List'; import ListSubheader from '@mui/joy/ListSubheader'; import ListItem from '@mui/joy/ListItem'; import ListItemButton from '@mui/joy/ListItemButton'; import ListItemDecorator from '@mui/joy/ListItemDecorator'; import ListItemContent from '@mui/joy/ListItemContent'; // Icons import import InboxRoundedIcon from '@mui/icons-material/InboxRounded'; import OutboxRoundedIcon from '@mui/icons-material/OutboxRounded'; import DraftsRoundedIcon from '@mui/icons-material/DraftsRounded'; import AssistantPhotoRoundedIcon from '@mui/icons-material/AssistantPhotoRounded'; import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; export default function Navigation() { return ( <List size="sm" sx={{ '--ListItem-radius': '8px', '--List-gap': '4px' }}> <ListItem nested> <ListSubheader sx={{ letterSpacing: '2px', fontWeight: '800' }}> Browse </ListSubheader> <List aria-labelledby="nav-list-browse"> <ListItem> <ListItemButton selected> <ListItemDecorator> <InboxRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Inbox</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <OutboxRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Sent</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <DraftsRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Draft</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <AssistantPhotoRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Flagged</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <DeleteRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Trash</ListItemContent> </ListItemButton> </ListItem> </List> </ListItem> <ListItem nested sx={{ mt: 2 }}> <ListSubheader sx={{ letterSpacing: '2px', fontWeight: '800' }}> Tags </ListSubheader> <List aria-labelledby="nav-list-tags" size="sm" sx={{ '--ListItemDecorator-size': '32px', }} > <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'primary.500', }} /> </ListItemDecorator> <ListItemContent>Personal</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'danger.500', }} /> </ListItemDecorator> <ListItemContent>Work</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'warning.400', }} /> </ListItemDecorator> <ListItemContent>Travels</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'success.400', }} /> </ListItemDecorator> <ListItemContent>Concert tickets</ListItemContent> </ListItemButton> </ListItem> </List> </ListItem> </List> ); }
1,856
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/email/components/WriteEmail.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import ModalClose from '@mui/joy/ModalClose'; import Button from '@mui/joy/Button'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import Textarea from '@mui/joy/Textarea'; import Sheet from '@mui/joy/Sheet'; import { IconButton, Input, Stack, Typography } from '@mui/joy'; import FormatColorTextRoundedIcon from '@mui/icons-material/FormatColorTextRounded'; import AttachFileRoundedIcon from '@mui/icons-material/AttachFileRounded'; import InsertPhotoRoundedIcon from '@mui/icons-material/InsertPhotoRounded'; import FormatListBulletedRoundedIcon from '@mui/icons-material/FormatListBulletedRounded'; interface WriteEmailProps { open?: boolean; onClose?: () => void; } const WriteEmail = React.forwardRef<HTMLDivElement, WriteEmailProps>( function WriteEmail({ open, onClose }, ref) { return ( <Sheet ref={ref} sx={{ alignItems: 'center', px: 1.5, py: 1.5, ml: 'auto', width: { xs: '100dvw', md: 600 }, flexGrow: 1, border: '1px solid', borderRadius: '8px 8px 0 0', backgroundColor: 'background.level1', borderColor: 'neutral.outlinedBorder', boxShadow: 'lg', zIndex: 1000, position: 'fixed', bottom: 0, right: 24, transform: open ? 'translateY(0)' : 'translateY(100%)', transition: 'transform 0.3s ease', }} > <Box sx={{ mb: 2 }}> <Typography level="title-sm">New message</Typography> <ModalClose id="close-icon" onClick={onClose} /> </Box> <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2, flexShrink: 0 }} > <FormControl> <FormLabel>To</FormLabel> <Input placeholder="[email protected]" aria-label="Message" /> </FormControl> <FormControl> <FormLabel>CC</FormLabel> <Input placeholder="[email protected]" aria-label="Message" /> </FormControl> <Input placeholder="Subject" aria-label="Message" /> <FormControl sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}> <Textarea placeholder="Type your message here…" aria-label="Message" minRows={8} endDecorator={ <Stack direction="row" justifyContent="space-between" alignItems="center" flexGrow={1} sx={{ py: 1, pr: 1, borderTop: '1px solid', borderColor: 'divider', }} > <div> <IconButton size="sm" variant="plain" color="neutral"> <FormatColorTextRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <AttachFileRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <InsertPhotoRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <FormatListBulletedRoundedIcon /> </IconButton> </div> <Button color="primary" sx={{ borderRadius: 'sm' }} onClick={onClose} > Send </Button> </Stack> } sx={{ '& textarea:first-of-type': { minHeight: 72, }, }} /> </FormControl> </Box> </Sheet> ); }, ); export default WriteEmail;
1,857
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/App.tsx
import * as React from 'react'; import { CssVarsProvider } from '@mui/joy/styles'; import CssBaseline from '@mui/joy/CssBaseline'; import AspectRatio from '@mui/joy/AspectRatio'; import Avatar from '@mui/joy/Avatar'; import AvatarGroup from '@mui/joy/AvatarGroup'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Card from '@mui/joy/Card'; import CardOverflow from '@mui/joy/CardOverflow'; import CardCover from '@mui/joy/CardCover'; import CardContent from '@mui/joy/CardContent'; import Typography from '@mui/joy/Typography'; import IconButton from '@mui/joy/IconButton'; import Divider from '@mui/joy/Divider'; import Sheet from '@mui/joy/Sheet'; import Tabs from '@mui/joy/Tabs'; import TabList from '@mui/joy/TabList'; import Tab from '@mui/joy/Tab'; import TabPanel from '@mui/joy/TabPanel'; import List from '@mui/joy/List'; import ListItem from '@mui/joy/ListItem'; import ListDivider from '@mui/joy/ListDivider'; import ListItemButton from '@mui/joy/ListItemButton'; import ListItemContent from '@mui/joy/ListItemContent'; import Stack from '@mui/joy/Stack'; import Chip from '@mui/joy/Chip'; import Dropdown from '@mui/joy/Dropdown'; import Menu from '@mui/joy/Menu'; import MenuButton from '@mui/joy/MenuButton'; import MenuItem from '@mui/joy/MenuItem'; // Icons import import FolderRoundedIcon from '@mui/icons-material/FolderRounded'; import EditRoundedIcon from '@mui/icons-material/EditRounded'; import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; import EmailRoundedIcon from '@mui/icons-material/EmailRounded'; import PeopleAltRoundedIcon from '@mui/icons-material/PeopleAltRounded'; import MoreVertRoundedIcon from '@mui/icons-material/MoreVertRounded'; import InsertDriveFileRoundedIcon from '@mui/icons-material/InsertDriveFileRounded'; import ShareRoundedIcon from '@mui/icons-material/ShareRounded'; import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; // custom import Layout from './components/Layout'; import Navigation from './components/Navigation'; import Header from './components/Header'; import TableFiles from './components/TableFiles'; export default function FilesExample() { const [drawerOpen, setDrawerOpen] = React.useState(false); return ( <CssVarsProvider disableTransitionOnChange> <CssBaseline /> {drawerOpen && ( <Layout.SideDrawer onClose={() => setDrawerOpen(false)}> <Navigation /> </Layout.SideDrawer> )} <Stack id="tab-bar" direction="row" justifyContent="space-around" spacing={1} sx={{ display: { xs: 'flex', sm: 'none' }, zIndex: '999', bottom: 0, position: 'fixed', width: '100dvw', py: 2, backgroundColor: 'background.body', borderTop: '1px solid', borderColor: 'divider', }} > <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/email/" size="sm" startDecorator={<EmailRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Email </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/team/" size="sm" startDecorator={<PeopleAltRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Team </Button> <Button variant="plain" color="neutral" aria-pressed="true" component="a" href="/joy-ui/getting-started/templates/files/" size="sm" startDecorator={<FolderRoundedIcon />} sx={{ flexDirection: 'column', '--Button-gap': 0 }} > Files </Button> </Stack> <Layout.Root sx={{ gridTemplateColumns: { xs: '1fr', sm: 'minmax(64px, 200px) minmax(450px, 1fr)', md: 'minmax(160px, 300px) minmax(600px, 1fr) minmax(300px, 420px)', }, ...(drawerOpen && { height: '100vh', overflow: 'hidden', }), }} > <Layout.Header> <Header /> </Layout.Header> <Layout.SideNav> <Navigation /> </Layout.SideNav> <Layout.Main> <Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))', gap: 2, }} > {' '} <Sheet variant="outlined" sx={{ borderRadius: 'sm', gridColumn: '1/-1', display: { xs: 'none', md: 'flex' }, }} > <TableFiles /> </Sheet> <Sheet variant="outlined" sx={{ display: { xs: 'inherit', sm: 'none' }, borderRadius: 'sm', overflow: 'auto', backgroundColor: 'background.surface', '& > *': { '&:nth-child(n):not(:nth-last-child(-n+4))': { borderBottom: '1px solid', borderColor: 'divider', }, }, }} > <List size="sm" aria-labelledby="table-in-list"> <ListItem> <ListItemButton variant="soft" sx={{ bgcolor: 'transparent' }}> <ListItemContent sx={{ p: 1 }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', }} > <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Travel pictures </Typography> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px', }} > <Avatar src="https://i.pravatar.cc/24?img=6" srcSet="https://i.pravatar.cc/48?img=6 2x" /> <Avatar src="https://i.pravatar.cc/24?img=7" srcSet="https://i.pravatar.cc/48?img=7 2x" /> <Avatar src="https://i.pravatar.cc/24?img=8" srcSet="https://i.pravatar.cc/48?img=8 2x" /> <Avatar src="https://i.pravatar.cc/24?img=9" srcSet="https://i.pravatar.cc/48?img=9 2x" /> </AvatarGroup> </Box> <Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 2, }} > <Typography level="body-sm">987.5MB</Typography> <Typography level="body-sm">21 Oct 2023, 3PM</Typography> </Box> </ListItemContent> </ListItemButton> </ListItem> <ListDivider /> <ListItem> <ListItemButton variant="soft" sx={{ bgcolor: 'transparent' }}> <ListItemContent sx={{ p: 1 }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', }} > <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Important documents </Typography> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px', }} > <Avatar src="https://i.pravatar.cc/24?img=1" srcSet="https://i.pravatar.cc/48?img=1 2x" /> <Avatar src="https://i.pravatar.cc/24?img=9" srcSet="https://i.pravatar.cc/48?img=9 2x" /> <Avatar src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" /> <Avatar src="https://i.pravatar.cc/24?img=3" srcSet="https://i.pravatar.cc/48?img=3 2x" /> <Avatar>+3</Avatar> </AvatarGroup> </Box> <Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 2, }} > <Typography level="body-sm">232.3MB</Typography> <Typography level="body-sm">26 Sep 2023, 7PM</Typography> </Box> </ListItemContent> </ListItemButton> </ListItem> <ListDivider /> <ListItem> <ListItemButton variant="soft" sx={{ bgcolor: 'transparent' }}> <ListItemContent sx={{ p: 1 }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', }} > <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Projects </Typography> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px', }} > <Avatar src="https://i.pravatar.cc/24?img=4" srcSet="https://i.pravatar.cc/48?img=4 2x" /> <Avatar src="https://i.pravatar.cc/24?img=8" srcSet="https://i.pravatar.cc/48?img=8 2x" /> <Avatar src="https://i.pravatar.cc/24?img=5" srcSet="https://i.pravatar.cc/48?img=5 2x" /> </AvatarGroup> </Box> <Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 2, }} > <Typography level="body-sm">1.6GB</Typography> <Typography level="body-sm">12 Aug 2021, 7PM</Typography> </Box> </ListItemContent> </ListItemButton> </ListItem> <ListDivider /> <ListItem> <ListItemButton variant="soft" sx={{ bgcolor: 'transparent' }}> <ListItemContent sx={{ p: 1 }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 1, }} > <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Invoices </Typography> <Avatar size="sm" src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" sx={{ '--Avatar-size': '24px' }} /> </Box> <Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 2, }} > <Typography level="body-sm">123.3KB</Typography> <Typography level="body-sm">14 Mar 2021, 7PM</Typography> </Box> </ListItemContent> </ListItemButton> </ListItem> </List> </Sheet> <Card variant="outlined" size="sm"> <Box sx={{ display: 'flex', alignItems: 'center' }}> <Box sx={{ flex: 1 }}> <Typography level="title-md">lotr-two-towers.pdf</Typography> <Typography level="body-sm">132.2MB</Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', borderRadius: '9999999px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </Box> <CardOverflow sx={{ borderBottom: '1px solid', borderTop: '1px solid', borderColor: 'neutral.outlinedBorder', }} > <AspectRatio ratio="16/9" color="primary" sx={{ borderRadius: 0 }}> <img alt="" src="https://images.unsplash.com/photo-1621351183012-e2f9972dd9bf?auto=format&fit=crop&q=80&w=3024&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" /> </AspectRatio> </CardOverflow> <Typography level="body-xs">Added 27 Jun 2023</Typography> </Card> <Card variant="outlined" size="sm"> <Box sx={{ display: 'flex', alignItems: 'center' }}> <Box sx={{ flex: 1 }}> <Typography level="title-md">photos-travel.zip</Typography> <Typography level="body-sm">2.4GB</Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </Box> <CardOverflow sx={{ borderBottom: '1px solid', borderTop: '1px solid', borderColor: 'neutral.outlinedBorder', }} > <AspectRatio ratio="16/9" color="primary" sx={{ borderRadius: 0, color: 'primary.plainColor' }} > <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', }} > <InsertDriveFileRoundedIcon /> </Box> </AspectRatio> </CardOverflow> <Typography level="body-xs">Added 16 May 2021</Typography> </Card> <Card variant="solid" invertedColors size="sm" sx={{ border: '1px solid', borderColor: 'var(--joy-palette-neutral-outlinedBorder)', minHeight: { xs: 250, md: '100%' }, }} > <CardContent sx={{ mb: 'auto', flexGrow: 0, flexDirection: 'row', alignItems: 'center', }} > <Box sx={{ flex: 1 }}> <Typography level="title-md">torres-del-paine.png</Typography> <Typography level="body-xs" mt={0.5}> Added 5 Apr 2021 </Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </CardContent> <CardCover> <img alt="" src="https://images.unsplash.com/photo-1534067783941-51c9c23ecefd?auto=format&fit=crop&w=774" /> </CardCover> <CardCover sx={{ background: 'linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0.12))', }} /> </Card> <Card variant="solid" size="sm" invertedColors sx={{ minHeight: { xs: 250, md: '100%' }, border: '1px solid', borderColor: 'var(--joy-palette-neutral-outlinedBorder)', }} > <CardContent sx={{ mb: 'auto', flexGrow: 0, flexDirection: 'row', alignItems: 'center', }} > <Box sx={{ flex: 1 }}> <Typography level="title-md">serra-das-araras.png</Typography> <Typography level="body-xs" mt={0.5}> Added 2 Mar 2021 </Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </CardContent> <CardCover> <img alt="" src="https://images.unsplash.com/photo-1599593752325-ffa41031056e?auto=format&fit=crop&q=80&w=3570&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" /> </CardCover> <CardCover sx={{ background: 'linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0.12))', }} /> </Card> <Card variant="outlined" size="sm"> <Box sx={{ display: 'flex', alignItems: 'center' }}> <Box sx={{ flex: 1 }}> <Typography level="title-md">translated-docs.txt</Typography> <Typography level="body-sm">12.2KB</Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', borderRadius: '9999999px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </Box> <CardOverflow sx={{ borderBottom: '1px solid', borderTop: '1px solid', borderColor: 'neutral.outlinedBorder', }} > <AspectRatio ratio="16/9" color="primary" sx={{ borderRadius: 0 }}> <img alt="" src="https://images.unsplash.com/photo-1572445271230-a78b5944a659?auto=format&fit=crop&q=80&w=3024&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" /> </AspectRatio> </CardOverflow> <Typography level="body-xs">Added 25 May 2019</Typography> </Card> <Card variant="outlined" size="sm"> <Box sx={{ display: 'flex', alignItems: 'center' }}> <Box sx={{ flex: 1 }}> <Typography level="title-md">final-version-v3.fig</Typography> <Typography level="body-sm">1.1GB</Typography> </Box> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', borderRadius: '9999999px', }} > <IconButton component="span" variant="plain" color="neutral" size="sm" > <MoreVertRoundedIcon /> </IconButton> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <EditRoundedIcon /> Rename file </MenuItem> <MenuItem> <ShareRoundedIcon /> Share file </MenuItem> <MenuItem sx={{ textColor: 'danger.500' }}> <DeleteRoundedIcon color="danger" /> Delete file </MenuItem> </Menu> </Dropdown> </Box> <CardOverflow sx={{ borderBottom: '1px solid', borderTop: '1px solid', borderColor: 'neutral.outlinedBorder', }} > <AspectRatio ratio="16/9" color="primary" sx={{ borderRadius: 0, color: 'primary.plainColor' }} > <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', }} > <InsertDriveFileRoundedIcon /> </Box> </AspectRatio> </CardOverflow> <Typography level="body-xs">Added 12 May 2019</Typography> </Card> </Box> </Layout.Main> <Sheet sx={{ display: { xs: 'none', sm: 'initial' }, borderLeft: '1px solid', borderColor: 'divider', }} > <Box sx={{ p: 2, display: 'flex', alignItems: 'center' }}> <Typography level="title-md" sx={{ flex: 1 }}> torres-del-paine.png </Typography> <IconButton component="span" variant="plain" color="neutral" size="sm"> <CloseRoundedIcon /> </IconButton> </Box> <Divider /> <Tabs> <TabList> <Tab sx={{ flexGrow: 1 }}> <Typography level="title-sm">Details</Typography> </Tab> <Tab sx={{ flexGrow: 1 }}> <Typography level="title-sm">Activity</Typography> </Tab> </TabList> <TabPanel value={0} sx={{ p: 0 }}> <AspectRatio ratio="21/9"> <img alt="" src="https://images.unsplash.com/photo-1534067783941-51c9c23ecefd?auto=format&fit=crop&w=774" /> </AspectRatio> <Box sx={{ p: 2, display: 'flex', gap: 1, alignItems: 'center' }}> <Typography level="title-sm" mr={1}> Shared with </Typography> <AvatarGroup size="sm" sx={{ '--Avatar-size': '24px' }}> <Avatar src="https://i.pravatar.cc/24?img=6" srcSet="https://i.pravatar.cc/48?img=6 2x" /> <Avatar src="https://i.pravatar.cc/24?img=7" srcSet="https://i.pravatar.cc/48?img=7 2x" /> <Avatar src="https://i.pravatar.cc/24?img=8" srcSet="https://i.pravatar.cc/48?img=8 2x" /> <Avatar src="https://i.pravatar.cc/24?img=9" srcSet="https://i.pravatar.cc/48?img=9 2x" /> </AvatarGroup> </Box> <Divider /> <Box sx={{ gap: 2, p: 2, display: 'grid', gridTemplateColumns: 'auto 1fr', '& > *:nth-child(odd)': { color: 'text.secondary' }, }} > <Typography level="title-sm">Type</Typography> <Typography level="body-sm" textColor="text.primary"> Image </Typography> <Typography level="title-sm">Size</Typography> <Typography level="body-sm" textColor="text.primary"> 3,6 MB (3,258,385 bytes) </Typography> <Typography level="title-sm">Location</Typography> <Typography level="body-sm" textColor="text.primary"> Travel pictures </Typography> <Typography level="title-sm">Owner</Typography> <Typography level="body-sm" textColor="text.primary"> Michael Scott </Typography> <Typography level="title-sm">Modified</Typography> <Typography level="body-sm" textColor="text.primary"> 26 October 2016 </Typography> <Typography level="title-sm">Created</Typography> <Typography level="body-sm" textColor="text.primary"> 5 August 2016 </Typography> </Box> <Divider /> <Box sx={{ py: 2, px: 1 }}> <Button variant="plain" size="sm" endDecorator={<EditRoundedIcon />}> Add a description </Button> </Box> </TabPanel> <TabPanel value={1} sx={{ display: 'flex', flexDirection: 'column', gap: 3 }} > <Typography level="title-md">This week</Typography> <Box sx={{ display: 'flex', gap: 1 }}> <Avatar size="sm" src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" /> <div> <Box sx={{ display: 'flex', gap: 0.5, alignItems: 'center', mb: 1 }} > <Typography level="title-sm" sx={{ alignItems: 'center' }}> You </Typography> <Typography level="body-sm">shared</Typography> <Typography level="title-sm">torres-del-paine.png</Typography> </Box> <Chip variant="outlined" startDecorator={<ShareRoundedIcon />}> Shared with 3 users </Chip> <Typography level="body-xs" sx={{ mt: 1 }}> 3 Nov 2023 </Typography> </div> </Box> <Typography level="title-md">Older</Typography> <Box sx={{ display: 'flex', gap: 1 }}> <Avatar size="sm" src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" /> <div> <Box sx={{ display: 'flex', gap: 0.5, alignItems: 'center', mb: 1 }} > <Typography level="title-sm" sx={{ alignItems: 'center' }}> You </Typography> <Typography level="body-sm">edited</Typography> <Typography level="title-sm">torres-del-paine.png</Typography> </Box> <Chip variant="outlined" startDecorator={<EditRoundedIcon />}> Changed name </Chip> <Typography level="body-xs" sx={{ mt: 1 }}> 12 Apr 2021 </Typography> </div> </Box> <Box sx={{ display: 'flex', gap: 1 }}> <Avatar size="sm" src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" /> <div> <Box sx={{ display: 'flex', gap: 0.5, alignItems: 'center', mb: 1 }} > <Typography level="title-sm" sx={{ alignItems: 'center' }}> You </Typography> <Typography level="body-sm">created</Typography> <Typography level="title-sm">torres-del-paine.png</Typography> </Box> <Chip variant="outlined" startDecorator={<EditRoundedIcon />}> Added 5 Apr 2021 </Chip> <Typography level="body-xs" sx={{ mt: 1 }}> 12 Apr 2021 </Typography> </div> </Box> </TabPanel> </Tabs> </Sheet> </Layout.Root> </CssVarsProvider> ); }
1,858
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/components/Header.tsx
import * as React from 'react'; import { useColorScheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import Avatar from '@mui/joy/Avatar'; import Input from '@mui/joy/Input'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; import Dropdown from '@mui/joy/Dropdown'; import Menu from '@mui/joy/Menu'; import MenuButton from '@mui/joy/MenuButton'; import MenuItem from '@mui/joy/MenuItem'; import ListDivider from '@mui/joy/ListDivider'; import Drawer from '@mui/joy/Drawer'; import ModalClose from '@mui/joy/ModalClose'; import DialogTitle from '@mui/joy/DialogTitle'; // Icons import import SearchRoundedIcon from '@mui/icons-material/SearchRounded'; import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded'; import LightModeRoundedIcon from '@mui/icons-material/LightModeRounded'; import BookRoundedIcon from '@mui/icons-material/BookRounded'; import LanguageRoundedIcon from '@mui/icons-material/LanguageRounded'; import SettingsRoundedIcon from '@mui/icons-material/SettingsRounded'; import HelpRoundedIcon from '@mui/icons-material/HelpRounded'; import OpenInNewRoundedIcon from '@mui/icons-material/OpenInNewRounded'; import LogoutRoundedIcon from '@mui/icons-material/LogoutRounded'; import MenuRoundedIcon from '@mui/icons-material/MenuRounded'; // Custom import Navigation from './Navigation'; function ColorSchemeToggle() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return <IconButton size="sm" variant="outlined" color="primary" />; } return ( <Tooltip title="Change theme" variant="outlined"> <IconButton id="toggle-mode" size="sm" variant="plain" color="neutral" sx={{ alignSelf: 'center' }} onClick={() => { if (mode === 'light') { setMode('dark'); } else { setMode('light'); } }} > {mode === 'light' ? <DarkModeRoundedIcon /> : <LightModeRoundedIcon />} </IconButton> </Tooltip> ); } export default function Header() { const [open, setOpen] = React.useState(false); return ( <Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'space-between', }} > <Stack direction="row" justifyContent="center" alignItems="center" spacing={1} sx={{ display: { xs: 'none', sm: 'flex' } }} > <IconButton size="md" variant="outlined" color="neutral" sx={{ display: { xs: 'none', sm: 'inline-flex' }, borderRadius: '50%', }} > <LanguageRoundedIcon /> </IconButton> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/email/" size="sm" sx={{ alignSelf: 'center' }} > Email </Button> <Button variant="plain" color="neutral" component="a" href="/joy-ui/getting-started/templates/team/" size="sm" sx={{ alignSelf: 'center' }} > Team </Button> <Button variant="plain" color="neutral" aria-pressed="true" component="a" href="/joy-ui/getting-started/templates/files/" size="sm" sx={{ alignSelf: 'center' }} > Files </Button> </Stack> <Box sx={{ display: { xs: 'inline-flex', sm: 'none' } }}> <IconButton variant="plain" color="neutral" onClick={() => setOpen(true)}> <MenuRoundedIcon /> </IconButton> <Drawer sx={{ display: { xs: 'inline-flex', sm: 'none' } }} open={open} onClose={() => setOpen(false)} > <ModalClose /> <DialogTitle>Acme Co.</DialogTitle> <Box sx={{ px: 1 }}> <Navigation /> </Box> </Drawer> </Box> <Box sx={{ display: 'flex', flexDirection: 'row', gap: 1.5, alignItems: 'center', }} > <Input size="sm" variant="outlined" placeholder="Search anything…" startDecorator={<SearchRoundedIcon color="primary" />} endDecorator={ <IconButton variant="outlined" color="neutral" sx={{ bgcolor: 'background.level1' }} > <Typography level="title-sm" textColor="text.icon"> ⌘ K </Typography> </IconButton> } sx={{ alignSelf: 'center', display: { xs: 'none', sm: 'flex', }, }} /> <IconButton size="sm" variant="outlined" color="neutral" sx={{ display: { xs: 'inline-flex', sm: 'none' }, alignSelf: 'center' }} > <SearchRoundedIcon /> </IconButton> <Tooltip title="Joy UI overview" variant="outlined"> <IconButton size="sm" variant="plain" color="neutral" component="a" href="/blog/first-look-at-joy/" sx={{ alignSelf: 'center' }} > <BookRoundedIcon /> </IconButton> </Tooltip> <ColorSchemeToggle /> <Dropdown> <MenuButton variant="plain" size="sm" sx={{ maxWidth: '32px', maxHeight: '32px', borderRadius: '9999999px' }} > <Avatar src="https://i.pravatar.cc/40?img=2" srcSet="https://i.pravatar.cc/80?img=2" sx={{ maxWidth: '32px', maxHeight: '32px' }} /> </MenuButton> <Menu placement="bottom-end" size="sm" sx={{ zIndex: '99999', p: 1, gap: 1, '--ListItem-radius': 'var(--joy-radius-sm)', }} > <MenuItem> <Box sx={{ display: 'flex', alignItems: 'center', }} > <Avatar src="https://i.pravatar.cc/40?img=2" srcSet="https://i.pravatar.cc/80?img=2" sx={{ borderRadius: '50%' }} /> <Box sx={{ ml: 1.5 }}> <Typography level="title-sm" textColor="text.primary"> Rick Sanchez </Typography> <Typography level="body-xs" textColor="text.tertiary"> [email protected] </Typography> </Box> </Box> </MenuItem> <ListDivider /> <MenuItem> <HelpRoundedIcon /> Help </MenuItem> <MenuItem> <SettingsRoundedIcon /> Settings </MenuItem> <ListDivider /> <MenuItem component="a" href="/blog/first-look-at-joy/"> First look at Joy UI <OpenInNewRoundedIcon /> </MenuItem> <MenuItem component="a" href="https://github.com/mui/material-ui/tree/master/docs/data/joy/getting-started/templates/email" > Sourcecode <OpenInNewRoundedIcon /> </MenuItem> <ListDivider /> <MenuItem> <LogoutRoundedIcon /> Log out </MenuItem> </Menu> </Dropdown> </Box> </Box> ); }
1,859
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/components/Layout.tsx
import * as React from 'react'; import Box, { BoxProps } from '@mui/joy/Box'; import Sheet from '@mui/joy/Sheet'; function Root(props: BoxProps) { return ( <Box {...props} sx={[ { display: 'grid', gridTemplateColumns: { xs: '1fr', sm: 'minmax(64px, 200px) minmax(450px, 1fr)', md: 'minmax(160px, 300px) minmax(300px, 500px) minmax(500px, 1fr)', }, gridTemplateRows: '64px 1fr', minHeight: '100vh', }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function Header(props: BoxProps) { return ( <Box component="header" className="Header" {...props} sx={[ { p: 2, gap: 2, bgcolor: 'background.surface', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gridColumn: '1 / -1', borderBottom: '1px solid', borderColor: 'divider', position: 'sticky', top: 0, zIndex: 1100, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function SideNav(props: BoxProps) { return ( <Box component="nav" className="Navigation" {...props} sx={[ { p: 2, bgcolor: 'background.surface', borderRight: '1px solid', borderColor: 'divider', display: { xs: 'none', sm: 'initial', }, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function SidePane(props: BoxProps) { return ( <Box className="Inbox" {...props} sx={[ { bgcolor: 'background.surface', borderRight: '1px solid', borderColor: 'divider', display: { xs: 'none', md: 'initial', }, }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} /> ); } function Main(props: BoxProps) { return ( <Box component="main" className="Main" {...props} sx={[{ p: 2 }, ...(Array.isArray(props.sx) ? props.sx : [props.sx])]} /> ); } function SideDrawer({ onClose, ...props }: BoxProps & { onClose: React.MouseEventHandler<HTMLDivElement> }) { return ( <Box {...props} sx={[ { position: 'fixed', zIndex: 1200, width: '100%', height: '100%' }, ...(Array.isArray(props.sx) ? props.sx : [props.sx]), ]} > <Box role="button" onClick={onClose} sx={{ position: 'absolute', inset: 0, bgcolor: (theme) => `rgba(${theme.vars.palette.neutral.darkChannel} / 0.8)`, }} /> <Sheet sx={{ minWidth: 256, width: 'max-content', height: '100%', p: 2, boxShadow: 'lg', bgcolor: 'background.surface', }} > {props.children} </Sheet> </Box> ); } export default { Root, Header, SideNav, SidePane, SideDrawer, Main, };
1,860
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/components/Menu.tsx
import * as React from 'react'; import JoyMenu, { MenuActions } from '@mui/joy/Menu'; import MenuItem from '@mui/joy/MenuItem'; import { ListActionTypes } from '@mui/base/useList'; function Menu({ control, menus, id, }: { control: React.ReactElement; id: string; menus: Array<{ label: string } & { [k: string]: any }>; }) { const [buttonElement, setButtonElement] = React.useState<HTMLButtonElement | null>( null, ); const [isOpen, setOpen] = React.useState(false); const buttonRef = React.useRef<HTMLButtonElement>(null); const menuActions = React.useRef<MenuActions>(null); const preventReopen = React.useRef(false); const updateAnchor = React.useCallback((node: HTMLButtonElement | null) => { setButtonElement(node); }, []); const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => { if (preventReopen.current) { event.preventDefault(); preventReopen.current = false; return; } setOpen((open) => !open); }; const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => { if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { event.preventDefault(); setOpen(true); if (event.key === 'ArrowUp') { menuActions.current?.dispatch({ type: ListActionTypes.keyDown, key: event.key, event, }); } } }; const close = () => { setOpen(false); buttonRef.current!.focus(); }; return ( <React.Fragment> {React.cloneElement(control, { type: 'button', onClick: handleButtonClick, onKeyDown: handleButtonKeyDown, ref: updateAnchor, 'aria-controls': isOpen ? id : undefined, 'aria-expanded': isOpen || undefined, 'aria-haspopup': 'menu', })} <JoyMenu id={id} placement="bottom-end" actions={menuActions} open={isOpen} onClose={close} anchorEl={buttonElement} sx={{ minWidth: 120 }} > {menus.map(({ label, active, ...item }) => { const menuItem = ( <MenuItem selected={active} variant={active ? 'soft' : 'plain'} onClick={close} {...item} > {label} </MenuItem> ); if (item.href) { return ( <li key={label} role="none"> {React.cloneElement(menuItem, { component: 'a' })} </li> ); } return React.cloneElement(menuItem, { key: label }); })} </JoyMenu> </React.Fragment> ); } export default Menu;
1,861
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/components/Navigation.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import List from '@mui/joy/List'; import ListSubheader from '@mui/joy/ListSubheader'; import ListItem from '@mui/joy/ListItem'; import ListItemButton from '@mui/joy/ListItemButton'; import ListItemDecorator from '@mui/joy/ListItemDecorator'; import ListItemContent from '@mui/joy/ListItemContent'; // Icons import import FolderRoundedIcon from '@mui/icons-material/FolderRounded'; import ShareRoundedIcon from '@mui/icons-material/ShareRounded'; import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; export default function Navigation() { return ( <List size="sm" sx={{ '--ListItem-radius': '8px', '--List-gap': '4px' }}> <ListItem nested> <ListSubheader sx={{ letterSpacing: '2px', fontWeight: '800' }}> Browse </ListSubheader> <List aria-labelledby="nav-list-browse" sx={{ '& .JoyListItemButton-root': { p: '8px' }, }} > <ListItem> <ListItemButton selected> <ListItemDecorator> <FolderRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>My files</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <ShareRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Shared files</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <DeleteRoundedIcon fontSize="small" /> </ListItemDecorator> <ListItemContent>Trash</ListItemContent> </ListItemButton> </ListItem> </List> </ListItem> <ListItem nested sx={{ mt: 2 }}> <ListSubheader sx={{ letterSpacing: '2px', fontWeight: '800' }}> Tags </ListSubheader> <List aria-labelledby="nav-list-tags" size="sm" sx={{ '--ListItemDecorator-size': '32px', '& .JoyListItemButton-root': { p: '8px' }, }} > <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'primary.500', }} /> </ListItemDecorator> <ListItemContent>Personal</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'danger.500', }} /> </ListItemDecorator> <ListItemContent>Work</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'warning.400', }} /> </ListItemDecorator> <ListItemContent>Travels</ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <ListItemDecorator> <Box sx={{ width: '10px', height: '10px', borderRadius: '99px', bgcolor: 'success.400', }} /> </ListItemDecorator> <ListItemContent>Concert tickets</ListItemContent> </ListItemButton> </ListItem> </List> </ListItem> </List> ); }
1,862
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/files/components/TableFiles.tsx
import * as React from 'react'; import Avatar from '@mui/joy/Avatar'; import AvatarGroup from '@mui/joy/AvatarGroup'; import Typography from '@mui/joy/Typography'; import Table from '@mui/joy/Table'; // Icons import import FolderRoundedIcon from '@mui/icons-material/FolderRounded'; import ArrowDropDownRoundedIcon from '@mui/icons-material/ArrowDropDownRounded'; // custom function TableFiles() { return ( <div> <Table hoverRow size="sm" borderAxis="none" variant="soft" sx={{ '--TableCell-paddingX': '1rem', '--TableCell-paddingY': '1rem', }} > <thead> <tr> <th> <Typography level="title-sm">Folder</Typography> </th> <th> <Typography level="title-sm" endDecorator={<ArrowDropDownRoundedIcon />} > Last modified </Typography> </th> <th> <Typography level="title-sm">Size</Typography> </th> <th> <Typography level="title-sm">Users</Typography> </th> </tr> </thead> <tbody> <tr> <td> <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Travel pictures </Typography> </td> <td> <Typography level="body-sm">21 Oct 2023, 3PM</Typography> </td> <td> <Typography level="body-sm">987.5MB</Typography> </td> <td> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px' }} > <Avatar src="https://i.pravatar.cc/24?img=6" srcSet="https://i.pravatar.cc/48?img=6 2x" /> <Avatar src="https://i.pravatar.cc/24?img=7" srcSet="https://i.pravatar.cc/48?img=7 2x" /> <Avatar src="https://i.pravatar.cc/24?img=8" srcSet="https://i.pravatar.cc/48?img=8 2x" /> <Avatar src="https://i.pravatar.cc/24?img=9" srcSet="https://i.pravatar.cc/48?img=9 2x" /> </AvatarGroup> </td> </tr> <tr> <td> <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Important documents </Typography> </td> <td> <Typography level="body-sm">26 Sep 2023, 7PM</Typography> </td> <td> <Typography level="body-sm">232.3MB</Typography> </td> <td> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px' }} > <Avatar src="https://i.pravatar.cc/24?img=1" srcSet="https://i.pravatar.cc/48?img=1 2x" /> <Avatar src="https://i.pravatar.cc/24?img=9" srcSet="https://i.pravatar.cc/48?img=9 2x" /> <Avatar src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" /> <Avatar src="https://i.pravatar.cc/24?img=3" srcSet="https://i.pravatar.cc/48?img=3 2x" /> <Avatar>+3</Avatar> </AvatarGroup> </td> </tr> <tr> <td> <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Projects </Typography> </td> <td> <Typography level="body-sm">12 Aug 2021, 7PM</Typography> </td> <td> <Typography level="body-sm">1.6GB</Typography> </td> <td> <AvatarGroup size="sm" sx={{ '--AvatarGroup-gap': '-8px', '--Avatar-size': '24px' }} > <Avatar src="https://i.pravatar.cc/24?img=4" srcSet="https://i.pravatar.cc/48?img=4 2x" /> <Avatar src="https://i.pravatar.cc/24?img=8" srcSet="https://i.pravatar.cc/48?img=8 2x" /> <Avatar src="https://i.pravatar.cc/24?img=5" srcSet="https://i.pravatar.cc/48?img=5 2x" /> </AvatarGroup> </td> </tr> <tr> <td> <Typography level="title-sm" startDecorator={<FolderRoundedIcon color="primary" />} sx={{ alignItems: 'flex-start' }} > Invoices </Typography> </td> <td> <Typography level="body-sm">14 Mar 2021, 7PM</Typography> </td> <td> <Typography level="body-sm">123.3KB</Typography> </td> <td> <Avatar size="sm" src="https://i.pravatar.cc/24?img=2" srcSet="https://i.pravatar.cc/48?img=2 2x" sx={{ '--Avatar-size': '24px' }} /> </td> </tr> </tbody> </Table> </div> ); } export default TableFiles;
1,863
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/App.tsx
import * as React from 'react'; import { CssVarsProvider, useColorScheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import CssBaseline from '@mui/joy/CssBaseline'; import IconButton from '@mui/joy/IconButton'; // Icons import import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded'; import LightModeRoundedIcon from '@mui/icons-material/LightModeRounded'; import framesxTheme from './theme'; import HeroLeft01 from './blocks/HeroLeft01'; import HeroLeft02 from './blocks/HeroLeft02'; import HeroLeft03 from './blocks/HeroLeft03'; import HeroLeft04 from './blocks/HeroLeft04'; import HeroLeft05 from './blocks/HeroLeft05'; import HeroLeft06 from './blocks/HeroLeft06'; import HeroLeft07 from './blocks/HeroLeft07'; import HeroLeft08 from './blocks/HeroLeft08'; import HeroLeft09 from './blocks/HeroLeft09'; import HeroLeft10 from './blocks/HeroLeft10'; function ColorSchemeToggle() { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return ( <IconButton id="toggle-mode" size="lg" variant="soft" color="neutral" onClick={() => { if (mode === 'light') { setMode('dark'); } else { setMode('light'); } }} sx={{ position: 'fixed', zIndex: 999, top: '1rem', right: '1rem', borderRadius: '50%', boxShadow: 'sm', }} > {mode === 'light' ? <DarkModeRoundedIcon /> : <LightModeRoundedIcon />} </IconButton> ); } export default function TeamExample() { return ( <CssVarsProvider disableTransitionOnChange theme={framesxTheme}> <CssBaseline /> <ColorSchemeToggle /> <Box sx={{ height: '100vh', overflowY: 'scroll', scrollSnapType: 'y mandatory', '& > div': { scrollSnapAlign: 'start', }, }} > <HeroLeft01 /> <HeroLeft02 /> <HeroLeft03 /> <HeroLeft04 /> <HeroLeft05 /> <HeroLeft06 /> <HeroLeft07 /> <HeroLeft08 /> <HeroLeft09 /> <HeroLeft10 /> </Box> </CssVarsProvider> ); }
1,864
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/theme.tsx
import { extendTheme } from '@mui/joy/styles'; import { inputClasses } from '@mui/joy/Input'; export default extendTheme({ colorSchemes: { light: { palette: { primary: { 50: '#F2F7FF', 100: '#DCEBFE', 200: '#BDDAFE', 300: '#91C3FC', 400: '#60A5FA', 500: '#3479E8', 600: '#2362EA', 700: '#1D4FD7', 800: '#1D3FAE', 900: '#1E3B8A', solidBg: 'var(--joy-palette-primary-600)', solidHoverBg: 'var(--joy-palette-primary-500)', solidActiveBg: 'var(--joy-palette-primary-400)', }, }, }, dark: { palette: { primary: { 50: '#1D223F', 100: '#0A318C', 200: '#1347CC', 300: '#1055EA', 400: '#357AEA', 500: '#2E88F6', 600: '#50A1FF', 700: '#7AB7FF', 800: '#DCEBFE', 900: '#F0F6FF', solidBg: 'var(--joy-palette-primary-700)', solidColor: 'var(--joy-palette-common-black)', solidHoverBg: 'var(--joy-palette-primary-600)', solidActiveBg: 'var(--joy-palette-primary-400)', }, background: { body: 'var(--joy-palette-common-black)', surface: 'var(--joy-palette-neutral-900)', }, }, }, }, fontFamily: { display: "'Inter', var(--joy-fontFamily-fallback)", body: "'Inter', var(--joy-fontFamily-fallback)", }, components: { JoyInput: { styleOverrides: { root: ({ ownerState, theme }) => ({ ...(ownerState.variant === 'outlined' && { [`&:not(.${inputClasses.focused}):hover::before`]: { boxShadow: `inset 0 0 0 2px ${ theme.vars.palette?.[ownerState.color!]?.outlinedBorder }`, }, }), }), input: { caretColor: 'var(--Input-focusedHighlight)', }, }, }, }, });
1,865
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft01.tsx
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import Button from '@mui/joy/Button'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft01() { return ( <TwoSidedLayout> <Typography color="primary" fontSize="lg" fontWeight="lg"> The power to do more </Typography> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />}> Get Started </Button> <Typography> Already a member? <Link fontWeight="lg">Sign in</Link> </Typography> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft01 </Typography> </TwoSidedLayout> ); }
1,866
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft02.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Input from '@mui/joy/Input'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import Star from '@mui/icons-material/Star'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft02() { return ( <TwoSidedLayout> <Typography color="primary" fontSize="lg" fontWeight="lg"> The power to do more </Typography> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Box sx={{ display: 'flex', gap: 2, my: 2, flexWrap: 'wrap', '& > *': { flex: 'auto' }, }} > <Input size="lg" placeholder="Sign in with email" /> <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />}> Get Started </Button> </Box> <Box sx={(theme) => ({ display: 'flex', textAlign: 'center', alignSelf: 'stretch', columnGap: 4.5, '& > *': { display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', flexWrap: 'wrap', flex: 1, }, [theme.breakpoints.up(834)]: { textAlign: 'left', '& > *': { flexDirection: 'row', gap: 1.5, justifyContent: 'initial', flexWrap: 'nowrap', flex: 'none', }, }, })} > <div> <Typography fontSize="xl4" fontWeight="lg" endDecorator={<Star fontSize="xl4" sx={{ color: 'warning.300' }} />} > 4.9 </Typography> <Typography textColor="text.secondary"> Over <b>5k</b> positive <br /> customer reviews. </Typography> </div> <div> <Typography fontSize="xl4" fontWeight="lg"> 2M </Typography> <Typography textColor="text.secondary"> Global <br /> Transactions. </Typography> </div> </Box> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft02 </Typography> </TwoSidedLayout> ); }
1,867
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft03.tsx
import * as React from 'react'; import AvatarGroup from '@mui/joy/AvatarGroup'; import Avatar from '@mui/joy/Avatar'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft03() { return ( <TwoSidedLayout> <Typography color="primary" fontSize="lg" fontWeight="lg"> The power to do more </Typography> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 2, my: 2, '& > *': { flex: 'auto' }, }} > <Button size="lg" variant="outlined" color="neutral"> Learn More </Button> <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />}> Get Started </Button> </Box> <Box sx={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 2, textAlign: 'left', '& > *': { flexShrink: 0, }, }} > <AvatarGroup size="lg"> <Avatar /> <Avatar /> <Avatar /> </AvatarGroup> <Typography textColor="text.secondary"> Join a community of over <b>10K</b> <br /> designers and developers. </Typography> </Box> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft03 </Typography> </TwoSidedLayout> ); }
1,868
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft04.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Chip from '@mui/joy/Chip'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import PlayCircleOutlineIcon from '@mui/icons-material/PlayCircleOutline'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft04() { return ( <TwoSidedLayout> <Chip size="lg" variant="outlined" color="neutral"> The power to do more </Chip> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Box sx={{ display: 'flex', gap: 2, my: 2, flexWrap: 'wrap', '& > *': { flex: 'auto' }, }} > <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />}> Get Started </Button> <Button size="lg" variant="outlined" color="neutral" startDecorator={<PlayCircleOutlineIcon />} > Watch Video </Button> </Box> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft04 </Typography> </TwoSidedLayout> ); }
1,869
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft05.tsx
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import Button from '@mui/joy/Button'; import Input from '@mui/joy/Input'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft05() { return ( <TwoSidedLayout> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Input size="lg" placeholder="Sign in with email" sx={{ alignSelf: 'stretch', mt: 2 }} /> <Button size="lg" endDecorator={<ArrowForward />} sx={{ alignSelf: 'stretch' }} > Get Started </Button> <Typography textColor="text.secondary"> By continuing you agree to our{' '} <Link color="neutral"> <b>Privacy Policy</b> </Link> </Typography> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft05 </Typography> </TwoSidedLayout> ); }
1,870
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft06.tsx
import * as React from 'react'; import Avatar from '@mui/joy/Avatar'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import Star from '@mui/icons-material/Star'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft06() { return ( <TwoSidedLayout> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Button size="lg">Get Started For Free</Button> <Typography fontSize="xl" fontWeight="md" endDecorator={ <React.Fragment> <Star sx={{ color: 'warning.300' }} /> <Star sx={{ color: 'warning.300' }} /> <Star sx={{ color: 'warning.300' }} /> <Star sx={{ color: 'warning.300' }} /> <Star sx={{ color: 'warning.300' }} /> </React.Fragment> } sx={{ mt: 3 }} > 5.0 </Typography> <Typography textColor="text.secondary"> The resource and tips in Frames X are worth a fortune. My team loves the design kits. </Typography> <Typography startDecorator={<Avatar component="span" size="lg" variant="outlined" />} sx={{ '--Typography-gap': '12px' }} > <b>John Seed</b>, Apple Inc. </Typography> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft06 </Typography> </TwoSidedLayout> ); }
1,871
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft07.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import Card from '@mui/joy/Card'; import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft07() { return ( <TwoSidedLayout> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Card variant="outlined" color="neutral" orientation="horizontal" sx={{ gap: 2, my: 1, textAlign: 'left' }} > <AutoAwesomeIcon color="success" fontSize="xl3" /> <div> <Typography fontSize="xl" fontWeight="lg" sx={{ mb: 1 }}> The new version is out. </Typography> <Typography level="body-sm"> This is where a notification message will appear. <br /> Enter text into this container. </Typography> </div> </Card> <Button size="lg">Download the App</Button> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft07 </Typography> </TwoSidedLayout> ); }
1,872
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft08.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import Star from '@mui/icons-material/Star'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft08() { return ( <TwoSidedLayout> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 2, my: 2, '& > *': { flex: 'auto' }, }} > <Button size="lg" variant="outlined" color="neutral"> Learn More </Button> <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />}> Get Started </Button> </Box> <Box sx={(theme) => ({ display: 'flex', columnGap: 4.5, rowGap: 1.5, textAlign: 'center', alignSelf: 'stretch', '& > *': { flex: 1, display: 'flex', flexDirection: 'column', gap: 1.5, alignItems: 'center', }, [theme.breakpoints.up(834)]: { textAlign: 'left', '& > *': { alignItems: 'initial', }, }, })} > <div> <Typography fontSize="xl4" fontWeight="lg" endDecorator={<Star fontSize="xl4" sx={{ color: 'warning.300' }} />} > 4.9 </Typography> <Typography textColor="text.secondary"> Rated by <b>5k</b> people on trustpilot.com </Typography> </div> <div> <Typography fontSize="xl4" fontWeight="lg"> 9.5k+ </Typography> <Typography textColor="text.secondary"> Active users from the top world companies. </Typography> </div> </Box> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft08 </Typography> </TwoSidedLayout> ); }
1,873
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft09.tsx
/* eslint-disable jsx-a11y/anchor-is-valid */ import * as React from 'react'; import Button from '@mui/joy/Button'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft09() { return ( <TwoSidedLayout reversed> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Button size="lg" endDecorator={<ArrowForward fontSize="xl" />} sx={{ mt: 2, mb: 1 }} > Get Started </Button> <Typography> Already a member? <Link fontWeight="lg">Sign in</Link> </Typography> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft09 </Typography> </TwoSidedLayout> ); }
1,874
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/blocks/HeroLeft10.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Chip from '@mui/joy/Chip'; import Input from '@mui/joy/Input'; import IconButton from '@mui/joy/IconButton'; import Typography from '@mui/joy/Typography'; import ArrowForward from '@mui/icons-material/ArrowForward'; import TwoSidedLayout from '../components/TwoSidedLayout'; export default function HeroLeft04() { return ( <TwoSidedLayout reversed> <Chip size="lg" variant="outlined" color="neutral"> The power to do more </Chip> <Typography level="h1" fontWeight="xl" fontSize="clamp(1.875rem, 1.3636rem + 2.1818vw, 3rem)" > A large headlinerer about our product features & services </Typography> <Typography fontSize="lg" textColor="text.secondary" lineHeight="lg"> A descriptive secondary text placeholder. Use it to explain your business offer better. </Typography> <Box component="form" sx={{ display: 'flex', gap: 1, my: 2, alignSelf: 'stretch', flexBasis: '80%', }} > <Input required name="email" type="email" size="lg" placeholder="Sign in with email" sx={{ flex: 'auto' }} /> <IconButton type="submit" size="lg" variant="solid" color="primary"> <ArrowForward /> </IconButton> </Box> <Typography level="body-xs" sx={{ position: 'absolute', top: '2rem', left: '50%', transform: 'translateX(-50%)', }} > HeroLeft10 </Typography> </TwoSidedLayout> ); }
1,875
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/framesx-web-blocks/components/TwoSidedLayout.tsx
import * as React from 'react'; import AspectRatio from '@mui/joy/AspectRatio'; import Box from '@mui/joy/Box'; import Container from '@mui/joy/Container'; import { typographyClasses } from '@mui/joy/Typography'; export default function TwoSidedLayout({ children, reversed, }: React.PropsWithChildren<{ reversed?: boolean }>) { return ( <Container sx={(theme) => ({ position: 'relative', minHeight: '100vh', display: 'flex', flexDirection: reversed ? 'column-reverse' : 'column', alignItems: 'center', py: 10, gap: 4, [theme.breakpoints.up(834)]: { flexDirection: 'row', gap: 6, }, [theme.breakpoints.up(1199)]: { gap: 12, }, })} > <Box sx={(theme) => ({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '1rem', maxWidth: '50ch', textAlign: 'center', flexShrink: 999, [theme.breakpoints.up(834)]: { minWidth: 420, alignItems: 'flex-start', textAlign: 'initial', }, [`& .${typographyClasses.root}`]: { textWrap: 'balance', }, })} > {children} </Box> <AspectRatio ratio={600 / 520} variant="outlined" maxHeight={300} sx={(theme) => ({ minWidth: 300, alignSelf: 'stretch', [theme.breakpoints.up(834)]: { alignSelf: 'initial', flexGrow: 1, '--AspectRatio-maxHeight': '520px', '--AspectRatio-minHeight': '400px', }, borderRadius: 'sm', bgcolor: 'background.level2', flexBasis: '50%', })} > <img src="https://images.unsplash.com/photo-1483791424735-e9ad0209eea2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80" alt="" /> </AspectRatio> </Container> ); }
1,876
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/App.tsx
import * as React from 'react'; import { CssVarsProvider } from '@mui/joy/styles'; import CssBaseline from '@mui/joy/CssBaseline'; import Box from '@mui/joy/Box'; import Sidebar from './components/Sidebar'; import Header from './components/Header'; import MyMessages from './components/MyMessages'; export default function JoyMessagesTemplate() { return ( <CssVarsProvider disableTransitionOnChange> <CssBaseline /> <Box sx={{ display: 'flex', minHeight: '100dvh' }}> <Sidebar /> <Header /> <Box component="main" className="MainContent" sx={{ flex: 1 }}> <MyMessages /> </Box> </Box> </CssVarsProvider> ); }
1,877
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/data.tsx
import { ChatProps, UserProps } from './types'; export const users: UserProps[] = [ { name: 'Steve E.', username: '@steveEberger', avatar: '/static/images/avatar/2.jpg', online: true, }, { name: 'Katherine Moss', username: '@kathy', avatar: '/static/images/avatar/3.jpg', online: false, }, { name: 'Phoenix Baker', username: '@phoenix', avatar: '/static/images/avatar/1.jpg', online: true, }, { name: 'Eleanor Pena', username: '@eleanor', avatar: '/static/images/avatar/4.jpg', online: false, }, { name: 'Kenny Peterson', username: '@kenny', avatar: '/static/images/avatar/5.jpg', online: true, }, { name: 'Al Sanders', username: '@al', avatar: '/static/images/avatar/6.jpg', online: true, }, { name: 'Melissa Van Der Berg', username: '@melissa', avatar: '/static/images/avatar/7.jpg', online: false, }, ]; export const chats: ChatProps[] = [ { id: '1', sender: users[0], messages: [ { id: '1', content: 'Hi Olivia, I am currently working on the project.', timestamp: 'Wednesday 9:00am', sender: users[0], }, { id: '2', content: 'That sounds great, Mabel! Keep up the good work.', timestamp: 'Wednesday 9:10am', sender: 'You', }, { id: '3', timestamp: 'Wednesday 11:30am', sender: users[0], content: 'I will send the draft by end of the day.', }, { id: '4', timestamp: 'Wednesday 2:00pm', sender: 'You', content: 'Sure, I will be waiting for it.', }, { id: '5', timestamp: 'Wednesday 4:30pm', sender: users[0], content: 'Just a heads up, I am about to send the draft.', }, { id: '6', content: "Thanks Olivia! Almost there. I'll work on making those changes you suggested and will shoot it over.", timestamp: 'Thursday 10:16am', sender: users[0], }, { id: '7', content: "Hey Olivia, I've finished with the requirements doc! I made some notes in the gdoc as well for Phoenix to look over.", timestamp: 'Thursday 11:40am', sender: users[0], }, { id: '3', timestamp: 'Thursday 11:40am', sender: users[0], content: 'Tech requirements.pdf', attachment: { fileName: 'Tech requirements.pdf', type: 'pdf', size: '1.2 MB', }, }, { id: '8', timestamp: 'Thursday 11:41am', sender: 'You', content: "Awesome! Thanks. I'll look at this today.", }, { id: '9', timestamp: 'Thursday 11:44am', sender: users[0], content: "No rush though — we still have to wait for Lana's designs.", }, { id: '10', timestamp: 'Today 2:20pm', sender: users[0], content: 'Hey Olivia, can you please review the latest design when you can?', }, { id: '11', timestamp: 'Just now', sender: 'You', content: "Sure thing, I'll have a look today. They're looking great!", }, ], }, { id: '2', sender: users[1], messages: [ { id: '1', content: 'Hi Olivia, I am thinking about taking a vacation.', timestamp: 'Wednesday 9:00am', sender: users[1], }, { id: '2', content: 'That sounds like a great idea, Katherine! Any idea where you want to go?', timestamp: 'Wednesday 9:05am', sender: 'You', }, { id: '3', content: 'I am considering a trip to the beach.', timestamp: 'Wednesday 9:30am', sender: users[1], }, { id: '4', content: 'The beach sounds perfect this time of year!', timestamp: 'Wednesday 9:35am', sender: 'You', }, { id: '5', content: 'Yes, I agree. It will be a much-needed break.', timestamp: 'Wednesday 10:00am', sender: users[1], }, { id: '6', content: 'Make sure to take lots of pictures!', timestamp: 'Wednesday 10:05am', sender: 'You', }, ], }, { id: '3', sender: users[2], messages: [ { id: '1', content: 'Hey!', timestamp: '5 mins ago', sender: users[2], unread: true, }, ], }, { id: '4', sender: users[3], messages: [ { id: '1', content: 'Hey Olivia, I was thinking about doing some home improvement work.', timestamp: 'Wednesday 9:00am', sender: users[3], }, { id: '2', content: 'That sounds interesting! What kind of improvements are you considering?', timestamp: 'Wednesday 9:05am', sender: 'You', }, { id: '3', content: 'I am planning to repaint the walls and replace the old furniture.', timestamp: 'Wednesday 9:15am', sender: users[3], }, { id: '4', content: 'That will definitely give your house a fresh look. Do you need help with anything?', timestamp: 'Wednesday 9:20am', sender: 'You', }, { id: '5', content: 'I might need some help with picking the right paint colors. Can we discuss this over the weekend?', timestamp: 'Wednesday 9:30am', sender: users[3], }, ], }, { id: '5', sender: users[4], messages: [ { id: '1', content: 'Sup', timestamp: '5 mins ago', sender: users[4], unread: true, }, ], }, { id: '6', sender: users[5], messages: [ { id: '1', content: 'Heyo', timestamp: '5 mins ago', sender: 'You', unread: true, }, ], }, { id: '7', sender: users[6], messages: [ { id: '1', content: "Hey Olivia, I've finished with the requirements doc! I made some notes in the gdoc as well for Phoenix to look over.", timestamp: '5 mins ago', sender: users[6], unread: true, }, ], }, ];
1,878
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/types.tsx
export type UserProps = { name: string; username: string; avatar: string; online: boolean; }; export type MessageProps = { id: string; content: string; timestamp: string; unread?: boolean; sender: UserProps | 'You'; attachment?: { fileName: string; type: string; size: string; }; }; export type ChatProps = { id: string; sender: UserProps; messages: MessageProps[]; };
1,879
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/useScript.ts
import * as React from 'react'; export type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'; // Cached script statuses const cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {}; /** * Simplified version of https://usehooks-ts.com/react-hook/use-script */ function getScriptNode(src: string) { const node: HTMLScriptElement | null = document.querySelector(`script[src="${src}"]`); const status = node?.getAttribute('data-status') as UseScriptStatus | undefined; return { node, status, }; } function useScript(src: string): UseScriptStatus { const [status, setStatus] = React.useState<UseScriptStatus>(() => { if (typeof window === 'undefined') { // SSR Handling - always return 'loading' return 'loading'; } return cachedScriptStatuses[src] ?? 'loading'; }); React.useEffect(() => { const cachedScriptStatus = cachedScriptStatuses[src]; if (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') { // If the script is already cached, set its status immediately setStatus(cachedScriptStatus); return; } // Fetch existing script element by src // It may have been added by another instance of this hook const script = getScriptNode(src); let scriptNode = script.node; if (!scriptNode) { // Create script element and add it to document body scriptNode = document.createElement('script'); scriptNode.src = src; scriptNode.async = true; scriptNode.setAttribute('data-status', 'loading'); document.body.appendChild(scriptNode); // Store status in attribute on script // This can be read by other instances of this hook const setAttributeFromEvent = (event: Event) => { const scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error'; scriptNode?.setAttribute('data-status', scriptStatus); }; scriptNode.addEventListener('load', setAttributeFromEvent); scriptNode.addEventListener('error', setAttributeFromEvent); } else { // Grab existing script status from attribute and set to state. setStatus(script.status ?? cachedScriptStatus ?? 'loading'); } // Script event handler to update status in state // Note: Even if the script already exists we still need to add // event handlers to update the state for *this* hook instance. const setStateFromEvent = (event: Event) => { const newStatus = event.type === 'load' ? 'ready' : 'error'; setStatus(newStatus); cachedScriptStatuses[src] = newStatus; }; // Add event listeners scriptNode.addEventListener('load', setStateFromEvent); scriptNode.addEventListener('error', setStateFromEvent); // Remove event listeners on cleanup // eslint-disable-next-line consistent-return return () => { if (scriptNode) { scriptNode.removeEventListener('load', setStateFromEvent); scriptNode.removeEventListener('error', setStateFromEvent); } if (scriptNode) { try { scriptNode.remove(); } catch (error) { // ignore error } } }; }, [src]); return status; } export default useScript;
1,880
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/utils.ts
export const openSidebar = () => { if (typeof document !== 'undefined') { document.body.style.overflow = 'hidden'; document.documentElement.style.setProperty('--SideNavigation-slideIn', '1'); } }; export const closeSidebar = () => { if (typeof document !== 'undefined') { document.documentElement.style.removeProperty('--SideNavigation-slideIn'); document.body.style.removeProperty('overflow'); } }; export const toggleSidebar = () => { if (typeof window !== 'undefined' && typeof document !== 'undefined') { const slideIn = window .getComputedStyle(document.documentElement) .getPropertyValue('--SideNavigation-slideIn'); if (slideIn) { closeSidebar(); } else { openSidebar(); } } }; export const openMessagesPane = () => { if (typeof document !== 'undefined') { document.body.style.overflow = 'hidden'; document.documentElement.style.setProperty('--MessagesPane-slideIn', '1'); } }; export const closeMessagesPane = () => { if (typeof document !== 'undefined') { document.documentElement.style.removeProperty('--MessagesPane-slideIn'); document.body.style.removeProperty('overflow'); } }; export const toggleMessagesPane = () => { if (typeof window !== 'undefined' && typeof document !== 'undefined') { const slideIn = window .getComputedStyle(document.documentElement) .getPropertyValue('--MessagesPane-slideIn'); if (slideIn) { closeMessagesPane(); } else { openMessagesPane(); } } };
1,881
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/AvatarWithStatus.tsx
import * as React from 'react'; import Badge from '@mui/joy/Badge'; import Avatar, { AvatarProps } from '@mui/joy/Avatar'; type AvatarWithStatusProps = AvatarProps & { online?: boolean; }; export default function AvatarWithStatus({ online = false, ...rest }: AvatarWithStatusProps) { return ( <div> <Badge color={online ? 'success' : 'neutral'} variant={online ? 'solid' : 'soft'} size="sm" anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} badgeInset="4px 4px" > <Avatar size="sm" {...rest} /> </Badge> </div> ); }
1,882
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/ChatBubble.tsx
import * as React from 'react'; import Avatar from '@mui/joy/Avatar'; import Box from '@mui/joy/Box'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import Sheet from '@mui/joy/Sheet'; import Typography from '@mui/joy/Typography'; import CelebrationOutlinedIcon from '@mui/icons-material/CelebrationOutlined'; import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'; import InsertDriveFileRoundedIcon from '@mui/icons-material/InsertDriveFileRounded'; import { MessageProps } from '../types'; type ChatBubbleProps = MessageProps & { variant: 'sent' | 'received'; }; export default function ChatBubble({ content, variant, timestamp, attachment = undefined, sender, }: ChatBubbleProps) { const isSent = variant === 'sent'; const [isHovered, setIsHovered] = React.useState<boolean>(false); const [isLiked, setIsLiked] = React.useState<boolean>(false); const [isCelebrated, setIsCelebrated] = React.useState<boolean>(false); return ( <Box sx={{ maxWidth: '60%', minWidth: 'auto' }}> <Stack direction="row" justifyContent="space-between" spacing={2} sx={{ mb: 0.25 }} > <Typography level="body-xs"> {sender === 'You' ? sender : sender.name} </Typography> <Typography level="body-xs">{timestamp}</Typography> </Stack> {attachment ? ( <Sheet variant="outlined" sx={{ px: 1.75, py: 1.25, borderRadius: 'lg', borderTopRightRadius: isSent ? 0 : 'lg', borderTopLeftRadius: isSent ? 'lg' : 0, }} > <Stack direction="row" spacing={1.5} alignItems="center"> <Avatar color="primary" size="lg"> <InsertDriveFileRoundedIcon /> </Avatar> <div> <Typography fontSize="sm">{attachment.fileName}</Typography> <Typography level="body-sm">{attachment.size}</Typography> </div> </Stack> </Sheet> ) : ( <Box sx={{ position: 'relative' }} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > <Sheet color={isSent ? 'primary' : 'neutral'} variant={isSent ? 'solid' : 'soft'} sx={{ p: 1.25, borderRadius: 'lg', borderTopRightRadius: isSent ? 0 : 'lg', borderTopLeftRadius: isSent ? 'lg' : 0, backgroundColor: isSent ? 'var(--joy-palette-primary-solidBg)' : 'background.body', }} > <Typography level="body-sm" sx={{ color: isSent ? 'var(--joy-palette-common-white)' : 'var(--joy-palette-text-primary)', }} > {content} </Typography> </Sheet> {(isHovered || isLiked || isCelebrated) && ( <Stack direction="row" justifyContent={isSent ? 'flex-end' : 'flex-start'} spacing={0.5} sx={{ position: 'absolute', top: '50%', p: 1.5, ...(isSent ? { left: 0, transform: 'translate(-100%, -50%)', } : { right: 0, transform: 'translate(100%, -50%)', }), }} > <IconButton variant={isLiked ? 'soft' : 'plain'} color={isLiked ? 'danger' : 'neutral'} size="sm" onClick={() => setIsLiked((prevState) => !prevState)} > {isLiked ? '❤️' : <FavoriteBorderIcon />} </IconButton> <IconButton variant={isCelebrated ? 'soft' : 'plain'} color={isCelebrated ? 'warning' : 'neutral'} size="sm" onClick={() => setIsCelebrated((prevState) => !prevState)} > {isCelebrated ? '🎉' : <CelebrationOutlinedIcon />} </IconButton> </Stack> )} </Box> )} </Box> ); }
1,883
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/ChatListItem.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import ListDivider from '@mui/joy/ListDivider'; import ListItem from '@mui/joy/ListItem'; import ListItemButton, { ListItemButtonProps } from '@mui/joy/ListItemButton'; import Stack from '@mui/joy/Stack'; import Typography from '@mui/joy/Typography'; import CircleIcon from '@mui/icons-material/Circle'; import AvatarWithStatus from './AvatarWithStatus'; import { ChatProps, MessageProps, UserProps } from '../types'; import { toggleMessagesPane } from '../utils'; type ChatListItemProps = ListItemButtonProps & { id: string; unread?: boolean; sender: UserProps; messages: MessageProps[]; selectedChatId?: string; setSelectedChat: (chat: ChatProps) => void; }; export default function ChatListItem({ id, sender, messages, selectedChatId, setSelectedChat, }: ChatListItemProps) { const selected = selectedChatId === id; return ( <React.Fragment> <ListItem> <ListItemButton onClick={() => { toggleMessagesPane(); setSelectedChat({ id, sender, messages }); }} selected={selected} color="neutral" sx={{ flexDirection: 'column', alignItems: 'initial', gap: 1, }} > <Stack direction="row" spacing={1.5}> <AvatarWithStatus online={sender.online} src={sender.avatar} /> <Box sx={{ flex: 1 }}> <Typography level="title-sm">{sender.name}</Typography> <Typography level="body-sm">{sender.username}</Typography> </Box> <Box sx={{ lineHeight: 1.5, textAlign: 'right', }} > {messages[0].unread && ( <CircleIcon sx={{ fontSize: 12 }} color="primary" /> )} <Typography level="body-xs" display={{ xs: 'none', md: 'block' }} noWrap > 5 mins ago </Typography> </Box> </Stack> <Typography level="body-sm" sx={{ display: '-webkit-box', WebkitLineClamp: '2', WebkitBoxOrient: 'vertical', overflow: 'hidden', textOverflow: 'ellipsis', }} > {messages[0].content} </Typography> </ListItemButton> </ListItem> <ListDivider sx={{ margin: 0 }} /> </React.Fragment> ); }
1,884
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/ChatsPane.tsx
import * as React from 'react'; import Stack from '@mui/joy/Stack'; import Sheet from '@mui/joy/Sheet'; import Typography from '@mui/joy/Typography'; import { Box, Chip, IconButton, Input } from '@mui/joy'; import List from '@mui/joy/List'; import EditNoteRoundedIcon from '@mui/icons-material/EditNoteRounded'; import SearchRoundedIcon from '@mui/icons-material/SearchRounded'; import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; import ChatListItem from './ChatListItem'; import { ChatProps } from '../types'; import { toggleMessagesPane } from '../utils'; type ChatsPaneProps = { chats: ChatProps[]; setSelectedChat: (chat: ChatProps) => void; selectedChatId: string; }; export default function ChatsPane({ chats, setSelectedChat, selectedChatId, }: ChatsPaneProps) { return ( <Sheet sx={{ borderRight: '1px solid', borderColor: 'divider', height: 'calc(100dvh - var(--Header-height))', overflowY: 'auto', }} > <Stack direction="row" spacing={1} alignItems="center" justifyContent="space-between" p={2} pb={1.5} > <Typography fontSize={{ xs: 'md', md: 'lg' }} component="h1" fontWeight="lg" endDecorator={ <Chip variant="soft" color="primary" size="md" slotProps={{ root: { component: 'span' } }} > 4 </Chip> } sx={{ mr: 'auto' }} > Messages </Typography> <IconButton variant="plain" aria-label="edit" color="neutral" size="sm" sx={{ display: { xs: 'none', sm: 'unset' } }} > <EditNoteRoundedIcon /> </IconButton> <IconButton variant="plain" aria-label="edit" color="neutral" size="sm" onClick={() => { toggleMessagesPane(); }} sx={{ display: { sm: 'none' } }} > <CloseRoundedIcon /> </IconButton> </Stack> <Box sx={{ px: 2, pb: 1.5 }}> <Input size="sm" startDecorator={<SearchRoundedIcon />} placeholder="Search" aria-label="Search" /> </Box> <List sx={{ py: 0, '--ListItem-paddingY': '0.75rem', '--ListItem-paddingX': '1rem', }} > {chats.map((chat) => ( <ChatListItem key={chat.id} {...chat} setSelectedChat={setSelectedChat} selectedChatId={selectedChatId} /> ))} </List> </Sheet> ); }
1,885
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/ColorSchemeToggle.tsx
import * as React from 'react'; import { useColorScheme } from '@mui/joy/styles'; import IconButton, { IconButtonProps } from '@mui/joy/IconButton'; import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded'; import LightModeIcon from '@mui/icons-material/LightMode'; export default function ColorSchemeToggle({ onClick, sx, ...props }: IconButtonProps) { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return ( <IconButton size="sm" variant="outlined" color="neutral" {...props} sx={sx} disabled /> ); } return ( <IconButton id="toggle-mode" size="sm" variant="outlined" color="neutral" {...props} onClick={(event) => { if (mode === 'light') { setMode('dark'); } else { setMode('light'); } onClick?.(event); }} sx={[ { '& > *:first-of-type': { display: mode === 'dark' ? 'none' : 'initial', }, '& > *:last-of-type': { display: mode === 'light' ? 'none' : 'initial', }, }, ...(Array.isArray(sx) ? sx : [sx]), ]} > <DarkModeRoundedIcon /> <LightModeIcon /> </IconButton> ); }
1,886
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/Header.tsx
import * as React from 'react'; import GlobalStyles from '@mui/joy/GlobalStyles'; import IconButton from '@mui/joy/IconButton'; import Sheet from '@mui/joy/Sheet'; import MenuRoundedIcon from '@mui/icons-material/MenuRounded'; import { toggleSidebar } from '../utils'; export default function Header() { return ( <Sheet sx={{ display: { xs: 'flex', sm: 'none' }, alignItems: 'center', justifyContent: 'space-between', position: 'fixed', top: 0, width: '100vw', height: 'var(--Header-height)', zIndex: 9995, p: 2, gap: 1, borderBottom: '1px solid', borderColor: 'background.level1', boxShadow: 'sm', }} > <GlobalStyles styles={(theme) => ({ ':root': { '--Header-height': '52px', [theme.breakpoints.up('lg')]: { '--Header-height': '0px', }, }, })} /> <IconButton onClick={() => toggleSidebar()} variant="outlined" color="neutral" size="sm" > <MenuRoundedIcon /> </IconButton> </Sheet> ); }
1,887
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/MessageInput.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import FormControl from '@mui/joy/FormControl'; import Textarea from '@mui/joy/Textarea'; import { IconButton, Stack } from '@mui/joy'; import FormatBoldRoundedIcon from '@mui/icons-material/FormatBoldRounded'; import FormatItalicRoundedIcon from '@mui/icons-material/FormatItalicRounded'; import StrikethroughSRoundedIcon from '@mui/icons-material/StrikethroughSRounded'; import FormatListBulletedRoundedIcon from '@mui/icons-material/FormatListBulletedRounded'; import SendRoundedIcon from '@mui/icons-material/SendRounded'; export type MessageInputProps = { textAreaValue: string; setTextAreaValue: (value: string) => void; onSubmit: () => void; }; export default function MessageInput({ textAreaValue, setTextAreaValue, onSubmit, }: MessageInputProps) { const textAreaRef = React.useRef<HTMLDivElement>(null); const handleClick = () => { if (textAreaValue.trim() !== '') { onSubmit(); setTextAreaValue(''); } }; return ( <Box sx={{ px: 2, pb: 3 }}> <FormControl> <Textarea placeholder="Type something here…" aria-label="Message" ref={textAreaRef} onChange={(e) => { setTextAreaValue(e.target.value); }} value={textAreaValue} minRows={3} maxRows={10} endDecorator={ <Stack direction="row" justifyContent="space-between" alignItems="center" flexGrow={1} sx={{ py: 1, pr: 1, borderTop: '1px solid', borderColor: 'divider', }} > <div> <IconButton size="sm" variant="plain" color="neutral"> <FormatBoldRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <FormatItalicRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <StrikethroughSRoundedIcon /> </IconButton> <IconButton size="sm" variant="plain" color="neutral"> <FormatListBulletedRoundedIcon /> </IconButton> </div> <Button size="sm" color="primary" sx={{ alignSelf: 'center', borderRadius: 'sm' }} endDecorator={<SendRoundedIcon />} onClick={handleClick} > Send </Button> </Stack> } onKeyDown={(event) => { if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { handleClick(); } }} sx={{ '& textarea:first-of-type': { minHeight: 72, }, }} /> </FormControl> </Box> ); }
1,888
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/MessagesPane.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Sheet from '@mui/joy/Sheet'; import Stack from '@mui/joy/Stack'; import AvatarWithStatus from './AvatarWithStatus'; import ChatBubble from './ChatBubble'; import MessageInput from './MessageInput'; import MessagesPaneHeader from './MessagesPaneHeader'; import { ChatProps, MessageProps } from '../types'; type MessagesPaneProps = { chat: ChatProps; }; export default function MessagesPane({ chat }: MessagesPaneProps) { const [chatMessages, setChatMessages] = React.useState(chat.messages); const [textAreaValue, setTextAreaValue] = React.useState(''); React.useEffect(() => { setChatMessages(chat.messages); }, [chat.messages]); return ( <Sheet sx={{ height: { xs: 'calc(100dvh - var(--Header-height))', lg: '100dvh' }, display: 'flex', flexDirection: 'column', backgroundColor: 'background.level1', }} > <MessagesPaneHeader sender={chat.sender} /> <Box sx={{ display: 'flex', flex: 1, minHeight: 0, px: 2, py: 3, overflowY: 'scroll', flexDirection: 'column-reverse', }} > <Stack spacing={2} justifyContent="flex-end"> {chatMessages.map((message: MessageProps, index: number) => { const isYou = message.sender === 'You'; return ( <Stack key={index} direction="row" spacing={2} flexDirection={isYou ? 'row-reverse' : 'row'} > {message.sender !== 'You' && ( <AvatarWithStatus online={message.sender.online} src={message.sender.avatar} /> )} <ChatBubble variant={isYou ? 'sent' : 'received'} {...message} /> </Stack> ); })} </Stack> </Box> <MessageInput textAreaValue={textAreaValue} setTextAreaValue={setTextAreaValue} onSubmit={() => { const newId = chatMessages.length + 1; const newIdString = newId.toString(); setChatMessages([ ...chatMessages, { id: newIdString, sender: 'You', content: textAreaValue, timestamp: 'Just now', }, ]); }} /> </Sheet> ); }
1,889
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/MessagesPaneHeader.tsx
import * as React from 'react'; import Avatar from '@mui/joy/Avatar'; import Button from '@mui/joy/Button'; import Chip from '@mui/joy/Chip'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import Typography from '@mui/joy/Typography'; import CircleIcon from '@mui/icons-material/Circle'; import ArrowBackIosNewRoundedIcon from '@mui/icons-material/ArrowBackIosNewRounded'; import PhoneInTalkRoundedIcon from '@mui/icons-material/PhoneInTalkRounded'; import MoreVertRoundedIcon from '@mui/icons-material/MoreVertRounded'; import { UserProps } from '../types'; import { toggleMessagesPane } from '../utils'; type MessagesPaneHeaderProps = { sender: UserProps; }; export default function MessagesPaneHeader({ sender }: MessagesPaneHeaderProps) { return ( <Stack direction="row" justifyContent="space-between" sx={{ borderBottom: '1px solid', borderColor: 'divider', backgroundColor: 'background.body', }} py={{ xs: 2, md: 2 }} px={{ xs: 1, md: 2 }} > <Stack direction="row" spacing={{ xs: 1, md: 2 }} alignItems="center"> <IconButton variant="plain" color="neutral" size="sm" sx={{ display: { xs: 'inline-flex', sm: 'none' }, }} onClick={() => toggleMessagesPane()} > <ArrowBackIosNewRoundedIcon /> </IconButton> <Avatar size="lg" src={sender.avatar} /> <div> <Typography fontWeight="lg" fontSize="lg" component="h2" noWrap endDecorator={ sender.online ? ( <Chip variant="outlined" size="sm" color="neutral" sx={{ borderRadius: 'sm', }} startDecorator={ <CircleIcon sx={{ fontSize: 8 }} color="success" /> } slotProps={{ root: { component: 'span' } }} > Online </Chip> ) : undefined } > {sender.name} </Typography> <Typography level="body-sm">{sender.username}</Typography> </div> </Stack> <Stack spacing={1} direction="row" alignItems="center"> <Button startDecorator={<PhoneInTalkRoundedIcon />} color="neutral" variant="outlined" size="sm" sx={{ display: { xs: 'none', md: 'inline-flex' }, }} > Call </Button> <Button color="neutral" variant="outlined" size="sm" sx={{ display: { xs: 'none', md: 'inline-flex' }, }} > View profile </Button> <IconButton size="sm" variant="plain" color="neutral"> <MoreVertRoundedIcon /> </IconButton> </Stack> </Stack> ); }
1,890
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/MuiLogo.tsx
import * as React from 'react'; import AspectRatio, { AspectRatioProps } from '@mui/joy/AspectRatio'; export default function MuiLogo({ sx, ...props }: AspectRatioProps) { return ( <AspectRatio ratio="1" variant="plain" {...props} sx={[ { width: 36, borderRadius: 'sm', }, ...(Array.isArray(sx) ? sx : [sx]), ]} > <div> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="20" viewBox="0 0 36 32" fill="none" > <path d="M30.343 21.976a1 1 0 00.502-.864l.018-5.787a1 1 0 01.502-.864l3.137-1.802a1 1 0 011.498.867v10.521a1 1 0 01-.502.867l-11.839 6.8a1 1 0 01-.994.001l-9.291-5.314a1 1 0 01-.504-.868v-5.305c0-.006.007-.01.013-.007.005.003.012 0 .012-.007v-.006c0-.004.002-.008.006-.01l7.652-4.396c.007-.004.004-.015-.004-.015a.008.008 0 01-.008-.008l.015-5.201a1 1 0 00-1.5-.87l-5.687 3.277a1 1 0 01-.998 0L6.666 9.7a1 1 0 00-1.499.866v9.4a1 1 0 01-1.496.869l-3.166-1.81a1 1 0 01-.504-.87l.028-16.43A1 1 0 011.527.86l10.845 6.229a1 1 0 00.996 0L24.21.86a1 1 0 011.498.868v16.434a1 1 0 01-.501.867l-5.678 3.27a1 1 0 00.004 1.735l3.132 1.783a1 1 0 00.993-.002l6.685-3.839zM31 7.234a1 1 0 001.514.857l3-1.8A1 1 0 0036 5.434V1.766A1 1 0 0034.486.91l-3 1.8a1 1 0 00-.486.857v3.668z" fill="#007FFF" /> </svg> </div> </AspectRatio> ); }
1,891
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/MyMessages.tsx
import * as React from 'react'; import Sheet from '@mui/joy/Sheet'; import MessagesPane from './MessagesPane'; import ChatsPane from './ChatsPane'; import { ChatProps } from '../types'; import { chats } from '../data'; export default function MyProfile() { const [selectedChat, setSelectedChat] = React.useState<ChatProps>(chats[0]); return ( <Sheet sx={{ flex: 1, width: '100%', mx: 'auto', pt: { xs: 'var(--Header-height)', sm: 0 }, display: 'grid', gridTemplateColumns: { xs: '1fr', sm: 'minmax(min-content, min(30%, 400px)) 1fr', }, }} > <Sheet sx={{ position: { xs: 'fixed', sm: 'sticky', }, transform: { xs: 'translateX(calc(100% * (var(--MessagesPane-slideIn, 0) - 1)))', sm: 'none', }, transition: 'transform 0.4s, width 0.4s', zIndex: 100, width: '100%', top: 52, }} > <ChatsPane chats={chats} selectedChatId={selectedChat.id} setSelectedChat={setSelectedChat} /> </Sheet> <MessagesPane chat={selectedChat} /> </Sheet> ); }
1,892
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/messages/components/Sidebar.tsx
import * as React from 'react'; import GlobalStyles from '@mui/joy/GlobalStyles'; import Avatar from '@mui/joy/Avatar'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Card from '@mui/joy/Card'; import Chip from '@mui/joy/Chip'; import Divider from '@mui/joy/Divider'; import IconButton from '@mui/joy/IconButton'; import Input from '@mui/joy/Input'; import LinearProgress from '@mui/joy/LinearProgress'; import List from '@mui/joy/List'; import ListItem from '@mui/joy/ListItem'; import ListItemButton, { listItemButtonClasses } from '@mui/joy/ListItemButton'; import ListItemContent from '@mui/joy/ListItemContent'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import Stack from '@mui/joy/Stack'; import SearchRoundedIcon from '@mui/icons-material/SearchRounded'; import HomeRoundedIcon from '@mui/icons-material/HomeRounded'; import DashboardRoundedIcon from '@mui/icons-material/DashboardRounded'; import ShoppingCartRoundedIcon from '@mui/icons-material/ShoppingCartRounded'; import AssignmentRoundedIcon from '@mui/icons-material/AssignmentRounded'; import QuestionAnswerRoundedIcon from '@mui/icons-material/QuestionAnswerRounded'; import GroupRoundedIcon from '@mui/icons-material/GroupRounded'; import SupportRoundedIcon from '@mui/icons-material/SupportRounded'; import SettingsRoundedIcon from '@mui/icons-material/SettingsRounded'; import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; import LogoutRoundedIcon from '@mui/icons-material/LogoutRounded'; import BrightnessAutoRoundedIcon from '@mui/icons-material/BrightnessAutoRounded'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import ColorSchemeToggle from './ColorSchemeToggle'; import { closeSidebar } from '../utils'; function Toggler({ defaultExpanded = false, renderToggle, children, }: { defaultExpanded?: boolean; children: React.ReactNode; renderToggle: (params: { open: boolean; setOpen: React.Dispatch<React.SetStateAction<boolean>>; }) => React.ReactNode; }) { const [open, setOpen] = React.useState(defaultExpanded); return ( <React.Fragment> {renderToggle({ open, setOpen })} <Box sx={{ display: 'grid', gridTemplateRows: open ? '1fr' : '0fr', transition: '0.2s ease', '& > *': { overflow: 'hidden', }, }} > {children} </Box> </React.Fragment> ); } export default function Sidebar() { return ( <Sheet className="Sidebar" sx={{ position: { xs: 'fixed', md: 'sticky', }, transform: { xs: 'translateX(calc(100% * (var(--SideNavigation-slideIn, 0) - 1)))', md: 'none', }, transition: 'transform 0.4s, width 0.4s', zIndex: 10000, height: '100dvh', width: 'var(--Sidebar-width)', top: 0, p: 2, flexShrink: 0, display: 'flex', flexDirection: 'column', gap: 2, borderRight: '1px solid', borderColor: 'divider', }} > <GlobalStyles styles={(theme) => ({ ':root': { '--Sidebar-width': '220px', [theme.breakpoints.up('lg')]: { '--Sidebar-width': '240px', }, }, })} /> <Box className="Sidebar-overlay" sx={{ position: 'fixed', zIndex: 9998, top: 0, left: 0, width: '100vw', height: '100vh', opacity: 'var(--SideNavigation-slideIn)', backgroundColor: 'var(--joy-palette-background-backdrop)', transition: 'opacity 0.4s', transform: { xs: 'translateX(calc(100% * (var(--SideNavigation-slideIn, 0) - 1) + var(--SideNavigation-slideIn, 0) * var(--Sidebar-width, 0px)))', lg: 'translateX(-100%)', }, }} onClick={() => closeSidebar()} /> <Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}> <IconButton variant="soft" color="primary" size="sm"> <BrightnessAutoRoundedIcon /> </IconButton> <Typography level="title-lg">Acme Co.</Typography> <ColorSchemeToggle sx={{ ml: 'auto' }} /> </Box> <Input size="sm" startDecorator={<SearchRoundedIcon />} placeholder="Search" /> <Box sx={{ minHeight: 0, overflow: 'hidden auto', flexGrow: 1, display: 'flex', flexDirection: 'column', [`& .${listItemButtonClasses.root}`]: { gap: 1.5, }, }} > <List size="sm" sx={{ gap: 1, '--List-nestedInsetStart': '30px', '--ListItem-radius': (theme) => theme.vars.radius.sm, }} > <ListItem> <ListItemButton> <HomeRoundedIcon /> <ListItemContent> <Typography level="title-sm">Home</Typography> </ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton> <DashboardRoundedIcon /> <ListItemContent> <Typography level="title-sm">Dashboard</Typography> </ListItemContent> </ListItemButton> </ListItem> <ListItem> <ListItemButton role="menuitem" component="a" href="/joy-ui/getting-started/templates/order-dashboard/" > <ShoppingCartRoundedIcon /> <ListItemContent> <Typography level="title-sm">Orders</Typography> </ListItemContent> </ListItemButton> </ListItem> <ListItem nested> <Toggler renderToggle={({ open, setOpen }) => ( <ListItemButton onClick={() => setOpen(!open)}> <AssignmentRoundedIcon /> <ListItemContent> <Typography level="title-sm">Tasks</Typography> </ListItemContent> <KeyboardArrowDownIcon sx={{ transform: open ? 'rotate(180deg)' : 'none' }} /> </ListItemButton> )} > <List sx={{ gap: 0.5 }}> <ListItem sx={{ mt: 0.5 }}> <ListItemButton>All tasks</ListItemButton> </ListItem> <ListItem> <ListItemButton>Backlog</ListItemButton> </ListItem> <ListItem> <ListItemButton>In progress</ListItemButton> </ListItem> <ListItem> <ListItemButton>Done</ListItemButton> </ListItem> </List> </Toggler> </ListItem> <ListItem> <ListItemButton selected> <QuestionAnswerRoundedIcon /> <ListItemContent> <Typography level="title-sm">Messages</Typography> </ListItemContent> <Chip size="sm" color="primary" variant="solid"> 4 </Chip> </ListItemButton> </ListItem> <ListItem nested> <Toggler renderToggle={({ open, setOpen }) => ( <ListItemButton onClick={() => setOpen(!open)}> <GroupRoundedIcon /> <ListItemContent> <Typography level="title-sm">Users</Typography> </ListItemContent> <KeyboardArrowDownIcon sx={{ transform: open ? 'rotate(180deg)' : 'none' }} /> </ListItemButton> )} > <List sx={{ gap: 0.5 }}> <ListItem sx={{ mt: 0.5 }}> <ListItemButton role="menuitem" component="a" href="/joy-ui/getting-started/templates/profile-dashboard/" > My profile </ListItemButton> </ListItem> <ListItem> <ListItemButton>Create a new user</ListItemButton> </ListItem> <ListItem> <ListItemButton>Roles & permission</ListItemButton> </ListItem> </List> </Toggler> </ListItem> </List> <List size="sm" sx={{ mt: 'auto', flexGrow: 0, '--ListItem-radius': (theme) => theme.vars.radius.sm, '--List-gap': '8px', mb: 2, }} > <ListItem> <ListItemButton> <SupportRoundedIcon /> Support </ListItemButton> </ListItem> <ListItem> <ListItemButton> <SettingsRoundedIcon /> Settings </ListItemButton> </ListItem> </List> <Card invertedColors variant="soft" color="warning" size="sm" sx={{ boxShadow: 'none' }} > <Stack direction="row" justifyContent="space-between" alignItems="center"> <Typography level="title-sm">Used space</Typography> <IconButton size="sm"> <CloseRoundedIcon /> </IconButton> </Stack> <Typography level="body-xs"> Your team has used 80% of your available space. Need more? </Typography> <LinearProgress variant="outlined" value={80} determinate sx={{ my: 1 }} /> <Button size="sm" variant="solid"> Upgrade plan </Button> </Card> </Box> <Divider /> <Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}> <Avatar variant="outlined" size="sm" src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?auto=format&fit=crop&w=286" /> <Box sx={{ minWidth: 0, flex: 1 }}> <Typography level="title-sm">Siriwat K.</Typography> <Typography level="body-xs">[email protected]</Typography> </Box> <IconButton size="sm" variant="plain" color="neutral"> <LogoutRoundedIcon /> </IconButton> </Box> </Sheet> ); }
1,893
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/App.tsx
import * as React from 'react'; import { CssVarsProvider } from '@mui/joy/styles'; import CssBaseline from '@mui/joy/CssBaseline'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Breadcrumbs from '@mui/joy/Breadcrumbs'; import Link from '@mui/joy/Link'; import Typography from '@mui/joy/Typography'; // icons import HomeRoundedIcon from '@mui/icons-material/HomeRounded'; import ChevronRightRoundedIcon from '@mui/icons-material/ChevronRightRounded'; import DownloadRoundedIcon from '@mui/icons-material/DownloadRounded'; import useScript from './useScript'; import Sidebar from './components/Sidebar'; import OrderTable from './components/OrderTable'; import OrderList from './components/OrderList'; import Header from './components/Header'; const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; export default function JoyOrderDashboardTemplate() { const status = useScript(`https://unpkg.com/feather-icons`); useEnhancedEffect(() => { // Feather icon setup: https://github.com/feathericons/feather#4-replace // @ts-ignore if (typeof feather !== 'undefined') { // @ts-ignore feather.replace(); } }, [status]); return ( <CssVarsProvider disableTransitionOnChange> <CssBaseline /> <Box sx={{ display: 'flex', minHeight: '100dvh' }}> <Header /> <Sidebar /> <Box component="main" className="MainContent" sx={{ px: { xs: 2, md: 6, }, pt: { xs: 'calc(12px + var(--Header-height))', sm: 'calc(12px + var(--Header-height))', md: 3, }, pb: { xs: 2, sm: 2, md: 3, }, flex: 1, display: 'flex', flexDirection: 'column', minWidth: 0, height: '100dvh', gap: 1, }} > <Box sx={{ display: 'flex', alignItems: 'center' }}> <Breadcrumbs size="sm" aria-label="breadcrumbs" separator={<ChevronRightRoundedIcon fontSize="sm" />} sx={{ pl: 0 }} > <Link underline="none" color="neutral" href="#some-link" aria-label="Home" > <HomeRoundedIcon /> </Link> <Link underline="hover" color="neutral" href="#some-link" fontSize={12} fontWeight={500} > Dashboard </Link> <Typography color="primary" fontWeight={500} fontSize={12}> Orders </Typography> </Breadcrumbs> </Box> <Box sx={{ display: 'flex', my: 1, gap: 1, flexDirection: { xs: 'column', sm: 'row' }, alignItems: { xs: 'start', sm: 'center' }, flexWrap: 'wrap', justifyContent: 'space-between', }} > <Typography level="h2">Orders</Typography> <Button color="primary" startDecorator={<DownloadRoundedIcon />} size="sm" > Download PDF </Button> </Box> <OrderTable /> <OrderList /> </Box> </Box> </CssVarsProvider> ); }
1,894
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/useScript.ts
import * as React from 'react'; export type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'; // Cached script statuses const cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {}; /** * Simplified version of https://usehooks-ts.com/react-hook/use-script */ function getScriptNode(src: string) { const node: HTMLScriptElement | null = document.querySelector(`script[src="${src}"]`); const status = node?.getAttribute('data-status') as UseScriptStatus | undefined; return { node, status, }; } function useScript(src: string): UseScriptStatus { const [status, setStatus] = React.useState<UseScriptStatus>(() => { if (typeof window === 'undefined') { // SSR Handling - always return 'loading' return 'loading'; } return cachedScriptStatuses[src] ?? 'loading'; }); React.useEffect(() => { const cachedScriptStatus = cachedScriptStatuses[src]; if (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') { // If the script is already cached, set its status immediately setStatus(cachedScriptStatus); return; } // Fetch existing script element by src // It may have been added by another instance of this hook const script = getScriptNode(src); let scriptNode = script.node; if (!scriptNode) { // Create script element and add it to document body scriptNode = document.createElement('script'); scriptNode.src = src; scriptNode.async = true; scriptNode.setAttribute('data-status', 'loading'); document.body.appendChild(scriptNode); // Store status in attribute on script // This can be read by other instances of this hook const setAttributeFromEvent = (event: Event) => { const scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error'; scriptNode?.setAttribute('data-status', scriptStatus); }; scriptNode.addEventListener('load', setAttributeFromEvent); scriptNode.addEventListener('error', setAttributeFromEvent); } else { // Grab existing script status from attribute and set to state. setStatus(script.status ?? cachedScriptStatus ?? 'loading'); } // Script event handler to update status in state // Note: Even if the script already exists we still need to add // event handlers to update the state for *this* hook instance. const setStateFromEvent = (event: Event) => { const newStatus = event.type === 'load' ? 'ready' : 'error'; setStatus(newStatus); cachedScriptStatuses[src] = newStatus; }; // Add event listeners scriptNode.addEventListener('load', setStateFromEvent); scriptNode.addEventListener('error', setStateFromEvent); // Remove event listeners on cleanup // eslint-disable-next-line consistent-return return () => { if (scriptNode) { scriptNode.removeEventListener('load', setStateFromEvent); scriptNode.removeEventListener('error', setStateFromEvent); } if (scriptNode) { try { scriptNode.remove(); } catch (error) { // ignore error } } }; }, [src]); return status; } export default useScript;
1,895
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/utils.ts
export const openSidebar = () => { if (typeof document !== 'undefined') { document.body.style.overflow = 'hidden'; document.documentElement.style.setProperty('--SideNavigation-slideIn', '1'); } }; export const closeSidebar = () => { if (typeof document !== 'undefined') { document.documentElement.style.removeProperty('--SideNavigation-slideIn'); document.body.style.removeProperty('overflow'); } }; export const toggleSidebar = () => { if (typeof window !== 'undefined' && typeof document !== 'undefined') { const slideIn = window .getComputedStyle(document.documentElement) .getPropertyValue('--SideNavigation-slideIn'); if (slideIn) { closeSidebar(); } else { openSidebar(); } } };
1,896
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/components/ColorSchemeToggle.tsx
import * as React from 'react'; import { useColorScheme } from '@mui/joy/styles'; import IconButton, { IconButtonProps } from '@mui/joy/IconButton'; import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded'; import LightModeIcon from '@mui/icons-material/LightMode'; export default function ColorSchemeToggle({ onClick, sx, ...props }: IconButtonProps) { const { mode, setMode } = useColorScheme(); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); if (!mounted) { return ( <IconButton size="sm" variant="outlined" color="neutral" {...props} sx={sx} disabled /> ); } return ( <IconButton id="toggle-mode" size="sm" variant="outlined" color="neutral" {...props} onClick={(event) => { if (mode === 'light') { setMode('dark'); } else { setMode('light'); } onClick?.(event); }} sx={[ { '& > *:first-child': { display: mode === 'dark' ? 'none' : 'initial', }, '& > *:last-child': { display: mode === 'light' ? 'none' : 'initial', }, }, ...(Array.isArray(sx) ? sx : [sx]), ]} > <DarkModeRoundedIcon /> <LightModeIcon /> </IconButton> ); }
1,897
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/components/Header.tsx
import * as React from 'react'; import GlobalStyles from '@mui/joy/GlobalStyles'; import Sheet from '@mui/joy/Sheet'; import IconButton from '@mui/joy/IconButton'; import MenuIcon from '@mui/icons-material/Menu'; import { toggleSidebar } from '../utils'; export default function Header() { return ( <Sheet sx={{ display: { xs: 'flex', md: 'none' }, alignItems: 'center', justifyContent: 'space-between', position: 'fixed', top: 0, width: '100vw', height: 'var(--Header-height)', zIndex: 9995, p: 2, gap: 1, borderBottom: '1px solid', borderColor: 'background.level1', boxShadow: 'sm', }} > <GlobalStyles styles={(theme) => ({ ':root': { '--Header-height': '52px', [theme.breakpoints.up('md')]: { '--Header-height': '0px', }, }, })} /> <IconButton onClick={() => toggleSidebar()} variant="outlined" color="neutral" size="sm" > <MenuIcon /> </IconButton> </Sheet> ); }
1,898
0
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard
petrpan-code/mui/material-ui/docs/data/joy/getting-started/templates/order-dashboard/components/MuiLogo.tsx
import * as React from 'react'; import AspectRatio, { AspectRatioProps } from '@mui/joy/AspectRatio'; export default function MuiLogo({ sx, ...props }: AspectRatioProps) { return ( <AspectRatio ratio="1" variant="plain" {...props} sx={[ { width: 36, }, ...(Array.isArray(sx) ? sx : [sx]), ]} > <div> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="20" viewBox="0 0 36 32" fill="none" > <path d="M30.343 21.976a1 1 0 00.502-.864l.018-5.787a1 1 0 01.502-.864l3.137-1.802a1 1 0 011.498.867v10.521a1 1 0 01-.502.867l-11.839 6.8a1 1 0 01-.994.001l-9.291-5.314a1 1 0 01-.504-.868v-5.305c0-.006.007-.01.013-.007.005.003.012 0 .012-.007v-.006c0-.004.002-.008.006-.01l7.652-4.396c.007-.004.004-.015-.004-.015a.008.008 0 01-.008-.008l.015-5.201a1 1 0 00-1.5-.87l-5.687 3.277a1 1 0 01-.998 0L6.666 9.7a1 1 0 00-1.499.866v9.4a1 1 0 01-1.496.869l-3.166-1.81a1 1 0 01-.504-.87l.028-16.43A1 1 0 011.527.86l10.845 6.229a1 1 0 00.996 0L24.21.86a1 1 0 011.498.868v16.434a1 1 0 01-.501.867l-5.678 3.27a1 1 0 00.004 1.735l3.132 1.783a1 1 0 00.993-.002l6.685-3.839zM31 7.234a1 1 0 001.514.857l3-1.8A1 1 0 0036 5.434V1.766A1 1 0 0034.486.91l-3 1.8a1 1 0 00-.486.857v3.668z" fill="#007FFF" /> </svg> </div> </AspectRatio> ); }
1,899