Skip to content

Commit

Permalink
fix: long labels on vertical orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
dauriamarco committed Mar 16, 2024
1 parent 62089ac commit 9df4fba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/components/stepper/step-label/step-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,39 @@
@include sbb.text-l--bold;

cursor: pointer;
position: relative;
display: flex;
align-items: center;
gap: var(--sbb-spacing-fixed-4x);
color: var(--sbb-step-label-color);
}

.sbb-step-label__prefix {
position: relative;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
min-width: var(--sbb-step-label-prefix-size);
min-height: var(--sbb-step-label-prefix-size);
width: var(--sbb-step-label-prefix-size);
height: var(--sbb-step-label-prefix-size);
border-radius: 50%;
border: var(--sbb-border-width-1x) var(--sbb-step-label-prefix-border-style)
var(--sbb-step-label-prefix-border-color);
background-color: var(--sbb-step-label-prefix-background-color);
inset-block-start: calc(
1em * (var(--sbb-typo-line-height-body-text) / 2) + (var(--sbb-border-width-1x) / 2) -
(var(--sbb-step-label-prefix-size) / 2)
);
transition: background-color var(--sbb-animation-duration-6x) ease;

&::before {
content: var(--sbb-step-label-counter);
}
}

.sbb-step-label__text {
@include sbb.ellipsis;

text-wrap: nowrap;
:host([data-orientation='horizontal']) & {
@include sbb.ellipsis;
}
}

sbb-icon {
Expand Down
6 changes: 5 additions & 1 deletion src/components/stepper/stepper/stepper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@
cursor: pointer;
position: absolute;
color: var(--sbb-step-label-color);
inset-block-start: calc(var(--sbb-step-label-prefix-size) / 2);
inset-block-start: calc(
var(--sbb-font-size-text-l) * (var(--sbb-typo-line-height-body-text) / 2) +
(var(--sbb-border-width-1x) / 2)
);
inset-inline-start: calc(var(--sbb-step-label-prefix-size) / 2);
transform: translate(-50%, -50%);
line-height: 1;
z-index: 1;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/components/stepper/stepper/stepper.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ export const LongLabels: StoryObj = {
args: { ...defaultArgs },
};

export const LongLabelsVertical: StoryObj = {
render: LongLabelsTemplate,
argTypes: defaultArgTypes,
args: { ...defaultArgs, orientation: orientation.options[1] },
};

const meta: Meta = {
decorators: [
(story) => html` <div style="padding: 2rem;">${story()}</div> `,
Expand Down
1 change: 1 addition & 0 deletions src/components/stepper/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class SbbStepperElement extends LitElement {
this.steps.forEach((step) => {
step.slot = this.orientation === 'horizontal' ? 'step' : 'step-label';
step.setAttribute('data-orientation', this.orientation);
step.label?.setAttribute('data-orientation', this.orientation);
});
}

Expand Down

0 comments on commit 9df4fba

Please sign in to comment.