Skip to content

Commit

Permalink
feat(sbb-toggle-check): add size 'xs' (#2724)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideMininni-Fincons committed Jun 13, 2024
1 parent 861f98d commit 7415aeb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["sbb-toggle-check should render DOM"] =
snapshots["sbb-toggle-check renders DOM"] =
`<sbb-toggle-check
checked=""
data-checked=""
Expand All @@ -11,9 +11,9 @@ snapshots["sbb-toggle-check should render DOM"] =
>
</sbb-toggle-check>
`;
/* end snapshot sbb-toggle-check should render DOM */
/* end snapshot sbb-toggle-check renders DOM */

snapshots["sbb-toggle-check should render Shadow DOM"] =
snapshots["sbb-toggle-check renders Shadow DOM"] =
`<span class="sbb-toggle-check">
<span class="sbb-toggle-check__container">
<span class="sbb-toggle-check__label">
Expand All @@ -38,7 +38,7 @@ snapshots["sbb-toggle-check should render Shadow DOM"] =
</span>
</span>
`;
/* end snapshot sbb-toggle-check should render Shadow DOM */
/* end snapshot sbb-toggle-check renders Shadow DOM */

snapshots["sbb-toggle-check A11y tree Chrome"] =
`<p>
Expand Down
11 changes: 11 additions & 0 deletions src/elements/toggle-check/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ The component can be displayed in `checked` or `disabled` states using the self-
<sbb-toggle-check name="other" value="Value" disabled>Option</sbb-toggle-check>
```

## Style

The component has three different sizes (`xs`, `s`, which is the default, and `m`),
which can be changed using the `size` property.

```html
<sbb-toggle-check size="m" value="single-checkbox"> Example in m size</sbb-toggle-check>

<sbb-toggle-check size="xs" value="single-checkbox"> Example in xs size </sbb-toggle-check>
```

## Events

Consumers can listen to the native `change` event on the `sbb-toggle-check` component to intercept the input's change;
Expand Down
4 changes: 4 additions & 0 deletions src/elements/toggle-check/toggle-check.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
:host([size='m']) & {
@include sbb.text-m--regular;
}

:host([size='xs']) & {
@include sbb.text-xs--regular;
}
}

.sbb-toggle-check__label {
Expand Down
2 changes: 1 addition & 1 deletion src/elements/toggle-check/toggle-check.snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { SbbToggleCheckElement } from './toggle-check.js';
import './toggle-check.js';

describe(`sbb-toggle-check`, () => {
describe('should render', async () => {
describe('renders', async () => {
let element: SbbToggleCheckElement;

beforeEach(async () => {
Expand Down
27 changes: 23 additions & 4 deletions src/elements/toggle-check/toggle-check.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const size: InputType = {
control: {
type: 'inline-radio',
},
options: ['s', 'm'],
options: ['xs', 's', 'm'],
};

const checked: InputType = {
Expand Down Expand Up @@ -89,7 +89,7 @@ const defaultArgTypes: ArgTypes = {
};

const defaultArgs: Args = {
size: size.options![0],
size: size.options![1],
checked: false,
disabled: false,
label: 'Label',
Expand Down Expand Up @@ -178,7 +178,16 @@ export const SbbToggleCheckDefaultSizeM: StoryObj = {
argTypes: defaultArgTypes,
args: {
...defaultArgs,
size: size.options![1],
size: size.options![2],
},
};

export const SbbToggleCheckDefaultSizeXS: StoryObj = {
render: Template,
argTypes: defaultArgTypes,
args: {
...defaultArgs,
size: size.options![0],
},
};

Expand Down Expand Up @@ -206,7 +215,17 @@ export const SbbToggleCheckDefaultLongLabelSizeM: StoryObj = {
args: {
...defaultArgs,
label: longLabel,
size: size.options![1],
size: size.options![2],
},
};

export const SbbToggleCheckDefaultLongLabelSizeXS: StoryObj = {
render: Template,
argTypes: defaultArgTypes,
args: {
...defaultArgs,
label: longLabel,
size: size.options![0],
},
};

Expand Down

0 comments on commit 7415aeb

Please sign in to comment.