overleaf/services/web/frontend/stylesheets/components/buttons.less
Jessica Lawshe 679d56620c Merge pull request #10755 from overleaf/jel-btn-border
[web] Only set a border size for buttons using mixins on new CSS

GitOrigin-RevId: c6c2ce4f43f038601e52c580ba8b10981bb59317
2022-12-06 09:04:50 +00:00

320 lines
6.3 KiB
Text
Executable file

//
// Buttons
// --------------------------------------------------
// Base styles
// --------------------------------------------------
.btn when(@is-new-css = false) {
display: inline-block;
margin-bottom: 0; // For input.btn
font-weight: @btn-font-weight;
text-align: center;
vertical-align: middle;
cursor: pointer;
background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
border: @btn-border-width solid transparent;
border-bottom: @btn-border-bottom-width solid transparent;
white-space: nowrap;
.button-size(
@padding-base-vertical; @padding-base-horizontal; @font-size-base;
@line-height-base; @btn-border-radius-base
);
.user-select(none);
&,
&:active,
&.active {
&:focus {
.tab-focus();
}
}
&:hover,
&:focus {
color: @btn-default-color;
text-decoration: none;
}
&:active,
&.active {
outline: 0;
background-image: none;
.box-shadow(inset 0 3px 5px rgba(0, 0, 0, 0.125));
}
&.disabled,
&[disabled],
fieldset[disabled] & {
cursor: not-allowed;
pointer-events: none; // Future-proof disabling of clicks
.opacity(0.65);
.box-shadow(none);
}
}
.btn when(@is-new-css = true) {
display: inline-block;
margin-bottom: 0; // For input.btn
font-weight: @btn-font-weight;
text-align: center;
vertical-align: middle;
cursor: pointer;
border: 0 solid transparent;
white-space: nowrap;
.button-size(
@padding-base-vertical; @padding-base-horizontal; @font-size-base;
@line-height-base; @btn-border-radius-base
);
.user-select(none);
&,
&:active,
&.active {
&:focus {
.tab-focus();
}
}
&:hover,
&:focus {
color: @btn-default-color;
text-decoration: none;
}
// &:active,
// &.active {
// }
&.disabled,
&[disabled],
fieldset[disabled] & {
&,
&:hover,
&:focus,
&:active,
&.active {
cursor: not-allowed;
opacity: 1; //needed to override deprecated styling in individual classes
.box-shadow(none);
}
}
&.disabled.btn-info,
&.disabled.btn-default,
&[disabled].btn-info,
&[disabled].btn-default,
fieldset[disabled].btn-info,
fieldset[disabled].btn-default & {
// style only for deprecated classes
.opacity(0.65);
}
}
// Alternate buttons
// --------------------------------------------------
.btn-default {
.button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
}
.btn-default-outline {
.button-outline-variant(@btn-default-bg);
}
.btn-primary when (@is-new-css = false) {
.button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
}
.btn-primary when (@is-new-css = true) {
.btn-borderless();
}
.btn-primary-on-primary-bg {
.button-variant(@white; @ol-dark-green; @ol-dark-green);
}
// Success appears as green
.btn-success {
.btn-primary;
}
// Info appears as blue-green
.btn-info {
.button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
}
// Warning appears as orange
.btn-warning {
.button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
}
// Danger and error appear as red
.btn-danger when(@is-new-css = false) {
.button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
}
.btn-danger when(@is-new-css = true) {
.btn-borderless(@white, @red, @red-60);
}
// btn-secondary
.btn-secondary when(@is-new-css = false) {
&:not(.btn-secondary-info) {
.btn-default;
}
}
.btn-secondary when(@is-new-css = true) {
.btn-bordered();
}
// btn-info for old and btn-secondary for new
.btn-secondary-info when(@is-new-css = false) {
.btn-info;
}
.btn-secondary-info when(@is-new-css = true) {
.btn-secondary;
}
.reset-btns {
// reset all buttons back to their original colors
.btn-danger {
.btn-danger;
}
.btn-default {
.btn-default;
}
.btn-default-outline {
.btn-default-outline;
}
.btn-info {
.btn-info;
}
.btn-primary {
.btn-primary;
}
.btn-success {
.btn-success;
}
.btn-warning {
.btn-warning;
}
.btn-secondary {
.btn-secondary;
}
}
// Link buttons
// -------------------------
// Make a button look and behave like a link
.btn-link {
color: @link-color;
font-weight: normal;
cursor: pointer;
border-radius: 0;
&,
&:active,
&[disabled],
fieldset[disabled] & {
background-color: transparent;
.box-shadow(none);
}
&,
&:hover,
&:focus,
&:active {
border-color: transparent;
}
&:hover,
&:focus {
color: @link-hover-color;
text-decoration: underline;
background-color: transparent;
}
&[disabled],
fieldset[disabled] & {
&:hover,
&:focus {
color: @btn-link-disabled-color;
text-decoration: none;
}
}
&.btn-danger {
color: @ol-red;
&:hover,
&:focus {
color: @ol-dark-red;
}
}
}
.btn-inline-link {
.btn-link();
padding: 0;
font-size: inherit;
vertical-align: inherit;
}
// Button Sizes
// --------------------------------------------------
.btn-xl {
.button-size(
@padding-large-vertical; @padding-large-horizontal; @font-size-h2;
@line-height-large; @btn-border-radius-large
);
}
.btn-lg {
// line-height: ensure even-numbered height of button next to large input
.button-size(
@padding-large-vertical; @padding-large-horizontal; @font-size-large;
@line-height-large; @btn-border-radius-large
);
}
.btn-sm {
// line-height: ensure proper height of button next to small input
.button-size(
@padding-small-vertical; @padding-small-horizontal; @font-size-small;
@line-height-small; @btn-border-radius-small
);
}
.btn-xs {
.button-size(
@padding-xs-vertical; @padding-xs-horizontal; @font-size-small;
@line-height-small; @btn-border-radius-small
);
}
// Block button
// --------------------------------------------------
.btn-block {
display: block;
width: 100%;
padding-left: 0;
padding-right: 0;
}
// Vertically space out multiple block buttons
.btn-block + .btn-block {
margin-top: 5px;
}
// Specificity overrides
input[type='submit'],
input[type='reset'],
input[type='button'] {
&.btn-block {
width: 100%;
}
}
.login-btn when(@is-new-css = true) {
.btn;
.btn-secondary;
position: relative;
padding-left: 20px;
padding-right: 0;
}
.login-btn when(@is-new-css = false) {
.btn;
.btn-default;
position: relative;
padding-left: 20px;
padding-right: 0;
}