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