muffin-admin 9.4.5 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MuffinAdmin.d.ts +1 -1
- package/dist/MuffinAdmin.js +15 -2
- package/dist/MuffinMenu.js +8 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/themes.d.ts +3 -0
- package/dist/themes.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/MuffinAdmin.tsx +6 -3
- package/src/MuffinMenu.tsx +14 -2
- package/src/index.tsx +1 -1
- package/src/themes.ts +35 -0
package/package.json
CHANGED
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -20,9 +20,14 @@ import { useEffect } from "react"
|
|
|
20
20
|
import { ConfirmationProvider } from "./common"
|
|
21
21
|
import { useMuffinAdminOpts } from "./hooks"
|
|
22
22
|
import { buildProvider, muffinTranslations } from "./i18n"
|
|
23
|
+
import { muffinDarkTheme, muffinLightTheme } from "./themes"
|
|
23
24
|
import { buildAdmin, deepMerge, findBuilder, findIcon, setupAdmin } from "./utils"
|
|
24
25
|
|
|
25
|
-
export function MuffinAdmin(
|
|
26
|
+
export function MuffinAdmin({
|
|
27
|
+
lightTheme = muffinLightTheme,
|
|
28
|
+
darkTheme = muffinDarkTheme,
|
|
29
|
+
...props
|
|
30
|
+
}: AdminProps) {
|
|
26
31
|
const opts = useMuffinAdminOpts()
|
|
27
32
|
const { resources = [], auth, adminProps, apiUrl, locales: backendLocales } = opts
|
|
28
33
|
|
|
@@ -57,8 +62,6 @@ export function MuffinAdmin(props: AdminProps) {
|
|
|
57
62
|
store = localStorageStore(),
|
|
58
63
|
ready,
|
|
59
64
|
theme,
|
|
60
|
-
lightTheme,
|
|
61
|
-
darkTheme,
|
|
62
65
|
defaultTheme,
|
|
63
66
|
title = "React Admin",
|
|
64
67
|
} = props
|
package/src/MuffinMenu.tsx
CHANGED
|
@@ -4,8 +4,9 @@ import Collapse from "@mui/material/Collapse"
|
|
|
4
4
|
import ListItemButton from "@mui/material/ListItemButton"
|
|
5
5
|
import ListItemIcon from "@mui/material/ListItemIcon"
|
|
6
6
|
import ListItemText from "@mui/material/ListItemText"
|
|
7
|
+
import { matchPath, useLocation } from "react-router-dom"
|
|
7
8
|
|
|
8
|
-
import { Menu, MenuProps, useTranslate } from "react-admin"
|
|
9
|
+
import { Menu, MenuProps, useBasename, useTranslate } from "react-admin"
|
|
9
10
|
|
|
10
11
|
import find from "lodash/find"
|
|
11
12
|
import groupBy from "lodash/groupBy"
|
|
@@ -43,7 +44,18 @@ function MenuGroup({ name, resources }: { name: string; resources: AdminResource
|
|
|
43
44
|
const iconRes = find(resources, "icon")
|
|
44
45
|
const Icon = iconRes ? findIcon(iconRes.icon) : null
|
|
45
46
|
const translate = useTranslate()
|
|
46
|
-
const
|
|
47
|
+
const basename = useBasename()
|
|
48
|
+
const { pathname } = useLocation()
|
|
49
|
+
const match = resources.some(
|
|
50
|
+
(resource) =>
|
|
51
|
+
!!matchPath(
|
|
52
|
+
{
|
|
53
|
+
path: `${basename}/${resource.name}/*`,
|
|
54
|
+
},
|
|
55
|
+
pathname
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
const [groupOpen, setGroupOpen] = useState(match)
|
|
47
59
|
|
|
48
60
|
return (
|
|
49
61
|
<div>
|
package/src/index.tsx
CHANGED
package/src/themes.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defaultDarkTheme, defaultLightTheme } from "react-admin"
|
|
2
|
+
|
|
3
|
+
export const muffinLightTheme: typeof defaultLightTheme = {
|
|
4
|
+
...defaultLightTheme,
|
|
5
|
+
components: {
|
|
6
|
+
...defaultLightTheme.components,
|
|
7
|
+
RaMenuItemLink: {
|
|
8
|
+
styleOverrides: {
|
|
9
|
+
root: {
|
|
10
|
+
"&.RaMenuItemLink-active": {
|
|
11
|
+
backgroundColor: "#f0f0f0",
|
|
12
|
+
borderRadius: "4px",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const muffinDarkTheme: typeof defaultDarkTheme = {
|
|
21
|
+
...defaultDarkTheme,
|
|
22
|
+
components: {
|
|
23
|
+
...defaultDarkTheme.components,
|
|
24
|
+
RaMenuItemLink: {
|
|
25
|
+
styleOverrides: {
|
|
26
|
+
root: {
|
|
27
|
+
"&.RaMenuItemLink-active": {
|
|
28
|
+
backgroundColor: "#424242",
|
|
29
|
+
borderRadius: "4px",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|