Skip to content

Commit 7a95175

Browse files
committed
update deps; support context-only Root
1 parent 2569553 commit 7a95175

20 files changed

Lines changed: 873 additions & 1354 deletions

File tree

package-lock.json

Lines changed: 751 additions & 1294 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/material-native/src/Root.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from "react";
2-
import { useConfig, withWQ } from "@wq/react";
2+
import { withWQ } from "@wq/react";
33
import {
44
MD2LightTheme,
55
MD3LightTheme,
@@ -18,37 +18,45 @@ const THEMES = {
1818
"dark-3": MD3DarkTheme,
1919
};
2020

21-
const defaultConfig = {
22-
material: {
23-
theme: {
24-
primary: "#7500ae",
25-
secondary: "#0088bd",
26-
},
27-
},
21+
const defaultTheme = {
22+
type: "light",
23+
version: 3,
24+
primary: "#7500ae",
25+
secondary: "#0088bd",
2826
};
2927

30-
function Root({ children }) {
31-
const { material: { theme: configTheme } = {} } = useConfig(),
32-
theme = useMemo(() => createTheme(configTheme), [configTheme]);
33-
return <PaperProvider theme={theme}>{children}</PaperProvider>;
28+
function Root({ children, theme }) {
29+
if (theme) {
30+
return <ThemeRoot theme={theme}>{children}</ThemeRoot>;
31+
} else {
32+
return children || null;
33+
}
34+
}
35+
36+
function ThemeRoot({ children, theme }) {
37+
const paperTheme = useMemo(() => createTheme(theme), [theme]);
38+
return <PaperProvider theme={paperTheme}>{children}</PaperProvider>;
3439
}
3540

3641
export default withWQ(Root, {
3742
defaults: {
38-
config: defaultConfig,
3943
components: { ...components, useMinWidth },
40-
icons: { ...icons, List: icons.ListIcon },
44+
icons: { ...icons, List: icons.ListIcon, Menu: icons.MenuIcon },
4145
},
4246
});
4347

44-
function createTheme({
45-
type = "light",
46-
version = 3,
47-
primary,
48-
secondary,
49-
background,
50-
}) {
51-
const colors = {},
48+
function createTheme(theme) {
49+
if (theme === true) {
50+
theme = defaultTheme;
51+
}
52+
const {
53+
type = "light",
54+
version = 3,
55+
primary,
56+
secondary,
57+
background,
58+
} = theme || {},
59+
colors = {},
5260
base = THEMES[`${type}-${version}`];
5361
if (!base) {
5462
console.warn(`Unknown base theme type=${type} version=${version}`);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function NotImplemented() {
2+
return null; // FIXME
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function NotImplemented() {
2+
return null; // FIXME
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function NotImplemented() {
2+
return null; // FIXME
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function NotImplemented() {
2+
return null; // FIXME
3+
}

packages/material-native/src/components/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ import SidePanel from "./SidePanel.js";
5050
import Breadcrumbs from "./Breadcrumbs.js";
5151
import Pagination from "./Pagination.js";
5252

53+
import Badge from "./Badge.js";
54+
import Grid from "./Grid.js";
55+
import Menu from "./Menu.js";
56+
import MenuItem from "./MenuItem.js";
57+
5358
export {
5459
Container,
5560
Header,
@@ -106,3 +111,5 @@ export {
106111
};
107112

108113
export { Popup, SidePanel, Breadcrumbs, Pagination };
114+
115+
export { Badge, Grid, Menu, MenuItem };

packages/material-native/src/icons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Add = "plus",
1818
Map = "map",
1919
Home = "home",
2020
BreadcrumbSeparator = "chevron-right",
21-
Menu = "menu",
21+
MenuIcon = "menu",
2222
Login = "login",
2323
Logout = "logout",
2424
Config = "cog",

packages/material-web/package.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@
2929
},
3030
"homepage": "https://wq.io/@wq/material",
3131
"dependencies": {
32-
"@emotion/react": "^11.11.1",
33-
"@emotion/styled": "^11.11.0",
34-
"@mui/icons-material": "^5.11.16",
35-
"@mui/material": "^5.13.5",
36-
"@wq/react": "file:../react"
32+
"@wq/react": "^3.0.0-a1-dev4.g2569553"
33+
},
34+
"peerDependencies": {
35+
"@emotion/react": "*",
36+
"@emotion/styled": "*",
37+
"@mui/icons-material": "*",
38+
"@mui/material": "*",
39+
"react": "*",
40+
"react-dom": "*"
3741
},
3842
"devDependencies": {
39-
"react": "^18.2.0",
40-
"react-dom": "^18.2.0"
43+
"@emotion/react": "^11.14.0",
44+
"@emotion/styled": "^11.14.0",
45+
"@mui/icons-material": "^6.4.7",
46+
"@mui/material": "^6.4.7",
47+
"react": "^19.0.0",
48+
"react-dom": "^19.0.0"
4149
}
4250
}

packages/material-web/src/Root.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from "react";
2-
import { useConfig, withWQ } from "@wq/react";
2+
import { withWQ } from "@wq/react";
33
import {
44
createTheme as createMuiTheme,
55
ThemeProvider,
@@ -9,20 +9,21 @@ import * as components from "./components/index.js";
99
import { useMinWidth } from "./hooks.js";
1010
import * as icons from "./icons.js";
1111

12-
const defaultConfig = {
13-
material: {
14-
theme: {
15-
primary: "#7500ae",
16-
secondary: "#0088bd",
17-
},
18-
},
12+
const defaultTheme = {
13+
primary: "#7500ae",
14+
secondary: "#0088bd",
1915
};
2016

21-
function Root({ children }) {
22-
const {
23-
material: { theme },
24-
} = useConfig(),
25-
muiTheme = useMemo(() => createTheme(theme), [theme]);
17+
function Root({ children, theme }) {
18+
if (theme) {
19+
return <ThemeRoot theme={theme}>{children}</ThemeRoot>;
20+
} else {
21+
return children || null;
22+
}
23+
}
24+
25+
function ThemeRoot({ children, theme }) {
26+
const muiTheme = useMemo(() => createTheme(theme), [theme]);
2627
return (
2728
<ThemeProvider theme={muiTheme}>
2829
<CssBaseline />
@@ -33,16 +34,19 @@ function Root({ children }) {
3334

3435
export default withWQ(Root, {
3536
defaults: {
36-
config: defaultConfig,
3737
components: { ...components, useMinWidth },
3838
icons: {
3939
...icons,
4040
List: icons.ListIcon,
41+
Menu: icons.MenuIcon,
4142
},
4243
},
4344
});
4445

4546
function createTheme(theme) {
47+
if (theme === true) {
48+
theme = defaultTheme;
49+
}
4650
const { type, primary, secondary, background } = theme;
4751
const palette = theme.palette || {};
4852
if (type) {

0 commit comments

Comments
 (0)