payload-advanced-sidebar 1.1.5 → 1.3.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/components/Nav/Nav.client.js +41 -7
- package/dist/components/Nav/Nav.client.js.map +1 -1
- package/dist/components/Nav/Nav.js +70 -42
- package/dist/components/Nav/Nav.js.map +1 -1
- package/dist/components/Nav/NavWithGroups.js +1 -1
- package/dist/components/Nav/NavWithGroups.js.map +1 -1
- package/dist/components/Nav/get-nav-icon.js +11 -8
- package/dist/components/Nav/get-nav-icon.js.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/rsc.js +2 -2
- package/dist/exports/rsc.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Nav/Nav.scss +0 -82
|
@@ -4,11 +4,10 @@ import { getTranslation } from '@payloadcms/translations';
|
|
|
4
4
|
import { Link, useConfig, useTranslation } from '@payloadcms/ui';
|
|
5
5
|
import { EntityType, formatAdminURL } from '@payloadcms/ui/shared';
|
|
6
6
|
import { ChevronDown, ChevronRight, Home } from 'lucide-react';
|
|
7
|
-
import { useEffect, useState } from 'react';
|
|
8
|
-
// @ts-ignore
|
|
9
7
|
import { usePathname } from 'next/navigation';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
|
+
import { getNavIcon } from './get-nav-icon';
|
|
10
|
+
import { getActiveGroup, getSortedGroups } from './nav-utils';
|
|
12
11
|
const baseClass = 'nav';
|
|
13
12
|
let persistedOpenGroups = [];
|
|
14
13
|
export const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig })=>{
|
|
@@ -68,8 +67,41 @@ export const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig
|
|
|
68
67
|
})
|
|
69
68
|
}),
|
|
70
69
|
sortedGroups.map(({ entities, label: groupLabel }, key)=>{
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
if (!groupLabel) {
|
|
71
|
+
return /*#__PURE__*/ _jsx(React.Fragment, {
|
|
72
|
+
children: entities.map(({ slug, type, label, path })=>{
|
|
73
|
+
let href = null;
|
|
74
|
+
if (type === EntityType.collection) {
|
|
75
|
+
href = formatAdminURL({
|
|
76
|
+
adminRoute,
|
|
77
|
+
path: `/collections/${slug}`
|
|
78
|
+
});
|
|
79
|
+
} else if (type === EntityType.global) {
|
|
80
|
+
href = formatAdminURL({
|
|
81
|
+
adminRoute,
|
|
82
|
+
path: `/globals/${slug}`
|
|
83
|
+
});
|
|
84
|
+
} else if (type === 'custom') {
|
|
85
|
+
href = path.startsWith('/') && !path.startsWith(adminRoute) ? `${adminRoute}${path}` : path;
|
|
86
|
+
}
|
|
87
|
+
const ItemIcon = getNavIcon(slug, itemsConfig);
|
|
88
|
+
return /*#__PURE__*/ _jsx("li", {
|
|
89
|
+
className: "group",
|
|
90
|
+
children: /*#__PURE__*/ _jsxs(Link, {
|
|
91
|
+
className: `${baseClass}__link group-toggle ${pathname === href ? 'active' : ''}`,
|
|
92
|
+
href: href || '',
|
|
93
|
+
children: [
|
|
94
|
+
ItemIcon && /*#__PURE__*/ _jsx(ItemIcon, {
|
|
95
|
+
size: 16
|
|
96
|
+
}),
|
|
97
|
+
getTranslation(label, i18n)
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
}, slug);
|
|
101
|
+
})
|
|
102
|
+
}, key);
|
|
103
|
+
}
|
|
104
|
+
const Icon = getNavIcon(groupLabel, groupsConfig);
|
|
73
105
|
const isOpen = openGroups.includes(groupLabel);
|
|
74
106
|
const ChevronIcon = !animations && isOpen ? ChevronDown : ChevronRight;
|
|
75
107
|
return /*#__PURE__*/ _jsxs("li", {
|
|
@@ -107,7 +139,7 @@ export const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig
|
|
|
107
139
|
className: `sub-group-wrapper ${isOpen ? 'open' : ''} ${animations ? 'animated' : ''}`,
|
|
108
140
|
children: /*#__PURE__*/ _jsx("div", {
|
|
109
141
|
className: "sub-group-inner",
|
|
110
|
-
children: entities.map(({ slug, type, label })=>{
|
|
142
|
+
children: entities.map(({ slug, type, label, path })=>{
|
|
111
143
|
let href = null;
|
|
112
144
|
if (type === EntityType.collection) {
|
|
113
145
|
href = formatAdminURL({
|
|
@@ -119,6 +151,8 @@ export const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig
|
|
|
119
151
|
adminRoute,
|
|
120
152
|
path: `/globals/${slug}`
|
|
121
153
|
});
|
|
154
|
+
} else if (type === 'custom') {
|
|
155
|
+
href = path.startsWith('/') && !path.startsWith(adminRoute) ? `${adminRoute}${path}` : path;
|
|
122
156
|
}
|
|
123
157
|
const ItemIcon = getNavIcon(slug, itemsConfig);
|
|
124
158
|
return /*#__PURE__*/ _jsx(Link, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Nav/Nav.client.tsx"],"sourcesContent":["'use client'\n\nimport type { NavGroupType } from '@payloadcms/ui/shared'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link, useConfig, useTranslation } from '@payloadcms/ui'\nimport { EntityType, formatAdminURL } from '@payloadcms/ui/shared'\nimport { ChevronDown, ChevronRight, Home } from 'lucide-react'\nimport { useEffect, useState } from 'react'\n// @ts-ignore\nimport { usePathname } from 'next/navigation'\n\nimport { getNavIcon } from './get-nav-icon.js'\nimport { getActiveGroup, getSortedGroups } from './nav-utils.js'\n\ntype NavProps = {\n animations?: boolean\n groups: NavGroupType[]\n groupsConfig?: Record<string, { icon?: string }>\n itemsConfig?: Record<string, { icon?: string }>\n}\n\nconst baseClass = 'nav'\n\nlet persistedOpenGroups: string[] = []\n\nexport const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig }: NavProps) => {\n const pathname = usePathname()\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n const { i18n } = useTranslation()\n\n const activeGroupSlug = getActiveGroup(pathname, adminRoute)\n const sortedGroups = getSortedGroups(groups)\n\n const [openGroups, setOpenGroups] = useState<string[]>(() => {\n const initialGroups = [...persistedOpenGroups]\n const activeNavGroup = sortedGroups.find((g) =>\n g.entities.some((e) => e.slug === activeGroupSlug),\n )\n\n if (activeNavGroup && !initialGroups.includes(activeNavGroup.label)) {\n initialGroups.push(activeNavGroup.label)\n }\n\n return initialGroups\n })\n\n useEffect(() => {\n persistedOpenGroups = openGroups\n }, [openGroups])\n\n useEffect(() => {\n const activeNavGroup = sortedGroups.find((g) =>\n g.entities.some((e) => e.slug === activeGroupSlug),\n )\n if (activeNavGroup && !openGroups.includes(activeNavGroup.label)) {\n setOpenGroups((prev) => [...prev, activeNavGroup.label])\n }\n }, [activeGroupSlug, sortedGroups, openGroups])\n\n const toggleGroup = (label: string) => {\n setOpenGroups((prev) =>\n prev.includes(label) ? prev.filter((g) => g !== label) : [...prev, label],\n )\n }\n\n return (\n <div className=\"menu\">\n <li className=\"group\">\n <Link\n className={`${baseClass}__link group-toggle ${pathname === adminRoute ? 'active' : ''}`}\n href={adminRoute}\n >\n <Home size={16} />\n {'Home'}\n </Link>\n </li>\n {sortedGroups.map(({ entities, label: groupLabel }: NavGroupType, key: number) => {\n const groupSlug = groupLabel.toLowerCase()\n const Icon = getNavIcon(groupSlug, groupsConfig)\n const isOpen = openGroups.includes(groupLabel)\n const ChevronIcon = !animations && isOpen ? ChevronDown : ChevronRight\n\n return (\n <li className=\"group\" key={key}>\n <div\n className={`${baseClass}__link group-toggle`}\n onClick={() => toggleGroup(groupLabel)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleGroup(groupLabel)\n }\n }}\n role=\"button\"\n style={{ cursor: 'pointer' }}\n tabIndex={0}\n >\n {Icon && <Icon size={16} />}\n {getTranslation(groupLabel, i18n)}\n <div className=\"group-chevron\">\n <ChevronIcon\n className={animations ? `chevron animated ${isOpen ? 'open' : ''}` : undefined}\n size={16}\n />\n </div>\n </div>\n <div\n className={`sub-group-wrapper ${isOpen ? 'open' : ''} ${animations ? 'animated' : ''}`}\n >\n <div className=\"sub-group-inner\">\n {entities.map(({ slug, type, label }: any) => {\n let href: null | string = null\n if (type === EntityType.collection) {\n href = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}`,\n })\n } else if (type === EntityType.global) {\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n })\n }\n const ItemIcon = getNavIcon(slug, itemsConfig)\n\n return (\n <Link\n className={`${baseClass}__link sub-group-list ${pathname === href ? 'active' : ''}`}\n href={href || ''}\n key={slug}\n tabIndex={isOpen ? 0 : -1}\n >\n <div style={{ alignItems: 'center', display: 'flex', gap: '6px' }}>\n {ItemIcon && <ItemIcon size={14} />}\n {getTranslation(label, i18n)}\n </div>\n </Link>\n )\n })}\n </div>\n </div>\n </li>\n )\n })}\n </div>\n )\n}\n"],"names":["getTranslation","Link","useConfig","useTranslation","EntityType","formatAdminURL","ChevronDown","ChevronRight","Home","useEffect","useState","usePathname","getNavIcon","getActiveGroup","getSortedGroups","baseClass","persistedOpenGroups","NavClient","animations","groups","groupsConfig","itemsConfig","pathname","config","routes","admin","adminRoute","i18n","activeGroupSlug","sortedGroups","openGroups","setOpenGroups","initialGroups","activeNavGroup","find","g","entities","some","e","slug","includes","label","push","prev","toggleGroup","filter","div","className","li","href","size","map","groupLabel","key","groupSlug","toLowerCase","Icon","isOpen","ChevronIcon","onClick","onKeyDown","preventDefault","role","style","cursor","tabIndex","undefined","type","collection","path","global","ItemIcon","alignItems","display","gap"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,IAAI,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,UAAU,EAAEC,cAAc,QAAQ,wBAAuB;AAClE,SAASC,WAAW,EAAEC,YAAY,EAAEC,IAAI,QAAQ,eAAc;AAC9D,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,aAAa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C4B;gCAAIC,WAAU;0CACZX,SAASe,GAAG,CAAC,CAAC,EAAEZ,IAAI,EAAE4B,IAAI,EAAE1B,KAAK,EAAO;oCACvC,IAAIQ,OAAsB;oCAC1B,IAAIkB,SAAS/D,WAAWgE,UAAU,EAAE;wCAClCnB,OAAO5C,eAAe;4CACpBqB;4CACA2C,MAAM,CAAC,aAAa,EAAE9B,MAAM;wCAC9B;oCACF,OAAO,IAAI4B,SAAS/D,WAAWkE,MAAM,EAAE;wCACrCrB,OAAO5C,eAAe;4CACpBqB;4CACA2C,MAAM,CAAC,SAAS,EAAE9B,MAAM;wCAC1B;oCACF;oCACA,MAAMgC,WAAW3D,WAAW2B,MAAMlB;oCAElC,qBACE,KAACpB;wCACC8C,WAAW,GAAGhC,UAAU,sBAAsB,EAAEO,aAAa2B,OAAO,WAAW,IAAI;wCACnFA,MAAMA,QAAQ;wCAEdgB,UAAUR,SAAS,IAAI,CAAC;kDAExB,cAAA,MAACX;4CAAIiB,OAAO;gDAAES,YAAY;gDAAUC,SAAS;gDAAQC,KAAK;4CAAM;;gDAC7DH,0BAAY,KAACA;oDAASrB,MAAM;;gDAC5BlD,eAAeyC,OAAOd;;;uCALpBY;gCASX;;;;mBAvDqBc;YA4D/B;;;AAGN,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/Nav.client.tsx"],"sourcesContent":["'use client'\n\nimport type { NavGroupType } from '@payloadcms/ui/shared'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link, useConfig, useTranslation } from '@payloadcms/ui'\nimport { EntityType, formatAdminURL } from '@payloadcms/ui/shared'\nimport { ChevronDown, ChevronRight, Home } from 'lucide-react'\nimport { usePathname } from 'next/navigation'\nimport React, { useEffect, useState } from 'react'\n\nimport { getNavIcon } from './get-nav-icon'\nimport { getActiveGroup, getSortedGroups } from './nav-utils'\n\ntype NavProps = {\n animations?: boolean\n groups: NavGroupType[]\n groupsConfig?: Record<string, { icon?: string }>\n itemsConfig?: Record<string, { icon?: string }>\n}\n\nconst baseClass = 'nav'\n\nlet persistedOpenGroups: string[] = []\n\nexport const NavClient = ({ animations = true, groups, groupsConfig, itemsConfig }: NavProps) => {\n const pathname = usePathname()\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n const { i18n } = useTranslation()\n\n const activeGroupSlug = getActiveGroup(pathname, adminRoute)\n const sortedGroups = getSortedGroups(groups)\n\n const [openGroups, setOpenGroups] = useState<string[]>(() => {\n const initialGroups = [...persistedOpenGroups]\n const activeNavGroup = sortedGroups.find((g) =>\n g.entities.some((e) => e.slug === activeGroupSlug),\n )\n\n if (activeNavGroup && !initialGroups.includes(activeNavGroup.label)) {\n initialGroups.push(activeNavGroup.label)\n }\n\n return initialGroups\n })\n\n useEffect(() => {\n persistedOpenGroups = openGroups\n }, [openGroups])\n\n useEffect(() => {\n const activeNavGroup = sortedGroups.find((g) =>\n g.entities.some((e) => e.slug === activeGroupSlug),\n )\n if (activeNavGroup && !openGroups.includes(activeNavGroup.label)) {\n setOpenGroups((prev) => [...prev, activeNavGroup.label])\n }\n }, [activeGroupSlug, sortedGroups, openGroups])\n\n const toggleGroup = (label: string) => {\n setOpenGroups((prev) =>\n prev.includes(label) ? prev.filter((g) => g !== label) : [...prev, label],\n )\n }\n\n return (\n <div className=\"menu\">\n <li className=\"group\">\n <Link\n className={`${baseClass}__link group-toggle ${pathname === adminRoute ? 'active' : ''}`}\n href={adminRoute}\n >\n <Home size={16} />\n {'Home'}\n </Link>\n </li>\n {sortedGroups.map(({ entities, label: groupLabel }: NavGroupType, key: number) => {\n if (!groupLabel) {\n return (\n <React.Fragment key={key}>\n {entities.map(({ slug, type, label, path }: any) => {\n let href: null | string = null\n if (type === EntityType.collection) {\n href = formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n } else if (type === EntityType.global) {\n href = formatAdminURL({ adminRoute, path: `/globals/${slug}` })\n } else if (type === 'custom') {\n href =\n path.startsWith('/') && !path.startsWith(adminRoute)\n ? `${adminRoute}${path}`\n : path\n }\n const ItemIcon = getNavIcon(slug, itemsConfig)\n\n return (\n <li className=\"group\" key={slug}>\n <Link\n className={`${baseClass}__link group-toggle ${pathname === href ? 'active' : ''}`}\n href={href || ''}\n >\n {ItemIcon && <ItemIcon size={16} />}\n {getTranslation(label, i18n)}\n </Link>\n </li>\n )\n })}\n </React.Fragment>\n )\n }\n\n const Icon = getNavIcon(groupLabel, groupsConfig)\n const isOpen = openGroups.includes(groupLabel)\n const ChevronIcon = !animations && isOpen ? ChevronDown : ChevronRight\n\n return (\n <li className=\"group\" key={key}>\n <div\n className={`${baseClass}__link group-toggle`}\n onClick={() => toggleGroup(groupLabel)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleGroup(groupLabel)\n }\n }}\n role=\"button\"\n style={{ cursor: 'pointer' }}\n tabIndex={0}\n >\n {Icon && <Icon size={16} />}\n {getTranslation(groupLabel, i18n)}\n <div className=\"group-chevron\">\n <ChevronIcon\n className={animations ? `chevron animated ${isOpen ? 'open' : ''}` : undefined}\n size={16}\n />\n </div>\n </div>\n <div\n className={`sub-group-wrapper ${isOpen ? 'open' : ''} ${animations ? 'animated' : ''}`}\n >\n <div className=\"sub-group-inner\">\n {entities.map(({ slug, type, label, path }: any) => {\n let href: null | string = null\n if (type === EntityType.collection) {\n href = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}`,\n })\n } else if (type === EntityType.global) {\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n })\n } else if (type === 'custom') {\n href =\n path.startsWith('/') && !path.startsWith(adminRoute)\n ? `${adminRoute}${path}`\n : path\n }\n const ItemIcon = getNavIcon(slug, itemsConfig)\n\n return (\n <Link\n className={`${baseClass}__link sub-group-list ${pathname === href ? 'active' : ''}`}\n href={href || ''}\n key={slug}\n tabIndex={isOpen ? 0 : -1}\n >\n <div style={{ alignItems: 'center', display: 'flex', gap: '6px' }}>\n {ItemIcon && <ItemIcon size={14} />}\n {getTranslation(label, i18n)}\n </div>\n </Link>\n )\n })}\n </div>\n </div>\n </li>\n )\n })}\n </div>\n )\n}\n"],"names":["getTranslation","Link","useConfig","useTranslation","EntityType","formatAdminURL","ChevronDown","ChevronRight","Home","usePathname","React","useEffect","useState","getNavIcon","getActiveGroup","getSortedGroups","baseClass","persistedOpenGroups","NavClient","animations","groups","groupsConfig","itemsConfig","pathname","config","routes","admin","adminRoute","i18n","activeGroupSlug","sortedGroups","openGroups","setOpenGroups","initialGroups","activeNavGroup","find","g","entities","some","e","slug","includes","label","push","prev","toggleGroup","filter","div","className","li","href","size","map","groupLabel","key","Fragment","type","path","collection","global","startsWith","ItemIcon","Icon","isOpen","ChevronIcon","onClick","onKeyDown","preventDefault","role","style","cursor","tabIndex","undefined","alignItems","display","gap"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,IAAI,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,UAAU,EAAEC,cAAc,QAAQ,wBAAuB;AAClE,SAASC,WAAW,EAAEC,YAAY,EAAEC,IAAI,QAAQ,eAAc;AAC9D,SAASC,WAAW,QAAQ,kBAAiB;AAC7C,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,SAASC,UAAU,QAAQ,iBAAgB;AAC3C,SAASC,cAAc,EAAEC,eAAe,QAAQ,cAAa;AAS7D,MAAMC,YAAY;AAElB,IAAIC,sBAAgC,EAAE;AAEtC,OAAO,MAAMC,YAAY,CAAC,EAAEC,aAAa,IAAI,EAAEC,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAY;IAC1F,MAAMC,WAAWd;IACjB,MAAM,EACJe,QAAQ,EACNC,QAAQ,EAAEC,OAAOC,UAAU,EAAE,EAC9B,EACF,GAAGzB;IACJ,MAAM,EAAE0B,IAAI,EAAE,GAAGzB;IAEjB,MAAM0B,kBAAkBf,eAAeS,UAAUI;IACjD,MAAMG,eAAef,gBAAgBK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AOd;;;uCALpBY;gCASX;;;;mBA5DqBc;YAiE/B;;;AAGN,EAAC"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Logout } from '@payloadcms/ui';
|
|
2
|
+
import { GearIcon, Logout, Popup } from '@payloadcms/ui';
|
|
3
3
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
4
|
import { EntityType, groupNavItems } from '@payloadcms/ui/shared';
|
|
5
|
-
import { NavClient } from './Nav.client
|
|
5
|
+
import { NavClient } from './Nav.client';
|
|
6
6
|
import './Nav.css';
|
|
7
|
-
import { NavWrapper } from './NavWrapper
|
|
7
|
+
import { NavWrapper } from './NavWrapper';
|
|
8
8
|
const baseClass = 'nav';
|
|
9
9
|
const Nav = (props)=>{
|
|
10
|
-
const { animations, documentSubViewType, groupsConfig, i18n, itemsConfig, locale, params, payload, permissions, searchParams, user, viewType, visibleEntities } = props;
|
|
11
|
-
const { admin: { components: { afterNavLinks, beforeNavLinks, logout } }, collections, globals } = payload.config;
|
|
12
|
-
const
|
|
10
|
+
const { animations, documentSubViewType, groupsConfig, i18n, itemsConfig, locale, navLinks, params, payload, permissions, searchParams, user, viewType, visibleEntities } = props;
|
|
11
|
+
const { admin: { components: { afterNav, afterNavLinks, beforeNav, beforeNavLinks, logout, settingsMenu } }, collections, globals } = payload.config;
|
|
12
|
+
const componentProps = {
|
|
13
13
|
clientProps: {
|
|
14
14
|
documentSubViewType,
|
|
15
15
|
viewType
|
|
16
16
|
},
|
|
17
|
-
Component: logout?.Button,
|
|
18
|
-
Fallback: Logout,
|
|
19
17
|
importMap: payload.importMap,
|
|
20
18
|
serverProps: {
|
|
21
19
|
i18n,
|
|
@@ -26,7 +24,7 @@ const Nav = (props)=>{
|
|
|
26
24
|
searchParams,
|
|
27
25
|
user
|
|
28
26
|
}
|
|
29
|
-
}
|
|
27
|
+
};
|
|
30
28
|
const groups = groupNavItems([
|
|
31
29
|
...collections.filter(({ slug })=>visibleEntities?.collections.includes(slug)).map((collection)=>({
|
|
32
30
|
type: EntityType.collection,
|
|
@@ -37,52 +35,82 @@ const Nav = (props)=>{
|
|
|
37
35
|
entity: global
|
|
38
36
|
}))
|
|
39
37
|
], permissions, i18n);
|
|
38
|
+
const mergedItemsConfig = {
|
|
39
|
+
...itemsConfig || {}
|
|
40
|
+
};
|
|
41
|
+
if (navLinks && navLinks.length > 0) {
|
|
42
|
+
navLinks.forEach((link)=>{
|
|
43
|
+
const groupLabel = link.group || '';
|
|
44
|
+
let targetGroup = groups.find((g)=>g.label === groupLabel);
|
|
45
|
+
if (!targetGroup) {
|
|
46
|
+
targetGroup = {
|
|
47
|
+
entities: [],
|
|
48
|
+
label: groupLabel
|
|
49
|
+
};
|
|
50
|
+
groups.push(targetGroup);
|
|
51
|
+
}
|
|
52
|
+
const linkSlug = link.slug || link.path;
|
|
53
|
+
targetGroup.entities.push({
|
|
54
|
+
slug: linkSlug,
|
|
55
|
+
type: 'custom',
|
|
56
|
+
label: link.label,
|
|
57
|
+
path: link.path
|
|
58
|
+
});
|
|
59
|
+
if (link.icon) {
|
|
60
|
+
mergedItemsConfig[linkSlug] = {
|
|
61
|
+
icon: link.icon
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
40
66
|
return /*#__PURE__*/ _jsxs(NavWrapper, {
|
|
41
67
|
baseClass: baseClass,
|
|
42
68
|
children: [
|
|
43
69
|
RenderServerComponent({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
serverProps: {
|
|
51
|
-
i18n,
|
|
52
|
-
locale,
|
|
53
|
-
params,
|
|
54
|
-
payload,
|
|
55
|
-
permissions,
|
|
56
|
-
searchParams,
|
|
57
|
-
user
|
|
58
|
-
}
|
|
70
|
+
...componentProps,
|
|
71
|
+
Component: beforeNav
|
|
72
|
+
}),
|
|
73
|
+
RenderServerComponent({
|
|
74
|
+
...componentProps,
|
|
75
|
+
Component: beforeNavLinks
|
|
59
76
|
}),
|
|
60
77
|
/*#__PURE__*/ _jsx(NavClient, {
|
|
61
78
|
animations: animations,
|
|
62
79
|
groups: groups,
|
|
63
80
|
groupsConfig: groupsConfig,
|
|
64
|
-
itemsConfig:
|
|
81
|
+
itemsConfig: mergedItemsConfig
|
|
65
82
|
}),
|
|
66
83
|
RenderServerComponent({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
viewType
|
|
70
|
-
},
|
|
71
|
-
Component: afterNavLinks,
|
|
72
|
-
importMap: payload.importMap,
|
|
73
|
-
serverProps: {
|
|
74
|
-
i18n,
|
|
75
|
-
locale,
|
|
76
|
-
params,
|
|
77
|
-
payload,
|
|
78
|
-
permissions,
|
|
79
|
-
searchParams,
|
|
80
|
-
user
|
|
81
|
-
}
|
|
84
|
+
...componentProps,
|
|
85
|
+
Component: afterNavLinks
|
|
82
86
|
}),
|
|
83
|
-
/*#__PURE__*/
|
|
87
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
84
88
|
className: `${baseClass}__controls`,
|
|
85
|
-
children:
|
|
89
|
+
children: [
|
|
90
|
+
!!settingsMenu?.length && /*#__PURE__*/ _jsx(Popup, {
|
|
91
|
+
button: /*#__PURE__*/ _jsx(GearIcon, {
|
|
92
|
+
ariaLabel: i18n.t('general:menu')
|
|
93
|
+
}),
|
|
94
|
+
className: "settings-menu-button",
|
|
95
|
+
horizontalAlign: "left",
|
|
96
|
+
id: "settings-menu",
|
|
97
|
+
size: "small",
|
|
98
|
+
verticalAlign: "bottom",
|
|
99
|
+
children: RenderServerComponent({
|
|
100
|
+
...componentProps,
|
|
101
|
+
Component: settingsMenu
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
RenderServerComponent({
|
|
105
|
+
...componentProps,
|
|
106
|
+
Component: logout?.Button,
|
|
107
|
+
Fallback: Logout
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}),
|
|
111
|
+
RenderServerComponent({
|
|
112
|
+
...componentProps,
|
|
113
|
+
Component: afterNav
|
|
86
114
|
})
|
|
87
115
|
]
|
|
88
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Nav/Nav.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { ServerProps } from 'payload'\n\nimport { Logout } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType, groupNavItems } from '@payloadcms/ui/shared'\n\nimport { NavClient } from './Nav.client
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/Nav.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { ServerProps } from 'payload'\n\nimport { GearIcon, Logout, Popup } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType, groupNavItems } from '@payloadcms/ui/shared'\n\nimport { NavClient } from './Nav.client'\nimport './Nav.css'\nimport { NavWrapper } from './NavWrapper'\n\nconst baseClass = 'nav'\n\nimport type { CustomNavLink } from '../../index'\n\ntype NavProps = {\n animations?: boolean\n groupsConfig?: Record<string, { icon?: string }>\n itemsConfig?: Record<string, { icon?: string }>\n navLinks?: CustomNavLink[]\n} & ServerProps\n\nconst Nav = (props: NavProps) => {\n const {\n animations,\n documentSubViewType,\n groupsConfig,\n i18n,\n itemsConfig,\n locale,\n navLinks,\n params,\n payload,\n permissions,\n searchParams,\n user,\n viewType,\n visibleEntities,\n } = props\n const {\n admin: {\n components: { afterNav, afterNavLinks, beforeNav, beforeNavLinks, logout, settingsMenu },\n },\n collections,\n globals,\n } = payload.config\n const componentProps = {\n clientProps: {\n documentSubViewType,\n viewType,\n },\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n }\n\n const groups = groupNavItems(\n [\n ...collections\n .filter(({ slug }) => visibleEntities?.collections.includes(slug))\n .map(\n (collection) =>\n ({\n type: EntityType.collection,\n entity: collection,\n }) satisfies EntityToGroup,\n ),\n ...globals\n .filter(({ slug }) => visibleEntities?.globals.includes(slug))\n .map(\n (global) =>\n ({\n type: EntityType.global,\n entity: global,\n }) satisfies EntityToGroup,\n ),\n ],\n permissions as any,\n i18n,\n )\n\n const mergedItemsConfig = { ...(itemsConfig || {}) }\n\n if (navLinks && navLinks.length > 0) {\n navLinks.forEach((link) => {\n const groupLabel = link.group || ''\n let targetGroup = groups.find((g) => g.label === groupLabel)\n\n if (!targetGroup) {\n targetGroup = {\n entities: [],\n label: groupLabel,\n }\n groups.push(targetGroup)\n }\n\n const linkSlug = link.slug || link.path\n\n targetGroup.entities.push({\n slug: linkSlug,\n type: 'custom' as any,\n label: link.label,\n path: link.path,\n } as any)\n\n if (link.icon) {\n mergedItemsConfig[linkSlug] = { icon: link.icon }\n }\n })\n }\n\n return (\n <NavWrapper baseClass={baseClass}>\n {RenderServerComponent({ ...componentProps, Component: beforeNav })}\n {RenderServerComponent({ ...componentProps, Component: beforeNavLinks })}\n <NavClient\n animations={animations}\n groups={groups}\n groupsConfig={groupsConfig}\n itemsConfig={mergedItemsConfig}\n />\n {RenderServerComponent({ ...componentProps, Component: afterNavLinks })}\n <div className={`${baseClass}__controls`}>\n {!!settingsMenu?.length && (\n <Popup\n button={<GearIcon ariaLabel={i18n.t('general:menu')} />}\n className=\"settings-menu-button\"\n horizontalAlign=\"left\"\n id=\"settings-menu\"\n size=\"small\"\n verticalAlign=\"bottom\"\n >\n {RenderServerComponent({ ...componentProps, Component: settingsMenu })}\n </Popup>\n )}\n {RenderServerComponent({ ...componentProps, Component: logout?.Button, Fallback: Logout })}\n </div>\n {RenderServerComponent({ ...componentProps, Component: afterNav })}\n </NavWrapper>\n )\n}\n\nexport default Nav\n"],"names":["GearIcon","Logout","Popup","RenderServerComponent","EntityType","groupNavItems","NavClient","NavWrapper","baseClass","Nav","props","animations","documentSubViewType","groupsConfig","i18n","itemsConfig","locale","navLinks","params","payload","permissions","searchParams","user","viewType","visibleEntities","admin","components","afterNav","afterNavLinks","beforeNav","beforeNavLinks","logout","settingsMenu","collections","globals","config","componentProps","clientProps","importMap","serverProps","groups","filter","slug","includes","map","collection","type","entity","global","mergedItemsConfig","length","forEach","link","groupLabel","group","targetGroup","find","g","label","entities","push","linkSlug","path","icon","Component","div","className","button","ariaLabel","t","horizontalAlign","id","size","verticalAlign","Button","Fallback"],"mappings":";AAGA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,iBAAgB;AACxD,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAuB;AAEjE,SAASC,SAAS,QAAQ,eAAc;AACxC,OAAO,YAAW;AAClB,SAASC,UAAU,QAAQ,eAAc;AAEzC,MAAMC,YAAY;AAWlB,MAAMC,MAAM,CAACC;IACX,MAAM,EACJC,UAAU,EACVC,mBAAmB,EACnBC,YAAY,EACZC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,eAAe,EAChB,GAAGd;IACJ,MAAM,EACJe,OAAO,EACLC,YAAY,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,SAAS,EAAEC,cAAc,EAAEC,MAAM,EAAEC,YAAY,EAAE,EACzF,EACDC,WAAW,EACXC,OAAO,EACR,GAAGf,QAAQgB,MAAM;IAClB,MAAMC,iBAAiB;QACrBC,aAAa;YACXzB;YACAW;QACF;QACAe,WAAWnB,QAAQmB,SAAS;QAC5BC,aAAa;YACXzB;YACAE;YACAE;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,MAAMkB,SAASnC,cACb;WACK4B,YACAQ,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKlB,iBAAiBS,YAAYU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iC,cAAc;gBAAE4B,WAAWpC;YAAc;0BACrE,MAACqC;gBAAIC,WAAW,GAAG1D,UAAU,UAAU,CAAC;;oBACrC,CAAC,CAACwB,cAAckB,wBACf,KAAChD;wBACCiE,sBAAQ,KAACnE;4BAASoE,WAAWtD,KAAKuD,CAAC,CAAC;;wBACpCH,WAAU;wBACVI,iBAAgB;wBAChBC,IAAG;wBACHC,MAAK;wBACLC,eAAc;kCAEbtE,sBAAsB;4BAAE,GAAGiC,cAAc;4BAAE4B,WAAWhC;wBAAa;;oBAGvE7B,sBAAsB;wBAAE,GAAGiC,cAAc;wBAAE4B,WAAWjC,QAAQ2C;wBAAQC,UAAU1E;oBAAO;;;YAEzFE,sBAAsB;gBAAE,GAAGiC,cAAc;gBAAE4B,WAAWrC;YAAS;;;AAGtE;AAEA,eAAelB,IAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Nav/NavWithGroups.tsx"],"sourcesContent":["import type { ServerProps } from \"payload\";\n\nimport Nav from \"./Nav
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/NavWithGroups.tsx"],"sourcesContent":["import type { ServerProps } from \"payload\";\n\nimport Nav from \"./Nav\";\n\nexport type NavWithGroupsProps = {\n animations?: boolean;\n groupsConfig?: Record<string, { icon?: string }>;\n itemsConfig?: Record<string, { icon?: string }>;\n} & ServerProps;\n\nexport const NavWithGroups = (props: NavWithGroupsProps) => {\n return <Nav {...props} groupsConfig={props.groupsConfig} />;\n};\n\nexport default NavWithGroups;\n"],"names":["Nav","NavWithGroups","props","groupsConfig"],"mappings":";AAEA,OAAOA,SAAS,QAAQ;AAQxB,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,qBAAO,KAACF;QAAK,GAAGE,KAAK;QAAEC,cAAcD,MAAMC,YAAY;;AAC3D,EAAE;AAEF,eAAeF,cAAc"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as LucideIcons from "lucide-react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a Lucide icon from sidebar config.
|
|
4
|
+
*
|
|
5
|
+
* Group labels must match Payload `admin.group` labels exactly, such as
|
|
6
|
+
* `E-Mails`, while collection and global items use their slugs.
|
|
7
|
+
*/ export const getNavIcon = (slug, config)=>{
|
|
8
|
+
const iconName = config?.[slug]?.icon;
|
|
9
|
+
if (iconName) {
|
|
10
|
+
const IconComponent = LucideIcons[iconName];
|
|
11
|
+
if (IconComponent) {
|
|
12
|
+
return IconComponent;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Nav/get-nav-icon.ts"],"sourcesContent":["import type { LucideProps } from \"lucide-react\";\nimport type { ExoticComponent } from \"react\";\n\nimport * as LucideIcons from \"lucide-react\";\n\nexport const getNavIcon = (\n slug: string,\n config?: Record<string, { icon?: string }>\n): ExoticComponent<LucideProps> | undefined => {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/get-nav-icon.ts"],"sourcesContent":["import type { LucideProps } from \"lucide-react\";\nimport type { ExoticComponent } from \"react\";\n\nimport * as LucideIcons from \"lucide-react\";\n\n/**\n * Resolves a Lucide icon from sidebar config.\n *\n * Group labels must match Payload `admin.group` labels exactly, such as\n * `E-Mails`, while collection and global items use their slugs.\n */\nexport const getNavIcon = (\n slug: string,\n config?: Record<string, { icon?: string }>\n): ExoticComponent<LucideProps> | undefined => {\n const iconName = config?.[slug]?.icon;\n if (iconName) {\n const IconComponent = (LucideIcons as unknown as Record<string, ExoticComponent<LucideProps>>)[iconName];\n if (IconComponent) {\n return IconComponent;\n }\n }\n\n return undefined;\n};\n"],"names":["LucideIcons","getNavIcon","slug","config","iconName","icon","IconComponent","undefined"],"mappings":"AAGA,YAAYA,iBAAiB,eAAe;AAE5C;;;;;CAKC,GACD,OAAO,MAAMC,aAAa,CACtBC,MACAC;IAEA,MAAMC,WAAWD,QAAQ,CAACD,KAAK,EAAEG;IACjC,IAAID,UAAU;QACV,MAAME,gBAAgB,AAACN,WAAuE,CAACI,SAAS;QACxG,IAAIE,eAAe;YACf,OAAOA;QACX;IACJ;IAEA,OAAOC;AACX,EAAE"}
|
package/dist/exports/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { NavClient } from '../components/Nav/Nav.client
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { NavClient } from '../components/Nav/Nav.client'\n"],"names":["NavClient"],"mappings":"AAAA,SAASA,SAAS,QAAQ,+BAA8B"}
|
package/dist/exports/rsc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Nav } from '../components/Nav/Nav
|
|
2
|
-
export { default as NavWithGroups } from '../components/Nav/NavWithGroups
|
|
1
|
+
export { default as Nav } from '../components/Nav/Nav';
|
|
2
|
+
export { default as NavWithGroups } from '../components/Nav/NavWithGroups';
|
|
3
3
|
|
|
4
4
|
//# sourceMappingURL=rsc.js.map
|
package/dist/exports/rsc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { default as Nav } from '../components/Nav/Nav
|
|
1
|
+
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { default as Nav } from '../components/Nav/Nav'\nexport { default as NavWithGroups } from '../components/Nav/NavWithGroups'\n"],"names":["default","Nav","NavWithGroups"],"mappings":"AAAA,SAASA,WAAWC,GAAG,QAAQ,wBAAuB;AACtD,SAASD,WAAWE,aAAa,QAAQ,kCAAiC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export const advancedSidebarPlugin = (pluginConfig = {})=>{
|
|
|
11
11
|
clientProps: {
|
|
12
12
|
animations: pluginConfig.animations ?? true,
|
|
13
13
|
groupsConfig: pluginConfig.groups,
|
|
14
|
-
itemsConfig: pluginConfig.items
|
|
14
|
+
itemsConfig: pluginConfig.items,
|
|
15
|
+
navLinks: pluginConfig.navLinks
|
|
15
16
|
},
|
|
16
17
|
path: 'payload-advanced-sidebar/rsc#NavWithGroups'
|
|
17
18
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nexport type SidebarPluginConfig = {\n animations?: boolean\n enabled?: boolean\n groups?: Record<string, { icon?: string }>\n items?: Record<string, { icon?: string }>\n}\n\nexport const advancedSidebarPlugin = (pluginConfig: SidebarPluginConfig = {}) => {\n return (config: Config): Config => {\n if (pluginConfig.enabled === false) {\n return config\n }\n\n config.admin = {\n ...(config.admin ?? {}),\n components: {\n ...(config.admin?.components ?? {}),\n Nav: {\n clientProps: {\n animations: pluginConfig.animations ?? true,\n groupsConfig: pluginConfig.groups,\n itemsConfig: pluginConfig.items,\n },\n path: 'payload-advanced-sidebar/rsc#NavWithGroups',\n },\n },\n }\n\n return config\n }\n}\n\nexport default advancedSidebarPlugin\n"],"names":["advancedSidebarPlugin","pluginConfig","config","enabled","admin","components","Nav","clientProps","animations","groupsConfig","groups","itemsConfig","items","path"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nexport type CustomNavLink = {\n group?: string\n icon?: string\n label: Record<string, string> | string\n path: string\n slug?: string\n}\n\nexport type SidebarPluginConfig = {\n animations?: boolean\n enabled?: boolean\n groups?: Record<string, { icon?: string }>\n items?: Record<string, { icon?: string }>\n navLinks?: CustomNavLink[]\n}\n\nexport const advancedSidebarPlugin = (pluginConfig: SidebarPluginConfig = {}) => {\n return (config: Config): Config => {\n if (pluginConfig.enabled === false) {\n return config\n }\n\n config.admin = {\n ...(config.admin ?? {}),\n components: {\n ...(config.admin?.components ?? {}),\n Nav: {\n clientProps: {\n animations: pluginConfig.animations ?? true,\n groupsConfig: pluginConfig.groups,\n itemsConfig: pluginConfig.items,\n navLinks: pluginConfig.navLinks,\n },\n path: 'payload-advanced-sidebar/rsc#NavWithGroups',\n },\n },\n }\n\n return config\n }\n}\n\nexport default advancedSidebarPlugin\n"],"names":["advancedSidebarPlugin","pluginConfig","config","enabled","admin","components","Nav","clientProps","animations","groupsConfig","groups","itemsConfig","items","navLinks","path"],"mappings":"AAkBA,OAAO,MAAMA,wBAAwB,CAACC,eAAoC,CAAC,CAAC;IAC1E,OAAO,CAACC;QACN,IAAID,aAAaE,OAAO,KAAK,OAAO;YAClC,OAAOD;QACT;QAEAA,OAAOE,KAAK,GAAG;YACb,GAAIF,OAAOE,KAAK,IAAI,CAAC,CAAC;YACtBC,YAAY;gBACV,GAAIH,OAAOE,KAAK,EAAEC,cAAc,CAAC,CAAC;gBAClCC,KAAK;oBACHC,aAAa;wBACXC,YAAYP,aAAaO,UAAU,IAAI;wBACvCC,cAAcR,aAAaS,MAAM;wBACjCC,aAAaV,aAAaW,KAAK;wBAC/BC,UAAUZ,aAAaY,QAAQ;oBACjC;oBACAC,MAAM;gBACR;YACF;QACF;QAEA,OAAOZ;IACT;AACF,EAAC;AAED,eAAeF,sBAAqB"}
|
package/package.json
CHANGED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
$text-color: var(--theme-text, #333);
|
|
2
|
-
$hover-bg: var(--theme-elevation-50, rgba(128, 128, 128, 0.1));
|
|
3
|
-
$active-bg: var(--theme-elevation-100, rgba(128, 128, 128, 0.2));
|
|
4
|
-
$border-radius: 6px;
|
|
5
|
-
|
|
6
|
-
.nav {
|
|
7
|
-
&__link {
|
|
8
|
-
display: flex;
|
|
9
|
-
border-radius: $border-radius;
|
|
10
|
-
transition:
|
|
11
|
-
background-color 0.2s ease,
|
|
12
|
-
color 0.2s ease;
|
|
13
|
-
text-decoration: none;
|
|
14
|
-
color: $text-color;
|
|
15
|
-
|
|
16
|
-
&:focus:not(:focus-visible) {
|
|
17
|
-
box-shadow: none;
|
|
18
|
-
font-weight: 600;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&:hover {
|
|
22
|
-
background-color: $hover-bg;
|
|
23
|
-
text-decoration: none;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.active {
|
|
27
|
-
font-weight: 600;
|
|
28
|
-
background-color: $active-bg;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
.menu {
|
|
32
|
-
list-style: none;
|
|
33
|
-
padding: 0;
|
|
34
|
-
margin: 0;
|
|
35
|
-
|
|
36
|
-
li {
|
|
37
|
-
margin-bottom: 5px;
|
|
38
|
-
|
|
39
|
-
a {
|
|
40
|
-
display: block;
|
|
41
|
-
padding: 5px 7px;
|
|
42
|
-
font-size: 14px;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&.group {
|
|
46
|
-
.sub-menu {
|
|
47
|
-
// display: none;
|
|
48
|
-
padding-left: 15px;
|
|
49
|
-
list-style: none;
|
|
50
|
-
|
|
51
|
-
li a {
|
|
52
|
-
font-size: 13px;
|
|
53
|
-
padding: 8px;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.group-toggle {
|
|
58
|
-
display: flex;
|
|
59
|
-
align-items: center;
|
|
60
|
-
gap: 6px;
|
|
61
|
-
padding: 5px 7px;
|
|
62
|
-
|
|
63
|
-
.group-chevron {
|
|
64
|
-
margin-left: auto;
|
|
65
|
-
display: flex;
|
|
66
|
-
align-items: center;
|
|
67
|
-
opacity: 0.5;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.sub-group-list {
|
|
72
|
-
margin-left: 12px;
|
|
73
|
-
margin-top: 5px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&.open .sub-menu {
|
|
77
|
-
display: block;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|