Skip to content

Commit

Permalink
[core] A couple of simply fixes from mui#34870
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 30, 2022
1 parent 5a84b55 commit ecd2b72
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
37 changes: 20 additions & 17 deletions docs/packages/markdown/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ module.exports = async function demoLoader() {
this.addDependency(moduleFilepath);
demos[demoName] = {
module: moduleID,
raw: await fs.readFile(moduleFilepath, { encoding: 'utf-8' }),
raw: await fs.readFile(moduleFilepath, { encoding: 'utf8' }),
};
demoModuleIDs.add(moduleID);

try {
const previewFilepath = moduleFilepath.replace(/\.js$/, '.tsx.preview');

const jsxPreview = await fs.readFile(previewFilepath, { encoding: 'utf-8' });
const jsxPreview = await fs.readFile(previewFilepath, { encoding: 'utf8' });
this.addDependency(previewFilepath);

demos[demoName].jsxPreview = jsxPreview;
Expand All @@ -177,7 +177,7 @@ module.exports = async function demoLoader() {
moduleTS.replace(/\//g, path.sep),
);
this.addDependency(moduleTSFilepath);
const rawTS = await fs.readFile(moduleTSFilepath, { encoding: 'utf-8' });
const rawTS = await fs.readFile(moduleTSFilepath, { encoding: 'utf8' });

// In development devs can choose whether they want to work on the TS or JS version.
// But this leads to building both demo version i.e. more build time.
Expand Down Expand Up @@ -222,20 +222,23 @@ module.exports = async function demoLoader() {
return `import ${moduleIDToJSIdentifier(moduleID)} from '${moduleID}';`;
})
.join('\n')}
export const docs = ${JSON.stringify(docs, null, 2)};
export const demos = ${JSON.stringify(demos, null, 2)};
export const demoComponents = {${Array.from(demoModuleIDs)
.map((moduleID) => {
return `${JSON.stringify(moduleID)}: ${moduleIDToJSIdentifier(moduleID)},`;
})
.join('\n')}};
export const srcComponents = {${Array.from(componentModuleIDs)
.map((moduleID) => {
return `${JSON.stringify(components[moduleID])}: ${moduleIDToJSIdentifier(moduleID)},`;
})
.join('\n')}};
`;
export const docs = ${JSON.stringify(docs, null, 2)};
export const demos = ${JSON.stringify(demos, null, 2)};
export const demoComponents = {
${Array.from(demoModuleIDs)
.map((moduleID) => {
return ` "${moduleID}": ${moduleIDToJSIdentifier(moduleID)},`;
})
.join('\n')}
};
export const srcComponents = {
${Array.from(componentModuleIDs)
.map((moduleID) => {
return ` "${components[moduleID]}": ${moduleIDToJSIdentifier(moduleID)},`;
})
.join('\n')}
};
`;

return transformed;
};
2 changes: 1 addition & 1 deletion docs/scripts/reportBrokenLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function getLinksAndAnchors(fileName) {
const userLanguage = 'en';
const render = createRender({ headingHashes, toc, userLanguage });

const data = fse.readFileSync(fileName, { encoding: 'utf-8' });
const data = fse.readFileSync(fileName, { encoding: 'utf8' });
render(data);

const links = getPageLinks(data).map(cleanLink);
Expand Down
7 changes: 2 additions & 5 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const DemoRootMaterial = styled('div', {
radial-gradient(at 93% 85%, ${alpha(
theme.palette.primaryDark[500],
0.8,
)} 0px, transparent 50%),
)} 0px, transparent 50%),
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23003A75' fill-opacity='0.15'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v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%3E%3Cpath d='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");`
: `radial-gradient(at 51% 52%, ${alpha(
theme.palette.primary[50],
Expand All @@ -172,10 +172,7 @@ const DemoRootMaterial = styled('div', {
radial-gradient(at 80% 0%, #FFFFFF 0px, transparent 20%),
radial-gradient(at 0% 95%, ${alpha(theme.palette.primary[100], 0.3)}, transparent 40%),
radial-gradient(at 0% 20%, ${theme.palette.primary[50]} 0px, transparent 50%),
radial-gradient(at 93% 85%, ${alpha(
theme.palette.primary[100],
0.2,
)} 0px, transparent 50%),
radial-gradient(at 93% 85%, ${alpha(theme.palette.primary[100], 0.2)} 0px, transparent 50%),
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23003A75' fill-opacity='0.03'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3Cpath d='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");`,
}),
...(hiddenToolbar && {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/DemoSandboxed.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ DemoFrame.propTypes = {
};

// Use the default MUI theme for the demos
const getTheme = (outerTheme) => {
function getTheme(outerTheme) {
const brandingDesignTokens = getDesignTokens(outerTheme.palette.mode);
const isCustomized =
outerTheme.palette.primary?.main &&
Expand All @@ -149,7 +149,7 @@ const getTheme = (outerTheme) => {
resultTheme.spacing = outerTheme.spacing;
}
return resultTheme;
};
}

// TODO: Let demos decide whether they need JSS
const jss = create({
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/DemoToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ export default function DemoToolbar(props) {
setSourceHintSeen(true);
};

function handleResetFocusClick() {
const handleResetFocusClick = () => {
initialFocusRef.current.focusVisible();
}
};

const showSourceHint = demoHovered && !sourceHintSeen;

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function MarkdownDocs(props) {
js: demoComponents[demo.module] ?? noComponent(demo.module),
jsxPreview: demo.jsxPreview,
rawTS: demo.rawTS,
tsx: demo.moduleTS ? demoComponents[demo.moduleTS] : null,
tsx: demoComponents[demo.moduleTS] ?? null,
}}
disableAd={disableAd}
demoOptions={renderedMarkdownOrDemo}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-envinfo/envinfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('@mui/envinfo', () => {
isRunningOnWindows ? 'npx.cmd' : 'npx',
['--package', buildPath, 'envinfo', ...args],
{
encoding: 'utf-8',
encoding: 'utf8',
stdio: 'pipe',
},
);
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function sizeSnapshot(options) {
// eslint-disable-next-line no-console -- purpose of this plugin
console.info(infoString);
// TODO: Should lock `snapshotPath` since something else might write to `snapshotPath` between read and write
const snapshotContent = await fs.readFile(snapshotPath, { encoding: 'utf-8' }).then(
const snapshotContent = await fs.readFile(snapshotPath, { encoding: 'utf8' }).then(
(json) => {
return JSON.parse(json);
},
Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const yargs = require('yargs');
async function run(argv) {
const workspaceRoot = path.resolve(__dirname, '../');

const gitignore = fs.readFileSync(path.join(workspaceRoot, '.gitignore'), { encoding: 'utf-8' });
const gitignore = fs.readFileSync(path.join(workspaceRoot, '.gitignore'), { encoding: 'utf8' });
const ignore = gitignore
.split(/\r?\n/)
.filter((pattern) => {
Expand Down

0 comments on commit ecd2b72

Please sign in to comment.