From e4bbe7a5e8081347534badd6908655342b2764e3 Mon Sep 17 00:00:00 2001 From: Snorre Kim Date: Tue, 17 Sep 2024 18:53:44 +0200 Subject: [PATCH] doc option 'expanded' changed to 'accordion'. Removed option for expanded by default --- .../src/docs/uilib/about-the-lib/releases.mdx | 2 +- .../src/docs/uilib/components/fragments.mdx | 2 +- .../src/docs/uilib/components/pagination.mdx | 2 +- .../src/docs/uilib/extensions/forms/Form.mdx | 2 +- .../docs/uilib/extensions/forms/Iterate.mdx | 2 +- .../src/docs/uilib/extensions/forms/Value.mdx | 2 +- .../docs/uilib/extensions/forms/Wizard.mdx | 2 +- .../extensions/forms/create-component.mdx | 2 +- .../src/shared/menu/SidebarMenu.module.scss | 2 +- .../src/shared/menu/SidebarMenu.tsx | 19 +++++++------------ 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases.mdx b/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases.mdx index bb8814913dd..15d61de9df5 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases.mdx @@ -3,7 +3,7 @@ title: 'Releases and versions' developers: 'Overview of all major releases and changes, including migration guides.' redirect_from: - /uilib/releases -expanded: false +accordion: true --- import ListUiLibVersions from './releases/dnb-ui-lib/ListUiLibVersions' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/fragments.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/fragments.mdx index 83d529f31f4..65fddd82274 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/fragments.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/fragments.mdx @@ -3,7 +3,7 @@ title: 'Fragments' description: 'Fragments are small, low-level and reusable parts used inside other components.' order: -1 theme: 'sbanken' -expanded: false +accordion: true --- import ListFragments from 'dnb-design-system-portal/src/shared/parts/ListFragments' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination.mdx index 15276d1535b..263e6d7dd24 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination.mdx @@ -3,7 +3,7 @@ title: 'Pagination' description: 'The Pagination component supports both classical pagination and infinity scrolling.' showTabs: true theme: 'sbanken' -expanded: false +accordion: true --- import PaginationInfo from 'Docs/uilib/components/pagination/info' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form.mdx index 400640874ef..b88599af578 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form.mdx @@ -15,7 +15,7 @@ breadcrumb: href: /uilib/extensions/forms/ - text: Form href: /uilib/extensions/forms/Form/ -expanded: false +accordion: true --- import Info from 'Docs/uilib/extensions/forms/Form/info' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate.mdx index f1427c0c4e1..832d600f9c9 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate.mdx @@ -16,7 +16,7 @@ breadcrumb: href: /uilib/extensions/forms/ - text: Iterate href: /uilib/extensions/forms/Iterate/ -expanded: false +accordion: true --- import Info from 'Docs/uilib/extensions/forms/Iterate/info' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value.mdx index e98b8fe1dcf..fdd6629e4d4 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value.mdx @@ -15,7 +15,7 @@ breadcrumb: href: /uilib/extensions/forms/ - text: Value href: /uilib/extensions/forms/Value/ -expanded: false +accordion: true --- import Info from 'Docs/uilib/extensions/forms/Value/info' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Wizard.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Wizard.mdx index 1147183b634..8f2b6acdeba 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Wizard.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Wizard.mdx @@ -17,7 +17,7 @@ breadcrumb: href: /uilib/extensions/forms/ - text: Wizard href: /uilib/extensions/forms/Wizard/ -expanded: false +accordion: true --- import Info from 'Docs/uilib/extensions/forms/Wizard/info' diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/create-component.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/create-component.mdx index cc9ef882620..6fc523cbc03 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/create-component.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/create-component.mdx @@ -6,7 +6,7 @@ breadcrumb: href: /uilib/extensions/forms/ - text: Create your component href: /uilib/extensions/forms/create-component/ -expanded: false +accordion: true --- import ListBasisAPIs from './create-component/ListBasisAPIs' diff --git a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.module.scss b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.module.scss index feb3583acb1..75fc678b093 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.module.scss +++ b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.module.scss @@ -241,7 +241,7 @@ } } - &--default-collapsed { + &--accordion { &.dnb-sidebar-menu--expanded { border-right: 0.25rem solid var(--is-inside-active-path-color); diff --git a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx index 345cb3d48e3..8697257c46e 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx +++ b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx @@ -76,7 +76,7 @@ export default function SidebarLayout({ key } theme - expanded + accordion } } } @@ -259,7 +259,7 @@ type ListItemProps = { isInsideActivePath?: boolean isInsideActiveCategory?: boolean currentPathName?: string - expanded?: boolean + accordion?: boolean scrollRef?: React.MutableRefObject } @@ -278,7 +278,7 @@ function ListItem({ subheadings, hideInMenu, currentPathName, - expanded: defaultExpanded = null, + accordion = false, scrollRef, }: ListItemProps) { const currentTheme = useTheme()?.name @@ -292,11 +292,11 @@ function ListItem({ [subheadings], ) const isAccordion = useMemo( - () => defaultExpanded !== null && hasSubheadings, - [defaultExpanded, hasSubheadings], + () => accordion && hasSubheadings, + [accordion, hasSubheadings], ) const [isExpanded, setIsExpanded] = useState( - isAccordion ? defaultExpanded || isInsideActivePath || isActive : true, + isAccordion ? isInsideActivePath || isActive : true, ) const [manualClick, setManualClick] = useState(false) if (hideInMenu) { @@ -327,10 +327,7 @@ function ListItem({ } } else { const shouldAutoCollapse = - !defaultExpanded && - !isInsideActivePath && - !isActive && - hasCurrentPathNameChanged + !isInsideActivePath && !isActive && hasCurrentPathNameChanged if (shouldAutoCollapse) { setIsExpanded(false) @@ -354,8 +351,6 @@ function ListItem({ isAccordion && `dnb-sidebar-menu--accordion dnb-sidebar-menu--${ isExpanded ? 'expanded' : 'collapsed' - }${ - defaultExpanded ? '' : ' dnb-sidebar-menu--default-collapsed' }`, className, )}