Skip to content

Commit

Permalink
doc option 'expanded' changed to 'accordion'. Removed option for expa…
Browse files Browse the repository at this point in the history
…nded by default
  • Loading branch information
snorrekim committed Sep 23, 2024
1 parent 6a65d51 commit 10881b1
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
}
}

&--default-collapsed {
&--accordion {
&.dnb-sidebar-menu--expanded {
border-right: 0.25rem solid var(--is-inside-active-path-color);

Expand Down
19 changes: 7 additions & 12 deletions packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function SidebarLayout({
key
}
theme
expanded
accordion
}
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ type ListItemProps = {
isInsideActivePath?: boolean
isInsideActiveCategory?: boolean
currentPathName?: string
expanded?: boolean
accordion?: boolean
scrollRef?: React.MutableRefObject<HTMLElement>
}

Expand All @@ -278,7 +278,7 @@ function ListItem({
subheadings,
hideInMenu,
currentPathName,
expanded: defaultExpanded = null,
accordion = false,
scrollRef,
}: ListItemProps) {
const currentTheme = useTheme()?.name
Expand All @@ -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) {
Expand Down Expand Up @@ -327,10 +327,7 @@ function ListItem({
}
} else {
const shouldAutoCollapse =
!defaultExpanded &&
!isInsideActivePath &&
!isActive &&
hasCurrentPathNameChanged
!isInsideActivePath && !isActive && hasCurrentPathNameChanged

if (shouldAutoCollapse) {
setIsExpanded(false)
Expand All @@ -354,8 +351,6 @@ function ListItem({
isAccordion &&
`dnb-sidebar-menu--accordion dnb-sidebar-menu--${
isExpanded ? 'expanded' : 'collapsed'
}${
defaultExpanded ? '' : ' dnb-sidebar-menu--default-collapsed'
}`,
className,
)}
Expand Down

0 comments on commit 10881b1

Please sign in to comment.