From 8ade848a319a98fc97651cb4933a4cbb06e664d7 Mon Sep 17 00:00:00 2001 From: michaelmkraus Date: Tue, 15 Apr 2025 10:53:22 +0200 Subject: [PATCH 1/4] feat: enable text of navigation-item to break into multiple lines --- .../src/components/navigation-item/model.ts | 5 ++ .../navigation-item/navigation-item.lite.tsx | 1 + .../navigation-item/navigation-item.scss | 9 +++ .../navigation-item.component.html | 1 + .../src/components/navigation-item/index.tsx | 4 +- showcases/shared/navigation-item.json | 64 +++++++++++++++++++ .../navigation-item/NavigationItem.vue | 1 + 7 files changed, 84 insertions(+), 1 deletion(-) diff --git a/packages/components/src/components/navigation-item/model.ts b/packages/components/src/components/navigation-item/model.ts index b3c456aed69d..8662fdf53b3f 100644 --- a/packages/components/src/components/navigation-item/model.ts +++ b/packages/components/src/components/navigation-item/model.ts @@ -35,6 +35,11 @@ export type DBNavigationItemDefaultProps = { * This is for mobile navigation only, if it is set the sub-navigation is a static overlay */ subNavigationExpanded?: boolean | string; + + /** + * Determines whether the text should wrap when its parent container is too small, preventing overflow. + */ + wrap?: boolean | string; }; export type DBNavigationItemProps = DBNavigationItemDefaultProps & diff --git a/packages/components/src/components/navigation-item/navigation-item.lite.tsx b/packages/components/src/components/navigation-item/navigation-item.lite.tsx index 65cc7a8f9952..a095304a5461 100644 --- a/packages/components/src/components/navigation-item/navigation-item.lite.tsx +++ b/packages/components/src/components/navigation-item/navigation-item.lite.tsx @@ -116,6 +116,7 @@ export default function DBNavigationItem(props: DBNavigationItemProps) { data-icon={props.icon} data-hide-icon={getHideProp(props.showIcon)} data-active={props.active} + data-wrap={getBooleanAsString(props.wrap)} aria-disabled={getBooleanAsString(props.disabled)}> diff --git a/packages/components/src/components/navigation-item/navigation-item.scss b/packages/components/src/components/navigation-item/navigation-item.scss index ca95a8f472fc..1539945b6a1b 100644 --- a/packages/components/src/components/navigation-item/navigation-item.scss +++ b/packages/components/src/components/navigation-item/navigation-item.scss @@ -87,6 +87,15 @@ position: relative; inline-size: auto; + &[data-wrap="true"] { + .db-navigation-item-expand-button { + &:is(button) { + white-space: normal; + text-align: start; + } + } + } + @include screen-sizes.screen("md", "max") { &:not([data-width="full"]) { .db-navigation-item-expand-button { diff --git a/showcases/angular-showcase/src/app/components/navigation-item/navigation-item.component.html b/showcases/angular-showcase/src/app/components/navigation-item/navigation-item.component.html index e9e2f59b230f..d77790b35f0a 100644 --- a/showcases/angular-showcase/src/app/components/navigation-item/navigation-item.component.html +++ b/showcases/angular-showcase/src/app/components/navigation-item/navigation-item.component.html @@ -17,6 +17,7 @@ [width]="exampleProps?.width" [disabled]="exampleProps?.disabled" [active]="exampleProps?.active" + [wrap]="exampleProps?.wrap" (click)="showAlert(exampleName)" > diff --git a/showcases/react-showcase/src/components/navigation-item/index.tsx b/showcases/react-showcase/src/components/navigation-item/index.tsx index a5405f26d895..f53d138968a3 100644 --- a/showcases/react-showcase/src/components/navigation-item/index.tsx +++ b/showcases/react-showcase/src/components/navigation-item/index.tsx @@ -12,7 +12,8 @@ const getNavigationItem = ({ active, width, areaPopup, - showIcon + showIcon, + wrap }: DBNavigationItemProps & { areaPopup: boolean }) => (
    diff --git a/showcases/shared/navigation-item.json b/showcases/shared/navigation-item.json index 7a83347cdac8..3b04ecce3f1a 100644 --- a/showcases/shared/navigation-item.json +++ b/showcases/shared/navigation-item.json @@ -234,5 +234,69 @@ ] } ] + }, + { + "name": "Wrap", + "examples": [ + { + "name": "No Wrap (Default)", + "props": { + "areaPopup": true + }, + "children": [ + { + "name": "a", + "native": true, + "props": { + "href": "#" + }, + "content": "True" + } + ] + }, + { + "name": "This is a very long text that is broken into multiple lines.", + "props": { + "areaPopup": true, + "icon": "x_placeholder", + "showIcon": true, + "wrap": true + }, + "style": { + "width": "200px" + }, + "children": [ + { + "name": "a", + "native": true, + "props": { + "href": "#" + }, + "content": "True" + } + ] + }, + { + "name": "This is a very long text that is broken into multiple lines.", + "props": { + "areaPopup": true, + "wrap": true + }, + "style": { + "width": "200px" + }, + "slot": "sub-navigation", + "children": [ + { + "name": "a", + "native": true, + "props": { + "href": "#" + }, + "content": "True" + } + ] + } + ] } ] diff --git a/showcases/vue-showcase/src/components/navigation-item/NavigationItem.vue b/showcases/vue-showcase/src/components/navigation-item/NavigationItem.vue index afb63c120614..4be757042b97 100644 --- a/showcases/vue-showcase/src/components/navigation-item/NavigationItem.vue +++ b/showcases/vue-showcase/src/components/navigation-item/NavigationItem.vue @@ -25,6 +25,7 @@ const log = (exampleName?: string) => { :disabled="exampleProps?.disabled" :active="exampleProps?.active" :areaPopup="exampleProps?.areaPopup" + :wrap="exampleProps?.wrap" @click="log(exampleName)" >