Skip to content

Commit

Permalink
fix(sbb-teaser): prevent overlapping chip if including long content (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Mar 4, 2024
1 parent 5e5a7cb commit b78b3ce
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/teaser/teaser.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
flex-flow: var(--sbb-teaser-flex-direction) nowrap;
align-items: var(--sbb-teaser-align-items);
gap: var(--sbb-teaser-gap);
max-width: 100%;
}

.sbb-teaser__text {
overflow: hidden;
max-width: 100%;
}

::slotted([slot='image']) {
Expand Down
29 changes: 29 additions & 0 deletions src/components/teaser/teaser.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ const TemplateDefault = ({ description, ...remainingArgs }: Args): TemplateResul
`;
};

const TemplateDefaultFixedWidth = ({ description, ...remainingArgs }: Args): TemplateResult => {
return html`
<sbb-teaser ${sbbSpread(remainingArgs)} style="width:400px">
<img slot="image" src=${placeholderImage} alt="400x300" />
${description}
</sbb-teaser>
`;
};

const TemplateCustom = ({ description, ...remainingArgs }: Args): TemplateResult => {
return html`
<sbb-teaser ${sbbSpread(remainingArgs)}>
Expand Down Expand Up @@ -162,12 +171,32 @@ export const AfterChip: StoryObj = {
args: { ...defaultArgs, alignment: 'after', 'chip-content': 'This is a chip.' },
};

export const AfterWithLongContentChip: StoryObj = {
render: TemplateDefaultFixedWidth,
argTypes: defaultArgTypes,
args: {
...defaultArgs,
alignment: 'after',
'chip-content': 'This is a chip which has a very long content and should receive ellipsis.',
},
};

export const BelowChip: StoryObj = {
render: TemplateDefault,
argTypes: defaultArgTypes,
args: { ...defaultArgs, alignment: 'below', 'chip-content': 'This is a chip.' },
};

export const BelowWithLongContentChip: StoryObj = {
render: TemplateDefaultFixedWidth,
argTypes: defaultArgTypes,
args: {
...defaultArgs,
alignment: 'below',
'chip-content': 'This is a chip which has a very long content and should receive ellipsis.',
},
};

export const WithLongTextCentered: StoryObj = {
render: TemplateDefault,
argTypes: defaultArgTypes,
Expand Down

0 comments on commit b78b3ce

Please sign in to comment.