Skip to content

Commit 2fbd3e2

Browse files
committed
fix(snackbar): add width prop for snackbar
1 parent f27aea3 commit 2fbd3e2

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

packages/core-components/src/components/snackbar/readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| `opened` | `opened` | Whether the snackbar is currently visible. Set to true to display the snackbar. | `boolean` | `false` |
1717
| `timed` | `timed` | Whether snackbar is show for limited time. Default is true. Error snackbars cannot be timed. | `boolean` | `true` |
1818
| `type` | `type` | The type of snackbar. Default is info. | `"error" \| "info" \| "success" \| "warning"` | `'info'` |
19+
| `width` | `width` | Width of the snackbar in px, Default value is 270px* | `string` | `'270px'` |
1920

2021

2122
## Events

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

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
line-height: var(--b2b-size-copy-line-height-100);
88
color: var(--b2b-color-copy-default);
99
max-width: 1000px;
10-
min-width: 270px;
1110
max-height: 56px;
1211
min-height: 48px;
1312
box-shadow: 0 var(--b2b-size-1) var(--b2b-size-10) 0 #00000040;

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const meta: Meta = {
1818
duration: 5000,
1919
hasAction: true,
2020
actionLabel: 'Call to Action',
21+
width: '270px',
2122
},
2223
argTypes: getArgTypes('b2b-snackbar'),
2324
render: ({ ...args }) => {
@@ -42,7 +43,8 @@ const meta: Meta = {
4243
timed="${args.timed}"
4344
duration="${args.duration}"
4445
has-action="${args.hasAction}"
45-
action-label="${args.actionLabel}"></b2b-snackbar>`;
46+
action-label="${args.actionLabel}"
47+
width="${args.width}"></b2b-snackbar>`;
4648
},
4749
};
4850

@@ -104,6 +106,7 @@ export const TimedSnackbar: Story = {
104106
timed: true,
105107
duration: 3000,
106108
description: 'This is timed snackbar',
109+
width: '270px',
107110
},
108111
play: async () => {
109112
await showSnackBar();

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export class SnackbarComponent {
3535
/** Text for the Call-to-Action link. */
3636
@Prop() actionLabel: string;
3737

38+
/** Width of the snackbar in px, Default value is 270px. */
39+
@Prop() width: string = '270px';
40+
3841
/** Emits whenever the snackbar is closed. */
3942
@Event({ eventName: 'b2b-close' })
4043
b2bClose: EventEmitter<void>;
@@ -137,7 +140,8 @@ export class SnackbarComponent {
137140
'b2b-snackbar': true,
138141
[`b2b-snackbar--${this.type}`]: true,
139142
'b2b-snackbar--opened': this.opened,
140-
}}>
143+
}}
144+
style={{ minWidth: this.width }}>
141145
<div class="b2b-snackbar__content">
142146
<span class={{ [`b2b-snackbar--${this.type}__icon`]: true }}>
143147
{this.chooseIcon()}

0 commit comments

Comments
 (0)