Skip to content

Commit

Permalink
upgrade to MUI v5
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Feb 20, 2023
1 parent d25926e commit 9f9515c
Show file tree
Hide file tree
Showing 59 changed files with 1,416 additions and 465 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ init:
mkdir -p static/app/css

wq.js: init
cd packages/material-web && npm run rollup
cd ../../
npm run rollup -- -c
cp -p packages/app/css/wq.css static/app/css/wq.css
cp -p node_modules/mapbox-gl/dist/mapbox-gl.css static/app/css/mapbox-gl.css
Expand Down
File renamed without changes.
File renamed without changes.
1,422 changes: 1,217 additions & 205 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "wq.app",
"type": "module",
"scripts": {
"test": "npm test --workspaces",
"build": "npm run build --workspaces --if-present",
Expand Down
2 changes: 0 additions & 2 deletions packages/material-web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
/hooks.js
/components/
/inputs/
/vendor/
/src/vendor/
/__tests__/
10 changes: 7 additions & 3 deletions packages/material-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"scripts": {
"test": "cd ../../ && npm run jest packages/material-web",
"build": "npm run babel && npm run prettier",
"rollup": "cd ../../ && npm run rollup -- -c packages/material-web/rollup.config.js",
"babel": "cd ../../ && npm run babel -- packages/material-web/src --out-dir packages/material-web/",
"prettier": "cd ../../ && npm run prettier -- --write packages/material-web/",
"lint": "cd ../../ && npm run eslint packages/material-web/{,src/,src/*/,src/*/*/}*.js"
Expand All @@ -30,9 +29,14 @@
},
"homepage": "https://wq.io/@wq/material",
"dependencies": {
"@date-io/date-fns": "^2.16.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.5",
"@wq/react": "file:../react",
"date-fns": "^2.29.3"
"formik-mui": "^5.0.0-alpha.0",
"formik-mui-x-date-pickers": "^0.0.1",
"mui-file-dropzone": "^4.0.2"
},
"devDependencies": {
"@wq/model": "^1.3.0",
Expand Down
26 changes: 0 additions & 26 deletions packages/material-web/rollup.config.js

This file was deleted.

10 changes: 6 additions & 4 deletions packages/material-web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useMemo } from "react";
import { App as DefaultApp, usePlugin } from "@wq/react";
import { ThemeProvider } from "@material-ui/styles";
import { createMuiTheme } from "@material-ui/core/styles";
import CssBaseline from "@material-ui/core/CssBaseline";
import {
createTheme as createMuiTheme,
ThemeProvider,
} from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";

export default function App() {
const { theme } = usePlugin("material").config,
Expand All @@ -19,7 +21,7 @@ function createTheme(theme) {
const { type, primary, secondary, background } = theme;
const palette = theme.palette || {};
if (type) {
palette.type = type;
palette.mode = type;
}
if (primary) {
palette.primary = { main: primary };
Expand Down
36 changes: 36 additions & 0 deletions packages/material-web/src/components/Accordion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import MuiAccordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import PropTypes from "prop-types";

export default function Accordion({
summary,
children,
open,
onToggle,
...rest
}) {
let handleToggle;
if (onToggle) {
handleToggle = (evt, state) => onToggle(state);
}
return (
<MuiAccordion expanded={open} onChange={handleToggle} {...rest}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
{summary}
</AccordionSummary>
<AccordionDetails>
<div style={{ flex: 1 }}>{children}</div>
</AccordionDetails>
</MuiAccordion>
);
}

Accordion.propTypes = {
summary: PropTypes.node,
children: PropTypes.node,
open: PropTypes.bool,
onToggle: PropTypes.func,
};
25 changes: 11 additions & 14 deletions packages/material-web/src/components/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import React from "react";
import Paper from "@mui/material/Paper";
import MuiBreadcrumbs from "@mui/material/Breadcrumbs";
import NavigateNextIcon from "@mui/icons-material/NavigateNext";

import Paper from "@material-ui/core/Paper";
import MuiBreadcrumbs from "@material-ui/core/Breadcrumbs";
import NavigateNextIcon from "@material-ui/icons/NavigateNext";

import { makeStyles } from "@material-ui/core/styles";
import { useReverse, useComponents } from "@wq/react";

import PropTypes from "prop-types";

const useStyles = makeStyles((theme) => ({
breadcrumbs: {
padding: theme.spacing(1, 0),
borderBottom: `1px solid ${theme.palette.divider}`,
},
}));

export default function Breadcrumbs({ links }) {
const reverse = useReverse(),
classes = useStyles(),
{ ButtonLink, HomeLink } = useComponents();

if (!links) {
Expand All @@ -29,7 +19,14 @@ export default function Breadcrumbs({ links }) {
links[links.length - 1].active = true;

return (
<Paper elevation={0} className={classes.breadcrumbs} square>
<Paper
elevation={0}
square
sx={{
py: 1,
borderBottomColor: "divider",
}}
>
<MuiBreadcrumbs separator={<NavigateNextIcon fontSize="small" />}>
<HomeLink
to={links[0].url}
Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/Button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import MuiButton from "@material-ui/core/Button";
import MuiButton from "@mui/material/Button";
import { useIcon } from "@wq/react";
import PropTypes from "prop-types";

Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/CheckboxButton.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Checkbox from "@material-ui/core/Checkbox";
import Checkbox from "@mui/material/Checkbox";

export default Checkbox;
2 changes: 1 addition & 1 deletion packages/material-web/src/components/Chip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import MuiChip from "@material-ui/core/Chip";
import MuiChip from "@mui/material/Chip";
import { useIcon } from "@wq/react";
import PropTypes from "prop-types";

Expand Down
23 changes: 12 additions & 11 deletions packages/material-web/src/components/Container.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from "react";
import Box from "@mui/material/Box";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";

const useStyles = makeStyles(() => ({
container: {
display: "flex",
flexDirection: "column",
height: "100vh",
},
}));

export default function Container({ children }) {
const classes = useStyles();
return <div className={classes.container}>{children}</div>;
return (
<Box
sx={{
display: "flex",
flexDirection: "column",
height: "100vh",
}}
>
{children}
</Box>
);
}
Container.propTypes = {
children: PropTypes.node,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/Divider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Divider from "@material-ui/core/Divider";
import Divider from "@mui/material/Divider";

export default Divider;
2 changes: 1 addition & 1 deletion packages/material-web/src/components/ExpandableListItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { useComponents } from "@wq/react";
import Collapse from "@material-ui/core/Collapse";
import Collapse from "@mui/material/Collapse";
import PropTypes from "prop-types";

export default function ExpandableListItem({
Expand Down
36 changes: 0 additions & 36 deletions packages/material-web/src/components/ExpansionPanel.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/material-web/src/components/Fab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import MuiFab from "@material-ui/core/Fab";
import MuiFab from "@mui/material/Fab";
import { Link } from "@wq/react";
import PropTypes from "prop-types";
import { useIcon } from "@wq/react";
Expand Down
16 changes: 4 additions & 12 deletions packages/material-web/src/components/Fieldset.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import React from "react";
import Card from "@material-ui/core/Card";
import Typography from "@material-ui/core/Typography";
import CardContent from "@material-ui/core/CardContent";
import { makeStyles } from "@material-ui/core/styles";
import Card from "@mui/material/Card";
import Typography from "@mui/material/Typography";
import CardContent from "@mui/material/CardContent";
import PropTypes from "prop-types";

const useStyles = makeStyles({
card: {
marginBottom: "1em",
},
});

export default function Fieldset({ label, children }) {
const classes = useStyles();
return (
<Card className={classes.card}>
<Card sx={{ mb: 2 }}>
<CardContent>
{label && (
<Typography color="textSecondary">{label}</Typography>
Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/FileArray.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo, useCallback, useRef } from "react";
import { useField } from "formik";
import { DropzoneArea } from "../vendor/material-ui-dropzone.js";
import { DropzoneArea } from "mui-file-dropzone";
import Fieldset from "./Fieldset";
import HelperText from "../inputs/HelperText";
import PropTypes from "prop-types";
Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/FlatFieldset.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import Typography from "@material-ui/core/Typography";
import Typography from "@mui/material/Typography";
import PropTypes from "prop-types";

export default function FlatFieldset({ label, children }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-web/src/components/FormError.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useField } from "formik";
import FormHelperText from "@material-ui/core/FormHelperText";
import FormHelperText from "@mui/material/FormHelperText";

export default function FormError(props) {
const [, { error }] = useField("__other__");
Expand Down
6 changes: 3 additions & 3 deletions packages/material-web/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
import Typography from "@material-ui/core/Typography";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import Typography from "@mui/material/Typography";
import { useSiteTitle, useBreadcrumbs, useComponents } from "@wq/react";

export default function Header() {
Expand Down
14 changes: 3 additions & 11 deletions packages/material-web/src/components/HomeLink.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import React from "react";
import { Link } from "@wq/react";
import Button from "@material-ui/core/Button";
import HomeIcon from "@material-ui/icons/Home";
import { makeStyles } from "@material-ui/core/styles";
import Button from "@mui/material/Button";
import HomeIcon from "@mui/icons-material/Home";
import PropTypes from "prop-types";

const useStyles = makeStyles(() => ({
icon: {
verticalAlign: "middle",
},
}));

export default function HomeLink({ to, label, active, ...rest }) {
const styles = useStyles();
return (
<Button
component={Link}
Expand All @@ -21,7 +13,7 @@ export default function HomeLink({ to, label, active, ...rest }) {
aria-label={label}
{...rest}
>
<HomeIcon className={styles.icon} />
<HomeIcon sx={{ verticalAlign: "middle" }} />
</Button>
);
}
Expand Down
Loading

0 comments on commit 9f9515c

Please sign in to comment.