Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SideNavDropdownProps<C extends React.ElementType = 'a'> = {
};

type Group<C extends React.ElementType> = {
subHeading?: string;
subHeading?: React.ReactNode;
subItems: SideNavItemProps<C>[];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type SideNavItemProps<C extends React.ElementType = 'a'> = LinkProps<C> &
* Grouped submenu items (preferred for headings)
*/
subItemGroups?: {
subHeading?: string;
subHeading?: React.ReactNode;
subItems: SideNavItemProps<C>[];
}[];
/**
Expand Down Expand Up @@ -73,6 +73,7 @@ export const SideNavItem = <C extends React.ElementType = 'a'>(

const groupsToRender = subItemGroups ?? (subItems ? [{ subItems }] : null);
const hasChildren = !!groupsToRender;
const hasTreeIndicator = level > 1 && hasChildren;

const SideNavItemBEM = cn(
styles['tedi-sidenav__item'],
Expand All @@ -81,6 +82,7 @@ export const SideNavItem = <C extends React.ElementType = 'a'>(
[styles[`tedi-sidenav__item--level-${level}`]]: level > 1,
[styles['tedi-sidenav__item--current']]: isActive,
[styles['tedi-sidenav__item--has-children']]: hasChildren,
[styles['tedi-sidenav__item--with-tree']]: hasTreeIndicator,
},
className
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* istanbul ignore file */
import { Text } from '../../base/typography/text/text';
import { InfoButton } from '../../buttons/info-button/info-button';
import { SideNavItemProps } from './components/sidenav-item/sidenav-item';

export const exampleNavItems: SideNavItemProps[] = [
Expand Down Expand Up @@ -248,3 +250,63 @@ export const exampleThirdLevelMenuItemsLinks: SideNavItemProps[] = [
{ href: '#', children: 'Inventory Management', icon: 'inventory' },
{ href: '#', children: 'Billing & Finance', icon: 'payments' },
];

export const exampleThirdLevelMenuItemsLinksWithSubTitles: SideNavItemProps[] = [
{ href: '#', children: 'Dashboard', icon: 'dashboard' },
{ href: '#', children: 'Patient Records', icon: 'people' },
{
children: 'Clinical Management',
icon: 'medical_services',
subItemGroups: [
{
subHeading: (
<Text>
Minu tervise ajalugu <InfoButton color="inverted">Lorem ipsum</InfoButton>
</Text>
),
subItems: [
{ href: '#', children: 'Active Treatments' },
{ href: '#', children: 'Treatment History' },
{ href: '#', children: 'Treatment Plans' },
{ href: '#', children: 'Clinical Protocols' },
],
},
],
subItems: [
{ href: '#', children: 'Vital Signs' },
{ href: '#', children: 'Assessments' },
{
href: '#',
children: 'Treatments',
subItems: [
{ href: '#', children: 'Active Treatments' },
{ href: '#', children: 'Treatment History' },
{ href: '#', children: 'Treatment Plans' },
{ href: '#', children: 'Clinical Protocols' },
],
},
{
href: '#',
children: 'Documentation',
subItems: [
{ href: '#', children: 'Clinical Notes' },
{ href: '#', children: 'Medical Forms' },
{ href: '#', children: 'Consent Forms' },
{ href: '#', children: 'Reports' },
],
},
],
isDefaultOpen: true,
},
{
href: '#',
children: 'Administration',
icon: 'admin_panel_settings',
subItems: [
{ href: '#', children: 'Staff Management' },
{ href: '#', children: 'Scheduling' },
],
},
{ href: '#', children: 'Inventory Management', icon: 'inventory' },
{ href: '#', children: 'Billing & Finance', icon: 'payments' },
];
17 changes: 14 additions & 3 deletions src/tedi/components/layout/sidenav/sidenav.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@
}
}

.tedi-sidenav__item.tedi-sidenav__sub-item .tedi-sidenav__link {
.tedi-sidenav__item--with-tree .tedi-sidenav__item.tedi-sidenav__sub-item .tedi-sidenav__link,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to this PR I think, but I noticed that collapse icons are not centered with menu item texts when parents are links.

Copy link
Contributor Author

@airikej airikej Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you brought attention to that, I saw that bug already myself at some time but forgot about it, now its fixed also

.tedi-sidenav__item--level-2 .tedi-sidenav__link {
min-height: var(--navigation-vertical-item-min-height-medium);
padding-top: var(--navigation-vertical-item-padding-y);
padding-bottom: var(--navigation-vertical-item-padding-y);
Expand All @@ -208,11 +209,21 @@
);
}

.tedi-sidenav__item:not(.tedi-sidenav__item--with-tree) .tedi-sidenav__sub-item.tedi-sidenav__item .tedi-sidenav__link,
.tedi-sidenav__item--level-2 .tedi-sidenav__link,
.tedi-sidenav__item--with-tree.tedi-sidenav__item--level-2 .tedi-sidenav__link.tedi-sidenav__link--has-children-link {
@include breakpoints.media-breakpoint-down(md) {
padding-left: var(--navigation-vertical-item-padding-right);
}
}

.tedi-sidenav__item .tedi-sidenav__link--has-children-link {
padding-right: calc(var(--navigation-vertical-item-padding-right) + var(--button-xs-icon-size));

@include breakpoints.media-breakpoint-down(md) {
z-index: 1;
margin-left: calc(var(--navigation-vertical-item-padding-right) + var(--button-xs-icon-size));
background-color: var(--navigation-vertical-item-background-default);
}
}

Expand All @@ -227,7 +238,7 @@
+ .tedi-sidenav__link-collapse-wrapper
[data-name='collapse-trigger'] {
position: absolute;
top: calc(var(--navigation-vertical-item-min-height-medium) / 3);
top: calc((var(--navigation-vertical-item-min-height-large) - var(--button-xs-icon-size)) / 2);
right: var(--navigation-vertical-item-padding-right);
display: flex;
align-items: center;
Expand Down Expand Up @@ -359,7 +370,7 @@ button.tedi-sidenav__link.tedi-sidenav__back-button {
.tedi-sidenav__subheading {
padding: var(--layout-grid-gutters-02) var(--navigation-vertical-item-padding-left-level-1)
var(--layout-grid-gutters-04) var(--navigation-vertical-item-padding-right);
font-size: var(--size-00);
font-size: var(--body-extra-small-bold-size);
color: var(--navigation-vertical-group-title-text);
text-transform: uppercase;

Expand Down
8 changes: 8 additions & 0 deletions src/tedi/components/layout/sidenav/sidenav.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
exampleNavItems,
exampleThirdLevelMenuItems,
exampleThirdLevelMenuItemsLinks,
exampleThirdLevelMenuItemsLinksWithSubTitles,
} from './examples';
import { SideNav } from './sidenav';

Expand Down Expand Up @@ -278,3 +279,10 @@ export const SmallSideNavItems: Story = {
sideNavItemSize: 'small',
},
};

export const SubTitles: Story = {
render: Template,
args: {
navItems: exampleThirdLevelMenuItemsLinksWithSubTitles,
},
};
Loading