Skip to content

Commit

Permalink
- Selects, inputs, and buttons all now play well together in joined-ui
Browse files Browse the repository at this point in the history
- Moves some storties out of ui/forms.mdx, into a js file
  • Loading branch information
planktonic committed May 17, 2023
1 parent 68fc039 commit 67c7411
Show file tree
Hide file tree
Showing 16 changed files with 617 additions and 530 deletions.
10 changes: 5 additions & 5 deletions scss/bitstyles/atoms/badge/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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')} {
Expand Down
18 changes: 9 additions & 9 deletions scss/bitstyles/atoms/button/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
/* 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;
align-items: center;
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'))});
Expand Down
2 changes: 1 addition & 1 deletion scss/bitstyles/base/forms/_settings.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../settings/typography';
@use '../../design-tokens/typography';
@use '../../tools/palette';
@use '../../tools/size';

Expand Down
2 changes: 1 addition & 1 deletion scss/bitstyles/base/forms/input-checkbox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Label from './Label';
export default {
title: 'Base/Forms/Input checkbox',
component: Input,
subcomponents: [Label],
subcomponents: { Label },
argTypes: {},
};

Expand Down
2 changes: 1 addition & 1 deletion scss/bitstyles/base/forms/input-radio.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Label from './Label';
export default {
title: 'Base/Forms/Input radio',
component: Input,
subcomponents: [Label],
subcomponents: { Label },
argTypes: {},
};

Expand Down
2 changes: 1 addition & 1 deletion scss/bitstyles/base/forms/input-text.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Label from './Label';
export default {
title: 'Base/Forms/Input text',
component: Input,
subcomponents: [Label],
subcomponents: { Label },
argTypes: {},
};

Expand Down
5 changes: 3 additions & 2 deletions scss/bitstyles/base/input-text/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -74,6 +74,7 @@ textarea {
}

&:focus-visible {
z-index: 3;
outline: focus.$outline-color solid focus.$outline-width;
outline-offset: focus.$outline-offset;
}
Expand Down
15 changes: 12 additions & 3 deletions scss/bitstyles/base/select/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
@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 */
select {
#{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));
Expand All @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions scss/bitstyles/base/select/_settings.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../settings/typography';
@use '../../design-tokens/typography';
@use '../../tools/size';
@use '../../tools/color';
@use '../../tools/palette';
Expand All @@ -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 ////////////////////////////////////////
Expand Down
File renamed without changes.
9 changes: 2 additions & 7 deletions scss/bitstyles/organisms/joined-ui/JoinedUI.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
39 changes: 39 additions & 0 deletions scss/bitstyles/organisms/joined-ui/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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};
Expand All @@ -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);
}
}
106 changes: 106 additions & 0 deletions scss/bitstyles/ui/forms.stories.js
Original file line number Diff line number Diff line change
@@ -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: `<svg width="20" height="20" class="a-icon a-icon--m" aria-hidden="true" focusable="false"><use xlink:href="${icons}#icon-search"></use></svg><span class="u-sr-only">Search</span>`,
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;
};
Loading

0 comments on commit 67c7411

Please sign in to comment.