mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 14:32:47 +08:00
295 lines
6.2 KiB
Plaintext
295 lines
6.2 KiB
Plaintext
// mixins for button
|
|
// ------------------------
|
|
.button-size(@height; @padding; @font-size; @border-radius) {
|
|
padding: @padding;
|
|
font-size: @font-size;
|
|
border-radius: @border-radius;
|
|
height: @height;
|
|
}
|
|
|
|
.button-disabled() {
|
|
&.disabled,
|
|
&[disabled] {
|
|
&,
|
|
&:hover,
|
|
&:focus,
|
|
&:active,
|
|
&.active {
|
|
.button-color(@btn-disable-color; @btn-disable-bg; @btn-disable-border);
|
|
}
|
|
}
|
|
}
|
|
|
|
.button-variant-primary(@color; @background) {
|
|
.button-color(@color; @background; @background);
|
|
&:hover,
|
|
&:focus {
|
|
.button-color(@color; ~`colorPalette("@{background}", 5)`; ~`colorPalette("@{background}", 5)`);
|
|
}
|
|
|
|
&:active,
|
|
&.active {
|
|
.button-color(@color; ~`colorPalette("@{background}", 7)`; ~`colorPalette("@{background}", 7)`);
|
|
}
|
|
|
|
.button-disabled();
|
|
}
|
|
|
|
.button-variant-other(@color; @background; @border) {
|
|
.button-color(@color; @background; @border);
|
|
|
|
&:hover,
|
|
&:focus {
|
|
.button-color(@primary-color; @background; @primary-color);
|
|
}
|
|
|
|
&:active,
|
|
&.active {
|
|
.button-color(@primary-7; @background; @primary-7);
|
|
}
|
|
|
|
.button-disabled();
|
|
}
|
|
|
|
.button-variant-danger(@color; @background; @border) {
|
|
.button-color(@color; @background; @border);
|
|
|
|
&:hover,
|
|
&:focus {
|
|
.button-color(@btn-primary-color; @color; @color;);
|
|
}
|
|
|
|
&:active,
|
|
&.active {
|
|
.button-color(@btn-primary-color; ~`colorPalette("@{color}", 7)`; ~`colorPalette("@{color}", 7)`;);
|
|
}
|
|
|
|
.button-disabled();
|
|
}
|
|
|
|
.button-variant-ghost(@color) {
|
|
.button-color(@color; transparent; @color);
|
|
|
|
&:hover,
|
|
&:focus {
|
|
.button-color(~`colorPalette("@{color}", 5)`; transparent; ~`colorPalette("@{color}", 5)`);
|
|
}
|
|
|
|
&:active,
|
|
&.active {
|
|
.button-color(~`colorPalette("@{color}", 7)`; transparent; ~`colorPalette("@{color}", 7)`);
|
|
}
|
|
|
|
.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;
|
|
&:after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
bottom: 0;
|
|
right: 0;
|
|
background: transparent;
|
|
}
|
|
}
|
|
}
|
|
|
|
.button-group-base(@btnClassName) {
|
|
position: relative;
|
|
display: inline-block;
|
|
> .@{btnClassName} {
|
|
position: relative;
|
|
z-index: 1;
|
|
|
|
&:hover,
|
|
&:focus,
|
|
&:active,
|
|
&.active {
|
|
z-index: 2;
|
|
}
|
|
|
|
&:disabled {
|
|
z-index: 0;
|
|
}
|
|
}
|
|
|
|
// size
|
|
&-lg > .@{btnClassName} {
|
|
.button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; @btn-border-radius-base);
|
|
}
|
|
|
|
&-sm > .@{btnClassName} {
|
|
.button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; @btn-border-radius-sm);
|
|
> .@{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;
|
|
touch-action: manipulation;
|
|
cursor: pointer;
|
|
background-image: none;
|
|
border: @border-width-base @border-style-base transparent;
|
|
white-space: nowrap;
|
|
line-height: 1.15; // https://github.com/ant-design/ant-design/issues/7070
|
|
.button-size(@btn-height-base; @btn-padding-base; @font-size-base; @btn-border-radius-base);
|
|
user-select: none;
|
|
transition: all .3s @ease-in-out;
|
|
position: relative;
|
|
|
|
> .@{iconfont-css-prefix} {
|
|
line-height: 1;
|
|
}
|
|
|
|
&,
|
|
&:active,
|
|
&:focus {
|
|
outline: 0;
|
|
}
|
|
|
|
&:not([disabled]):hover {
|
|
text-decoration: none;
|
|
}
|
|
|
|
&:not([disabled]):active {
|
|
outline: 0;
|
|
transition: none;
|
|
}
|
|
|
|
&.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 {
|
|
.button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; @btn-border-radius-sm);
|
|
}
|
|
}
|
|
|
|
// 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 {
|
|
background: #fff;
|
|
}
|
|
}
|
|
|
|
// 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() {
|
|
.button-variant-danger(@btn-danger-color, @btn-danger-bg, @btn-danger-border);
|
|
}
|
|
|
|
// circle button: the content only contains icon
|
|
.btn-circle(@btnClassName: btn) {
|
|
.square(@btn-circle-size);
|
|
.button-size(@btn-circle-size; 0; @font-size-base + 2px; 50%);
|
|
|
|
&.@{btnClassName}-lg {
|
|
.square(@btn-circle-size-lg);
|
|
.button-size(@btn-circle-size-lg; 0; @btn-font-size-lg + 2px; 50%);
|
|
}
|
|
|
|
&.@{btnClassName}-sm {
|
|
.square(@btn-circle-size-sm);
|
|
.button-size(@btn-circle-size-sm; 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;
|
|
padding-left: 8px;
|
|
padding-right: 8px;
|
|
}
|
|
|
|
> .@{btnClassName}:first-child {
|
|
margin-left: 0;
|
|
&:not(:last-child) {
|
|
border-bottom-right-radius: 0;
|
|
border-top-right-radius: 0;
|
|
padding-right: 8px;
|
|
}
|
|
}
|
|
|
|
> .@{btnClassName}:last-child:not(:first-child) {
|
|
border-bottom-left-radius: 0;
|
|
border-top-left-radius: 0;
|
|
padding-left: 8px;
|
|
}
|
|
|
|
& > & {
|
|
float: left;
|
|
}
|
|
|
|
& > &:not(:first-child):not(:last-child) > .@{btnClassName} {
|
|
border-radius: 0;
|
|
}
|
|
|
|
& > &:first-child:not(:last-child) {
|
|
> .@{btnClassName}:last-child {
|
|
border-bottom-right-radius: 0;
|
|
border-top-right-radius: 0;
|
|
padding-right: 8px;
|
|
}
|
|
}
|
|
|
|
& > &:last-child:not(:first-child) > .@{btnClassName}:first-child {
|
|
border-bottom-left-radius: 0;
|
|
border-top-left-radius: 0;
|
|
padding-left: 8px;
|
|
}
|
|
}
|