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

[core] Remove dead and redundant code #33125

Merged
merged 3 commits into from
Jun 15, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions docs/src/components/header/HeaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,7 @@ export default function HeaderNavBar() {
role="menuitem"
href={ROUTES.productAdvanced}
icon={<IconImage name="product-advanced" />}
name={
<Box component="span" display="inline-flex" alignItems="center">
MUI&nbsp;X
</Box>
}
name="MUI X"
description="Advanced and powerful components for complex use cases."
onKeyDown={handleKeyDown}
/>
Expand Down
19 changes: 5 additions & 14 deletions docs/src/components/header/HeaderNavDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import Link from 'docs/src/modules/components/Link';
import ROUTES from 'docs/src/route';
import FEATURE_TOGGLE from 'docs/src/featureToggle';

const shouldShowJoy =
process.env.NODE_ENV === 'development' ||
process.env.PULL_REQUEST ||
FEATURE_TOGGLE.enable_joy_scope;

const Anchor = styled('a')<{ component?: React.ElementType; noLinkStyle?: boolean }>(
({ theme }) => ({
...theme.typography.body2,
Expand Down Expand Up @@ -77,15 +72,11 @@ const DOCS = [
description: "React components that implement Google's Material Design.",
href: ROUTES.materialDocs,
},
...(shouldShowJoy
? [
{
name: 'Joy UI',
description: 'React components for building your design system.',
href: ROUTES.joyDocs,
},
]
: []),
{
name: 'Joy UI',
description: 'React components for building your design system.',
href: ROUTES.joyDocs,
},
{
name: 'MUI Base',
description: 'Unstyled React components and low-level hooks.',
Expand Down
14 changes: 7 additions & 7 deletions docs/src/featureToggle.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// need to use commonjs export so that docs/packages/markdown can use
module.exports = {
nav_products: true,
enable_website_banner: false,
enable_toc_banner: true,
enable_docsnav_banner: false,
// TODO: cleanup once migration is done
enable_product_scope: true, // related to new structure change
enable_redirects: true, // related to new structure change
enable_mui_base_scope: true, // will be enabled after the migration
enable_system_scope: true, // will be enabled after the migration
enable_joy_scope: true,

// TODO: to remove
nav_products: true,
enable_product_scope: true,
enable_redirects: true,
enable_mui_base_scope: true,
enable_system_scope: true,
};
8 changes: 4 additions & 4 deletions docs/src/modules/components/AppNavDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import DoneRounded from '@mui/icons-material/DoneRounded';
import FEATURE_TOGGLE from 'docs/src/featureToggle';
import { isNewLocation } from 'docs/src/modules/utils/replaceUrl';
import MuiProductSelector from 'docs/src/modules/components/MuiProductSelector';
import materialPkgJson from '../../../../packages/mui-material/package.json';
import joyPkgJson from '../../../../packages/mui-joy/package.json';
import basePkgJson from '../../../../packages/mui-base/package.json';
import systemPkgJson from '../../../../packages/mui-system/package.json';
import materialPkgJson from 'packages/mui-material/package.json';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work in MUI X inside @mui/monorepo package.
I'll submit a PR to revert this as a quick fix

Copy link
Member Author

@oliviertassinari oliviertassinari Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, now we have solved the mystery! cc @Janpot

For some reason MUIX setup understands the packages/... alias and I can't figure out why.

mui/toolpad#542 (comment)

It's simply because we were not looking at the right source. MUI X didn't update to the latest version of mui/material-ui HEAD yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that explains a lot 😄.

import joyPkgJson from 'packages/mui-joy/package.json';
import basePkgJson from 'packages/mui-base/package.json';
import systemPkgJson from 'packages/mui-system/package.json';

const savedScrollTop = {};

Expand Down
71 changes: 31 additions & 40 deletions docs/src/modules/components/MuiProductSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ import Chip from '@mui/material/Chip';
import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';
import IconImage from 'docs/src/components/icon/IconImage';
import FEATURE_TOGGLE from 'docs/src/featureToggle';
import ROUTES from 'docs/src/route';
import Link from 'docs/src/modules/components/Link';
import useRouterExtra from 'docs/src/modules/utils/useRouterExtra';

const shouldShowJoy =
process.env.NODE_ENV === 'development' ||
process.env.PULL_REQUEST ||
FEATURE_TOGGLE.enable_joy_scope;

function ProductSubMenu({
icon,
name,
Expand Down Expand Up @@ -62,8 +56,31 @@ function ProductSubMenu({
);
}

const products = [
{
name: 'Material UI',
href: ROUTES.materialDocs,
slug: 'material-ui',
},
{
name: 'Joy UI',
href: ROUTES.joyDocs,
slug: 'joy-ui',
},
{
name: 'MUI Base',
href: ROUTES.baseDocs,
slug: 'base',
},
{
name: 'MUI System',
href: ROUTES.systemDocs,
slug: 'system',
},
];

export default function MuiProductSelector() {
const { product } = useRouterExtra();
const routerExtra = useRouterExtra();

return (
<React.Fragment>
Expand Down Expand Up @@ -108,44 +125,18 @@ export default function MuiProductSelector() {
},
}}
>
<Chip
color={product === 'material-ui' ? 'default' : undefined}
variant={product === 'material-ui' ? 'filled' : 'outlined'}
component={Link}
href={ROUTES.materialDocs}
label={<React.Fragment>Material UI </React.Fragment>}
clickable
size="small"
/>
{shouldShowJoy && (
{products.map((product) => (
<Chip
color={product === 'joy-ui' ? 'default' : undefined}
variant={product === 'joy-ui' ? 'filled' : 'outlined'}
key={product.name}
color={routerExtra.product === product.slug ? 'default' : undefined}
variant={routerExtra.product === product.slug ? 'filled' : 'outlined'}
component={Link}
href={ROUTES.joyDocs}
label={<React.Fragment>Joy UI </React.Fragment>}
href={product.href}
label={product.name}
clickable
size="small"
/>
)}
<Chip
color={product === 'base' ? 'default' : undefined}
variant={product === 'base' ? 'filled' : 'outlined'}
component={Link}
href={ROUTES.baseDocs}
label={<React.Fragment>MUI Base </React.Fragment>}
clickable
size="small"
/>
<Chip
color={product === 'system' ? 'default' : undefined}
variant={product === 'system' ? 'filled' : 'outlined'}
component={Link}
href={ROUTES.systemDocs}
label={<React.Fragment>MUI System </React.Fragment>}
clickable
size="small"
/>
))}
</Stack>
</Box>
</Box>
Expand Down