Skip to content

Commit 3826540

Browse files
author
Bharat Patel
authored
feat(Breadcrumb): [BLA-1021] make padding configurable
1 parent 5659845 commit 3826540

File tree

7 files changed

+146
-54
lines changed

7 files changed

+146
-54
lines changed

packages/core-components/src/components.d.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ export namespace Components {
7878
}
7979
interface B2bBreadcrumb {
8080
/**
81-
* Vertical padding for the breadcrumb component
81+
* Padding for the bottom of the breadcrumb component
8282
*/
83-
"paddingVertical": number;
83+
"paddingBottom": number;
84+
/**
85+
* Padding for the top of the breadcrumb component
86+
*/
87+
"paddingTop": number;
8488
}
8589
interface B2bBreadcrumbItem {
8690
/**
@@ -2328,9 +2332,13 @@ declare namespace LocalJSX {
23282332
*/
23292333
"onB2b-selected"?: (event: B2bBreadcrumbCustomEvent<BreadCrumbChangeEventDetail>) => void;
23302334
/**
2331-
* Vertical padding for the breadcrumb component
2335+
* Padding for the bottom of the breadcrumb component
2336+
*/
2337+
"paddingBottom"?: number;
2338+
/**
2339+
* Padding for the top of the breadcrumb component
23322340
*/
2333-
"paddingVertical"?: number;
2341+
"paddingTop"?: number;
23342342
}
23352343
interface B2bBreadcrumbItem {
23362344
/**

packages/core-components/src/components/breadcrumb/breadcrumb.docs.mdx

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ The link provided will open in the same page, similar to `target="self"`.
3333
Whether the item is currently active. This state must be controlled by consumers. When an item is active, it cannot be hovered and no selection
3434
event is emitted in order to prevent navigating in place.
3535

36-
### paddingVertical
36+
### paddingTop & paddingBottom
3737

38-
The `paddingVertical` property allows you to adjust the vertical padding (top and bottom) of the `Breadcrumb` component. This property accepts pixel values as a number.
38+
The `paddingTop` and `paddingBottom` properties allow you to adjust the top and bottom padding of the `Breadcrumb` component respectively. These properties accept pixel values as numbers.
3939

40-
| Property | Type | Default | Description |
41-
| ----------------- | -------- | ------- | ------------------------------------------------------ |
42-
| `paddingVertical` | `number` | `0` | Sets the vertical padding of the breadcrumb component. |
40+
| Property | Type | Default | Description |
41+
| --------------- | -------- | ------- | ------------------------------------------ |
42+
| `paddingTop` | `number` | `0` | Sets the top padding of the breadcrumb. |
43+
| `paddingBottom` | `number` | `0` | Sets the bottom padding of the breadcrumb. |
4344

4445
## Events
4546

packages/core-components/src/components/breadcrumb/breadcrumb.scss

+28-29
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,39 @@
22
@use '../../global/b2b-styles';
33

44
:host {
5-
.b2b-breadcrumb-nav {
6-
z-index: 99;
7-
display: flex;
8-
flex-flow: row nowrap;
9-
padding-top: var(--b2b-breadcrumb-padding-vertical, 0);
10-
padding-bottom: var(--b2b-breadcrumb-padding-vertical, 0);
11-
height: var(--b2b-size-90);
12-
margin-bottom: 1.125rem;
13-
border-bottom: var(--b2b-size-border-width-50) solid
14-
var(--b2b-color-grey-200);
5+
display: block;
6+
}
157

16-
&__item {
17-
font-size: var(--b2b-size-copy-125);
18-
line-height: var(--b2b-size-copy-line-height-125);
19-
display: inline-flex;
20-
color: var(--b2b-color-copy-secondary);
21-
cursor: pointer;
8+
.b2b-breadcrumb-nav {
9+
z-index: 99;
10+
display: flex;
11+
flex-flow: row nowrap;
12+
height: var(--b2b-size-90);
13+
margin-bottom: 1.125rem;
14+
border-bottom: var(--b2b-size-border-width-50) solid var(--b2b-color-grey-200);
2215

23-
& a {
24-
color: var(--b2b-color-grey-400);
25-
text-decoration: none;
26-
}
16+
&__item {
17+
font-size: var(--b2b-size-copy-125);
18+
line-height: var(--b2b-size-copy-line-height-125);
19+
display: inline-flex;
20+
color: var(--b2b-color-copy-secondary);
21+
cursor: pointer;
22+
23+
& a {
24+
color: var(--b2b-color-grey-400);
25+
text-decoration: none;
26+
}
2727

28+
&:hover,
29+
a:hover {
30+
color: var(--b2b-color-red-100);
31+
}
32+
33+
&--active {
2834
&:hover,
2935
a:hover {
30-
color: var(--b2b-color-red-100);
31-
}
32-
33-
&--active {
34-
&:hover,
35-
a:hover {
36-
cursor: default;
37-
color: var(--b2b-color-grey-400);
38-
}
36+
cursor: default;
37+
color: var(--b2b-color-grey-400);
3938
}
4039
}
4140
}

packages/core-components/src/components/breadcrumb/breadcrumb.stories.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { Meta, Story } from '@storybook/web-components';
22
import { html } from 'lit-html';
33
import { getArgTypes } from '../../docs/config/utils';
44

5-
const Template: Story = ({ href, active, paddingVertical }) => {
5+
const Template: Story = ({ href, active, paddingTop, paddingBottom }) => {
66
return html`
7-
<b2b-breadcrumb padding-vertical="${paddingVertical}">
7+
<b2b-breadcrumb
8+
padding-top="${paddingTop}"
9+
padding-bottom="${paddingBottom}">
810
<b2b-breadcrumb-item href="${href}">Start</b2b-breadcrumb-item>
911
<b2b-breadcrumb-item>Weiter</b2b-breadcrumb-item>
1012
<b2b-breadcrumb-item active="${active}">Ende</b2b-breadcrumb-item>
@@ -15,19 +17,21 @@ const Template: Story = ({ href, active, paddingVertical }) => {
1517
const defaultArgs = {
1618
href: 'https://www.otto.de',
1719
active: true,
18-
paddingVertical: 0, // Default padding in px
20+
paddingTop: 0, // Default padding top in px
21+
paddingBottom: 0, // Default padding bottom in px
1922
};
2023

2124
export const story010Default = Template.bind({});
2225
story010Default.args = { ...defaultArgs };
2326
story010Default.storyName = 'Default Breadcrumb';
2427

25-
export const story020PaddingVertical = Template.bind({});
26-
story020PaddingVertical.args = {
28+
export const story020PaddingTopBottom = Template.bind({});
29+
story020PaddingTopBottom.args = {
2730
...defaultArgs,
28-
paddingVertical: 20, // Example with custom paddingVertical
31+
paddingTop: 10, // Example with custom padding top
32+
paddingBottom: 15, // Example with custom padding bottom
2933
};
30-
story020PaddingVertical.storyName = 'Breadcrumb with Custom Vertical Padding';
34+
story020PaddingTopBottom.storyName = 'Custom Padding';
3135

3236
const breadcrumbArgs = getArgTypes('b2b-breadcrumb');
3337

packages/core-components/src/components/breadcrumb/breadcrumb.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ import { BreadCrumbChangeEventDetail } from '../../utils/interfaces/interaction.
1818
export class B2bBreadCrumbComponent {
1919
@Element() host: HTMLB2bBreadcrumbElement;
2020

21-
/** Vertical padding for the breadcrumb component */
22-
@Prop() paddingVertical: number = 0; // Default value is 0px
21+
/** Padding for the top of the breadcrumb component */
22+
@Prop() paddingTop: number = 0; // Default value is 0px
23+
24+
/** Padding for the bottom of the breadcrumb component */
25+
@Prop() paddingBottom: number = 0; // Default value is 0px
2326

2427
/** Emits the value of the currently selected item whenever an item is selected. */
2528
@Event({ eventName: 'b2b-selected' })
@@ -38,15 +41,16 @@ export class B2bBreadCrumbComponent {
3841

3942
private updateActiveItem = (newItem: HTMLB2bBreadcrumbItemElement) => {
4043
this.getBreadcrumbItems()
41-
.filter(x => x.value != newItem.value)
44+
.filter(x => x.value !== newItem.value)
4245
.forEach(x => (x.active = false));
4346
};
4447

4548
render() {
4649
return (
4750
<Host
4851
style={{
49-
'--b2b-breadcrumb-padding-vertical': `${this.paddingVertical}px`,
52+
paddingTop: `${this.paddingTop}px`,
53+
paddingBottom: `${this.paddingBottom}px`,
5054
}}>
5155
<div class="b2b-breadcrumb-nav">
5256
<slot></slot>

packages/core-components/src/docs/config/components-args.json

+81-5
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
}
173173
},
174174
"b2b-breadcrumb": {
175-
"paddingVertical": {
175+
"paddingBottom": {
176176
"table": {
177177
"type": {
178178
"summary": "number"
@@ -181,7 +181,18 @@
181181
"summary": "0"
182182
}
183183
},
184-
"description": "Vertical padding for the breadcrumb component"
184+
"description": "Padding for the bottom of the breadcrumb component"
185+
},
186+
"paddingTop": {
187+
"table": {
188+
"type": {
189+
"summary": "number"
190+
},
191+
"defaultValue": {
192+
"summary": "0"
193+
}
194+
},
195+
"description": "Padding for the top of the breadcrumb component"
185196
}
186197
},
187198
"b2b-breadcrumb-item": {
@@ -2571,9 +2582,16 @@
25712582
"description": "The maximum amount of chips visible. Adjust this depending on available size of the dropdown."
25722583
},
25732584
"optionsList": {
2585+
"options": [
2586+
null,
2587+
null
2588+
],
2589+
"control": {
2590+
"type": "radio"
2591+
},
25742592
"table": {
25752593
"type": {
2576-
"summary": "string[]"
2594+
"summary": "string"
25772595
},
25782596
"defaultValue": {
25792597
"summary": "[]"
@@ -2609,9 +2627,16 @@
26092627
"description": "The string displayed as the select all label."
26102628
},
26112629
"selectedValues": {
2630+
"options": [
2631+
null,
2632+
null
2633+
],
2634+
"control": {
2635+
"type": "radio"
2636+
},
26122637
"table": {
26132638
"type": {
2614-
"summary": "string[]"
2639+
"summary": "string"
26152640
},
26162641
"defaultValue": {
26172642
"summary": "[]"
@@ -2711,6 +2736,39 @@
27112736
},
27122737
"description": "The alignment of the text."
27132738
},
2739+
"display": {
2740+
"options": [
2741+
"block",
2742+
"inline",
2743+
"inline-block"
2744+
],
2745+
"control": {
2746+
"type": "radio"
2747+
},
2748+
"table": {
2749+
"type": {
2750+
"summary": "string"
2751+
},
2752+
"defaultValue": {
2753+
"summary": "'block'"
2754+
}
2755+
},
2756+
"description": "The positioning of the paragraph in the page flow. Defaults to native block behavior."
2757+
},
2758+
"margin": {
2759+
"control": {
2760+
"type": "boolean"
2761+
},
2762+
"table": {
2763+
"type": {
2764+
"summary": "boolean"
2765+
},
2766+
"defaultValue": {
2767+
"summary": "true"
2768+
}
2769+
},
2770+
"description": "Whether or not the paragraph has a bottom margin. Defaults to true."
2771+
},
27142772
"size": {
27152773
"options": [
27162774
"100",
@@ -2729,6 +2787,24 @@
27292787
},
27302788
"description": "The size of the text."
27312789
},
2790+
"variant": {
2791+
"options": [
2792+
"black-100",
2793+
"grey-400"
2794+
],
2795+
"control": {
2796+
"type": "radio"
2797+
},
2798+
"table": {
2799+
"type": {
2800+
"summary": "string"
2801+
},
2802+
"defaultValue": {
2803+
"summary": "'black-100'"
2804+
}
2805+
},
2806+
"description": "The color of the paragraph. Defaults to black."
2807+
},
27322808
"weight": {
27332809
"options": [
27342810
"bold",
@@ -4174,4 +4250,4 @@
41744250
"description": "Use when wizard has property custom true. The step number"
41754251
}
41764252
}
4177-
}
4253+
}

0 commit comments

Comments
 (0)