0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 09:33:54 +01:00
wagtail/client/scss/components/_button.scss

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

574 lines
11 KiB
SCSS
Raw Normal View History

@use 'sass:color';
// Core button style
// Note that these styles include methods to render buttons the same x-browser, described here:
// http: //cbjdigital.com/blog/2010/08/bulletproof_css_input_button_heights
// input[type=submit],
// input[type=reset],
// input[type=button],
.button {
border-radius: 3px;
font-family: $font-sans;
width: auto;
height: 2.4em;
padding: 0 1em;
font-size: 0.9em;
font-weight: normal;
vertical-align: middle;
display: inline-block;
background-color: $color-button;
border: 1px solid $color-button;
color: $color-white;
text-decoration: none;
white-space: nowrap;
position: relative;
overflow: hidden;
box-sizing: border-box;
-webkit-font-smoothing: auto;
// stylelint-disable-next-line property-no-vendor-prefix
-moz-appearance: none;
2020-06-18 18:18:08 +02:00
transition: background-color 0.1s ease;
&:hover {
color: $color-teal;
}
&.yes {
background-color: $color-button-yes;
border: 1px solid $color-button-yes;
&.button-secondary {
border: 1px solid $color-button-yes;
color: $color-button-yes;
background-color: transparent;
}
&:hover {
color: $color-white;
border-color: transparent;
background-color: $color-button-yes;
}
}
&.warning {
background-color: $color-button-warning;
border: 1px solid $color-button-warning;
&.button-secondary {
border: 1px solid $color-button-warning;
color: $color-button-warning;
background-color: transparent;
}
&:hover {
color: $color-white;
border-color: transparent;
background-color: $color-button-warning;
}
}
&.no,
&.serious {
background-color: $color-button-no;
border: 1px solid $color-button-no;
&.button-secondary {
border: 1px solid $color-button-no;
color: $color-button-no;
background-color: transparent;
}
&:hover {
color: $color-white;
border-color: transparent;
background-color: $color-button-no;
}
}
&.bicolor {
border: 1px solid transparent;
padding-inline-start: 3.5em;
2020-06-15 11:44:18 +02:00
&:before {
// iconfont
font-size: 1rem;
position: absolute;
inset-inline-start: 0;
top: 0;
width: 2em;
line-height: 1.85em;
height: 100%;
text-align: center;
background-color: theme('colors.black-20');
display: block;
// Remove once we drop support for Safari 14.
// stylelint-disable-next-line property-disallowed-list
border-top-left-radius: inherit;
border-start-start-radius: inherit;
// Remove once we drop support for Safari 14.
// stylelint-disable-next-line property-disallowed-list
border-bottom-left-radius: inherit;
border-end-start-radius: inherit;
}
2020-06-15 11:44:18 +02:00
.icon-wrapper {
background-color: theme('colors.black-20');
display: flex;
align-items: center;
justify-content: center;
2020-06-15 11:44:18 +02:00
position: absolute;
inset-inline-start: 0;
top: 0;
2020-06-15 11:44:18 +02:00
width: 3em;
height: 100%;
box-sizing: content-box;
2020-06-15 11:44:18 +02:00
text-align: center;
// Remove once we drop support for Safari 14.
// stylelint-disable-next-line property-disallowed-list
2020-06-15 11:44:18 +02:00
border-top-left-radius: inherit;
border-start-start-radius: inherit;
// Remove once we drop support for Safari 14.
// stylelint-disable-next-line property-disallowed-list
2020-06-15 11:44:18 +02:00
border-bottom-left-radius: inherit;
border-end-start-radius: inherit;
}
2020-06-15 11:44:18 +02:00
&.button--icon {
&:before {
display: none; // TODO: remove once the icon font styles are gone
}
}
&.button--icon-flipped {
.icon {
transform: scaleX(-1);
}
}
&.button-secondary {
border: 1px solid theme('colors.black-20');
}
}
&.button-small.bicolor {
padding-inline-start: 3.5em;
2020-06-15 11:44:18 +02:00
.icon-wrapper {
width: 2em;
}
2020-06-15 11:44:18 +02:00
&.button--icon .icon {
@include svg-icon(0.9rem);
2020-06-15 12:06:29 +02:00
padding: 0.25em;
}
}
// + input[type=submit],
// + input[type=reset],
// + input[type=button],
+ .button {
// + button {
margin-inline-start: 1em;
}
// A completely unstyled button
&.unbutton {
border-radius: 0;
width: auto;
height: auto;
padding: 0;
font-size: inherit;
font-weight: normal;
vertical-align: middle;
display: inline;
background-color: transparent;
border: 0;
color: inherit;
text-decoration: none;
white-space: nowrap;
position: relative;
overflow: hidden;
box-sizing: border-box;
-webkit-font-smoothing: auto;
// stylelint-disable-next-line property-no-vendor-prefix
-moz-appearance: none;
&:hover,
&:focus,
2020-06-18 18:18:08 +02:00
&:active {
background-color: transparent;
}
}
// stylelint-disable-next-line no-duplicate-selectors
&:hover {
background-color: $color-button-hover;
color: $color-white;
border-color: transparent;
&.hover-no {
background-color: $color-button-no;
}
}
&.button-longrunning {
span {
// iconfont
@include transition(all 0.3s ease);
transform: scale(0.9);
display: inline-block;
height: 0.9em;
position: relative;
opacity: 0;
width: 0;
visibility: hidden;
text-align: center;
padding-inline-end: 0;
}
em {
font-style: normal;
}
&-active {
display: inline-flex;
align-items: center;
}
&-active span {
// iconfont
transform: scale(1);
visibility: visible;
width: 1em;
2020-06-15 13:31:05 +02:00
height: 1em;
opacity: 0.8;
padding-inline-end: 0.5em;
}
span.icon-spinner:after {
// iconfont
text-align: center;
position: absolute;
inset-inline-start: 0;
margin: 0;
line-height: 1em;
display: inline-block;
font-size: 1em;
}
svg.icon-spinner {
@include transition(all 0.3s ease);
display: none;
}
&-active svg.icon-spinner {
@include svg-icon();
display: inline-block;
opacity: 0.8;
2020-06-15 13:31:05 +02:00
padding: 0;
}
&-active .button-longrunning__icon {
display: none;
}
}
&:disabled,
&[disabled],
&.disabled {
background-color: $color-grey-3;
border-color: $color-grey-3;
color: $color-grey-2;
cursor: default;
@media (forced-colors: active) {
color: GrayText;
border-color: GrayText;
border-style: dashed;
}
}
&.button-secondary:disabled,
&.button-secondary[disabled],
&.button-secondary.disabled {
background-color: $color-white;
border-color: $color-grey-3;
color: $color-grey-3;
}
&.button-strokeonhover {
border: 1px solid transparent;
&:hover {
border-color: $color-grey-2;
}
}
&.button--icon {
.icon {
@include svg-icon(1.5em);
}
}
@include media-breakpoint-up(sm) {
font-size: 0.95em;
padding: 0 1.4em;
height: 3em;
&.bicolor {
padding-inline-start: 3.7em;
&:before {
width: 2em;
line-height: 2.2em;
font-size: 1.1rem;
}
}
&.button-small.bicolor {
// line-height: 2.2em;
padding-inline-start: 3em;
&:before {
width: 1.8em;
line-height: 1.65em;
}
}
}
}
.button-small {
padding: 0 0.8em;
height: 2em;
font-size: 0.95em;
}
.button-secondary {
color: $color-button;
background-color: transparent;
}
// Buttons which are only an icon
2020-06-15 12:06:29 +02:00
.button.icon.text-replace {
// iconfont
font-size: 0; // unavoidable duplication of setting in icons.scss
width: 1.8rem;
height: 1.8rem;
box-sizing: content-box;
2020-06-15 12:06:29 +02:00
&:before {
line-height: 1.7em;
}
2020-06-15 12:06:29 +02:00
@include media-breakpoint-up(sm) {
width: 2.2rem;
height: 2.2rem;
&:before {
line-height: 2.1em;
}
2020-06-15 12:06:29 +02:00
&.button-small {
height: 1.8rem;
width: 1.8rem;
&:before {
line-height: 1.7em;
}
}
}
2020-06-15 12:06:29 +02:00
}
.button--icon.text-replace {
font-size: 0;
text-align: center;
.icon {
font-size: initial;
@include svg-icon(1rem, middle);
padding: 0.5em;
box-sizing: content-box;
2020-06-15 12:06:29 +02:00
}
&.button-small {
line-height: 1.7rem;
height: 1.8rem;
width: 1.8rem;
2020-06-15 12:06:29 +02:00
.icon {
padding: 0.25em;
}
}
2020-06-15 12:06:29 +02:00
@include media-breakpoint-up(sm) {
width: 2.2rem;
height: 2.2rem;
}
}
2020-06-15 11:44:18 +02:00
button.button.bicolor .icon-wrapper {
line-height: 1.65em; // work around differences in a and button elements
}
.button-neutral {
color: $color-grey-2;
&:hover {
color: $color-teal;
}
}
.yes {
background-color: $color-button-yes;
border: 1px solid $color-button-yes;
&.button-secondary {
border: 1px solid $color-button-yes;
color: $color-button-yes;
background-color: transparent;
}
&:hover {
color: $color-white;
border-color: transparent;
background-color: $color-button-yes;
}
}
.no,
.serious {
background-color: $color-button-no;
border: 1px solid $color-button-no;
&.button-secondary {
border: 1px solid $color-button-no;
color: $color-button-no;
background-color: transparent;
}
&:hover {
color: $color-white;
border-color: transparent;
background-color: $color-button-no;
}
}
.bicolor {
border: 0;
padding-inline-start: 3.5em;
&:before {
font-size: 1rem;
position: absolute;
inset-inline-start: 0;
top: 0;
width: 2em;
line-height: 1.85em;
height: 100%;
text-align: center;
background-color: theme('colors.black-20');
display: block;
}
}
.button-small.bicolor {
padding-inline-start: 3.5em;
&:before {
width: 2em;
font-size: 0.8rem;
line-height: 1.65em;
}
}
a.button {
line-height: 2.4em;
height: auto;
&.button-small {
line-height: 1.85em;
}
@include media-breakpoint-up(sm) {
line-height: 2.9em;
}
}
// Special styles to counteract Firefox's completely unwarranted assumptions about button styles
input[type='submit'],
input[type='reset'],
input[type='button'],
button {
padding: 0 1em;
@include media-breakpoint-up(sm) {
&.button-small {
height: 2em;
}
}
}
.multiple {
padding: 0;
overflow: hidden;
> li {
@include row(1.5em);
border-radius: 2px;
position: relative;
overflow: hidden;
background-color: $color-white;
padding: 1em 1.5em;
padding-inline-end: 10em; // 10em padding leaves room for controls
margin-bottom: 1em;
border: 1px solid theme('colors.grey.100');
}
&.moving {
position: relative;
}
li.moving {
position: absolute;
width: 100%;
}
fieldset {
padding-top: 0;
padding-bottom: 0;
}
// Object controls
.controls {
position: absolute;
z-index: 1;
inset-inline-end: 1em;
top: 1em;
color: $color-white;
li {
float: left;
margin-inline-end: 1px;
&:last-child {
margin-inline-end: 0;
}
}
.disabled {
display: none;
visibility: hidden;
}
}
}
2021-08-06 18:35:13 +02:00
// wrapper around add button for multiple objects
.add {
font-weight: 700;
cursor: pointer;
margin-top: 0;
margin-bottom: 0;
padding-top: 1em;
padding-bottom: 2em;
clear: both;
}