Skip to content

Commit

Permalink
refactor: refactoring form-feedback messages
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Dec 27, 2023
1 parent 1488f36 commit e4a113a
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 51 deletions.
118 changes: 69 additions & 49 deletions paragon/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,53 +57,73 @@
// This loop is modeled after the loop in bootstrap's _forms.scss
// which calls a mixin, form-validation-state($state, $color, $icon).
// We make several overrides here for icons and focus states.
@each $state, $data in $form-validation-states {
$color: map-get($data, color);
$icon: map-get($data, icon);

// Do not use validation color for feedback text
// Add the validation icon to feedback text
.#{$state}-feedback {
color: $body-color;
font-weight: 400;

&:before {
content: '';
background-image: $icon;
height: 1rem;
width: 1rem;
display: inline-block;
vertical-align: text-bottom;
margin-right: .3em;
}
.valid-feedback {
color: var(--pgn-color-body-base);
font-weight: 400;

&:before {
content: '';
background-image: var(--pgn-other-content-form-feedback-icon-valid);
height: var(--pgn-spacing-spacer-base);
width: var(--pgn-spacing-spacer-base);
display: inline-block;
vertical-align: text-bottom;
margin-right: .3em;
}
}

// Override focus states, use the standard focus
// instead of a generated color.
.form-control {
.was-validated &:#{$state},
&.is-#{$state} {
&:focus {
border-color: $color;
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) $color;
}
}
// Override focus states, use the standard focus
// instead of a generated color.
.form-control {
.was-validated &:valid, &.is-valid:focus {
border-color: var(--pgn-color-form-feedback-valid);
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) var(--pgn-color-form-feedback-valid);
}
}

.custom-select {
.was-validated &:#{$state},
&.is-#{$state} {
&:focus {
border-color: $color;
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) $color;
}
}
.custom-select {
.was-validated &:valid, &.is-valid:focus {
border-color: var(--pgn-color-form-feedback-valid);
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) var(--pgn-color-form-feedback-valid);
}
}

// Do not use validation color for feedback text
// Add the validation icon to feedback text
.invalid-feedback {
color: var(--pgn-color-body-base);
font-weight: 400;

&:before {
content: '';
background-image: var(--pgn-other-content-form-feedback-icon-invalid);
height: var(--pgn-spacing-spacer-base);
width: var(--pgn-spacing-spacer-base);
display: inline-block;
vertical-align: text-bottom;
margin-right: .3em;
}
}

// Override focus states, use the standard focus
// instead of a generated color.
.form-control {
.was-validated &:invalid, &.is-invalid:focus {
border-color: var(--pgn-color-form-feedback-invalid);
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) var(--pgn-color-form-feedback-invalid);
}
}

.custom-select {
.was-validated &:invalid, &.is-invalid:focus {
border-color: var(--pgn-color-form-feedback-invalid);
box-shadow: 0 0 0 var(--pgn-size-form-input-width-focus) var(--pgn-color-form-feedback-invalid);
}
}

select.form-control {
background-repeat: no-repeat;
background-position: right 1rem center;
background-position: right var(--pgn-spacing-spacer-base) center;
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
Expand Down Expand Up @@ -134,48 +154,48 @@ body {
}

h1, .h1 {
line-height: calc((44 / 16) * 1rem);
line-height: calc((44 / 16) * var(--pgn-spacing-spacer-base));
letter-spacing: -2%;

@media (--max-pgn-size-breakpoint-xs) {
line-height: calc((40 / 16) * 1rem);
line-height: calc((40 / 16) * var(--pgn-spacing-spacer-base));
}

.mobile-type & {
line-height: calc((40 / 16) * 1rem);
line-height: calc((40 / 16) * var(--pgn-spacing-spacer-base));
}
}

h2, .h2 {
line-height: calc((36 / 16) * 1rem);
line-height: calc((36 / 16) * var(--pgn-spacing-spacer-base));
}

h3, .h3 {
line-height: calc((28 / 16) * 1rem);
line-height: calc((28 / 16) * var(--pgn-spacing-spacer-base));
}

h4, .h4 {
line-height: calc((24 / 16) * 1rem);
line-height: calc((24 / 16) * var(--pgn-spacing-spacer-base));
}

h5, .h5 {
line-height: calc((20 / 16) * 1rem);
line-height: calc((20 / 16) * var(--pgn-spacing-spacer-base));
}

h6, .h6 {
line-height: calc((20 / 16) * 1rem);
line-height: calc((20 / 16) * var(--pgn-spacing-spacer-base));
}

.lead {
line-height: calc((36 / 16) * 1rem);
line-height: calc((36 / 16) * var(--pgn-spacing-spacer-base));
}

.small {
line-height: calc((24 / 16) * 1rem);
line-height: calc((24 / 16) * var(--pgn-spacing-spacer-base));
}

.x-small {
line-height: calc((20 / 16) * 1rem);
line-height: calc((20 / 16) * var(--pgn-spacing-spacer-base));
}

p > a[href]:not(.btn),
Expand Down
2 changes: 1 addition & 1 deletion paragon/css/core/custom-media-breakpoints.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* IMPORTANT: This file is the result of assembling design tokens
* Do not edit directly
* Generated on Thu, 27 Jul 2023 08:38:40 GMT
* Generated on Sun, 23 Jul 2023 16:09:04 GMT
*/

7 changes: 6 additions & 1 deletion paragon/css/themes/light/variables.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* IMPORTANT: This file is the result of assembling design tokens
* Do not edit directly
* Generated on Thu, 27 Jul 2023 08:38:40 GMT
* Generated on Thu, 10 Aug 2023 08:21:39 GMT
*/

:root {
Expand Down Expand Up @@ -195,12 +195,17 @@
--pgn-color-btn-border-outline-brand: #F2F0EFFF;
--pgn-color-btn-bg-inverse-warning: #000000FF;
--pgn-color-btn-bg-warning: #F0CC00FF;
--pgn-color-btn-bg-outline-success: #FFFFFFFF;
--pgn-color-btn-bg-outline-secondary: #FFFFFFFF;
--pgn-color-btn-bg-inverse-primary: #FFFFFFFF;
--pgn-color-btn-bg-outline-primary: #FFFFFFFF;
--pgn-color-btn-bg-outline-light: #FFFFFFFF;
--pgn-color-btn-bg-inverse-light: #000000FF;
--pgn-color-btn-bg-outline-info: #FFFFFFFF;
--pgn-color-btn-bg-info: #03C7E8FF;
--pgn-color-btn-bg-outline-dark: #FFFFFFFF;
--pgn-color-btn-bg-outline-danger: #FFFFFFFF;
--pgn-color-btn-bg-outline-brand: #FFFFFFFF;
--pgn-color-btn-text-warning: #000000FF;
--pgn-color-btn-text-light: #000000FF;
--pgn-color-btn-text-inverse-info: #03C7E8FF;
Expand Down
1 change: 1 addition & 0 deletions tokens/src/themes/light/components/Button/brand.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"inverse-brand": { "value": "{color.white}" }
},
"bg": {
"outline-brand": { "value": "{color.white}" },
"inverse-brand": { "value": "{color.brand.500}", "modify": null }
},
"border": {
Expand Down
3 changes: 3 additions & 0 deletions tokens/src/themes/light/components/Button/danger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"color": {
"btn": {
"bg": {
"outline-danger": { "value": "{color.white}" }
},
"border": {
"danger": { "value": "transparent" },
"outline-danger": { "value": "{color.light.300}" }
Expand Down
3 changes: 3 additions & 0 deletions tokens/src/themes/light/components/Button/dark.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"color": {
"btn": {
"bg": {
"outline-dark": { "value": "{color.white}" }
},
"active": {
"bg": {
"inverse-outline-dark": { "value": "{color.white}" }
Expand Down
1 change: 1 addition & 0 deletions tokens/src/themes/light/components/Button/primary.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"color": {
"btn": {
"bg": {
"outline-primary": { "value": "{color.white}" },
"inverse-primary": { "value": "{color.white}", "modify": null }
},
"border": {
Expand Down
3 changes: 3 additions & 0 deletions tokens/src/themes/light/components/Button/success.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"color": {
"btn": {
"bg": {
"outline-success": { "value": "{color.white}" }
},
"border": {
"outline-success": { "value": "{color.light.300}" }
},
Expand Down

0 comments on commit e4a113a

Please sign in to comment.