Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sbb-time-input): add size 's' #3018

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/elements/core/styles/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

// Time Input
--sbb-time-input-max-width: #{functions.px-to-rem-build(58)};
--sbb-time-input-s-max-width: #{functions.px-to-rem-build(51)};

// Overlay
--sbb-overlay-default-z-index: 1000;
Expand All @@ -41,6 +42,7 @@

// Time Input
--sbb-time-input-max-width: #{functions.px-to-rem-build(65)};
--sbb-time-input-s-max-width: #{functions.px-to-rem-build(58)};
}
}
}
Expand Down Expand Up @@ -123,4 +125,8 @@ sbb-title + p {

input[data-sbb-time-input] {
max-width: var(--sbb-time-input-max-width);

sbb-form-field[size='s'] & {
max-width: var(--sbb-time-input-s-max-width);
}
}
28 changes: 14 additions & 14 deletions src/elements/time-input/time-input.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const value: InputType = {
type: 'text',
},
table: {
category: 'Native input attribute',
category: 'Native input',
},
};

Expand All @@ -81,7 +81,7 @@ const readonly: InputType = {
type: 'boolean',
},
table: {
category: 'Native input attribute',
category: 'Native input',
},
};

Expand All @@ -90,7 +90,7 @@ const disabled: InputType = {
type: 'boolean',
},
table: {
category: 'Native input attribute',
category: 'Native input',
},
};

Expand All @@ -99,17 +99,17 @@ const required: InputType = {
type: 'boolean',
},
table: {
category: 'Native input attribute',
category: 'Native input',
},
};

const size: InputType = {
control: {
type: 'inline-radio',
},
options: ['m', 'l'],
options: ['s', 'm', 'l'],
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -118,7 +118,7 @@ const negative: InputType = {
type: 'boolean',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -127,7 +127,7 @@ const label: InputType = {
type: 'text',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -136,7 +136,7 @@ const optional: InputType = {
type: 'boolean',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -145,7 +145,7 @@ const borderless: InputType = {
type: 'boolean',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -154,7 +154,7 @@ const iconStart: InputType = {
type: 'text',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand All @@ -163,7 +163,7 @@ const iconEnd: InputType = {
type: 'text',
},
table: {
category: 'Form-field attribute',
category: 'Form-field',
},
};

Expand Down Expand Up @@ -196,7 +196,7 @@ const basicArgs: Args = {
const formFieldBasicArgs = {
...basicArgs,
label: 'Label',
size: size.options![0],
size: size.options![1],
optional: false,
borderless: false,
iconStart: undefined,
Expand All @@ -206,7 +206,7 @@ const formFieldBasicArgs = {
const formFieldBasicArgsWithIcons = {
...basicArgs,
label: 'Label',
size: size.options![0],
size: size.options![1],
optional: false,
borderless: false,
iconStart: 'clock-small',
Expand Down
25 changes: 17 additions & 8 deletions src/elements/time-input/time-input.visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ describe(`sbb-time-input`, () => {
withError: [false, true],
};

const sizeCases = {
size: ['s', 'm', 'l'],
noIcons: [false, true],
};

type ParamsType = { [K in keyof typeof cases]: (typeof cases)[K][number] } & {
[K in keyof typeof sizeCases]: (typeof sizeCases)[K][number];
} & {
readonly?: boolean;
borderless?: boolean;
disabled?: boolean;
noIcons?: boolean;
};
const template = (args: Partial<ParamsType>): TemplateResult => html`
TomMenga marked this conversation as resolved.
Show resolved Hide resolved
<sbb-form-field ?borderless=${args.borderless} ?negative=${args.negative} width="collapse">
Expand Down Expand Up @@ -62,6 +68,16 @@ describe(`sbb-time-input`, () => {
);
});

// Size and icons cases
describeEach(sizeCases, (params) => {
it(
state.name,
state.with(async (setup) => {
await setup.withFixture(template(params));
}),
);
});

it(
`disabled_${state.name}`,
state.with(async (setup) => {
Expand All @@ -82,13 +98,6 @@ describe(`sbb-time-input`, () => {
await setup.withFixture(template({ borderless: true }));
}),
);

it(
`no icon_${state.name}`,
state.with(async (setup) => {
await setup.withFixture(template({ noIcons: true }));
}),
);
}
});
});
Loading