2015-06-09 15:21:44 +08:00
|
|
|
// mixins for button
|
|
|
|
// ------------------------
|
|
|
|
.button-size(@padding; @font-size; @border-radius) {
|
|
|
|
padding: @padding;
|
|
|
|
font-size: @font-size;
|
|
|
|
border-radius: @border-radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button-variant(@color; @background; @border) {
|
|
|
|
.button-color(@color; @background; @border);
|
|
|
|
|
2016-02-17 15:12:44 +08:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2015-07-05 17:40:52 +08:00
|
|
|
.button-color(tint(@color, 20%); tint(@background, 20%); tint(@border, 20%));
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2015-07-09 10:56:28 +08:00
|
|
|
.button-color(shade(@color, 5%); shade(@background, 5%); shade(@background, 5%));
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&.disabled,
|
|
|
|
&[disabled],
|
|
|
|
fieldset[disabled] & {
|
|
|
|
&,
|
|
|
|
&:hover,
|
2016-02-17 15:12:44 +08:00
|
|
|
&:focus,
|
2015-06-09 15:21:44 +08:00
|
|
|
&:active,
|
|
|
|
&.active {
|
|
|
|
.button-color(@btn-disable-color; @btn-disable-bg; @btn-disable-border);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
right: 0;
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
}
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.button-group-base(@btnClassName) {
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: middle;
|
|
|
|
> .@{btnClassName} {
|
|
|
|
position: relative;
|
|
|
|
float: left;
|
|
|
|
&:hover,
|
|
|
|
&:focus,
|
|
|
|
&:active,
|
|
|
|
&.active {
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// size
|
|
|
|
&-lg > .@{btnClassName} {
|
2016-09-19 17:41:41 +08:00
|
|
|
.button-size(@btn-padding-lg; @btn-font-size-lg; @btn-border-radius-base);
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&-sm > .@{btnClassName} {
|
2016-09-19 17:41:41 +08:00
|
|
|
.button-size(@btn-padding-sm; @font-size-base; @btn-border-radius-sm);
|
2015-06-09 15:21:44 +08:00
|
|
|
> .@{iconfont-css-prefix} {
|
|
|
|
font-size: @font-size-base;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Base styles of buttons
|
|
|
|
// --------------------------------------------------
|
|
|
|
.btn() {
|
|
|
|
display: inline-block;
|
|
|
|
margin-bottom: 0;
|
|
|
|
font-weight: @btn-font-weight;
|
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
|
|
|
touch-action: manipulation;
|
|
|
|
cursor: pointer;
|
|
|
|
background-image: none;
|
|
|
|
border: 1px solid transparent;
|
2015-06-17 18:22:02 +08:00
|
|
|
// outline: none;
|
2015-06-09 15:21:44 +08:00
|
|
|
white-space: nowrap;
|
|
|
|
line-height: @line-height-base;
|
2016-09-19 17:41:41 +08:00
|
|
|
.button-size(@btn-padding-base; @font-size-base; @btn-border-radius-base);
|
2016-04-19 15:15:54 +08:00
|
|
|
user-select: none;
|
|
|
|
transition: all .3s @ease-in-out;
|
2016-03-29 18:53:09 +08:00
|
|
|
transform: translate3d(0, 0, 0);
|
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;
|
2016-04-19 15:15:54 +08:00
|
|
|
transition: none;
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&.disabled,
|
2015-11-26 19:32:55 +08:00
|
|
|
&[disabled] {
|
2015-06-09 15:21:44 +08:00
|
|
|
cursor: @cursor-disabled;
|
2016-04-29 00:43:03 +08:00
|
|
|
> * {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&-lg {
|
2016-01-21 17:12:25 +08:00
|
|
|
.button-size(@btn-padding-lg; @btn-font-size-lg; @border-radius-base);
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
&-sm {
|
2016-01-21 17:12:25 +08:00
|
|
|
.button-size(@btn-padding-sm; @font-size-base; @border-radius-sm);
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// primary button style
|
|
|
|
.btn-primary() {
|
2015-07-09 10:56:28 +08:00
|
|
|
.button-variant(@btn-primary-color; @btn-primary-bg; @primary-color);
|
2015-06-11 17:16:32 +08:00
|
|
|
|
|
|
|
&:hover,
|
2016-02-17 15:12:44 +08:00
|
|
|
&:focus,
|
2015-06-11 17:16:32 +08:00
|
|
|
&:active,
|
|
|
|
&.active {
|
2015-06-29 18:50:49 +08:00
|
|
|
color: @btn-primary-color;
|
2015-06-11 17:16:32 +08:00
|
|
|
}
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// default button style
|
|
|
|
.btn-default() {
|
|
|
|
.button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
|
|
|
|
|
2016-02-17 15:12:44 +08:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2015-07-06 12:31:30 +08:00
|
|
|
.button-color(tint(@primary-color, 20%); white; tint(@primary-color, 20%));
|
2015-06-29 18:50:49 +08:00
|
|
|
}
|
2015-06-09 15:21:44 +08:00
|
|
|
&:active,
|
|
|
|
&.active {
|
2015-07-06 12:31:30 +08:00
|
|
|
.button-color(shade(@primary-color, 5%); white; shade(@primary-color, 5%));
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ghost button style
|
|
|
|
.btn-ghost() {
|
|
|
|
.button-variant(@btn-ghost-color, @btn-ghost-bg, @btn-ghost-border);
|
|
|
|
|
2016-02-17 15:12:44 +08:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2016-03-05 14:11:39 +08:00
|
|
|
.button-color(tint(@primary-color, 20%); @btn-ghost-bg; tint(@primary-color, 20%));
|
2015-06-29 18:50:49 +08:00
|
|
|
}
|
2015-06-09 15:21:44 +08:00
|
|
|
&:active,
|
|
|
|
&.active {
|
2016-03-05 14:11:39 +08:00
|
|
|
.button-color(shade(@primary-color, 5%); @btn-ghost-bg; shade(@primary-color, 5%));
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-30 18:26:44 +08:00
|
|
|
// ghost button style
|
|
|
|
.btn-dashed() {
|
|
|
|
.button-variant(@btn-ghost-color, @btn-ghost-bg, @btn-ghost-border);
|
|
|
|
border-style: dashed;
|
|
|
|
|
2016-02-17 15:12:44 +08:00
|
|
|
&:hover,
|
|
|
|
&:focus {
|
2016-03-05 14:11:39 +08:00
|
|
|
.button-color(tint(@primary-color, 20%); @btn-ghost-bg; tint(@primary-color, 20%));
|
2015-11-30 18:26:44 +08:00
|
|
|
}
|
|
|
|
&:active,
|
|
|
|
&.active {
|
2016-03-05 14:11:39 +08:00
|
|
|
.button-color(shade(@primary-color, 5%); @btn-ghost-bg; shade(@primary-color, 5%));
|
2015-11-30 18:26:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-09 15:21:44 +08:00
|
|
|
// circle button: the content only contains icon
|
|
|
|
.btn-circle(@btnClassName: btn) {
|
|
|
|
.square(@btn-circle-size);
|
|
|
|
.button-size(0; @font-size-base + 2; 50%);
|
|
|
|
|
|
|
|
&.@{btnClassName}-lg {
|
|
|
|
.square(@btn-circle-size-lg);
|
|
|
|
.button-size(0; @btn-font-size-lg + 2; 50%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.@{btnClassName}-sm {
|
|
|
|
.square(@btn-circle-size-sm);
|
|
|
|
.button-size(0; @font-size-base; 50%);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Horizontal button groups styl
|
|
|
|
// --------------------------------------------------
|
|
|
|
.btn-group(@btnClassName: btn) {
|
|
|
|
.button-group-base(@btnClassName);
|
|
|
|
|
|
|
|
.@{btnClassName} + .@{btnClassName},
|
|
|
|
.@{btnClassName} + &,
|
|
|
|
& + .@{btnClassName},
|
|
|
|
& + & {
|
|
|
|
margin-left: -1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.@{btnClassName}:not(:first-child):not(:last-child) {
|
|
|
|
border-radius: 0;
|
2016-02-22 19:48:51 +08:00
|
|
|
padding-left: 8px;
|
|
|
|
padding-right: 8px;
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
> .@{btnClassName}:first-child {
|
|
|
|
margin-left: 0;
|
|
|
|
&:not(:last-child) {
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-top-right-radius: 0;
|
2016-02-22 19:48:51 +08:00
|
|
|
padding-right: 8px;
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .@{btnClassName}:last-child:not(:first-child) {
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
border-top-left-radius: 0;
|
2016-02-22 19:48:51 +08:00
|
|
|
padding-left: 8px;
|
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 {
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-top-right-radius: 0;
|
2016-02-22 19:48:51 +08:00
|
|
|
padding-right: 8px;
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-15 20:13:02 +08:00
|
|
|
& > &:last-child:not(:first-child) > .@{btnClassName}:first-child {
|
2015-06-09 15:21:44 +08:00
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
border-top-left-radius: 0;
|
2016-02-22 19:48:51 +08:00
|
|
|
padding-left: 8px;
|
2015-06-09 15:21:44 +08:00
|
|
|
}
|
|
|
|
}
|