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

[website] Modernize the Base UI website #538

Merged
merged 160 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
b480de9
Create MDX loading infra
michaldudak Aug 9, 2024
ce89d9f
Clean up
michaldudak Aug 9, 2024
3e15948
Remove old redirects
michaldudak Aug 9, 2024
c33b9f1
More cleanup
michaldudak Aug 9, 2024
4fb1dd1
Make docs:api pass
michaldudak Aug 9, 2024
0be7caf
Making the CI happy
michaldudak Aug 9, 2024
9928f55
More cleanup
michaldudak Aug 9, 2024
9b820ae
Dedupe
michaldudak Aug 9, 2024
d2a44d3
Fix titles
michaldudak Aug 9, 2024
3e0ac7a
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 9, 2024
2251236
Prettier
michaldudak Aug 9, 2024
c166609
Fix TS errors
michaldudak Aug 9, 2024
ed16e13
Remove the i18n check
michaldudak Aug 9, 2024
6db7706
Disable link checker
michaldudak Aug 9, 2024
f99d8fc
Simplify _app and _document
michaldudak Aug 9, 2024
7b9a236
Move API translations under data
michaldudak Aug 9, 2024
229b9c6
Quick and dirty API reference
michaldudak Aug 9, 2024
85cb6ff
Style the markdown content
michaldudak Aug 12, 2024
1468378
Style prop tables
michaldudak Aug 12, 2024
93cc614
Refactor API docs generation
michaldudak Aug 12, 2024
7730e3d
Make it more obvious TOC is a dummy
michaldudak Aug 12, 2024
0e22ba3
Migrate to App Router
michaldudak Aug 12, 2024
5b20f8a
Convert all pages to mdx
michaldudak Aug 12, 2024
b3a9f6e
Lint
michaldudak Aug 12, 2024
914062e
Favicon
michaldudak Aug 12, 2024
d547b2c
Remove unused npm packages
michaldudak Aug 12, 2024
bcb98a8
Replace mdx-bundler with mdx-js
michaldudak Aug 13, 2024
319db4d
Table of contents
michaldudak Aug 13, 2024
2d78650
TOC styles
michaldudak Aug 13, 2024
895518e
Flat component list in side nav
michaldudak Aug 13, 2024
3133c1f
fix css px bug
colmtuite Aug 13, 2024
cf842ea
style figure element
colmtuite Aug 13, 2024
55c59f9
basic ass homepage
colmtuite Aug 13, 2024
74f60bf
refactor description component
colmtuite Aug 13, 2024
c672328
componentise select adornment
colmtuite Aug 13, 2024
39f8c70
fix strong tags
colmtuite Aug 13, 2024
3ec2d50
replace kbd classnames
colmtuite Aug 13, 2024
1425bc0
remove layout from homepage
colmtuite Aug 13, 2024
d454e20
improve mdx typography
colmtuite Aug 13, 2024
1db30d4
fix font family in code blocks
colmtuite Aug 13, 2024
f4cad96
improve main layout
colmtuite Aug 13, 2024
1caf5b5
style mdx links
colmtuite Aug 14, 2024
bd847dd
remove specificity declarations from mdx styles
colmtuite Aug 14, 2024
37ec12f
tweak heading spacing
colmtuite Aug 14, 2024
aeaf3fe
tweak homepage
colmtuite Aug 14, 2024
245b472
make homepage responsive
colmtuite Aug 14, 2024
e5cf28e
Version selector
michaldudak Aug 14, 2024
3581ca8
Remove the /base-ui-react/ route segment
michaldudak Aug 14, 2024
5c99f19
Lint
michaldudak Aug 14, 2024
f4dd02e
Redirect to first subpage
michaldudak Aug 14, 2024
396329c
Runnable demos
michaldudak Aug 14, 2024
e37b593
Add 'use client' to demos
michaldudak Aug 14, 2024
14748a9
Render the System variant of complex demos temporarily
michaldudak Aug 14, 2024
19f806f
Display demo sources
michaldudak Aug 14, 2024
9e8efad
Remove redirection
michaldudak Aug 15, 2024
6d46395
Unstyled demo viewer
michaldudak Aug 15, 2024
577b974
Support multi-variant demos
michaldudak Aug 16, 2024
09be073
Add separate pages for /getting-started and /guides
michaldudak Aug 16, 2024
db2466c
Support multiple files in demos
michaldudak Aug 16, 2024
f1b48b8
Split AlertDialog CSS demo to two files
michaldudak Aug 16, 2024
b1b3287
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 19, 2024
1ca95bd
Callout component
michaldudak Aug 19, 2024
71632f7
Use globally defined colors in Dialog demos
michaldudak Aug 19, 2024
c0e42dc
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 19, 2024
0be4d59
Package manager code snippet component
michaldudak Aug 20, 2024
6049057
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 20, 2024
d884859
Fix regression tests
michaldudak Aug 20, 2024
e885205
polish the calloutz
colmtuite Aug 20, 2024
d9bd88d
Include demo CSS variables
michaldudak Aug 20, 2024
78c8fa5
Prettier
michaldudak Aug 20, 2024
0879414
Page metadata
michaldudak Aug 20, 2024
572b5d7
Home page SEO description
michaldudak Aug 20, 2024
1ff9f55
Remove the 'base' subdirectory of docs/data
michaldudak Aug 21, 2024
c8d7262
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 21, 2024
a121334
Enable Tailwind CSS on demos
michaldudak Aug 21, 2024
6a5566a
Enable Tailwind CSS on regression tests
michaldudak Aug 21, 2024
253f11b
Disable custom font in regression tests
michaldudak Aug 21, 2024
2a91625
ComponentLinkHeader
michaldudak Aug 21, 2024
d3d72b5
Support demos with transitive dependencies
michaldudak Aug 21, 2024
11cd02d
Fix React errors
michaldudak Aug 21, 2024
463ebc1
ToggleButtonGroup component
michaldudak Aug 22, 2024
f661ccd
Demo file selector
michaldudak Aug 22, 2024
86c5fcd
Improve Lighhouse score
michaldudak Aug 22, 2024
da91fdd
Fix TS error
michaldudak Aug 22, 2024
f3fe522
Do not run regression tests for demo dependencies
michaldudak Aug 22, 2024
8d1245f
Remove ComponentPageTabs usage
michaldudak Aug 22, 2024
a9a2c51
Quickstart -> Quick start
michaldudak Aug 22, 2024
2e86111
Clean up docs' content
michaldudak Aug 22, 2024
df30594
Copey source button
michaldudak Aug 23, 2024
8c6123d
Remove sidenav on smaller screens
michaldudak Aug 23, 2024
5a83497
Fix font in ComponentLinkHeader
michaldudak Aug 23, 2024
6a9c793
Open demos in CodeSandbox
michaldudak Aug 26, 2024
5abf254
CSB generation improvements
michaldudak Aug 26, 2024
412aab2
Move sandbox generation code to blocks
michaldudak Aug 26, 2024
3154387
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 26, 2024
7a9f398
Add the focus reset button to demos
michaldudak Aug 27, 2024
50dee9c
Demo playground focus styles
michaldudak Aug 27, 2024
f16b88f
Reset demo button
michaldudak Aug 27, 2024
b4b5562
JSDocs
michaldudak Aug 21, 2024
76e5d4e
Fix the build
michaldudak Aug 27, 2024
9e1b654
Fix the build even more
michaldudak Aug 27, 2024
153b174
IconButton component
michaldudak Aug 27, 2024
06c6642
Add TooltipProvider
michaldudak Aug 27, 2024
4d21611
Add mdx extension to vscode recommendations
michaldudak Aug 27, 2024
b7d65b6
Add the theme file to demos
michaldudak Aug 27, 2024
3e67cf1
Plain CSS -> CSS modules
michaldudak Aug 27, 2024
cf62329
Fix prop spreading
michaldudak Aug 27, 2024
7e05c9f
Split IconLinkButton
michaldudak Aug 27, 2024
519fa82
Lint
michaldudak Aug 28, 2024
34c174d
Move things around
michaldudak Aug 28, 2024
3af8cbf
Collapse/expand source code
michaldudak Aug 28, 2024
4db04d9
Page headers as links
michaldudak Aug 28, 2024
5fb3580
View code on GitHub
michaldudak Aug 28, 2024
56d4d58
StackBlitz link
michaldudak Aug 28, 2024
e20f9b9
Package manager instructions as tabs
michaldudak Aug 28, 2024
1737f78
polish tooltips
colmtuite Aug 28, 2024
8cc2c4b
polish toolbar button
colmtuite Aug 28, 2024
bce7137
tweak playground
colmtuite Aug 28, 2024
df53f96
polish version selector
colmtuite Aug 28, 2024
49d9e9d
tweak description links
colmtuite Aug 28, 2024
6d00522
Calm down the dancing menu
michaldudak Aug 28, 2024
6f23ec2
Remove hover styles from DocsVersionSelector
michaldudak Aug 28, 2024
2d06a0e
Better a11y of demo viewer
michaldudak Aug 29, 2024
df49aaa
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Aug 29, 2024
5e13876
Use Collapsible to hide code blocks
michaldudak Aug 29, 2024
ce24583
Refactor DemoContext
michaldudak Aug 29, 2024
53eb7ee
File selector as Tabs
michaldudak Aug 29, 2024
9e4c476
Fix hover style of file tabs
michaldudak Aug 29, 2024
6e905da
Fix broken link checker
michaldudak Aug 29, 2024
2c8223c
Add missing dependency
michaldudak Aug 29, 2024
2d07b89
Update API docs builder
michaldudak Aug 29, 2024
cfecc7b
eslint
michaldudak Aug 29, 2024
9f85b5c
Previous/next page links
michaldudak Aug 29, 2024
c961c9e
Edit page on GitHub link
michaldudak Aug 30, 2024
bcb16ec
Experiments
michaldudak Aug 30, 2024
bf95f4d
Navigation and TOC styles
michaldudak Aug 30, 2024
5163f9a
Fix demo variant selector
michaldudak Sep 1, 2024
6e3e4f7
Refactoring + JSDocs
michaldudak Sep 2, 2024
4d45338
Remember the package manager selection between pages and sessions
michaldudak Sep 2, 2024
341166a
lint
michaldudak Sep 2, 2024
413fec8
Remove old references to src/pages
michaldudak Sep 2, 2024
740b7fc
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Sep 2, 2024
4fed4e4
Google analytics component
michaldudak Sep 2, 2024
1cb938e
Move GoogleAnalytics and GoogleTagManager to blocks
michaldudak Sep 3, 2024
608f9b4
Infinite loops are bad
michaldudak Sep 3, 2024
c3c3e68
polish edit on gh link
colmtuite Sep 3, 2024
b87a858
polish sidebar headings
colmtuite Sep 3, 2024
95f4bd8
Fix Tooltip arrow styling
michaldudak Sep 3, 2024
feca284
Scroll source code horizontally
michaldudak Sep 3, 2024
c046298
Maintain nav scroll position
michaldudak Sep 3, 2024
b52a19a
Fix focus rest on demos
michaldudak Sep 3, 2024
b754c30
fix code block style bug
colmtuite Sep 3, 2024
b7b637f
enable border radius on next previous links
colmtuite Sep 3, 2024
fae0a3f
oops
colmtuite Sep 3, 2024
25df237
Remove redundant components from content pages
michaldudak Sep 3, 2024
f0511ae
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Sep 3, 2024
85c9c94
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Sep 4, 2024
682f3db
Support multiple components in InstallationInstructions
michaldudak Sep 4, 2024
cc0610e
Merge remote-tracking branch 'upstream/master' into new-docs
michaldudak Sep 4, 2024
1976926
Update @mui/monorepo
michaldudak Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 0 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ jobs:
- run:
name: '`pnpm docs:api` changes committed?'
command: git add -A && git diff --exit-code --staged
- run:
name: Update the navigation translations
command: pnpm docs:i18n
- run:
name: '`pnpm docs:i18n` changes committed?'
command: git add -A && git diff --exit-code --staged
- run:
name: '`pnpm extract-error-codes` changes committed?'
command: |
Expand Down
52 changes: 36 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ const OneLevelImportMessage = [
'See https://github.com/mui/material-ui/pull/24147 for the kind of win it can unlock.',
].join('\n');

const NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED = [
{
group: ['@base_ui/react/*/*', '!@base_ui/react/legacy/*'],
message: OneLevelImportMessage,
},
];

module.exports = {
...baseline,
settings: {
Expand All @@ -27,27 +34,15 @@ module.exports = {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@mui/*/*/*',
'@pigment-css/*/*/*',
'@base_ui/react/*/*',
'!@base_ui/react/legacy/*',
// Allow any import depth with any internal packages
'!@mui/internal-*/**',
// TODO delete, @mui/docs should be @mui/internal-docs
'!@mui/docs/**',
],
message: OneLevelImportMessage,
},
],
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
},
],
'@typescript-eslint/no-redeclare': 'off',
},
overrides: [
...baseline.overrides,
...baseline.overrides.filter(
(ruleSet) => !ruleSet.rules.hasOwnProperty('filenames/match-exported'),
),
{
files: ['docs/pages/experiments/**/*{.tsx,.js}', 'docs/pages/playground/**/*{.tsx,.js}'],
rules: {
Expand All @@ -67,5 +62,30 @@ module.exports = {
'testing-library/render-result-naming-convention': 'off', // False positives
},
},
{
files: ['docs/**/*{.ts,.tsx,.js}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
},
],
'react/prop-types': 'off',
'@typescript-eslint/no-use-before-define': 'off',
},
},
{
files: ['docs/data/**/*{.tsx,.js}'],
excludedFiles: [
'docs/data/**/css/*{.tsx,.js}',
'docs/data/**/css-modules/*{.tsx,.js}',
'docs/data/**/system/*{.tsx,.js}',
'docs/data/**/tailwind/*{.tsx,.js}',
],
rules: {
'filenames/match-exported': ['error'],
},
},
],
};
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"unifiedjs.vscode-mdx",
"yoavbls.pretty-ts-errors"
]
}
2 changes: 0 additions & 2 deletions docs/.link-check-errors.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
Broken links found by `pnpm docs:link-check` that exist:

27 changes: 27 additions & 0 deletions docs/app/(content)/components/[slug]/getApiReferenceData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { readFile } from 'node:fs/promises';
import { ComponentAPIReference } from 'docs-base/types/ComponentAPIReference';
import kebabCase from 'lodash/kebabCase';

export function getApiReferenceData(componentNames: string[]): Promise<ComponentAPIReference[]> {
return Promise.all(
componentNames.map(async (componentName) => {
const kebabedComponentName = kebabCase(componentName);
const apiDescriptionFilePath = `data/api/${kebabedComponentName}.json`;
const translationsFilePath = `data/translations/api-docs/${kebabedComponentName}/${kebabedComponentName}.json`;

const apiDescription = JSON.parse(await readFile(apiDescriptionFilePath, 'utf-8'));
const translations = JSON.parse(await readFile(translationsFilePath, 'utf-8'));

return {
name: componentName,
description: translations.componentDescription,
props: Object.keys(apiDescription.props).map((propName) => ({
name: propName,
...apiDescription.props[propName],
defaultValue: apiDescription.props[propName].default ?? null,
...translations.propDescriptions[propName],
})),
} satisfies ComponentAPIReference;
}),
);
}
107 changes: 107 additions & 0 deletions docs/app/(content)/components/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import * as React from 'react';
import { Metadata } from 'next';
import { components } from 'docs-base/src/components/content/MDXComponents';
import { getMarkdownPage, getMarkdownPageMetadata } from 'docs-base/app/(content)/getMarkdownPage';
import { ComponentLinkHeader } from 'docs-base/src/components/content/ComponentLinkHeader';
import { Description } from 'docs-base/src/components/content/Description';
import { TableOfContents } from 'docs-base/src/components/TableOfContents';
import routes, { getSlugs } from 'docs-base/data/pages';
import { SiblingPageLinks } from 'docs-base/src/components/SiblingPageLinks';
import { EditPageGithubLink } from 'docs-base/src/components/EditPageGithhubLink';
import {
ApiReference,
getApiReferenceTableOfContents,
} from 'docs-base/src/components/ApiReference';
import { DemoLoader, DemoLoaderProps } from 'docs-base/src/components/demo/DemoLoader';
import { getApiReferenceData } from './getApiReferenceData';
import classes from '../../styles.module.css';

const CATEGORY_SEGMENT = 'components';

interface Props {
params: {
slug: string;
};
}

function componentNameFromSlug(slug: string) {
return slug.replace('react-', '');
}

export default async function ComponentPage(props: Props) {
const {
params: { slug },
} = props;

const componentName = componentNameFromSlug(slug);

const { MDXContent, metadata, tableOfContents } = await getMarkdownPage(
CATEGORY_SEGMENT,
componentName,
);

const documentedComponents = metadata.components?.split(',').map((c: string) => c.trim()) ?? [];
const componentsApi = await getApiReferenceData(documentedComponents);
const apiReferenceToc = getApiReferenceTableOfContents(componentsApi);

tableOfContents[0].children?.push(apiReferenceToc);

const allComponents = {
...components,
// eslint-disable-next-line react/no-unstable-nested-components
Demo: (demoProps: Omit<DemoLoaderProps, 'componentName'>) => (
<DemoLoader componentName={componentName} {...demoProps} />
),
// eslint-disable-next-line react/no-unstable-nested-components
Description: () => <Description text={metadata.description} />,
// eslint-disable-next-line react/no-unstable-nested-components
ComponentLinkHeader: () => (
<ComponentLinkHeader ariaSpecUrl={metadata.waiAria} githubLabel={metadata.githubLabel} />
),
};

return (
<React.Fragment>
<main className={classes.content}>
<MDXContent components={{ ...allComponents }} />
<ApiReference componentsApi={componentsApi} />
<div>
<div className={classes.editLink}>
<EditPageGithubLink category={CATEGORY_SEGMENT} slug={componentName} />
</div>
<div>
<SiblingPageLinks currentSlug={`/${CATEGORY_SEGMENT}/${slug}`} pages={routes} />
</div>
</div>
</main>

<TableOfContents toc={tableOfContents} renderDepth={3} />
</React.Fragment>
);
}

export async function generateStaticParams() {
return getSlugs(`/${CATEGORY_SEGMENT}`).map((slug) => ({ slug }));
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = params;
const componentName = componentNameFromSlug(slug);
const { title = 'Components', description } = await getMarkdownPageMetadata(
CATEGORY_SEGMENT,
componentName,
);

return {
title,
description,
twitter: {
title,
description,
},
openGraph: {
title,
description,
},
};
}
88 changes: 88 additions & 0 deletions docs/app/(content)/getMarkdownPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import path from 'node:path';
import fs from 'node:fs';
import { readFile } from 'node:fs/promises';
import rehypePrettyCode from 'rehype-pretty-code';
import { evaluate } from '@mdx-js/mdx';
import * as jsxRuntime from 'react/jsx-runtime';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
import extractToc, { type Toc } from '@stefanprobst/rehype-extract-toc';
import exportToc from '@stefanprobst/rehype-extract-toc/mdx';
import { read as readVFile } from 'to-vfile';
import { matter } from 'vfile-matter';
import { config } from 'docs-base/config';

export const DATA_PATH = path.join(process.cwd(), 'data');

export interface PageMetadata {
title: string;
description: string;
components?: string;
githubLabel?: string;
waiAria?: string;
slug: string;
}

export const getMarkdownPage = async (basePath: string, slug: string) => {
const mdxFilePath = path.join(DATA_PATH, basePath, `/${slug}/${slug}.mdx`);
const mdFilePath = path.join(DATA_PATH, basePath, `/${slug}/${slug}.md`);

let filePath: string;

if (fs.existsSync(mdxFilePath)) {
filePath = mdxFilePath;
} else if (fs.existsSync(mdFilePath)) {
filePath = mdFilePath;
} else {
throw new Error(`No MD(X) file found for ${basePath}/${slug}`);
}

const mdxSource = await readFile(filePath, 'utf8');

const {
default: MDXContent,
frontmatter,
tableOfContents,
// @ts-ignore https://github.com/mdx-js/mdx/issues/2463
} = await evaluate(mdxSource, {
...jsxRuntime,
remarkPlugins: [remarkGfm, remarkFrontmatter, remarkMdxFrontmatter],
rehypePlugins: [
[rehypePrettyCode, { theme: config.shikiThemes }],
rehypeSlug,
extractToc,
exportToc,
],
});

return {
metadata: {
...(frontmatter as Partial<PageMetadata>),
slug,
} as PageMetadata,
tableOfContents: tableOfContents as Toc,
MDXContent,
};
};

export const getMarkdownPageMetadata = async (basePath: string, slug: string) => {
const mdxFilePath = path.join(DATA_PATH, basePath, `/${slug}/${slug}.mdx`);
const mdFilePath = path.join(DATA_PATH, basePath, `/${slug}/${slug}.md`);

let filePath: string;

if (fs.existsSync(mdxFilePath)) {
filePath = mdxFilePath;
} else if (fs.existsSync(mdFilePath)) {
filePath = mdFilePath;
} else {
throw new Error(`No MD(X) file found for ${basePath}/${slug}`);
}

const file = await readVFile(filePath);
matter(file);

return file.data.matter as PageMetadata;
};
Loading
Loading