components/sass/form/_index.scss

273 lines
5.5 KiB
SCSS
Raw Normal View History

2019-02-06 01:03:03 +01:00
form {
2019-02-07 00:41:44 +01:00
// setting the font size here sizes everything within
2019-02-13 17:37:50 +01:00
&:not(:last-child) {
margin-bottom: var(--spacing-s);
}
2019-02-07 21:22:04 +01:00
2019-02-13 17:37:50 +01:00
button:not(.button--link),
2019-02-07 21:22:04 +01:00
input,
select {
height: var(--spacing-l);
border: 1px solid;
}
2019-02-14 00:31:55 +01:00
checkbox-element,
2019-02-13 17:37:50 +01:00
radio-element,
2019-02-14 00:31:55 +01:00
select {
2019-02-13 17:37:50 +01:00
cursor: pointer;
}
2019-02-07 21:22:04 +01:00
[type="email"],
2019-02-13 17:37:50 +01:00
[type="number"],
2019-02-20 05:44:38 +01:00
[type="password"],
2019-02-14 00:31:55 +01:00
[type="text"] {
2019-02-07 21:22:04 +01:00
padding-right: var(--spacing-s);
padding-left: var(--spacing-s);
transition: border 0.2s;
}
2019-02-13 17:37:50 +01:00
[type="submit"],
.button--primary {
2019-02-07 21:22:04 +01:00
color: $lbry-white;
padding-right: var(--spacing-m);
padding-left: var(--spacing-m);
transition: all 0.2s;
&:not(:hover) {
background-color: $lbry-black;
border-color: $lbry-black;
}
&:hover {
background-color: $lbry-teal-3;
border-color: $lbry-teal-5;
}
}
select {
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 96 96' xmlns='http://www.w3.org/2000/svg' fill='%23212529'%3E%3Cpath d='M17.172, 31.172c1.562, -1.562 4.095, -1.562 5.656, 0l25.172, 25.171l25.172, -25.171c1.562, -1.562 4.095, -1.562 5.656, 0c1.562, 1.562 1.562, 4.095 0, 5.656l-28, 28c-1.562, 1.562 -4.095, 1.562 -5.656, 0l-28, -28c-0.781, -0.781 -1.172, -1.805 -1.172, -2.828c0, -1.023 0.391, -2.047 1.172, -2.828Z'/%3E%3C/svg%3E%0A");
background-position: 99% center;
background-repeat: no-repeat;
background-size: 1rem;
padding-right: var(--spacing-l);
padding-left: var(--spacing-s);
2019-02-20 06:12:38 +01:00
[data-mode='dark'] & {
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 96 96' xmlns='http://www.w3.org/2000/svg' fill='%23ffffff'%3E%3Cpath d='M17.172, 31.172c1.562, -1.562 4.095, -1.562 5.656, 0l25.172, 25.171l25.172, -25.171c1.562, -1.562 4.095, -1.562 5.656, 0c1.562, 1.562 1.562, 4.095 0, 5.656l-28, 28c-1.562, 1.562 -4.095, 1.562 -5.656, 0l-28, -28c-0.781, -0.781 -1.172, -1.805 -1.172, -2.828c0, -1.023 0.391, -2.047 1.172, -2.828Z'/%3E%3C/svg%3E%0A");
}
2019-02-07 21:22:04 +01:00
}
2019-01-29 22:13:16 +01:00
}
2019-02-06 01:03:03 +01:00
fieldset {
2019-02-07 00:41:44 +01:00
border-top: 1px solid $lbry-gray-1;
2019-02-07 21:22:04 +01:00
margin-bottom: var(--spacing-m);
2019-02-06 01:03:03 +01:00
position: relative;
2019-02-07 21:22:04 +01:00
}
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
fieldset-group {
display: flex;
flex-direction: row;
justify-content: space-between;
}
2019-01-29 22:13:16 +01:00
2019-02-07 21:22:04 +01:00
fieldset-section {
display: flex;
flex-direction: column;
margin-bottom: var(--spacing-m);
2019-01-29 22:13:16 +01:00
2019-02-07 21:22:04 +01:00
&.full-width {
width: 100%;
}
2019-01-29 22:13:16 +01:00
2019-02-07 21:22:04 +01:00
fieldset-group &,
.fieldset-group & {
width: 49%;
}
2019-01-29 22:13:16 +01:00
2019-02-07 21:22:04 +01:00
label {
color: $lbry-gray-4;
display: inline-block;
font-size: smaller;
margin-bottom: var(--spacing-xxs);
text-transform: uppercase;
}
[type="email"],
[type="text"],
2019-02-20 05:44:38 +01:00
[type="number"],
2019-02-07 21:22:04 +01:00
select,
textarea {
&:not(:focus) {
border-color: $lbry-black;
2019-01-29 22:13:16 +01:00
}
2019-02-07 21:22:04 +01:00
&:focus {
border-color: $lbry-teal-5;
}
}
input,
select {
width: 100%;
2019-01-29 22:13:16 +01:00
}
}
2019-02-06 01:03:03 +01:00
2019-02-07 00:41:44 +01:00
legend {
2019-02-07 21:22:04 +01:00
padding: var(--spacing-xs) var(--spacing-s); // sass-lint:disable-line shorthand-values
2019-02-07 00:41:44 +01:00
border: 1px solid $lbry-gray-1;
2019-02-07 21:22:04 +01:00
margin-bottom: var(--spacing-s);
2019-02-07 00:41:44 +01:00
pointer-events: none;
}
2019-02-07 21:22:04 +01:00
input-submit {
display: flex;
2019-02-07 00:41:44 +01:00
2019-02-07 21:22:04 +01:00
[type="email"],
[type="text"] {
flex: 1;
2019-02-07 00:41:44 +01:00
2019-02-07 21:22:04 +01:00
&:not(:focus) {
border-top-color: $lbry-black;
border-right-color: transparent;
border-bottom-color: $lbry-black;
border-left-color: $lbry-black;
}
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
&:focus {
border-top-color: $lbry-teal-5;
border-right-color: transparent;
border-bottom-color: $lbry-teal-5;
border-left-color: $lbry-teal-5;
}
2019-02-07 00:41:44 +01:00
}
}
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
checkbox-element {
@include tick;
2019-02-06 01:03:03 +01:00
&:hover {
2019-02-07 21:22:04 +01:00
checkbox-toggle,
.checkbox-toggle {
border-color: $lbry-teal-4;
2019-02-06 01:03:03 +01:00
}
2019-02-07 21:22:04 +01:00
}
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
input {
&[type="checkbox"] {
2019-02-20 05:45:40 +01:00
width: 0; height: 0;
2019-02-07 21:22:04 +01:00
visibility: hidden;
&:not(:checked) {
+ label + checkbox-toggle::before,
+ label + .checkbox-toggle::before {
opacity: 0;
visibility: hidden;
}
}
&:checked {
+ label {
color: $lbry-teal-4;
}
}
2019-02-06 01:03:03 +01:00
}
}
2019-02-07 21:22:04 +01:00
}
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
checkbox-toggle {
@include tick-toggle;
&::before {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2333b58f' stroke-width='2'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E%0A");
background-position: center left;
background-repeat: no-repeat;
background-size: 130%;
transition: all 0.2s;
}
}
radio-element {
@include tick;
&:hover {
radio-toggle,
.radio-toggle {
border-color: $lbry-teal-4;
}
2019-02-06 01:03:03 +01:00
}
input {
&[type="radio"] {
2019-02-20 05:45:40 +01:00
width: 0; height: 0;
2019-02-06 01:03:03 +01:00
visibility: hidden;
&:not(:checked) {
2019-02-07 21:22:04 +01:00
+ label + radio-toggle::before,
+ label + .radio-toggle::before {
2019-02-06 01:03:03 +01:00
background-color: transparent;
}
}
&:checked {
+ label {
2019-02-07 00:41:44 +01:00
color: $lbry-teal-4;
2019-02-06 01:03:03 +01:00
}
2019-02-07 21:22:04 +01:00
+ label + radio-toggle::before,
+ label + .radio-toggle::before {
2019-02-07 00:41:44 +01:00
background-color: $lbry-teal-4;
2019-02-06 01:03:03 +01:00
}
}
}
}
}
2019-02-07 21:22:04 +01:00
radio-toggle {
@include tick-toggle;
border-radius: 50%;
&::before {
border-radius: 50%;
transform: scale(0.6);
transition: background-color 0.2s;
}
}
// Custom elements are apparently difficult to use in React, so use classes
2019-02-06 01:03:03 +01:00
2019-02-07 21:22:04 +01:00
.checkbox-element {
@extend checkbox-element;
}
.checkbox-toggle {
@extend checkbox-toggle;
2019-02-06 01:03:03 +01:00
}
.fieldset {
@extend fieldset;
}
2019-02-07 21:22:04 +01:00
.fieldset-group {
@extend fieldset-group;
}
.fieldset-section {
@extend fieldset-section;
}
2019-02-06 01:03:03 +01:00
.form {
@extend form;
}
2019-02-07 21:22:04 +01:00
.input-submit {
@extend input-submit;
}
.radio-element {
@extend radio-element;
}
.radio-toggle {
@extend radio-toggle;
2019-02-06 01:03:03 +01:00
}