Skip to content

Commit 753c211

Browse files
authored
increase indentation and use classes (#32)
using classes instead of a `style` tag to indent icons. this way we can override it when required
1 parent b69826c commit 753c211

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Removed sidebar drop shadow on screens where it's closed by default (small/medium size screens) in order to avoid having a shadow visible to the left of the screen even when the menu is closed on mobile/tablet
1313
- Fixed a problem where menu-open would be added to menu items without children
1414
- Menu styling is now using different colors for hovering and normal state
15+
- Indentation of menu items is now using classes. This lets the user overwrite the indentation with custom styles when required
1516

1617
### Added
1718

src/lib/SideBar/SideBarMenuItem.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ const SideBarMenuItem = ({ item, depth = 0 }: SideBarMenuItemProps) => {
2323
return (
2424
<>
2525
<div className={classNames(item.className, { "menu-open": isOpen, active: item.isActive })}>
26-
<div
27-
onClick={() => toggleItem(item.id)}
28-
className={classNames("nav-item", { "menu-open": isOpen })}
29-
style={{ paddingLeft: `${0.5 * depth}rem` }}
30-
>
26+
<div onClick={() => toggleItem(item.id)} className={classNames({ "menu-open": isOpen }, `nesting-level-${depth}`, "nav-item")}>
3127
{hasChildren ? (
3228
<>
3329
<div className={classNames({ dropend: !isOpen })}>

styles/Layout/SideBarLayout.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,21 @@ $topnav-light-toggler-color: $gray-900;
264264
text-transform: uppercase;
265265
}
266266

267+
.nav-item {
268+
&.nesting-level-1 {
269+
padding-left: 1rem;
270+
}
271+
&.nesting-level-2 {
272+
padding-left: 2rem;
273+
}
274+
&.nesting-level-3 {
275+
padding-left: 3rem;
276+
}
277+
&.nesting-level-4 {
278+
padding-left: 4rem;
279+
}
280+
}
281+
267282
.nav-item.menu-open .nav-link {
268283
&::after {
269284
@include chevron-down();

0 commit comments

Comments
 (0)