Skip to content

Commit

Permalink
feat(button): implemented size 'S' (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMenga authored Apr 10, 2024
1 parent 20a98b2 commit 396d4dc
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/button/button-link/button-link.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -44,6 +45,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
2 changes: 2 additions & 0 deletions src/components/button/button-static/button-static.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withSlottedIcon,
withHiddenSlottedIcon,
} from '../common/common-stories.js';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
2 changes: 2 additions & 0 deletions src/components/button/button/button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -45,6 +46,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
9 changes: 9 additions & 0 deletions src/components/button/common/button-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ $icon-only: ':where([data-slot-names~=icon], [icon-name]):not([data-slot-names~=
}
}

:host([size='s']) {
--sbb-button-min-height: var(--sbb-size-element-xs);
--sbb-button-padding-inline: var(--sbb-spacing-fixed-4x);

@include sbb.mq($from: medium) {
--sbb-button-padding-inline: var(--sbb-spacing-fixed-5x);
}
}

:host(#{$icon-only}) {
--sbb-button-padding-inline: 0;
--icon-margin-inline-end: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/common/button-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SbbIconNameMixin, type SbbIconNameMixinType } from '../../icon/index.js

export type SbbButtonCommonElement = SbbButtonCommonElementMixinType & SbbActionBaseElement;

export type SbbButtonSize = 'l' | 'm';
export type SbbButtonSize = 'l' | 'm' | 's';

export declare class SbbButtonCommonElementMixinType
implements SbbNegativeMixinType, Partial<SbbDisabledMixinType>, Partial<SbbIconNameMixinType>
Expand Down
9 changes: 8 additions & 1 deletion src/components/button/common/common-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const size: InputType = {
control: {
type: 'inline-radio',
},
options: ['l', 'm'],
options: ['l', 'm', 's'],
};

const iconName: InputType = {
Expand Down Expand Up @@ -192,6 +192,13 @@ export const sizeM: StoryObj = {
},
};

export const sizeS: StoryObj = {
render: Template,
args: {
size: size.options[2],
},
};

export const fixedWidth: StoryObj = {
render: FixedWidthTemplate,
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -44,6 +45,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withSlottedIcon,
withHiddenSlottedIcon,
} from '../common/common-stories.js';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -45,6 +46,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -44,6 +45,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withSlottedIcon,
withHiddenSlottedIcon,
} from '../common/common-stories.js';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -45,6 +46,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -44,6 +45,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withSlottedIcon,
withHiddenSlottedIcon,
} from '../common/common-stories.js';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
primaryNegativeActive,
primaryNegativeDisabled,
sizeM,
sizeS,
withHiddenSlottedIcon,
withSlottedIcon,
} from '../common/common-stories.js';
Expand All @@ -45,6 +46,7 @@ export const IconOnlyNegative: StoryObj = iconOnlyNegative;
export const IconOnlyDisabled: StoryObj = iconOnlyDisabled;
export const NoIcon: StoryObj = noIcon;
export const SizeM: StoryObj = sizeM;
export const SizeS: StoryObj = sizeS;
export const FixedWidth: StoryObj = fixedWidth;
export const WithSlottedIcon: StoryObj = withSlottedIcon;
export const Active: StoryObj = primaryActive;
Expand Down

0 comments on commit 396d4dc

Please sign in to comment.