Skip to content

Commit

Permalink
[docs] Add Joy default theme viewer (#35554)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored Jan 24, 2023
1 parent eb8ca56 commit 5717d16
Show file tree
Hide file tree
Showing 37 changed files with 2,052 additions and 1,716 deletions.
2 changes: 1 addition & 1 deletion docs/data/joy/customization/approaches/approaches.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Here are some examples that reproduce popular designs (only the light mode, thou

### Customizing theme tokens

Theme tokens refer to both [_low-level_ and _global variant_ design tokens](/joy-ui/customization/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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Default theme viewer

<p class="description">Here's what 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.
:::

## Explore

Explore the default theme:

{{"demo": "JoyDefaultTheme.js", "hideToolbar": true, "bg": "inline"}}

To create your own theme, starts with customizing the [theme colors](/joy-ui/customization/theme-colors/).
100 changes: 0 additions & 100 deletions docs/data/joy/customization/default-theme/default-theme-pt.md

This file was deleted.

100 changes: 0 additions & 100 deletions docs/data/joy/customization/default-theme/default-theme-zh.md

This file was deleted.

101 changes: 0 additions & 101 deletions docs/data/joy/customization/default-theme/default-theme.md

This file was deleted.

Loading

0 comments on commit 5717d16

Please sign in to comment.