docbrown/app/assets/stylesheets/components/forms.scss
ludwiczakpawel e17cbd3efb
NOT MERGE Add tabs to Crayons and to the notifications page (#7737)
* tabs

* frontned

* notifications tabs

* ntofiications

* .

* doc

* names instead of slugs

* flare tag line height

* .

* js
2020-05-14 11:38:57 +02:00

256 lines
5.3 KiB
SCSS

@import '../config/import';
%form-styling {
--border-width: 1px;
background-color: var(--form-bg);
border: var(--border-width) solid var(--form-border);
color: var(--body-color);
appearance: none;
-webkit-appearance: none;
border-radius: var(--radius);
transition: all var(--transition-props);
&-hover {
border-color: var(--form-border-hover);
}
&-focus {
background-color: var(--form-bg-focus);
border-color: var(--form-border-focus);
box-shadow: 1px 1px 0 var(--form-border-focus);
}
&-disabled {
opacity: 0.6;
}
&-checked {
background-color: var(--form-border-focus);
border-color: var(--form-border-focus);
color: var(--form-bg-focus);
background-position: center center;
background-repeat: no-repeat;
}
}
// Text inputs and textareas.
.crayons-textfield {
line-height: var(--lh-base);
padding: calc(0.5em - var(--border-width)) 0.5em;
font-family: inherit;
font-size: var(--fs-base);
width: 100%;
@extend %form-styling;
&::placeholder {
color: var(--form-placeholder-color);
}
&:hover {
@extend %form-styling-hover;
}
&:focus {
@extend %form-styling-focus;
}
&--disabled,
&[disabled] {
@extend %form-styling-disabled;
}
&::-ms-clear {
display: none;
}
&--icon {
padding-left: var(--su-7);
}
}
// Checkboxes, Radios
.crayons-checkbox,
.crayons-radio {
@extend %form-styling;
width: 1.125em;
height: 1.125em;
cursor: pointer;
background-position: center center;
vertical-align: middle;
flex-shrink: 0;
&:hover {
@extend %form-styling-hover;
}
&--disabled,
&[disabled] {
@extend %form-styling-disabled;
}
&--checked,
&:checked {
@extend %form-styling-checked;
background-image: url("data:image/svg+xml,%3Csvg width='12' height='10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.157.933a.75.75 0 01.077 1.058L4.817 9.407a.75.75 0 01-1.134 0L.766 6.037a.75.75 0 011.135-.982L4.25 7.77l5.85-6.76a.75.75 0 011.057-.077z' fill='%23fff'/%3E%3C/svg%3E");
&--disabled,
&[disabled] {
@extend %form-styling-disabled;
}
}
}
// Radios
.crayons-radio {
border-radius: 50%;
&--checked,
&:checked {
@extend %form-styling-checked;
background-image: url("data:image/svg+xml,%3Csvg width='6' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='6' height='6' rx='3' fill='%23fff'/%3E%3C/svg%3E");
}
}
// Selects
.crayons-select {
line-height: var(--lh-base);
padding: calc(0.5em - var(--border-width)) 0.5em;
padding-right: var(--su-7);
font-family: inherit;
font-size: var(--fs-base);
width: 100%;
position: relative;
outline: none;
@extend %form-styling;
background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 16l-6-6h12l-6 6z' fill='%2308090A'/%3E%3C/svg%3E");
background-position: calc(100% - var(--su-2)) calc(50% - 1px);
background-repeat: no-repeat;
&:hover {
@extend %form-styling-hover;
}
&:focus {
@extend %form-styling-focus;
}
&--disabled,
&[disabled] {
@extend %form-styling-disabled;
}
&::-ms-clear {
display: none;
}
}
///////////////////////////////////////////////////
// Full Fields markup
.crayons-field {
display: flex;
flex-flow: column;
font-size: var(--fs-base); // todo: do we need it?
$this: &;
&__label {
color: var(--label-primary);
font-weight: var(--fw-medium);
+ .crayons-field__description {
margin-top: 0;
}
}
&__description {
color: var(--label-secondary);
font-size: var(--fs-s);
font-weight: var(--fw-normal); // for when it's inside --label
margin: 0; //todo remove
}
> * + * {
margin-top: var(--su-2);
}
&--checkbox,
&--radio {
display: grid;
grid-template-columns: 1.5em 1fr;
grid-gap: var(--su-2);
border-radius: var(--radius);
transition: all var(--transition-props);
&:hover {
background: var(--body-bg);
box-shadow: 0 0 0 var(--su-1) var(--body-bg);
}
#{$this}__label {
margin-top: 0;
padding-right: var(
--su-2
); // adding this to make hovers look slightly better.
}
}
.crayons-checkbox,
.crayons-radio {
margin: 0.1875em; // centering checkbox within 1.5em grid cell.
justify-self: center;
}
}
.crayons-fields {
display: flex;
flex-flow: column;
$this: &;
&:not(#{$this}--horizontal) {
> .crayons-field + .crayons-field {
margin-top: var(--su-4);
}
}
&--horizontal {
flex-flow: row;
flex-wrap: wrap;
> .crayons-field:not(:last-child) {
margin-right: var(--su-4);
}
}
}
///////////////////////////////////////////////////
.crayons-textfield {
&--ghost,
&--ghost:hover,
&--ghost:focus,
&--ghost[disabled] {
all: unset;
width: 100%;
}
}
textarea.crayons-textfield.crayons-textfield--ghost {
white-space: pre-wrap;
}
///////////////////////////////////////////////////
.crayons-color-selector {
@extend %form-styling;
padding: calc(0.5em - var(--border-width)) 0.5em;
height: 40px;
&::-webkit-color-swatch-wrapper {
padding: 0;
height: var(--su-6);
width: var(--su-6);
}
&::-webkit-color-swatch {
border: 0;
}
}