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(styles): Update form-control and form-select sizes #2396

Merged
merged 45 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
abf203b
feat(styles): Add success state to text input
imagoiq Dec 11, 2023
17f937f
Test update to stencil/core4.8.2 to fix unit
imagoiq Dec 12, 2023
b6ac40f
Merge branch 'main' into feat/1835-text-input-success-state
imagoiq Dec 12, 2023
73866ec
fix(unit): Upgrade to Jest 29
imagoiq Dec 12, 2023
3202f8f
Merge remote-tracking branch 'origin/feat/1835-text-input-success-sta…
imagoiq Dec 12, 2023
8dc04fc
fix(unit): Add missing jest-environment-jsdom
imagoiq Dec 12, 2023
b19ba6e
fix(unit): Upgrade ts-jest
imagoiq Dec 12, 2023
79d0614
Merge branch 'main' into feat/1835-text-input-success-state
imagoiq Dec 12, 2023
1eb8aa0
Remove early optimization on duplication of icons
imagoiq Dec 12, 2023
b244e47
Readd input size condition
imagoiq Dec 12, 2023
5694872
Better support for success and other type of inputs
imagoiq Dec 13, 2023
d144c78
Fix missing variables
imagoiq Dec 13, 2023
638faca
Merge success state into is-valid for select and input
imagoiq Jan 8, 2024
8601562
Fix for floating label
imagoiq Jan 8, 2024
4a4d435
Fix changelog
imagoiq Jan 8, 2024
f07fe5a
Merge branch 'main' into feat/1835-text-input-success-state
imagoiq Jan 8, 2024
9e1abc2
feat(styles): Update forms styles
imagoiq Dec 13, 2023
1122cfa
Add changeset
imagoiq Dec 13, 2023
8db2880
Fix test
imagoiq Dec 13, 2023
bb7bd03
Fix mixins test
imagoiq Dec 13, 2023
ceb12ac
Fix icon size validation
imagoiq Dec 13, 2023
066c487
Add floatingLabel small variant to snapshot
imagoiq Dec 13, 2023
8521bbf
Improve date native icon centering
imagoiq Dec 13, 2023
95bb3c3
Fix missing import
imagoiq Dec 13, 2023
20546a8
Lint
imagoiq Dec 13, 2023
f2306a0
Lint
imagoiq Dec 13, 2023
5bb5e47
Fix code smell
imagoiq Dec 13, 2023
09ec89e
Change input story to display large variant by default
imagoiq Jan 8, 2024
80204c2
Fix line-height and padding
imagoiq Jan 8, 2024
018aacd
Remove duplication
imagoiq Jan 8, 2024
f1012c3
Improve structure
imagoiq Jan 8, 2024
825c4f1
Fixes for input multiple and arrows
imagoiq Jan 9, 2024
465c19d
Lint
imagoiq Jan 9, 2024
376ee3e
Merge branch 'main' into feat/1835-update-form-styles
imagoiq Jan 15, 2024
dd08ce7
Merge branch 'main' into feat/1835-update-form-styles
imagoiq Jan 16, 2024
6846d5e
Fix code smell
imagoiq Jan 16, 2024
6a5b0a4
Merge branch 'main' into feat/1835-update-form-styles
imagoiq Jan 18, 2024
f45aa3e
Merge branch 'main' into feat/1835-update-form-styles
imagoiq Jan 30, 2024
12f2b1f
Hide deprecated sizes when using floating-label
imagoiq Jan 30, 2024
3d12da2
Remove success from snapshots
imagoiq Jan 30, 2024
ba75717
fix(docs): update select snapshot tests
alizedebray Jan 30, 2024
f58875b
Slight improvement for select multiple
imagoiq Jan 30, 2024
0231a08
Improvement position of validation icon for date and time input and t…
imagoiq Jan 30, 2024
1e0935a
Merge branch 'main' into feat/1835-update-form-styles
imagoiq Jan 30, 2024
179a9a7
Support week and month input type
imagoiq Jan 30, 2024
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
5 changes: 5 additions & 0 deletions .changeset/grumpy-pianos-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-styles': patch
---

Updated `form-control` and `form-select` sizes and added support for floating label small size variant.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function renderInputSnapshot(_args: Args, context: StoryContext) {
label: `Label - with Value`,
value: 'Lorem Ipsum',
},
{
label: `Label - Floating label`,
floatingLabel: true,
},
];
return html`
<div class="d-flex flex-wrap align-items-start gap-regular">
Expand Down
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const meta: Meta = {
hiddenLabel: false,
placeholder: 'Placeholder',
type: 'text',
size: 'null',
size: 'form-control-lg',
hint: 'Hintus textus elare volare cantare hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.',
disabled: false,
validation: 'null',
Expand Down Expand Up @@ -103,10 +103,6 @@ const meta: Meta = {
size: {
name: 'Size',
description: "Sets the size of the component's appearance.",
if: {
arg: 'floatingLabel',
truthy: false,
},
control: {
type: 'select',
labels: {
Expand Down
44 changes: 41 additions & 3 deletions packages/styles/src/components/floating-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
padding-bottom: forms.$form-floating-input-padding-b;

~ label {
color: forms.$form-floating-label-color;
padding-top: 0.7rem;
max-width: calc(
(100% * #{forms.$form-floating-label-upscale}) - #{forms.$form-floating-label-translate-x *
Expand All @@ -68,6 +69,38 @@
padding-top: forms.$form-floating-input-padding-t * 1.33;
}
}

&.form-control-sm {
&[type='date']::-webkit-calendar-picker-indicator {
margin-top: -(spacing.$size-small-regular);
}
font-size: forms.$form-floating-label-font-size-placeholder-sm;
height: forms.$form-floating-label-height-sm;
min-height: forms.$form-floating-label-height-sm;
padding-inline: forms.$form-floating-padding-x-sm;

~ label {
font-size: forms.$form-floating-label-font-size-placeholder-sm;
padding-top: forms.$form-floating-label-padding-t-sm;
padding-inline: calc(#{forms.$form-floating-padding-x-sm} - #{forms.$input-border-width});
}

&:focus,
&:not(:placeholder-shown) {
padding-top: forms.$form-floating-padding-y-sm * 2;

~ label {
padding-top: forms.$form-floating-padding-y-sm;
font-size: forms.$form-floating-label-font-size-sm;
}
}
}

&.form-control-lg {
&[type='date']::-webkit-calendar-picker-indicator {
margin-top: -(spacing.$size-small-large);
}
}
}

> .form-select {
Expand Down Expand Up @@ -121,7 +154,12 @@
2} - #{forms.$form-floating-padding-x * forms.$form-floating-label-upscale}
);
height: auto;
background: forms.$input-bg;
}

&:not(:disabled) {
~ label {
background: forms.$input-bg;
}
}

&:empty {
Expand Down Expand Up @@ -161,7 +199,7 @@
}

> textarea.form-control {
padding-top: forms.$input-padding-y-lg * 1.5;
padding-top: forms.$input-padding-y-lg * 2;
padding-bottom: forms.$input-padding-y-lg;
height: auto;

Expand All @@ -174,7 +212,7 @@

&:focus,
&:not(:placeholder-shown) {
padding-top: forms.$input-padding-y-lg * 1.5;
padding-top: forms.$input-padding-y-lg * 2;
padding-bottom: forms.$input-padding-y-lg;

~ label {
Expand Down
70 changes: 47 additions & 23 deletions packages/styles/src/components/form-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,74 @@
@use './../variables/components/form-select' as form-select;

.form-select-rg {
@include forms-mixins.form-control-rg;
@include forms-mixins.form-rg;
background-size: forms.$form-bg-size;
}

.form-select-lg {
background-size: form-select.$form-select-bg-size;
.form-select-sm {
@include forms-mixins.form-sm;
background-size: forms.$form-bg-size-sm;
}

.form-select-sm {
background-size: form-select.$form-select-bg-size-sm;
.form-select-lg {
@include forms-mixins.form-lg;
background-size: forms.$form-bg-size;
}

.form-select {
background-size: forms.$form-bg-size; // Support deprecated medium size

&:not(:disabled) {
&:hover {
border-color: var(--post-contrast-color);
}
}

&.is-valid,
&.is-invalid {
background-position:
right b.$form-select-padding-x * 2.5 center,
b.$form-select-bg-position;
&:not([multiple]) {
&:disabled {
background-image: b.escape-svg(form-select.$form-select-indicator-disabled),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
}

&.form-select-lg {
&.is-valid,
&.is-invalid {
background-position:
right b.$form-select-padding-x * 3 center,
right b.$form-select-padding-x * 2.5 center,
b.$form-select-bg-position;

&.form-select-lg {
background-position:
right b.$form-select-padding-x * 3 center,
b.$form-select-bg-position;
}
}
}

&:disabled {
background-image: b.escape-svg(form-select.$form-select-indicator-disabled),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
}
&.is-valid {
background-image: b.escape-svg(form-select.$form-select-indicator-success),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
}

&.is-valid {
background-image: b.escape-svg(form-select.$form-select-indicator-success),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
&.is-invalid {
background-image: b.escape-svg(form-select.$form-select-indicator-error),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
}
}

&.is-invalid {
background-image: b.escape-svg(form-select.$form-select-indicator-error),
var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
&[multiple] {
&.is-valid,
&.is-invalid {
background-position: right b.$form-select-padding-x * 1.5 center;
}

&.is-valid {
background-image: b.escape-svg(form-select.$form-select-indicator-success),
var(--bs-form-select-bg-icon, none);
}

&.is-invalid {
background-image: b.escape-svg(form-select.$form-select-indicator-error),
var(--bs-form-select-bg-icon, none);
}
}

@include utilities.high-contrast-mode() {
Expand Down
8 changes: 8 additions & 0 deletions packages/styles/src/components/form-validation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
background-repeat: no-repeat;
background-position: right b.$input-height-inner-quarter center;
background-size: form-validation.$form-feedback-icon-size;

&.form-control-sm {
background-size: forms.$form-bg-size-sm;
}

&.form-control-lg {
background-size: forms.$form-bg-size;
}
}
}

Expand Down
25 changes: 9 additions & 16 deletions packages/styles/src/components/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
@use './../themes/bootstrap/forms/input-group' as bfig;

.form-control-rg {
@include form-mixins.form-control-rg;
@include form-mixins.form-rg;
}

.form-control-sm {
@include form-mixins.form-sm;
}

.form-control-lg {
@include form-mixins.form-lg;
}

select.form-control-rg:not([size]):not([multiple]) {
Expand All @@ -35,11 +43,6 @@ select.form-control-rg:not([size]):not([multiple]) {
&[type='file'] {
position: relative;

min-height: calc(
(1rem * forms.$input-line-height) + (forms.$input-padding-y * 2) +
(forms.$input-border-width * 2)
);

&::file-selector-button {
display: block;
position: absolute;
Expand Down Expand Up @@ -108,11 +111,6 @@ select.form-control-rg:not([size]):not([multiple]) {
}

&.form-control-sm {
min-height: calc(
(1rem * forms.$input-line-height-sm) + (forms.$input-padding-y-sm * 2) +
(forms.$input-border-width * 2)
);

&::after {
padding-inline: forms.$input-padding-y-sm;
}
Expand All @@ -130,11 +128,6 @@ select.form-control-rg:not([size]):not([multiple]) {
}

&.form-control-lg {
min-height: calc(
(1rem * forms.$input-line-height-lg) + (forms.$input-padding-y-lg * 2) +
(forms.$input-border-width * 2)
);

&::after {
padding-inline: forms.$input-padding-y-lg;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/styles/src/components/timepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}

.form-control {
@include form-mixins.form-control-rg;
@include form-mixins.form-rg;
}
}

Expand Down
18 changes: 17 additions & 1 deletion packages/styles/src/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@
background-position: calc(100% - #{form-validation.$form-feedback-icon-offset}) center;
}

@mixin form-control-rg {
@mixin form-rg {
padding: forms.$input-padding-y-rg forms.$input-padding-x-rg;
font-size: type.$font-size-regular;
line-height: forms.$input-line-height-rg;
}

@mixin form-sm {
font-size: type.$font-size-14;
line-height: forms.$input-line-height-sm;
height: forms.$input-height-sm;
min-height: forms.$input-height-sm;
padding-block: forms.$input-padding-y-sm;
padding-inline: forms.$input-padding-x-sm;
}

@mixin form-lg {
font-size: type.$font-size-16;
line-height: forms.$input-line-height-lg;
height: forms.$input-height-lg;
min-height: forms.$input-height-lg;
}

@mixin focus-outline {
outline: none;
outline-offset: forms.$input-focus-outline-thickness;
Expand Down
1 change: 1 addition & 0 deletions packages/styles/src/variables/_type.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $font-size-40: sizing.px-to-rem(40px);
$font-size-48: sizing.px-to-rem(48px);
$font-size-56: sizing.px-to-rem(56px);

$line-height-sm: 1;
$line-height-copy: 1.5;
$line-height-heading: 1.2;

Expand Down
2 changes: 1 addition & 1 deletion packages/styles/src/variables/components/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $input-btn-padding-x: spacing.$size-small-large - $input-btn-border-width-rem !d
$input-btn-line-height: type.$line-height-copy !default;

$input-btn-padding-y-sm: spacing.$size-mini - $input-btn-border-width-rem !default;
$input-btn-padding-x-sm: spacing.$size-regular - $input-btn-border-width-rem !default;
$input-btn-padding-x-sm: spacing.$size-small-regular !default;
$input-btn-line-height-sm: type.$line-height-copy !default;

$input-btn-padding-y-rg: spacing.$size-small-regular - $input-btn-border-width-rem !default;
Expand Down
2 changes: 0 additions & 2 deletions packages/styles/src/variables/components/_form-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ $form-select-disabled-color: forms.$input-disabled-color;
$form-select-disabled-bg: forms.$input-disabled-bg;
$form-select-disabled-border-color: forms.$input-disabled-border-color;
$form-select-indicator-color: color.$black;
$form-select-bg-size: 32px 32px !default;
$form-select-bg-size-sm: 24px 24px !default;
$_form-select-indicator-icon: icons.get-colored-svg-url('2113', $form-select-indicator-color);
$form-select-indicator: url($_form-select-indicator-icon) !default;
$form-select-indicator-disabled: url(icons.get-colored-svg-url(
Expand Down
Loading
Loading