Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-infra] Improve demo container and related components design #41827

Merged
merged 7 commits into from Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/pages/experiments/docs/demos.md
@@ -1,19 +1,30 @@
# Demos

<p class="description">Demos</p>
<p class="description">The different variants of demo containers we have in the docs.</p>

Check warning on line 3 in docs/pages/experiments/docs/demos.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.We] Try to avoid using first-person plural like 'we'. Raw Output: {"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/pages/experiments/docs/demos.md", "range": {"start": {"line": 3, "column": 66}}}, "severity": "WARNING"}

## Standard demo

"Standard" refers to when no background is explicitly defined.
So, it renders the "outlined" background variant.

{{"demo": "DemoInDocs.js"}}

## "bg": "inline" demo
## "bg": "outlined"
danilo-leal marked this conversation as resolved.
Show resolved Hide resolved

{{"demo": "DemoInDocs.js", "bg": "outlined"}}

## "bg": "inline"

{{"demo": "DemoInDocs.js", "bg": "inline"}}

## "bg": true

{{"demo": "DemoInDocs.js", "bg": true}}

## "bg": gradient

{{"demo": "DemoInDocs.js", "bg": "gradient"}}

## "hideToolbar": true

{{"demo": "DemoInDocs.js", "hideToolbar": true}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppNavDrawerItem.js
Expand Up @@ -144,7 +144,7 @@ const Item = styled(
theme.applyDarkStyles({
...color,
'&::before': {
background: alpha(theme.palette.primaryDark[700], 0.6),
background: alpha(theme.palette.primaryDark[500], 0.3),
},
'&.app-drawer-active': {
color: (theme.vars || theme).palette.primary[300],
Expand Down
32 changes: 18 additions & 14 deletions docs/src/modules/components/Demo.js
Expand Up @@ -210,6 +210,11 @@ const DemoRootMaterial = styled('div', {
...(bg === 'inline' && {
padding: theme.spacing(0),
}),
...(bg === 'gradient' && {
padding: theme.spacing(12, 8),
borderLeftWidth: 1,
borderRightWidth: 1,
}),
},
/* Isolate the demo with an outline. */
...(bg === 'outlined' && {
Expand All @@ -218,7 +223,6 @@ const DemoRootMaterial = styled('div', {
border: `1px solid ${(theme.vars || theme).palette.divider}`,
borderLeftWidth: 0,
borderRightWidth: 0,
borderBottomWidth: 0,
...theme.applyDarkStyles({
backgroundColor: alpha(theme.palette.primaryDark[700], 0.1),
}),
Expand All @@ -232,28 +236,25 @@ const DemoRootMaterial = styled('div', {
/* Prepare the background to display an inner elevation. */
...(bg === true && {
padding: theme.spacing(3),
backgroundColor: alpha(theme.palette.grey[50], 0.6),
backgroundColor: alpha((theme.vars || theme).palette.grey[50], 0.5),
border: `1px solid ${(theme.vars || theme).palette.divider}`,
...theme.applyDarkStyles({
backgroundColor: alpha(theme.palette.primaryDark[700], 0.15),
backgroundColor: alpha((theme.vars || theme).palette.primaryDark[700], 0.4),
}),
}),
/* Mostly meant for introduction demos. */
...(bg === 'gradient' && {
overflow: 'auto',
padding: theme.spacing(20, 8),
border: `1px solid`,
borderColor: (theme.vars || theme).palette.divider,
padding: theme.spacing(4, 2),
border: `1px solid ${(theme.vars || theme).palette.divider}`,
borderLeftWidth: 0,
borderRightWidth: 0,
backgroundClip: 'padding-box',
backgroundColor: alpha(theme.palette.primary[50], 0.5),
backgroundImage: `radial-gradient(140% 108% at 50% 8%, transparent 40%, ${
theme.palette.primary[50]
} 70%, ${alpha(theme.palette.primary[100], 0.2)} 100%)`,
backgroundColor: alpha(theme.palette.primary[50], 0.2),
backgroundImage: `radial-gradient(120% 140% at 50% 10%, transparent 40%, ${alpha((theme.vars || theme).palette.primary[100], 0.2)} 70%)`,
...theme.applyDarkStyles({
borderColor: (theme.vars || theme).palette.divider,
backgroundColor: '#00111A',
backgroundImage:
'radial-gradient(140% 120% at 50% 8%, transparent 40%, #051729 70%, #041425 100%)',
backgroundColor: (theme.vars || theme).palette.primaryDark[900],
backgroundImage: `radial-gradient(120% 140% at 50% 10%, transparent 30%, ${alpha((theme.vars || theme).palette.primary[900], 0.3)} 80%)`,
}),
}),
}));
Expand Down Expand Up @@ -332,6 +333,9 @@ const DemoCodeViewer = styled(HighlightedCode)(() => ({
maxWidth: 'initial',
borderRadius: 0,
},
'& .MuiCode-copy': {
display: 'none',
},
}));

const AnchorLink = styled('div')({
Expand Down
15 changes: 6 additions & 9 deletions docs/src/modules/components/DemoEditor.tsx
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import SimpleCodeEditor from 'react-simple-code-editor';
import Box from '@mui/material/Box';
import { NoSsr } from '@mui/base/NoSsr';
import { styled, useTheme } from '@mui/material/styles';
import { styled, alpha, useTheme } from '@mui/material/styles';
import prism from '@mui/internal-markdown/prism';
import MarkdownElement from 'docs/src/modules/components/MarkdownElement';
import CodeCopyButton from 'docs/src/modules/components/CodeCopyButton';
Expand All @@ -20,10 +20,10 @@ const StyledMarkdownElement = styled(MarkdownElement)(({ theme }) => [
border: `1px solid ${(theme.vars || theme).palette.divider}`,
colorScheme: 'dark',
'&:hover': {
boxShadow: `0 0 0 3px ${(theme.vars || theme).palette.primary.light}`,
boxShadow: `0 0 0 3px ${alpha((theme.vars || theme).palette.primary[500], 0.5)}`,
},
'&:focus-within': {
boxShadow: `0 0 0 2px ${(theme.vars || theme).palette.primary.main}`,
boxShadow: `0 0 0 2px ${alpha((theme.vars || theme).palette.primary[500], 0.5)}`,
},
[theme.breakpoints.up('sm')]: {
borderRadius: '0 0 12px 12px',
Expand All @@ -35,16 +35,13 @@ const StyledMarkdownElement = styled(MarkdownElement)(({ theme }) => [
maxWidth: 'initial',
maxHeight: 'initial',
},
'& .MuiCode-copy': {
display: 'none',
},
},
theme.applyDarkStyles({
'& .scrollContainer': {
borderColor: (theme.vars || theme).palette.divider,
'&:hover': {
boxShadow: `0 0 0 3px ${(theme.vars || theme).palette.primaryDark[300]}`,
},
'&:focus-within': {
boxShadow: `0 0 0 2px ${(theme.vars || theme).palette.primaryDark[400]}`,
},
},
}),
]) as any;
Expand Down
5 changes: 3 additions & 2 deletions docs/src/modules/components/DemoToolbarRoot.ts
Expand Up @@ -11,11 +11,12 @@ const DemoToolbarRoot = styled('div', {
{
display: 'none',
[theme.breakpoints.up('sm')]: {
top: 0,
display: 'block',
border: `1px solid ${(theme.vars || theme).palette.divider}`,
marginTop: demoOptions.bg === 'inline' ? theme.spacing(1) : -1,
top: 0,
padding: theme.spacing(0.5, 1),
border: `1px solid ${(theme.vars || theme).palette.divider}`,
borderTopWidth: demoOptions.bg === 'inline' ? 1 : 0,
backgroundColor: alpha(theme.palette.grey[50], 0.2),
borderRadius: openDemoSource ? 0 : '0 0 12px 12px',
transition: theme.transitions.create('border-radius'),
Expand Down
69 changes: 32 additions & 37 deletions docs/src/modules/components/MaterialUIExampleCollection.js
Expand Up @@ -11,85 +11,85 @@ import CloudRoundedIcon from '@mui/icons-material/CloudRounded';
const examples = [
{
name: 'Next.js App Router',
label: 'View JS example',
tsLabel: 'View TS example',
label: 'View JavaScript',
tsLabel: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-nextjs',
tsLink: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-nextjs-ts',
src: '/static/images/examples/next.svg',
},
{
name: 'Vite.js',
label: 'View JS example',
tsLabel: 'View TS example',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-vite',
tsLink: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-vite-ts',
src: '/static/images/examples/vite.svg',
},
{
name: 'Next.js Pages Router',
label: 'View JS example',
tsLabel: 'View TS example',
label: 'View JavaScript',
tsLabel: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-nextjs-pages-router',
tsLink:
'https://github.com/mui/material-ui/tree/next/examples/material-ui-nextjs-pages-router-ts',
src: '/static/images/examples/next.svg',
},
{
name: 'Vite.js',
label: 'View JavaScript',
tsLabel: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-vite',
tsLink: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-vite-ts',
src: '/static/images/examples/vite.svg',
},
{
name: 'Remix',
label: 'View TS example',
label: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-remix-ts',
src: '/static/images/examples/remix.svg',
},
{
name: 'Tailwind CSS + CRA',
label: 'View TS example',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra-tailwind-ts',
src: '/static/images/examples/tailwindcss.svg',
},
{
name: 'Create React App',
label: 'View JS example',
tsLabel: 'View TS example',
label: 'View JavaScript',
tsLabel: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra',
tsLink: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra-ts',
src: '/static/images/examples/cra.svg',
},
{
name: 'Tailwind CSS + Create React App',
label: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra-tailwind-ts',
src: '/static/images/examples/tailwindcss.svg',
},
{
name: 'styled-components',
label: 'View JS example',
tsLabel: 'View TS example',
label: 'View JavaScript',
tsLabel: 'View TypeScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra-styled-components',
tsLink:
'https://github.com/mui/material-ui/tree/next/examples/material-ui-cra-styled-components-ts',
src: '/static/images/examples/styled.png',
},
{
name: 'Preact',
label: 'View JS example',
label: 'View JavaScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-preact',
src: '/static/images/examples/preact.svg',
},
{
name: 'CDN',
label: 'View JS example',
label: 'View JavaScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-via-cdn',
src: <CloudRoundedIcon />,
},
{
name: 'Express.js (server-rendered)',
label: 'View JS example',
label: 'View JavaScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-express-ssr',
src: '/static/images/examples/express.png',
},
{
name: 'Gatsby',
label: 'View JS example',
label: 'View JavaScript',
link: 'https://github.com/mui/material-ui/tree/next/examples/material-ui-gatsby',
src: '/static/images/examples/gatsby.svg',
},
{
name: 'React-admin',
label: 'View TS example',
label: 'View TypeScript',
link: 'https://github.com/marmelab/material-ui-react-admin',
src: '/static/images/examples/reactadmin.svg',
},
Expand All @@ -107,12 +107,7 @@ export default function MaterialUIExampleCollection() {
display: 'flex',
alignItems: 'center',
gap: 2,
background: `${(theme.vars || theme).palette.gradients.linearSubtle}`,
...theme.applyDarkStyles({
bgcolor: 'primaryDark.900',
background: `${(theme.vars || theme).palette.gradients.linearSubtle}`,
borderColor: 'primaryDark.700',
}),
background: `${(theme.vars || theme).palette.gradients.radioSubtle}`,
})}
>
<Avatar
Expand Down Expand Up @@ -159,11 +154,11 @@ export default function MaterialUIExampleCollection() {
variant="caption"
sx={{
display: { xs: 'none', sm: 'block' },
opacity: 0.2,
mr: 0.75,
opacity: 0.1,
mr: 1,
}}
>
&bull;
/
</Typography>
<Link
href={example.tsLink}
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-docs/src/InfoCard/InfoCard.tsx
Expand Up @@ -23,11 +23,11 @@ export function GlowingIconContainer({ icon }: GlowingIconContainerProps) {
border: '1px solid',
borderColor: 'primary.200',
bgcolor: 'primary.50',
boxShadow: `0px 1px 6px 0px ${alpha(theme.palette.primary[500], 0.2)}, 0px 2px 12px 0px rgba(234, 237, 241, 0.3) inset`,
boxShadow: `0px 0 0 2px ${alpha(theme.palette.primary[500], 0.1)}, 0px 2px 12px 0px rgba(234, 237, 241, 0.3) inset`,
...theme.applyDarkStyles({
borderColor: alpha(theme.palette.primary[400], 0.25),
bgcolor: alpha(theme.palette.primary[900], 0.25),
boxShadow: `0 2px 6px 0 ${alpha(theme.palette.primary[600], 0.3)}, 0px 2px 12px 0px rgba(0, 0, 0, 0.25) inset`,
bgcolor: alpha(theme.palette.primary[900], 0.4),
boxShadow: `0 0 0 2px ${alpha(theme.palette.primary[600], 0.1)}, 0px 2px 12px 0px rgba(0, 0, 0, 0.25) inset`,
}),
})}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-docs/src/branding/brandingTheme.ts
Expand Up @@ -821,7 +821,7 @@ export function getThemedComponents(): ThemeOptions {
root: ({ theme }) => ({
borderColor: (theme.vars || theme).palette.grey[100],
...theme.applyDarkStyles({
borderColor: alpha(theme.palette.primaryDark[700], 0.8),
borderColor: alpha(theme.palette.primaryDark[500], 0.3),
}),
}),
},
Expand Down