Skip to content

Commit

Permalink
get it done
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 4, 2020
1 parent e488c4a commit dae3284
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { create } from 'jss';
import rtl from 'jss-rtl';
import { useRouter } from 'next/router';
import { StylesProvider, jssPreset } from '@material-ui/styles';
import { ponyfillGlobal } from '@material-ui/utils';
import pages from 'docsx/src/pages';
import initRedux from 'docs/src/modules/redux/initRedux';
import PageContext from 'docs/src/modules/components/PageContext';
Expand All @@ -29,6 +30,48 @@ import { ThemeProvider } from 'docs/src/modules/components/ThemeContext';
import { pathnameToLanguage, getCookie } from 'docs/src/modules/utils/helpers';
import { ACTION_TYPES, CODE_VARIANTS } from 'docs/src/modules/constants';

function getMuiPackageVersion(packageName, commitRef) {
if (commitRef === undefined) {
return 'latest';
}
const shortSha = commitRef.slice(0, 8);
return `https://pkg.csb.dev/mui-org/material-ui-x/commit/${shortSha}/@material-ui/${packageName}`;
}

ponyfillGlobal.muiDocConfig = {
csbIncludePeerDependencies: (deps, { versions }) => {
const newDeps = { ...deps };

if (
newDeps['@material-ui/x'] ||
newDeps['@material-ui/x-grid'] ||
newDeps['@material-ui/data-grid']
) {
newDeps['@material-ui/core'] = versions['@material-ui/core'];
}

if (newDeps['@material-ui/x-grid-data-generator']) {
newDeps['@material-ui/core'] = versions['@material-ui/core'];
newDeps['@material-ui/icons'] = versions['@material-ui/icons'];
newDeps['@material-ui/lab'] = versions['@material-ui/lab'];
}

return newDeps;
},
csbGetVersions: (versions, { muiCommitRef }) => {
const output = {
...versions,
'@material-ui/x-grid': getMuiPackageVersion('x-grid', muiCommitRef),
'@material-ui/x-grid-data-generator': getMuiPackageVersion(
'x-grid-data-generator',
muiCommitRef,
),
'@material-ui/data-grid': getMuiPackageVersion('data-grid', muiCommitRef),
};
return output;
},
};

// Configure JSS
const jss = create({
plugins: [...jssPreset().plugins, rtl()],
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,7 @@

"@material-ui/monorepo@https://github.com/mui-org/material-ui.git#master":
version "4.11.1"
resolved "https://github.com/mui-org/material-ui.git#b8092ce09e164a1cb2fec2f3a5b6aa6e2dc6cbbd"
resolved "https://github.com/mui-org/material-ui.git#34be88ec011d91d7f0fe6ddb0ec04e588149bdfe"

"@material-ui/monorepo@https://github.com/mui-org/material-ui.git#next":
version "5.0.0-alpha.16"
Expand Down

0 comments on commit dae3284

Please sign in to comment.