diff --git a/scss/bitstyles/atoms/badge/_index.scss b/scss/bitstyles/atoms/badge/_index.scss index 0604b6826..84757ac91 100644 --- a/scss/bitstyles/atoms/badge/_index.scss +++ b/scss/bitstyles/atoms/badge/_index.scss @@ -13,19 +13,19 @@ /* stylelint-disable scss/dollar-variable-default */ /* prettier-ignore */ -$padding-horizontal-property: custom-property.get($items: ('badge', 'padding-horizontal'), $layer: 'atom'); +$padding-horizontal-property: custom-property.get($items: ('badge', 'padding-horizontal')); /* prettier-ignore */ -$padding-vertical-property: custom-property.get($items: ('badge', 'padding-vertical'), $layer: 'atom'); +$padding-vertical-property: custom-property.get($items: ('badge', 'padding-vertical')); /* prettier-ignore */ -$gap-property: custom-property.get($items: ('badge', 'gap'), $layer: 'atom'); +$gap-property: custom-property.get($items: ('badge', 'gap')); /* prettier-ignore */ -$prepend-spacing-property: custom-property.get($items: ('badge', 'prepend', 'spacing'), $layer: 'atom'); +$prepend-spacing-property: custom-property.get($items: ('badge', 'prepend', 'spacing')); /* prettier-ignore */ -$shadow-property: custom-property.get($items: ('badge', 'shadow'), $layer: 'atom'); +$shadow-property: custom-property.get($items: ('badge', 'shadow')); /* stylelint-enable scss/dollar-variable-default */ #{classname.get($classname-items: 'badge', $layer: 'atom')} { diff --git a/scss/bitstyles/atoms/button/_index.scss b/scss/bitstyles/atoms/button/_index.scss index b779d17ff..c09fef12b 100644 --- a/scss/bitstyles/atoms/button/_index.scss +++ b/scss/bitstyles/atoms/button/_index.scss @@ -6,12 +6,12 @@ /* prettier-ignore */ #{classname.get($classname-items: 'button', $layer: 'atom')} { - #{custom-property.get('button', 'border-top-right-radius')}: var(custom-property.get($items: ('button', 'border-radius'))); - #{custom-property.get('button', 'border-bottom-right-radius')}: var(custom-property.get($items: ('button', 'border-radius'))); - #{custom-property.get('button', 'border-bottom-left-radius')}: var(custom-property.get($items: ('button', 'border-radius'))); - #{custom-property.get('button', 'border-top-left-radius')}: var(custom-property.get($items: ('button', 'border-radius'))); - #{custom-property.get('button', 'transition')}: settings.$transition; - #{custom-property.get('button', 'justify-content')}: settings.$justify-content; + #{custom-property.get($items: ('button', 'border-top-right-radius'))}: var(custom-property.get($items: ('button', 'border-radius'))); + #{custom-property.get($items: ('button', 'border-bottom-right-radius'))}: var(custom-property.get($items: ('button', 'border-radius'))); + #{custom-property.get($items: ('button', 'border-bottom-left-radius'))}: var(custom-property.get($items: ('button', 'border-radius'))); + #{custom-property.get($items: ('button', 'border-top-left-radius'))}: var(custom-property.get($items: ('button', 'border-radius'))); + #{custom-property.get($items: ('button', 'transition'))}: settings.$transition; + #{custom-property.get($items: ('button', 'justify-content'))}: settings.$justify-content; display: flex; position: relative; flex-shrink: 0; @@ -19,10 +19,10 @@ justify-content: var(#{custom-property.get($items: ('button', 'justify-content'))}); min-width: var(#{custom-property.get($items: ('button', 'min-width'))}); max-width: 100%; - min-height: var(custom-property.get('button', 'min-height')); + min-height: var(custom-property.get($items: ('button', 'min-height'))); padding: - calc(var(custom-property.get('button', 'padding-vertical')) - var(custom-property.get('button', 'border-width'), 0rem)) - calc(var(custom-property.get('button','padding-horizontal')) - var(custom-property.get('button', 'border-width'), 0rem)); + calc(var(custom-property.get($items: ('button', 'padding-vertical'))) - var(custom-property.get($items: ('button', 'border-width')), 0rem)) + calc(var(custom-property.get($items: ('button','padding-horizontal'))) - var(custom-property.get($items: ('button', 'border-width')), 0rem)); overflow: visible; transition: var(#{custom-property.get($items: ('button', 'transition'))}); border-width: var(#{custom-property.get($items: ('button', 'border-width'))}); diff --git a/scss/bitstyles/base/forms/_settings.scss b/scss/bitstyles/base/forms/_settings.scss index 42ae20e77..3020659b6 100644 --- a/scss/bitstyles/base/forms/_settings.scss +++ b/scss/bitstyles/base/forms/_settings.scss @@ -1,4 +1,4 @@ -@use '../../settings/typography'; +@use '../../design-tokens/typography'; @use '../../tools/palette'; @use '../../tools/size'; diff --git a/scss/bitstyles/base/forms/input-checkbox.stories.js b/scss/bitstyles/base/forms/input-checkbox.stories.js index 280f221e5..b06778257 100644 --- a/scss/bitstyles/base/forms/input-checkbox.stories.js +++ b/scss/bitstyles/base/forms/input-checkbox.stories.js @@ -4,7 +4,7 @@ import Label from './Label'; export default { title: 'Base/Forms/Input checkbox', component: Input, - subcomponents: [Label], + subcomponents: { Label }, argTypes: {}, }; diff --git a/scss/bitstyles/base/forms/input-radio.stories.js b/scss/bitstyles/base/forms/input-radio.stories.js index 3d3d480f1..389de436e 100644 --- a/scss/bitstyles/base/forms/input-radio.stories.js +++ b/scss/bitstyles/base/forms/input-radio.stories.js @@ -4,7 +4,7 @@ import Label from './Label'; export default { title: 'Base/Forms/Input radio', component: Input, - subcomponents: [Label], + subcomponents: { Label }, argTypes: {}, }; diff --git a/scss/bitstyles/base/forms/input-text.stories.js b/scss/bitstyles/base/forms/input-text.stories.js index f575b3dee..4014b034d 100644 --- a/scss/bitstyles/base/forms/input-text.stories.js +++ b/scss/bitstyles/base/forms/input-text.stories.js @@ -4,7 +4,7 @@ import Label from './Label'; export default { title: 'Base/Forms/Input text', component: Input, - subcomponents: [Label], + subcomponents: { Label }, argTypes: {}, }; diff --git a/scss/bitstyles/base/input-text/_index.scss b/scss/bitstyles/base/input-text/_index.scss index 3572598bf..8bdd3dee0 100644 --- a/scss/bitstyles/base/input-text/_index.scss +++ b/scss/bitstyles/base/input-text/_index.scss @@ -45,8 +45,8 @@ textarea { #{custom-property.get($items: ('input-text', 'padding-vertical'))}: settings.$padding-vertical; #{custom-property.get($items: ('input-text', 'padding-horizontal'))}: settings.$padding-horizontal; #{custom-property.get($items: ('input-text', 'border-width'))}: settings.$border-width; - display: block; - width: 100%; + display: flex; + flex-grow: 1; padding: calc(var(#{custom-property.get($items: ('input-text', 'padding-vertical'))}) - var(#{custom-property.get($items: ('input-text', 'border-width'))}, 0rem)) calc(var(#{custom-property.get($items: ('input-text','padding-horizontal'))}) - var(#{custom-property.get($items: ('input-text', 'border-width'))}, 0rem)); @@ -74,6 +74,7 @@ textarea { } &:focus-visible { + z-index: 3; outline: focus.$outline-color solid focus.$outline-width; outline-offset: focus.$outline-offset; } diff --git a/scss/bitstyles/base/select/_index.scss b/scss/bitstyles/base/select/_index.scss index 6afb36945..8c35a4ca7 100644 --- a/scss/bitstyles/base/select/_index.scss +++ b/scss/bitstyles/base/select/_index.scss @@ -4,6 +4,7 @@ @use '../../design-tokens/focus'; @use '../../tools/custom-property'; +/* prettier-ignore */ @supports (-webkit-appearance: none) or (-moz-appearance: none) or (appearance: none) { /* stylelint-disable selector-max-type */ @@ -11,8 +12,11 @@ #{custom-property.get($items: ('select', 'padding-vertical'))}: settings.$padding-vertical; #{custom-property.get($items: ('select', 'padding-horizontal'))}: settings.$padding-horizontal; #{custom-property.get($items: ('select', 'border-width'))}: settings.$border-width; - display: block; - width: 100%; + #{custom-property.get($items: ('select', 'border-top-right-radius'))}: settings.$border-radius; + #{custom-property.get($items: ('select', 'border-bottom-right-radius'))}: settings.$border-radius; + #{custom-property.get($items: ('select', 'border-bottom-left-radius'))}: settings.$border-radius; + #{custom-property.get($items: ('select', 'border-top-left-radius'))}: settings.$border-radius; + display: flex; padding: calc(var(#{custom-property.get($items: ('select', 'padding-vertical'))}) - var(#{custom-property.get($items: ('select', 'border-width'))}, 0rem)) calc(var(#{custom-property.get($items: ('select','padding-horizontal'))}) - var(#{custom-property.get($items: ('select', 'border-width'))}, 0rem)); @@ -23,7 +27,11 @@ animation.$transition-easing, border animation.$transition-duration animation.$transition-easing; border: settings.$border-width solid settings.$border-color; - border-radius: settings.$border-radius; + border-radius: + var(#{custom-property.get($items: ('select', 'border-top-left-radius'))}) + var(#{custom-property.get($items: ('select', 'border-top-right-radius'))}) + var(#{custom-property.get($items: ('select', 'border-bottom-right-radius'))}) + var(#{custom-property.get($items: ('select', 'border-bottom-left-radius'))}); outline-offset: 0; background-color: settings.$background-color; background-image: settings.$background-image; @@ -32,6 +40,7 @@ background-size: 1em; box-shadow: settings.$box-shadow; color: settings.$color; + font: settings.$font; font-weight: settings.$font-weight; text-overflow: ellipsis; cursor: pointer; diff --git a/scss/bitstyles/base/select/_settings.scss b/scss/bitstyles/base/select/_settings.scss index e6715de61..860c302bc 100644 --- a/scss/bitstyles/base/select/_settings.scss +++ b/scss/bitstyles/base/select/_settings.scss @@ -1,4 +1,4 @@ -@use '../../settings/typography'; +@use '../../design-tokens/typography'; @use '../../tools/size'; @use '../../tools/color'; @use '../../tools/palette'; @@ -10,7 +10,8 @@ $padding-vertical: size.get('s2') !default; $padding-horizontal: size.get('l1') !default; $border-radius: size.get('s4') !default; $border-width: 0.1875rem !default; -$font-weight: typography.$font-weight-normal !default; +$font: inherit !default; +$font-weight: typography.$font-weight-bold !default; // // Base appearance //////////////////////////////////////// diff --git a/scss/bitstyles/settings/_focus.scss b/scss/bitstyles/design-tokens/_focus.scss similarity index 100% rename from scss/bitstyles/settings/_focus.scss rename to scss/bitstyles/design-tokens/_focus.scss diff --git a/scss/bitstyles/organisms/joined-ui/JoinedUI.js b/scss/bitstyles/organisms/joined-ui/JoinedUI.js index 575cf2867..d525199cf 100644 --- a/scss/bitstyles/organisms/joined-ui/JoinedUI.js +++ b/scss/bitstyles/organisms/joined-ui/JoinedUI.js @@ -1,11 +1,6 @@ -export default ({ children }) => { +export default ({ children, classname }) => { const list = document.createElement('ul'); - list.classList.add( - 'u-list-none', - 'u-inline-flex', - 'u-items-stretch', - 'o-joined-ui' - ); + list.classList.add('u-list-none', 'o-joined-ui', classname); children.forEach((child) => { const listItem = document.createElement('li'); diff --git a/scss/bitstyles/organisms/joined-ui/_index.scss b/scss/bitstyles/organisms/joined-ui/_index.scss index 42331fae3..30856e463 100644 --- a/scss/bitstyles/organisms/joined-ui/_index.scss +++ b/scss/bitstyles/organisms/joined-ui/_index.scss @@ -23,9 +23,23 @@ $input-text-border-width-name: custom-property.get($items: ('input-text', 'border', 'width')); $input-text-box-shadow-name: custom-property.get($items: ('input-text', 'box-shadow')); + /* Selects */ + $select-border-top-left-radius-name: custom-property.get($items: ('select', 'border', 'top', 'left', 'radius')); + $select-border-top-right-radius-name: custom-property.get($items: ('select', 'border', 'top', 'right', 'radius')); + $select-border-bottom-right-radius-name: custom-property.get($items: ('select', 'border', 'bottom', 'right', 'radius')); + $select-border-bottom-left-radius-name: custom-property.get($items: ('select', 'border', 'bottom', 'left', 'radius')); + $select-border-width-name: custom-property.get($items: ('select', 'border', 'width')); + $select-box-shadow-name: custom-property.get($items: ('select', 'box-shadow')); + + display: inline-flex; + align-items: stretch; border-radius: settings.$border-radius; box-shadow: settings.$box-shadow; + > * { + display: flex; + } + > :first-child #{$button-classname}, > #{$button-classname}:first-child { #{$button-box-shadow-name}: none; @@ -42,6 +56,14 @@ margin-right: calc(var(#{$input-text-border-width-name}) * -1); } + > :first-child select, + > select:first-child { + #{$select-box-shadow-name}: none; + #{$select-border-top-right-radius-name}: #{0}; + #{$select-border-bottom-right-radius-name}: #{0}; + margin-right: calc(var(#{$select-border-width-name}) * -1); + } + > :last-child #{$button-classname}, > #{$button-classname}:last-child { #{$button-box-shadow-name}: none; @@ -58,6 +80,14 @@ margin-right: 0; } + > :last-child select, + > select:last-child { + #{$select-box-shadow-name}: none; + #{$select-border-top-left-radius-name}: #{0}; + #{$select-border-bottom-left-radius-name}: #{0}; + margin-right: 0; + } + > :not(:first-child):not(:last-child) #{$button-classname}, > #{$button-classname}:not(:first-child):not(:last-child) { #{$button-border-top-left-radius-name}: #{0}; @@ -75,4 +105,13 @@ #{$input-text-border-bottom-left-radius-name}: #{0}; margin-right: calc(var(#{$input-text-border-width-name}) * -1); } + + > :not(:first-child):not(:last-child) select, + > select:not(:first-child):not(:last-child) { + #{$select-border-top-left-radius-name}: #{0}; + #{$select-border-top-right-radius-name}: #{0}; + #{$select-border-bottom-right-radius-name}: #{0}; + #{$select-border-bottom-left-radius-name}: #{0}; + margin-right: calc(var(#{$select-border-width-name}) * -1); + } } diff --git a/scss/bitstyles/ui/forms.stories.js b/scss/bitstyles/ui/forms.stories.js new file mode 100644 index 000000000..2a462897e --- /dev/null +++ b/scss/bitstyles/ui/forms.stories.js @@ -0,0 +1,106 @@ +import Input from '../base/forms/Input'; +import Label from '../base/forms/Label'; +import Select from '../base/forms/Select'; +import Button from '../atoms/button/Button'; +import JoinedUI from '../organisms/joined-ui/JoinedUI'; +import icons from '../../../assets/images/icons.svg'; + +export default { + title: 'UI/Data/Forms', + subcomponents: { Input, Label, Select, Button, JoinedUI }, +}; + +// ***** Default size, each shape & color ****************** // + +export const SearchFormWithButton = () => { + const form = document.createElement('form'); + form.setAttribute('action', ''); + form.setAttribute('role', 'search'); + form.setAttribute('method', 'post'); + form.append(Label({ for: 'text-search', children: ['Search users'] })); + form.append( + JoinedUI({ + children: [ + Input({ + type: 'text', + placeholder: 'Username or email', + }), + Button({ + colorVariant: ['outline'], + children: 'Search', + type: 'submit', + }), + ], + }) + ); + return form; +}; + +export const SearchFormWithIconButton = () => { + const form = document.createElement('form'); + form.setAttribute('action', ''); + form.setAttribute('role', 'search'); + form.setAttribute('method', 'post'); + form.append(Label({ for: 'text-search', children: ['Search users'] })); + form.append( + JoinedUI({ + children: [ + Input({ + type: 'text', + placeholder: 'Username or email', + }), + Button({ + colorVariant: ['outline'], + children: `Search`, + type: 'submit', + }), + ], + }) + ); + return form; +}; + +export const SearchFormWithSelectAndButton = () => { + const form = document.createElement('form'); + form.setAttribute('action', ''); + form.setAttribute('role', 'search'); + form.setAttribute('method', 'post'); + form.append(Label({ for: 'text-search', children: ['Search users'] })); + const wrapper = document.createElement('div'); + wrapper.setAttribute('class', 'u-flex u-gap-s5'); + wrapper.append( + JoinedUI({ + children: [ + Input({ + type: 'text', + placeholder: 'Username or email', + }), + Select({ + options: [ + { + value: 'user', + label: 'User', + }, + { + value: 'admin', + label: 'Admin', + }, + { + value: 'superuser', + label: 'Superuser', + }, + ], + }), + ], + }) + ); + wrapper.append( + Button({ + colorVariant: ['outline'], + children: 'Search', + type: 'submit', + }) + ); + form.append(wrapper); + return form; +}; diff --git a/scss/bitstyles/ui/forms.stories.mdx b/scss/bitstyles/ui/forms.stories.mdx index f91cc7549..ab369fb5c 100644 --- a/scss/bitstyles/ui/forms.stories.mdx +++ b/scss/bitstyles/ui/forms.stories.mdx @@ -1,7 +1,7 @@ import { Canvas, Meta, Story } from '@storybook/addon-docs'; import icons from '../../../assets/images/icons.svg'; - + # Forms @@ -64,7 +64,7 @@ Here are some examples using the grid utility classes to create common form layo