2017-10-26 07:18:08 +00:00
|
|
|
// mixins for button
|
|
|
|
// ------------------------
|
|
|
|
.button-size(@height; @padding; @font-size; @border-radius) {
|
2019-03-05 05:16:32 +00:00
|
|
|
height: @height;
|
2017-10-26 07:18:08 +00:00
|
|
|
padding: @padding;
|
|
|
|
font-size: @font-size;
|
|
|
|
border-radius: @border-radius;
|
|
|
|
}
|
|
|
|
|
2019-10-11 14:05:02 +00:00
|
|
|
.button-disabled(@color: @btn-disable-color; @background: @btn-disable-bg; @border: @btn-disable-border) {
|
2019-03-05 05:16:32 +00:00
|
|
|
&-disabled,
|
2017-10-26 07:18:08 +00:00
|
|
|
&.disabled,
|
|
|
|
&[disabled] {
|
|
|
|
&,
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2019-10-11 14:05:02 +00:00
|
|
|
.button-color(@color; @background; @border);
|
|
|
|
|
2018-11-14 13:33:56 +00:00
|
|
|
text-shadow: none;
|
|
|
|
box-shadow: none;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.button-variant-primary(@color; @background) {
|
|
|
|
.button-color(@color; @background; @background);
|
2020-03-07 11:45:13 +00:00
|
|
|
|
2019-03-05 05:16:32 +00:00
|
|
|
text-shadow: @btn-text-shadow;
|
|
|
|
box-shadow: @btn-primary-shadow;
|
2018-11-14 13:33:56 +00:00
|
|
|
|
2017-10-26 07:18:08 +00:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2019-01-02 13:01:56 +00:00
|
|
|
.button-color(
|
|
|
|
@color; ~`colorPalette('@{background}', 5) `; ~`colorPalette('@{background}', 5) `
|
|
|
|
);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2019-01-02 13:01:56 +00:00
|
|
|
.button-color(
|
|
|
|
@color; ~`colorPalette('@{background}', 7) `; ~`colorPalette('@{background}', 7) `
|
|
|
|
);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.button-disabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
.button-variant-other(@color; @background; @border) {
|
|
|
|
.button-color(@color; @background; @border);
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2019-03-05 05:16:32 +00:00
|
|
|
.button-color(
|
|
|
|
~`colorPalette('@{btn-primary-bg}', 5) `; @background; ~`colorPalette('@{btn-primary-bg}', 5)
|
|
|
|
`
|
|
|
|
);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2019-03-05 05:16:32 +00:00
|
|
|
.button-color(
|
|
|
|
~`colorPalette('@{btn-primary-bg}', 7) `; @background; ~`colorPalette('@{btn-primary-bg}', 7)
|
|
|
|
`
|
|
|
|
);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
.button-disabled();
|
|
|
|
}
|
2019-10-11 14:05:02 +00:00
|
|
|
.button-variant-ghost(@color; @border: @color) {
|
|
|
|
.button-color(@color; transparent; @border);
|
2018-11-14 13:33:56 +00:00
|
|
|
text-shadow: none;
|
2017-10-26 07:18:08 +00:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2019-10-11 14:05:02 +00:00
|
|
|
& when (@border = transparent) {
|
|
|
|
.button-color(~`colorPalette('@{color}', 5) `; transparent; transparent);
|
|
|
|
}
|
|
|
|
& when not(@border = transparent) {
|
|
|
|
.button-color(~`colorPalette('@{color}', 5) `; transparent; ~`colorPalette('@{color}', 5) `);
|
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2019-10-11 14:05:02 +00:00
|
|
|
& when (@border = transparent) {
|
|
|
|
.button-color(~`colorPalette('@{color}', 7) `; transparent; transparent);
|
|
|
|
}
|
|
|
|
& when not(@border = transparent) {
|
|
|
|
.button-color(~`colorPalette('@{color}', 7) `; transparent; ~`colorPalette('@{color}', 7) `);
|
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
.button-disabled();
|
|
|
|
}
|
|
|
|
.button-color(@color; @background; @border) {
|
|
|
|
color: @color;
|
|
|
|
background-color: @background;
|
|
|
|
border-color: @border;
|
|
|
|
// a inside Button which only work in Chrome
|
|
|
|
// http://stackoverflow.com/a/17253457
|
|
|
|
> a:only-child {
|
|
|
|
color: currentColor;
|
2019-03-05 05:16:32 +00:00
|
|
|
&::after {
|
2017-10-26 07:18:08 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
2019-03-05 05:16:32 +00:00
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
2017-10-26 07:18:08 +00:00
|
|
|
background: transparent;
|
2019-03-05 05:16:32 +00:00
|
|
|
content: '';
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.button-group-base(@btnClassName) {
|
|
|
|
position: relative;
|
2020-11-23 06:23:32 +00:00
|
|
|
display: inline-flex;
|
2018-07-17 13:16:22 +00:00
|
|
|
> .@{btnClassName},
|
|
|
|
> span > .@{btnClassName} {
|
2017-10-26 07:18:08 +00:00
|
|
|
position: relative;
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active,
|
|
|
|
&.active {
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
&:disabled {
|
|
|
|
z-index: 0;
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 11:45:13 +00:00
|
|
|
> .@{btnClassName}-icon-only {
|
|
|
|
font-size: @font-size-base;
|
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
// size
|
2018-07-17 13:16:22 +00:00
|
|
|
&-lg > .@{btnClassName},
|
|
|
|
&-lg > span > .@{btnClassName} {
|
|
|
|
.button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; 0);
|
2018-04-06 12:56:19 +00:00
|
|
|
line-height: @btn-height-lg - 2px;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
2020-03-07 11:45:13 +00:00
|
|
|
&-lg > .@{btnClassName}.@{btnClassName}-icon-only {
|
|
|
|
.square(@btn-height-lg);
|
|
|
|
padding-right: 0;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
2018-07-17 13:16:22 +00:00
|
|
|
&-sm > .@{btnClassName},
|
|
|
|
&-sm > span > .@{btnClassName} {
|
|
|
|
.button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; 0);
|
2018-04-06 12:56:19 +00:00
|
|
|
line-height: @btn-height-sm - 2px;
|
2017-10-26 07:18:08 +00:00
|
|
|
> .@{iconfont-css-prefix} {
|
|
|
|
font-size: @font-size-base;
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 11:45:13 +00:00
|
|
|
&-sm > .@{btnClassName}.@{btnClassName}-icon-only {
|
|
|
|
.square(@btn-height-sm);
|
|
|
|
padding-right: 0;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
// Base styles of buttons
|
|
|
|
// --------------------------------------------------
|
|
|
|
.btn() {
|
2019-03-05 05:16:32 +00:00
|
|
|
position: relative;
|
2017-10-26 07:18:08 +00:00
|
|
|
display: inline-block;
|
|
|
|
font-weight: @btn-font-weight;
|
2019-03-05 05:16:32 +00:00
|
|
|
white-space: nowrap;
|
2017-10-26 07:18:08 +00:00
|
|
|
text-align: center;
|
|
|
|
background-image: none;
|
2020-03-07 11:45:13 +00:00
|
|
|
border: @btn-border-width @btn-border-style transparent;
|
2019-03-05 05:16:32 +00:00
|
|
|
box-shadow: @btn-shadow;
|
|
|
|
cursor: pointer;
|
2019-01-02 13:01:56 +00:00
|
|
|
transition: all 0.3s @ease-in-out;
|
2019-03-05 05:16:32 +00:00
|
|
|
user-select: none;
|
|
|
|
touch-action: manipulation;
|
|
|
|
.button-size(@btn-height-base; @btn-padding-base; @font-size-base; @btn-border-radius-base);
|
2017-10-26 07:18:08 +00:00
|
|
|
> .@{iconfont-css-prefix} {
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
&,
|
|
|
|
&:active,
|
|
|
|
&:focus {
|
|
|
|
outline: 0;
|
|
|
|
}
|
|
|
|
&:not([disabled]):hover {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
&:not([disabled]):active {
|
|
|
|
outline: 0;
|
2018-11-14 13:33:56 +00:00
|
|
|
box-shadow: none;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
&.disabled,
|
|
|
|
&[disabled] {
|
|
|
|
cursor: not-allowed;
|
|
|
|
> * {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&-lg {
|
|
|
|
.button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; @btn-border-radius-base);
|
|
|
|
}
|
|
|
|
&-sm {
|
2018-01-15 10:54:26 +00:00
|
|
|
.button-size(@btn-height-sm; @btn-padding-sm; @btn-font-size-sm; @btn-border-radius-sm);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// primary button style
|
|
|
|
.btn-primary() {
|
|
|
|
.button-variant-primary(@btn-primary-color; @btn-primary-bg);
|
|
|
|
}
|
|
|
|
// default button style
|
|
|
|
.btn-default() {
|
|
|
|
.button-variant-other(@btn-default-color; @btn-default-bg; @btn-default-border);
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2018-04-06 12:56:19 +00:00
|
|
|
text-decoration: none;
|
2019-03-05 05:16:32 +00:00
|
|
|
background: @btn-default-bg;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// ghost button style
|
|
|
|
.btn-ghost() {
|
|
|
|
.button-variant-other(@btn-ghost-color, @btn-ghost-bg, @btn-ghost-border);
|
|
|
|
}
|
|
|
|
// dashed button style
|
|
|
|
.btn-dashed() {
|
|
|
|
.button-variant-other(@btn-default-color, @btn-default-bg, @btn-default-border);
|
|
|
|
border-style: dashed;
|
|
|
|
}
|
|
|
|
// danger button style
|
|
|
|
.btn-danger() {
|
2020-03-07 11:45:13 +00:00
|
|
|
.button-variant-primary(@btn-danger-color, @btn-danger-bg);
|
|
|
|
}
|
|
|
|
// link button style
|
|
|
|
.btn-link() {
|
|
|
|
.button-variant-other(@link-color, transparent, transparent);
|
|
|
|
box-shadow: none;
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active {
|
|
|
|
border-color: transparent;
|
|
|
|
}
|
|
|
|
.button-disabled(@disabled-color; transparent; transparent);
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
2019-03-05 05:16:32 +00:00
|
|
|
// round button
|
|
|
|
.btn-round(@btnClassName: btn) {
|
2020-12-27 06:50:32 +00:00
|
|
|
.button-size(@btn-circle-size; 0 (@btn-circle-size / 2) ; @font-size-base; @btn-circle-size);
|
2019-03-05 05:16:32 +00:00
|
|
|
&.@{btnClassName}-lg {
|
|
|
|
.button-size(
|
2020-12-27 06:50:32 +00:00
|
|
|
@btn-circle-size-lg; 0 (@btn-circle-size-lg / 2) ; @btn-font-size-lg; @btn-circle-size-lg
|
2019-03-05 05:16:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
&.@{btnClassName}-sm {
|
|
|
|
.button-size(
|
2020-12-27 06:50:32 +00:00
|
|
|
@btn-circle-size-sm; 0 (@btn-circle-size-sm / 2) ; @font-size-base; @btn-circle-size-sm
|
2019-03-05 05:16:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 11:45:13 +00:00
|
|
|
// square button: the content only contains icon
|
|
|
|
.btn-square(@btnClassName: btn) {
|
|
|
|
.square(@btn-square-size);
|
|
|
|
.button-size(@btn-square-size; 0; @font-size-base + 2px; @btn-border-radius-base);
|
|
|
|
&.@{btnClassName}-lg {
|
|
|
|
.square(@btn-square-size-lg);
|
|
|
|
.button-size(@btn-square-size-lg; 0; @btn-font-size-lg + 2px; @btn-border-radius-base);
|
|
|
|
}
|
|
|
|
&.@{btnClassName}-sm {
|
|
|
|
.square(@btn-square-size-sm);
|
|
|
|
.button-size(@btn-square-size-sm; 0; @font-size-base; @btn-border-radius-base);
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
// circle button: the content only contains icon
|
|
|
|
.btn-circle(@btnClassName: btn) {
|
2020-03-07 11:45:13 +00:00
|
|
|
min-width: @btn-height-base;
|
|
|
|
padding-right: 0;
|
|
|
|
padding-left: 0;
|
|
|
|
text-align: center;
|
|
|
|
border-radius: 50%;
|
2017-10-26 07:18:08 +00:00
|
|
|
&.@{btnClassName}-lg {
|
2020-03-07 11:45:13 +00:00
|
|
|
min-width: @btn-height-lg;
|
|
|
|
border-radius: 50%;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
&.@{btnClassName}-sm {
|
2020-03-07 11:45:13 +00:00
|
|
|
min-width: @btn-height-sm;
|
|
|
|
border-radius: 50%;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-07 11:45:13 +00:00
|
|
|
// Horizontal button groups style
|
2017-10-26 07:18:08 +00:00
|
|
|
// --------------------------------------------------
|
|
|
|
.btn-group(@btnClassName: btn) {
|
|
|
|
.button-group-base(@btnClassName);
|
|
|
|
.@{btnClassName} + .@{btnClassName},
|
|
|
|
.@{btnClassName} + &,
|
2018-02-22 07:09:03 +00:00
|
|
|
span + .@{btnClassName},
|
|
|
|
.@{btnClassName} + span,
|
2018-07-17 13:16:22 +00:00
|
|
|
> span + span,
|
2017-10-26 07:18:08 +00:00
|
|
|
& + .@{btnClassName},
|
|
|
|
& + & {
|
|
|
|
margin-left: -1px;
|
|
|
|
}
|
2018-07-17 13:16:22 +00:00
|
|
|
.@{btnClassName}-primary + .@{btnClassName}:not(.@{btnClassName}-primary):not([disabled]) {
|
|
|
|
border-left-color: transparent;
|
|
|
|
}
|
|
|
|
.@{btnClassName} {
|
2017-10-26 07:18:08 +00:00
|
|
|
border-radius: 0;
|
|
|
|
}
|
2018-02-22 07:09:03 +00:00
|
|
|
> .@{btnClassName}:first-child,
|
|
|
|
> span:first-child > .@{btnClassName} {
|
2017-10-26 07:18:08 +00:00
|
|
|
margin-left: 0;
|
|
|
|
}
|
2018-07-20 02:25:33 +00:00
|
|
|
> .@{btnClassName}:only-child {
|
2018-07-18 01:39:57 +00:00
|
|
|
border-radius: @btn-border-radius-base;
|
|
|
|
}
|
2018-07-20 02:25:33 +00:00
|
|
|
> span:only-child > .@{btnClassName} {
|
2018-07-18 01:39:57 +00:00
|
|
|
border-radius: @btn-border-radius-base;
|
|
|
|
}
|
2018-02-22 07:09:03 +00:00
|
|
|
> .@{btnClassName}:first-child:not(:last-child),
|
|
|
|
> span:first-child:not(:last-child) > .@{btnClassName} {
|
2018-07-17 13:16:22 +00:00
|
|
|
border-top-left-radius: @btn-border-radius-base;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-bottom-left-radius: @btn-border-radius-base;
|
2018-02-22 07:09:03 +00:00
|
|
|
}
|
|
|
|
> .@{btnClassName}:last-child:not(:first-child),
|
|
|
|
> span:last-child:not(:first-child) > .@{btnClassName} {
|
2018-07-17 13:16:22 +00:00
|
|
|
border-top-right-radius: @btn-border-radius-base;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-bottom-right-radius: @btn-border-radius-base;
|
2018-07-17 13:16:22 +00:00
|
|
|
}
|
|
|
|
&-sm {
|
2018-07-20 02:25:33 +00:00
|
|
|
> .@{btnClassName}:only-child {
|
2018-07-18 01:39:57 +00:00
|
|
|
border-radius: @btn-border-radius-sm;
|
|
|
|
}
|
2018-07-20 02:25:33 +00:00
|
|
|
> span:only-child > .@{btnClassName} {
|
2018-07-18 01:39:57 +00:00
|
|
|
border-radius: @btn-border-radius-sm;
|
|
|
|
}
|
2018-07-17 13:16:22 +00:00
|
|
|
> .@{btnClassName}:first-child:not(:last-child),
|
|
|
|
> span:first-child:not(:last-child) > .@{btnClassName} {
|
|
|
|
border-top-left-radius: @btn-border-radius-sm;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-bottom-left-radius: @btn-border-radius-sm;
|
2018-07-17 13:16:22 +00:00
|
|
|
}
|
|
|
|
> .@{btnClassName}:last-child:not(:first-child),
|
|
|
|
> span:last-child:not(:first-child) > .@{btnClassName} {
|
|
|
|
border-top-right-radius: @btn-border-radius-sm;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-bottom-right-radius: @btn-border-radius-sm;
|
2018-07-17 13:16:22 +00:00
|
|
|
}
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
& > & {
|
|
|
|
float: left;
|
|
|
|
}
|
|
|
|
& > &:not(:first-child):not(:last-child) > .@{btnClassName} {
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
& > &:first-child:not(:last-child) {
|
|
|
|
> .@{btnClassName}:last-child {
|
|
|
|
padding-right: 8px;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
& > &:last-child:not(:first-child) > .@{btnClassName}:first-child {
|
|
|
|
padding-left: 8px;
|
2019-03-05 05:16:32 +00:00
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2017-10-26 07:18:08 +00:00
|
|
|
}
|
|
|
|
}
|