Skip to content

feat: add link property wrap #4540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 3.0-release
Choose a base branch
from
Open
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

it looks like that the arrow is slightly off (vertically) due to the changes of this ticket, even though that I can't identify why this happens (based on the code changes being made).

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
Copy link
Collaborator

@mfranzke mfranzke Jul 17, 2025

Choose a reason for hiding this comment

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

show icon = false still does display an icon according to this screenshot, and the page https://design-system.deutschebahn.com/core-web/review/feat-add-link-property-wrap/components/action/link/overview

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
- link "External"
- link "Show Icon"
- link "(Default) True"
- link "False"
- link "False"
- link "Wrap"
- link "(Default) False"
- link "True [Multiline]"
- link "Examples"
- link "Variant Inline"
3 changes: 2 additions & 1 deletion packages/components/src/components/link/link.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default function DBLink(props: DBLinkProps) {
data-size={props.size}
data-hide-icon-trailing={getHideProp(props.showIcon ?? true)}
data-variant={props.variant}
data-content={props.content || 'internal'}>
data-content={props.content || 'internal'}
data-wrap={getBooleanAsString(props.wrap)}>
<Show when={props.text} else={props.children}>
{props.text}
</Show>
Expand Down
8 changes: 6 additions & 2 deletions packages/components/src/components/link/link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
}

&[data-content="internal"] {
@include icons.set-icon("arrow_right", "after");
&:not([data-variant="inline"]) {
@include icons.set-icon("arrow_right", "after");
}

&:not([data-hide-icon-trailing="true"])::after {
vertical-align: top;
}
}

&[data-content="external"] {
@include icons.set-icon("arrow_up_right", "after");
&:not([data-variant="inline"]) {
@include icons.set-icon("arrow_up_right", "after");
}
}

&[data-content="internal"],
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/components/link/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
GlobalState,
LinkProps,
ShowIconProps,
TextProps
TextProps,
WrapProps
} from '../../shared/model';

export const LinkVariantList = ['adaptive', 'brand'] as const;
export const LinkVariantList = ['adaptive', 'brand', 'inline'] as const;
export type LinkVariantType = (typeof LinkVariantList)[number];

export const LinkSizeList = ['medium', 'small'] as const;
Expand Down Expand Up @@ -37,7 +38,8 @@ export type DBLinkProps = DBLinkDefaultProps &
ClickEventProps<HTMLAnchorElement> &
LinkProps &
ShowIconProps &
TextProps;
TextProps &
WrapProps;

export type DBLinkDefaultState = {};

Expand Down
9 changes: 3 additions & 6 deletions packages/components/src/components/navigation-item/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
NavigationBehaviorState,
ShowIconProps,
TextProps,
WidthProps
WidthProps,
WrapProps
} from '../../shared/model';
import { NavigationItemSafeTriangle } from '../../utils/navigation';

Expand All @@ -35,18 +36,14 @@ 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 &
GlobalProps &
ClickEventProps<HTMLButtonElement> &
IconProps &
WidthProps &
WrapProps &
NavigationBackButtonProps &
ShowIconProps &
TextProps;
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/shared/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ export type OverflowProps = {
overflow?: boolean | string;
};

export type WrapProps = {
/**
* Determines whether the text should wrap when its parent container is too small, preventing overflow.
*/
wrap?: boolean | string;
}

export const OrientationList = ['horizontal', 'vertical'] as const;
export type OrientationType = (typeof OrientationList)[number];
export type OrientationProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

%db-link-height {
display: inline-block;
block-size: variables.$db-sizing-sm;

&:not([data-wrap="true"]) {
block-size: variables.$db-sizing-sm;
}
}

%db-link-default-color {
Expand Down Expand Up @@ -42,7 +45,7 @@
text-decoration-thickness: helpers.px-to-rem($pxValue: 1);
text-decoration-line: underline;

&:not([data-variant="inline"]) {
&:not(:is([data-wrap="true"], [data-variant="inline"])) {
white-space: nowrap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[size]="exampleProps?.size"
[content]="exampleProps?.content"
[showIcon]="exampleProps?.showIcon"
[wrap]="exampleProps?.wrap"
>{{ exampleName }}</db-link
>
</ng-template>
Expand Down
6 changes: 4 additions & 2 deletions showcases/react-showcase/src/components/link/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ const getLink = ({
size,
content,
children,
showIcon
showIcon,
wrap
}: DBLinkProps) => (
<DBLink
href={href}
variant={variant}
disabled={disabled}
size={size}
content={content}
showIcon={showIcon}>
showIcon={showIcon}
wrap={wrap}>
{children}
</DBLink>
);
Expand Down
32 changes: 32 additions & 0 deletions showcases/shared/link.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,37 @@
}
}
]
},
{
"name": "Wrap",
"examples": [
{
"name": "(Default) False",
"props": {
"href": "#",
"wrap": false
}
},
{
"name": "True [Multiline]",
"style": { "width": "2ch" },
"props": {
"href": "#",
"wrap": true
}
}
]
},
{
"name": "Examples",
"examples": [
{
"name": "Variant Inline",
"props": {
"href": "#",
"variant": "inline"
}
}
]
}
]
1 change: 1 addition & 0 deletions showcases/vue-showcase/src/components/link/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import DefaultComponent from "../DefaultComponent.vue";
:size="exampleProps?.size"
:content="exampleProps?.content"
:showIcon="exampleProps?.showIcon"
:wrap="exampleProps?.wrap"
>
{{ exampleName }}
</DBLink>
Expand Down