add Button UI
add Button UI
This commit is contained in:
parent
40f8606f58
commit
e1596b7e2c
9 changed files with 456 additions and 119 deletions
|
@ -1,7 +1,74 @@
|
|||
@btn-prefix-cls: ~"@{css-prefix}btn";
|
||||
|
||||
.@{btn-prefix-cls} {
|
||||
&-primary {
|
||||
color: @primary-color;
|
||||
}
|
||||
.btn;
|
||||
.btn-default;
|
||||
|
||||
&-primary {
|
||||
.btn-primary;
|
||||
|
||||
.@{btn-prefix-cls}-group &:not(:first-child):not(:last-child) {
|
||||
border-right-color: @btn-group-border;
|
||||
border-left-color: @btn-group-border;
|
||||
}
|
||||
|
||||
.@{btn-prefix-cls}-group &:first-child {
|
||||
&:not(:last-child) {
|
||||
border-right-color: @btn-group-border;
|
||||
&[disabled] {
|
||||
border-right-color: @btn-default-border;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.@{btn-prefix-cls}-group &:last-child:not(:first-child),
|
||||
.@{btn-prefix-cls}-group & + .@{btn-prefix-cls} {
|
||||
border-left-color: @btn-group-border;
|
||||
&[disabled] {
|
||||
border-left-color: @btn-default-border;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-ghost {
|
||||
.btn-ghost;
|
||||
}
|
||||
|
||||
//&-dashed {
|
||||
// .btn-dashed;
|
||||
//}
|
||||
|
||||
&-circle,
|
||||
&-circle-outline {
|
||||
.btn-circle(@btn-prefix-cls);
|
||||
}
|
||||
|
||||
&:before {
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
bottom: -1px;
|
||||
right: -1px;
|
||||
background: #fff;
|
||||
opacity: 0.35;
|
||||
content: '';
|
||||
border-radius: inherit;
|
||||
z-index: 1;
|
||||
.transition(opacity @animation-time);
|
||||
pointer-events: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
&&-loading {
|
||||
pointer-events: none;
|
||||
position: relative;
|
||||
|
||||
&:before {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
&-group {
|
||||
.btn-group(@btn-prefix-cls);
|
||||
}
|
||||
}
|
|
@ -36,13 +36,13 @@
|
|||
}
|
||||
|
||||
&-title {
|
||||
font-size: 14px;
|
||||
font-size: @font-size-base;
|
||||
color: @text-color;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
&-desc {
|
||||
font-size: @font-size-base;
|
||||
font-size: 12px;
|
||||
color: @legend-color;
|
||||
text-align: justify;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,261 @@
|
|||
.button-size(@padding; @font-size; @border-radius) {
|
||||
padding: @padding;
|
||||
font-size: @font-size;
|
||||
border-radius: @border-radius;
|
||||
}
|
||||
|
||||
.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-variant(@color; @background; @border) {
|
||||
.button-color(@color; @background; @border);
|
||||
|
||||
&:hover
|
||||
//&:focus
|
||||
{
|
||||
.button-color(tint(@color, 20%); tint(@background, 20%); tint(@border, 20%));
|
||||
}
|
||||
&:active,
|
||||
&.active {
|
||||
.button-color(shade(@color, 5%); shade(@background, 5%); shade(@background, 5%));
|
||||
}
|
||||
|
||||
&.disabled,
|
||||
&[disabled],
|
||||
fieldset[disabled] & {
|
||||
&,
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
&.active {
|
||||
.button-color(@btn-disable-color; @btn-disable-bg; @btn-disable-border);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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
|
||||
&-large > .@{btnClassName} {
|
||||
.button-size(@btn-padding-large; @btn-font-size-large; @btn-border-radius);
|
||||
}
|
||||
|
||||
&-small > .@{btnClassName} {
|
||||
.button-size(@btn-padding-small; @btn-font-size; @btn-border-radius-small);
|
||||
> .@{css-prefix-iconfont} {
|
||||
font-size: @btn-font-size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
white-space: nowrap;
|
||||
line-height: @line-height-base;
|
||||
user-select: none;
|
||||
.button-size(@btn-padding-base; @btn-font-size; @btn-border-radius);
|
||||
.transform(translate3d(0, 0, 0));
|
||||
.transition(all @animation-time linear);
|
||||
|
||||
> .@{css-prefix-iconfont} {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&,
|
||||
&:active,
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
&:not([disabled]):hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:not([disabled]):active {
|
||||
outline: 0;
|
||||
.transition(none)
|
||||
}
|
||||
|
||||
&.disabled,
|
||||
&[disabled] {
|
||||
cursor: @cursor-disabled;
|
||||
> * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-large {
|
||||
.button-size(@btn-padding-large; @btn-font-size-large; @btn-border-radius);
|
||||
}
|
||||
|
||||
&-small {
|
||||
.button-size(@btn-padding-small; @btn-font-size; @btn-border-radius-small);
|
||||
}
|
||||
}
|
||||
|
||||
// Default
|
||||
.btn-default() {
|
||||
.button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
|
||||
|
||||
&:hover
|
||||
//&:focus
|
||||
{
|
||||
.button-color(tint(@primary-color, 20%); white; tint(@primary-color, 20%));
|
||||
}
|
||||
&:active,
|
||||
&.active {
|
||||
.button-color(shade(@primary-color, 5%); white; shade(@primary-color, 5%));
|
||||
}
|
||||
}
|
||||
|
||||
// Primary
|
||||
.btn-primary() {
|
||||
.button-variant(@btn-primary-color; @btn-primary-bg; @primary-color);
|
||||
|
||||
&:hover,
|
||||
//&:focus,
|
||||
&:active,
|
||||
&.active {
|
||||
color: @btn-primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
// Ghost
|
||||
.btn-ghost() {
|
||||
.button-variant(@btn-ghost-color, @btn-ghost-bg, @btn-ghost-border);
|
||||
|
||||
&:hover
|
||||
//&:focus
|
||||
{
|
||||
.button-color(tint(@primary-color, 20%); @btn-ghost-bg; tint(@primary-color, 20%));
|
||||
}
|
||||
&:active,
|
||||
&.active {
|
||||
.button-color(shade(@primary-color, 5%); @btn-ghost-bg; shade(@primary-color, 5%));
|
||||
}
|
||||
}
|
||||
|
||||
// Dashed
|
||||
.btn-dashed() {
|
||||
.button-variant(@btn-ghost-color, @btn-ghost-bg, @btn-ghost-border);
|
||||
border-style: dashed;
|
||||
|
||||
&:hover
|
||||
//&:focus
|
||||
{
|
||||
.button-color(tint(@primary-color, 20%); @btn-ghost-bg; tint(@primary-color, 20%));
|
||||
}
|
||||
&:active,
|
||||
&.active {
|
||||
.button-color(shade(@primary-color, 5%); @btn-ghost-bg; shade(@primary-color, 5%));
|
||||
}
|
||||
}
|
||||
|
||||
// Circle for Icon
|
||||
.btn-circle(@btnClassName: ivu-btn) {
|
||||
.square(@btn-circle-size);
|
||||
.button-size(0; @font-size-base + 2; 50%);
|
||||
|
||||
&.@{btnClassName}-large {
|
||||
.square(@btn-circle-size-large);
|
||||
.button-size(0; @btn-font-size-large + 2; 50%);
|
||||
}
|
||||
|
||||
&.@{btnClassName}-small {
|
||||
.square(@btn-circle-size-small);
|
||||
.button-size(0; @font-size-base; 50%);
|
||||
}
|
||||
}
|
||||
|
||||
// Group
|
||||
.btn-group(@btnClassName: ivu-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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// Prefix
|
||||
@css-prefix : ivu-;
|
||||
|
||||
@css-prefix-iconfont : ivu-icon;
|
||||
// Color
|
||||
@primary-color : #0099e5;
|
||||
@info-color : #2db7f5;
|
||||
|
@ -21,6 +21,7 @@
|
|||
@line-height-computed : floor((@font-size-base * @line-height-base));
|
||||
@border-radius-base : 6px;
|
||||
@border-radius-small : 4px;
|
||||
@cursor-disabled : not-allowed;
|
||||
|
||||
// Border color
|
||||
@border-color-base : #d9d9d9; // outside
|
||||
|
@ -38,6 +39,36 @@
|
|||
@shadow-left : -1px 0 6px @shadow-color;
|
||||
@shadow-right : 1px 0 6px @shadow-color;
|
||||
|
||||
// Button
|
||||
@btn-font-weight : 400;
|
||||
@btn-padding-base : 4px 15px;
|
||||
@btn-padding-large : 4px 15px 5px 15px;
|
||||
@btn-padding-small : 1px 7px;
|
||||
@btn-font-size : 12px;
|
||||
@btn-font-size-large : 14px;
|
||||
@btn-border-radius : 4px;
|
||||
@btn-border-radius-small: 3px;
|
||||
@btn-group-border : shade(@primary-color, 5%);
|
||||
|
||||
@btn-disable-color : #ccc;
|
||||
@btn-disable-bg : @background-color-base;
|
||||
@btn-disable-border : @border-color-base;
|
||||
|
||||
@btn-default-color : @text-color;
|
||||
@btn-default-bg : @background-color-base;
|
||||
@btn-default-border : @border-color-base;
|
||||
|
||||
@btn-primary-color : #fff;
|
||||
@btn-primary-bg : @primary-color;
|
||||
|
||||
@btn-ghost-color : @text-color;
|
||||
@btn-ghost-bg : transparent;
|
||||
@btn-ghost-border : @border-color-base;
|
||||
|
||||
@btn-circle-size : 28px;
|
||||
@btn-circle-size-large : 32px;
|
||||
@btn-circle-size-small : 22px;
|
||||
|
||||
// Layout and Grid
|
||||
@grid-columns : 24;
|
||||
@grid-gutter-width : 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue