Skip to content

Commit 7027bea

Browse files
committed
feat: enhance DBBreadcrumb with vertical centering and className support across all showcases
1 parent 3abe49d commit 7027bea

File tree

7 files changed

+88
-34
lines changed

7 files changed

+88
-34
lines changed

packages/components/src/components/breadcrumb/breadcrumb.scss

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
align-items: center;
4343
padding: variables.$db-spacing-fixed-3xs
4444
variables.$db-spacing-fixed-2xs; // 2px 4px (small)
45+
4546
border-radius: variables.$db-border-radius-xs; // 4px
4647
background-color: colors.$db-adaptive-bg-basic-transparent-full-default;
4748
color: colors.$db-adaptive-on-bg-basic-emphasis-100-default;
@@ -88,24 +89,32 @@
8889
// Medium size variant
8990
&[data-size="medium"] {
9091
.db-breadcrumb-list {
91-
gap: variables.$db-spacing-fixed-2xs; // 4px gap for medium
92+
// Slightly more breathing room for medium size (matches Figma spacing)
93+
gap: variables.$db-spacing-fixed-xs; // 8px gap for medium
94+
95+
/* ensure list items are vertically centered in medium size */
96+
align-items: center;
9297
}
9398

9499
li {
95-
gap: variables.$db-spacing-fixed-2xs; // 4px between separator and item (medium)
100+
// Increase gap between separator and item for better touch target
101+
gap: variables.$db-spacing-fixed-xs; // 8px between separator and item (medium)
96102

97103
&:not(:first-child)::before {
98-
inline-size: variables.$db-sizing-md +
99-
variables.$db-spacing-fixed-2xs; // 28px (medium)
100-
block-size: variables.$db-sizing-md +
101-
variables.$db-spacing-fixed-2xs;
102-
font-size: variables.$db-sizing-lg; // 24px
104+
// Make the chevron larger to match visual weight in Figma
105+
inline-size: variables.$db-sizing-lg; // ~24px
106+
block-size: variables.$db-sizing-lg;
107+
font-size: variables.$db-sizing-lg; // use large sizing token
108+
font-weight: 600;
109+
color: colors.$db-adaptive-on-bg-basic-emphasis-100-default;
103110
}
104111

105112
a,
106113
span {
114+
// Keep the medium padding but ensure comfortable tap/click area
107115
padding: variables.$db-spacing-fixed-2xs
108116
variables.$db-spacing-fixed-xs; // 4px 8px (medium)
117+
109118
font-size: variables.$db-sizing-md; // 16px (body-md)
110119
line-height: variables.$db-sizing-lg; // 24px
111120
}

showcases/angular-showcase/src/app/components/breadcrumb/breadcrumb.component.html

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@
1010
let-exampleIndex="exampleIndex"
1111
let-variantIndex="variantIndex"
1212
>
13-
<db-breadcrumb>
14-
@for (item of exampleProps?.children; track $index) {
15-
@if (item.href) {
16-
<li>
17-
<a [href]="item.href">{{ item.text }}</a>
18-
</li>
19-
} @else {
20-
<li [attr.aria-current]="item.ariaCurrent">
21-
<span>{{ item.text }}</span>
22-
</li>
13+
<!-- Plain HTML structure to avoid relying on missing Angular wrapper / web component -->
14+
<nav
15+
[attr.class]="
16+
'db-breadcrumb' +
17+
(exampleProps?.className ? ' ' + exampleProps.className : '')
18+
"
19+
[attr.data-size]="exampleProps?.size ?? 'small'"
20+
aria-label="breadcrumb"
21+
>
22+
<ol class="db-breadcrumb-list" role="list">
23+
@for (item of exampleProps?.children; track $index) {
24+
@if (item.href) {
25+
<li>
26+
<a [href]="item.href">{{ item.text }}</a>
27+
</li>
28+
} @else {
29+
<li [attr.aria-current]="item.ariaCurrent">
30+
<span>{{ item.text }}</span>
31+
</li>
32+
}
2333
}
24-
}
25-
</db-breadcrumb>
34+
</ol>
35+
</nav>
2636
</ng-template>
2737
</app-default-component>

showcases/react-showcase/src/components/breadcrumb/index.tsx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,32 @@ import defaultComponentVariants from '../../../../shared/breadcrumb.json';
33
import { getVariants } from '../data';
44
import DefaultComponent from '../default-component';
55

6-
const getBreadcrumb = ({ children, size }: any) => (
7-
<DBBreadcrumb size={size}>
6+
type BreadcrumbItem = {
7+
href?: string;
8+
text: string;
9+
ariaCurrent?: 'page' | undefined;
10+
};
11+
12+
type BreadcrumbExampleProps = {
13+
children?: BreadcrumbItem[];
14+
size?: 'small' | 'medium';
15+
className?: string;
16+
};
17+
18+
const getBreadcrumb = ({
19+
children,
20+
size,
21+
className
22+
}: BreadcrumbExampleProps) => (
23+
<DBBreadcrumb size={size} className={className}>
824
{children && Array.isArray(children)
9-
? children.map((item: any, index: number) =>
25+
? children.map((item, index) =>
1026
item.href ? (
1127
<li key={index}>
1228
<a href={item.href}>{item.text}</a>
1329
</li>
1430
) : (
15-
<li key={index} aria-current={item.ariaCurrent}>
31+
<li key={index} aria-current={item.ariaCurrent as any}>
1632
<span>{item.text}</span>
1733
</li>
1834
)
@@ -21,16 +37,18 @@ const getBreadcrumb = ({ children, size }: any) => (
2137
</DBBreadcrumb>
2238
);
2339

24-
const BreadcrumbComponent = (props: any) => {
25-
return (
26-
<DefaultComponent
27-
title="DBBreadcrumb"
28-
variants={getVariants(
29-
defaultComponentVariants,
30-
getBreadcrumb,
31-
props.slotCode
32-
)}></DefaultComponent>
33-
);
40+
type BreadcrumbComponentProps = {
41+
slotCode?: Record<string, React.FC>;
3442
};
3543

44+
const BreadcrumbComponent = (props: BreadcrumbComponentProps) => (
45+
<DefaultComponent
46+
title="DBBreadcrumb"
47+
variants={getVariants(
48+
defaultComponentVariants,
49+
getBreadcrumb,
50+
props.slotCode
51+
)}></DefaultComponent>
52+
);
53+
3654
export default BreadcrumbComponent;

showcases/react-showcase/src/components/data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export const getVariants = (
1414
],
1515
examples: variant.examples.map((example, exampleIndex) => ({
1616
...example,
17+
// Ensure className from props is available on the example object
18+
className: example.className ?? example.props?.className,
1719
example: getExample({
1820
...example.props,
1921
id: example.props?.id ?? example.name,

showcases/shared/breadcrumb.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"examples": [
55
{
66
"name": "(Default) Small",
7+
"className": "w-full",
78
"props": {
89
"size": "small",
910
"children": [
@@ -15,6 +16,7 @@
1516
},
1617
{
1718
"name": "Medium",
19+
"className": "w-full",
1820
"props": {
1921
"size": "medium",
2022
"children": [

showcases/showcase-styles.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ db-card:is(.variants-card) > .db-card {
6767
margin-block: 0 auto;
6868
}
6969

70+
/* Breadcrumb showcase: stack breadcrumb examples vertically */
71+
@supports selector(:has(*)) {
72+
.variants-list > div:has(.db-breadcrumb) {
73+
flex: 0 0 100%;
74+
}
75+
}
76+
77+
/* Fallback: if :has unsupported, rely on utility class or force wrappers containing db-breadcrumb to behave as block via descendant width trick */
78+
.variants-list .db-breadcrumb {
79+
inline-size: 100%;
80+
}
81+
7082
.html-code-container {
7183
display: flex;
7284
flex-direction: column;

showcases/vue-showcase/src/components/breadcrumb/breadcrumb.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const DBBreadcrumb = "nav";
1515
>
1616
<component
1717
:is="DBBreadcrumb"
18-
class="db-breadcrumb"
18+
:class="['db-breadcrumb', exampleProps?.className]"
19+
:data-size="exampleProps?.size"
1920
aria-label="breadcrumb"
2021
>
2122
<ol class="db-breadcrumb-list" role="list">

0 commit comments

Comments
 (0)