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] Add a feature list "component" #41484

Merged
merged 11 commits into from
Mar 15, 2024
1 change: 1 addition & 0 deletions docs/data/docs-infra/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const pages: readonly MuiPage[] = [
children: [
{ pathname: '/experiments/docs/callouts' },
{ pathname: '/experiments/docs/codeblock' },
{ pathname: '/experiments/docs/custom-components' },
{ pathname: '/experiments/docs/demos' },
{ pathname: '/experiments/docs/data-grid-premium', title: 'API DataGridPremium' },
],
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/experiments/docs/custom-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import * as pageProps from './custom-components.md?muiMarkdown';

export default function Page() {
return <MarkdownDocs {...pageProps} />;
}
27 changes: 27 additions & 0 deletions docs/pages/experiments/docs/custom-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Callouts

<p class="description">Type of callouts.</p>

## Header chips

{{"component": "modules/components/ComponentLinkHeader.js"}}

## Feature list

### Approach 1: Componentized

Easier to protect the styles, but worse to read and write

{{"component": "modules/components/FeatureList.js", "features": ["Manages modal stacking when one-at-a-time just isn't enough.", "Creates a backdrop, for disabling interaction below the modal.", "It disables scrolling of the page content while open.", "It properly manages focus; moving to the modal content, and keeping it there until the modal is closed.", "Adds the appropriate ARIA roles automatically."]}}

### Approach 2: Plain HTML

Easier to write and read, and potentially easier to violate the styles?

<ul class='feature-list'>
<li>Manages modal stacking when one-at-a-time just isn't enough.</li>
<li>Creates a backdrop, for disabling interaction below the modal.est</li>
<li>It disables scrolling of the page content while open.</li>
<li>It properly manages focus; moving to the modal content, and keeping it there until the modal is closed.</li>
<li>Adds the appropriate ARIA roles automatically.</li>
</ul>
danilo-leal marked this conversation as resolved.
Show resolved Hide resolved
40 changes: 40 additions & 0 deletions docs/src/modules/components/FeatureList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import IconImage from 'docs/src/components/icon/IconImage';
import { styled } from '@mui/material/styles';

const ListRoot = styled('ul')({
padding: 0,
margin: 0,
marginBottom: 16,
listStyle: 'none',
display: 'flex',
flexDirection: 'column',
gap: 6,
});

export default function FeatureList({ features }) {
return (
<ListRoot>
{features.map((feature, item) => (
<Stack
key={item}
component="li"
direction="row"
alignItems="center"
spacing={1.5}
useFlexGap
>
<IconImage name="pricing/yes" />
<Typography color="text.secondary">{feature}</Typography>
</Stack>
))}
</ListRoot>
);
}

FeatureList.propTypes = {
features: PropTypes.string,
};
22 changes: 22 additions & 0 deletions docs/src/modules/components/MarkdownElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,21 @@ const Root = styled('div')(
marginBottom: theme.spacing(1),
},
},
'& .feature-list': {
padding: 0,
listStyle: 'none',
'& li': {
marginBottom: 6,
display: 'flex',
alignItems: 'center',
gap: 12,
'::before': {
content: `url('/static/branding/pricing/yes-light.svg')`,
width: '18px',
height: '18px',
},
},
},
}),
({ theme }) => ({
[`:where(${theme.vars ? '[data-mui-color-scheme="dark"]' : '.mode-dark'}) &`]: {
Expand Down Expand Up @@ -747,6 +762,13 @@ const Root = styled('div')(
backgroundColor: `var(--muidocs-palette-primaryDark-800, ${darkTheme.palette.primaryDark[800]})`,
},
},
'& .feature-list': {
'& li': {
'::before': {
content: `url('/static/branding/pricing/yes-dark.svg')`,
},
},
},
},
}),
);
Expand Down
Loading