From a9bc8ddf79f1b10b9aabefa13c07b7bb98a32a2b Mon Sep 17 00:00:00 2001 From: Darren Cadwallader Date: Thu, 4 May 2023 08:04:57 +0200 Subject: [PATCH] - Corrects colors - Cleanup stories - Adds zeplinLinks where available - Adds descriptive children/labels --- scss/bitstyles/base/forms/Label.js | 2 ++ scss/bitstyles/base/forms/_index.scss | 5 +++ scss/bitstyles/base/forms/_settings.scss | 6 +++- scss/bitstyles/base/forms/forms.stories.mdx | 36 ++++++++++++++++--- .../base/forms/input-checkbox.stories.js | 5 ++- .../base/forms/input-radio.stories.js | 13 ++++++- .../base/forms/input-text.stories.js | 7 ++-- scss/bitstyles/base/forms/label.stories.js | 6 ++++ scss/bitstyles/base/forms/select.stories.js | 3 -- .../bitstyles/base/input-checkbox/_index.scss | 7 ++++ .../base/input-checkbox/_settings.scss | 30 +++++++++------- scss/bitstyles/base/input-radio/_index.scss | 2 -- .../bitstyles/base/input-radio/_settings.scss | 23 ++++++------ 13 files changed, 104 insertions(+), 41 deletions(-) diff --git a/scss/bitstyles/base/forms/Label.js b/scss/bitstyles/base/forms/Label.js index 8c87b5809..26a0348eb 100644 --- a/scss/bitstyles/base/forms/Label.js +++ b/scss/bitstyles/base/forms/Label.js @@ -2,6 +2,7 @@ export default ({ children, htmlFor = null, ariaInvalid = false, + ariaDisabled = false, classnames = [], }) => { const label = document.createElement('label'); @@ -9,6 +10,7 @@ export default ({ label.append(child); }); if (ariaInvalid) label.setAttribute('aria-invalid', ariaInvalid); + if (ariaDisabled) label.setAttribute('aria-disabled', ariaDisabled); if (htmlFor) label.setAttribute('for', htmlFor); classnames.forEach((classname) => label.classList.add(classname)); return label; diff --git a/scss/bitstyles/base/forms/_index.scss b/scss/bitstyles/base/forms/_index.scss index 21c7139f6..37482d0ee 100644 --- a/scss/bitstyles/base/forms/_index.scss +++ b/scss/bitstyles/base/forms/_index.scss @@ -26,6 +26,11 @@ label { align-items: baseline; margin-bottom: settings.$label-gap; cursor: pointer; + font-weight: settings.$label-font-weight; + + &[aria-disabled="true"] { + color: settings.$label-disabled-color; + } } [type='color'] { diff --git a/scss/bitstyles/base/forms/_settings.scss b/scss/bitstyles/base/forms/_settings.scss index 4d226d036..42ae20e77 100644 --- a/scss/bitstyles/base/forms/_settings.scss +++ b/scss/bitstyles/base/forms/_settings.scss @@ -1,3 +1,5 @@ +@use '../../settings/typography'; +@use '../../tools/palette'; @use '../../tools/size'; // @@ -20,4 +22,6 @@ $legend-color: inherit !default; // // Label //////////////////////////////////////// -$label-gap: size.get('s7'); +$label-gap: size.get('s7') !default; +$label-font-weight: typography.$font-weight-medium !default; +$label-disabled-color: palette.get('grayscale') !default; diff --git a/scss/bitstyles/base/forms/forms.stories.mdx b/scss/bitstyles/base/forms/forms.stories.mdx index 21a9e58f8..be006f090 100644 --- a/scss/bitstyles/base/forms/forms.stories.mdx +++ b/scss/bitstyles/base/forms/forms.stories.mdx @@ -2,6 +2,8 @@ import { Canvas, Meta, Story } from '@storybook/addon-docs'; + + # Forms ## Inputs and labels @@ -18,6 +20,9 @@ This includes all standard `type="text"` inputs, plus all the text-based inputs + + + @@ -25,30 +30,53 @@ This includes all standard `type="text"` inputs, plus all the text-based inputs ## Textareas +### No values + - - - -## Checkboxes and Radios +### With values + + + + + + + +## Checkboxes + +### Unchecked + + +### Checked + + +## Radios + +### Unchecked + + + +### Checked + + diff --git a/scss/bitstyles/base/forms/input-checkbox.stories.js b/scss/bitstyles/base/forms/input-checkbox.stories.js index 6278b128d..280f221e5 100644 --- a/scss/bitstyles/base/forms/input-checkbox.stories.js +++ b/scss/bitstyles/base/forms/input-checkbox.stories.js @@ -12,12 +12,13 @@ const Template = (args) => { return Label({ htmlFor: args.id, ariaInvalid: args.ariaInvalid, + ariaDisabled: args.disabled, children: [Input(args), args.label], classname: 'u-items-baseline', }); }; -// ***** Text inputs with values ****************** // +// ***** Unchecked radios ****************** // export const Base = Template.bind({}); Base.args = { type: 'checkbox', label: 'Unchecked' }; @@ -56,6 +57,8 @@ Disabled.parameters = { 'https://app.zeplin.io/styleguide/63079b90d0bf4a646c46c227/components?coid=643fc971830548239007431f', }; +// ***** Checked radios ****************** // + export const Checked = Template.bind({}); Checked.args = { type: 'checkbox', diff --git a/scss/bitstyles/base/forms/input-radio.stories.js b/scss/bitstyles/base/forms/input-radio.stories.js index f9d83f6a1..3d3d480f1 100644 --- a/scss/bitstyles/base/forms/input-radio.stories.js +++ b/scss/bitstyles/base/forms/input-radio.stories.js @@ -12,12 +12,13 @@ const Template = (args) => { return Label({ htmlFor: args.id, ariaInvalid: args.ariaInvalid, + ariaDisabled: args.disabled, children: [Input(args), args.label], classname: 'u-items-baseline', }); }; -// ***** Text inputs with values ****************** // +// ***** Unchecked radios ****************** // export const Base = Template.bind({}); Base.args = { type: 'radio', label: 'Unchecked' }; @@ -43,6 +44,12 @@ Invalid.args = { type: 'radio', ariaInvalid: true, label: 'Unchecked invalid' }; export const Disabled = Template.bind({}); Disabled.args = { type: 'radio', disabled: true, label: 'Unchecked disabled' }; +Disabled.parameters = { + zeplinLink: + 'https://app.zeplin.io/styleguide/63079b90d0bf4a646c46c227/components?coid=643fc2bfc40d7123d9858e06', +}; + +// ***** Checked radios ****************** // export const Checked = Template.bind({}); Checked.args = { type: 'radio', checked: true, label: 'Checked' }; @@ -78,3 +85,7 @@ CheckedDisabled.args = { disabled: true, label: 'Checked disabled', }; +CheckedDisabled.parameters = { + zeplinLink: + 'https://app.zeplin.io/styleguide/63079b90d0bf4a646c46c227/components?coid=643fc2ba62f9d023b1e53c19', +}; diff --git a/scss/bitstyles/base/forms/input-text.stories.js b/scss/bitstyles/base/forms/input-text.stories.js index cab379ed9..f575b3dee 100644 --- a/scss/bitstyles/base/forms/input-text.stories.js +++ b/scss/bitstyles/base/forms/input-text.stories.js @@ -13,6 +13,7 @@ const Template = (args) => { const label = Label({ htmlFor: args.id, ariaInvalid: args.ariaInvalid, + ariaDisabled: args.disabled, children: [args.label], }); const input = Input(args); @@ -75,7 +76,7 @@ TextWithValueDisabled.parameters = { export const TextEmpty = Template.bind({}); TextEmpty.args = { value: '', - placeholder: 'Input text empty', + placeholder: 'Input text empty placeholder', label: 'Input text empty', }; TextEmpty.parameters = { @@ -98,7 +99,7 @@ TextEmpty.parameters = { export const TextEmptyInvalid = Template.bind({}); TextEmptyInvalid.args = { value: '', - placeholder: 'Input text empty invalid', + placeholder: 'Input text empty invalid placeholder', label: 'Input text empty invalid', ariaInvalid: true, }; @@ -110,7 +111,7 @@ TextEmptyInvalid.parameters = { export const TextEmptyDisabled = Template.bind({}); TextEmptyDisabled.args = { value: '', - placeholder: 'Input text empty disabled', + placeholder: 'Input text empty disabled placeholder', label: 'Input text empty disabled', disabled: true, }; diff --git a/scss/bitstyles/base/forms/label.stories.js b/scss/bitstyles/base/forms/label.stories.js index 57199a32e..0c8dfcb40 100644 --- a/scss/bitstyles/base/forms/label.stories.js +++ b/scss/bitstyles/base/forms/label.stories.js @@ -23,6 +23,12 @@ Invalid.args = { ariaInvalid: true, }; +export const Disabled = Template.bind({}); +Disabled.args = { + children: ['Simple text label for a disabled input'], + ariaDisabled: true, +}; + export const WithFor = Template.bind({}); WithFor.args = { children: ['Simple text label with a for attribute'], diff --git a/scss/bitstyles/base/forms/select.stories.js b/scss/bitstyles/base/forms/select.stories.js index e2b91cc32..e5302f28a 100644 --- a/scss/bitstyles/base/forms/select.stories.js +++ b/scss/bitstyles/base/forms/select.stories.js @@ -1,6 +1,5 @@ import Label from './Label'; import Select from './Select'; -import { generateLabel } from '../../../../.storybook/helpers'; export default { title: 'Base/Forms/Select', @@ -21,8 +20,6 @@ const Template = (args) => { return wrapper; }; -// ***** Selects with values ****************** // - export const Base = Template.bind({}); Base.args = { label: 'Select', diff --git a/scss/bitstyles/base/input-checkbox/_index.scss b/scss/bitstyles/base/input-checkbox/_index.scss index a0e97118d..4dea21b00 100644 --- a/scss/bitstyles/base/input-checkbox/_index.scss +++ b/scss/bitstyles/base/input-checkbox/_index.scss @@ -41,6 +41,13 @@ color: settings.$color-hover; } + &:active { + border-color: settings.$border-color-active; + background-color: settings.$background-color-active; + box-shadow: settings.$box-shadow-active; + color: settings.$color-active; + } + &::after { content: ''; display: block; diff --git a/scss/bitstyles/base/input-checkbox/_settings.scss b/scss/bitstyles/base/input-checkbox/_settings.scss index 1a39eee84..5c7447d6b 100644 --- a/scss/bitstyles/base/input-checkbox/_settings.scss +++ b/scss/bitstyles/base/input-checkbox/_settings.scss @@ -7,14 +7,14 @@ // Base styles //////////////////////////////////////// $border-radius: size.get('s6') !default; $gap: size.get('s4') !default; -$border-width: size.get('s7') !default; -$size: size.get('l1') !default; +$border-width: 0.1875rem !default; +$size: size.get('l2') !default; // // Base colors //////////////////////////////////////// $color: palette.get('grayscale') !default; $background-color: palette.get('grayscale', 'white') !default; -$border-color: palette.get('grayscale') !default; +$border-color: palette.get('grayscale', 'dark-2') !default; $box-shadow: none !default; // @@ -24,11 +24,18 @@ $background-color-hover: palette.get('grayscale', 'white') !default; $border-color-hover: palette.get('brand-1') !default; $box-shadow-hover: none !default; +// +// Active colors //////////////////////////////////////// +$color-active: palette.get('brand-1', 'dark-1') !default; +$background-color-active: palette.get('grayscale', 'white') !default; +$border-color-active: palette.get('brand-1', 'dark-1') !default; +$box-shadow-active: none !default; + // // Checked colors //////////////////////////////////////// $color-checked: palette.get('grayscale', 'white') !default; -$background-color-checked: palette.get('brand-1') !default; -$border-color-checked: palette.get('brand-1') !default; +$background-color-checked: palette.get('brand-1', 'dark-1') !default; +$border-color-checked: palette.get('brand-1', 'dark-1') !default; $background-image-checked: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='#{color.url-encode-color(#ffffff)}' d='m83.07 11.71-44.41 44.59-21.73-21.81-15.93 15.99 37.65 37.81 60.35-60.59z'/%3E%3C/svg%3E") !default; $box-shadow-checked: shadows.get('default') !default; @@ -44,7 +51,7 @@ $box-shadow-checked-hover: none !default; // Checked active colors //////////////////////////////////////// $color-checked-active: palette.get('grayscale', 'white') !default; $background-color-checked-active: palette.get('brand-1') !default; -$border-color-checked-active: palette.get('brand-1') !default; +$border-color-checked-active: palette.get('brand-1', 'dark-1') !default; $background-image-checked-active: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='#{color.url-encode-color(#ffffff)}' d='m83.07 11.71-44.41 44.59-21.73-21.81-15.93 15.99 37.65 37.81 60.35-60.59z'/%3E%3C/svg%3E") !default; $box-shadow-checked-active: none !default; @@ -67,16 +74,13 @@ $box-shadow-invalid-checked: none !default; // // Disabled colors //////////////////////////////////////// $color-disabled: palette.get('grayscale', 'light-2') !default; -$background-color-disabled: palette.get('grayscale', 'light-2') !default; -$border-color-disabled: palette.get('grayscale', 'light-2') !default; +$background-color-disabled: palette.get('grayscale', 'white') !default; +$border-color-disabled: palette.get('grayscale', 'light-1') !default; $box-shadow-disabled: none !default; // // Disabled-checked colors //////////////////////////////////////// -$color-disabled-checked: palette.get('grayscale', 'light-1') !default; -$background-color-disabled-checked: palette.get( - 'grayscale', - 'light-2' -) !default; +$color-disabled-checked: palette.get('grayscale', 'white') !default; +$background-color-disabled-checked: palette.get('grayscale', 'light-1') !default; $border-color-disabled-checked: palette.get('grayscale', 'light-1') !default; $box-shadow-disabled-checked: none !default; diff --git a/scss/bitstyles/base/input-radio/_index.scss b/scss/bitstyles/base/input-radio/_index.scss index 3f2dbd4dd..10e1378ad 100644 --- a/scss/bitstyles/base/input-radio/_index.scss +++ b/scss/bitstyles/base/input-radio/_index.scss @@ -4,14 +4,12 @@ @use '../../settings/focus'; [type='radio'] { - display: inline-block; position: relative; flex-shrink: 0; width: 1em; height: 1em; margin: settings.$gap; font-size: settings.$size; - vertical-align: middle; cursor: pointer; appearance: none; top: calc(settings.$gap / 2); diff --git a/scss/bitstyles/base/input-radio/_settings.scss b/scss/bitstyles/base/input-radio/_settings.scss index f773c4c83..b06a6278b 100644 --- a/scss/bitstyles/base/input-radio/_settings.scss +++ b/scss/bitstyles/base/input-radio/_settings.scss @@ -7,15 +7,15 @@ // Base styles //////////////////////////////////////// $border-radius: layout.$border-radius-round !default; $gap: size.get('s4') !default; -$border-width: size.get('s7') !default; +$border-width: 0.1875rem !default; $size: size.get('l2') !default; // // Base colors //////////////////////////////////////// $color: palette.get('grayscale', 'light-1') !default; $background-color: palette.get('grayscale', 'white') !default; -$border-color: palette.get('grayscale') !default; -$box-shadow: shadows.get('default') !default; +$border-color: palette.get('grayscale', 'dark-2') !default; +$box-shadow: none !default; // // Hover colors //////////////////////////////////////// @@ -25,18 +25,18 @@ $border-color-hover: palette.get('brand-1') !default; $box-shadow-hover: none !default; // -// Hover colors //////////////////////////////////////// +// Active colors //////////////////////////////////////// $color-active: palette.get('brand-1') !default; $background-color-active: palette.get('grayscale', 'white') !default; -$border-color-active: palette.get('brand-1') !default; +$border-color-active: palette.get('brand-1', 'dark-1') !default; $box-shadow-active: none !default; // // Checked colors //////////////////////////////////////// -$color-checked: palette.get('brand-1') !default; +$color-checked: palette.get('brand-1', 'dark-1') !default; $background-color-checked: palette.get('grayscale', 'white') !default; -$border-color-checked: palette.get('brand-1') !default; -$box-shadow-checked: none !default; +$border-color-checked: palette.get('brand-1', 'dark-1') !default; +$box-shadow-checked: shadows.get('default') !default; // // Checked hover colors //////////////////////////////////////// @@ -63,16 +63,13 @@ $box-shadow-invalid: none !default; // // Disabled colors //////////////////////////////////////// $color-disabled: palette.get('grayscale', 'light-1') !default; -$background-color-disabled: palette.get('grayscale', 'light-2') !default; +$background-color-disabled: palette.get('grayscale', 'white') !default; $border-color-disabled: palette.get('grayscale', 'light-1') !default; $box-shadow-disabled: none !default; // // Disabled-checked colors //////////////////////////////////////// $color-disabled-checked: palette.get('grayscale', 'light-1') !default; -$background-color-disabled-checked: palette.get( - 'grayscale', - 'light-2' -) !default; +$background-color-disabled-checked: palette.get('grayscale', 'white') !default; $border-color-disabled-checked: palette.get('grayscale', 'light-1') !default; $box-shadow-disabled-checked: none !default;