Blame view

src/styles/mixins/button.less 7.31 KB
e1596b7e   梁灏   add Button UI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  .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;
          }
      }
  
0bc06000   梁灏   optimize ButtonGr...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
      & .@{btnClassName}-icon-only .ivu-icon {
          font-size: 14px;
          position: relative;
          top: 1px;
      }
  
      &-large .@{btnClassName}-icon-only .ivu-icon{
          font-size: 16px;
          top: 2px;
      }
  
      &-small .@{btnClassName}-icon-only .ivu-icon{
          font-size: 12px;
          top: 0;
      }
  
f1b3ed30   梁灏   Button add circle...
84
85
86
87
      &-circle .@{btnClassName} {
          border-radius: @btn-circle-size;
      }
  
e1596b7e   梁灏   add Button UI
88
      // size
f1b3ed30   梁灏   Button add circle...
89
90
91
92
93
94
95
      &-large&-circle .@{btnClassName} {
          border-radius: @btn-circle-size-large;
      }
      &-large {
          & > .@{btnClassName} {
              .button-size(@btn-padding-large; @btn-font-size-large; @btn-border-radius);
          }
e1596b7e   梁灏   add Button UI
96
97
      }
  
f1b3ed30   梁灏   Button add circle...
98
99
100
101
102
103
104
105
106
      &-small&-circle .@{btnClassName} {
          border-radius: @btn-circle-size-small;
      }
      &-small {
          & > .@{btnClassName}{
              .button-size(@btn-padding-small; @btn-font-size; @btn-border-radius-small);
              > .@{css-prefix-iconfont} {
                  font-size: @btn-font-size;
              }
e1596b7e   梁灏   add Button UI
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
          }
      }
  }
  
  .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;
69576f47   梁灏   add Slider component
123
      .user-select();
e1596b7e   梁灏   add Button UI
124
125
      .button-size(@btn-padding-base; @btn-font-size; @btn-border-radius);
      .transform(translate3d(0, 0, 0));
698e3b61   梁灏   iButton add some ...
126
127
      //.transition(all @transition-time linear);
      .transition3(color @transition-time linear, background-color @transition-time linear, border @transition-time linear);
e1596b7e   梁灏   add Button UI
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
  
      > .@{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%));
      }
  }
  
698e3b61   梁灏   iButton add some ...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
  // Text
  .btn-text() {
      .button-variant(@link-color, @btn-ghost-bg, transparent);
  
      // for disabled
      &.disabled,
      &[disabled],
      fieldset[disabled] & {
          &,
          &:hover,
          &:focus,
          &:active,
          &.active {
              .button-color(@btn-disable-color; @btn-ghost-bg; transparent);
          }
      }
  
      &:hover
          //&:focus
      {
          .button-color(tint(@primary-color, 20%); @btn-ghost-bg; transparent);
      }
      &:active,
      &.active {
          .button-color(shade(@primary-color, 5%); @btn-ghost-bg; transparent);
      }
  }
  
e1596b7e   梁灏   add Button UI
251
252
  // Circle for Icon
  .btn-circle(@btnClassName: ivu-btn) {
f1b3ed30   梁灏   Button add circle...
253
      border-radius: @btn-circle-size;
e1596b7e   梁灏   add Button UI
254
  
698e3b61   梁灏   iButton add some ...
255
      &.@{btnClassName}-large{
f1b3ed30   梁灏   Button add circle...
256
          border-radius: @btn-circle-size-large;
e1596b7e   梁灏   add Button UI
257
258
      }
  
698e3b61   梁灏   iButton add some ...
259
      &.@{btnClassName}-size{
f1b3ed30   梁灏   Button add circle...
260
          border-radius: @btn-circle-size-small;
698e3b61   梁灏   iButton add some ...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
      }
  
      &.@{btnClassName}-icon-only{
          .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%);
          }
e1596b7e   梁灏   add Button UI
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
      }
  }
  
  // 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;
e1596b7e   梁灏   add Button UI
292
293
294
295
296
297
298
      }
  
      > .@{btnClassName}:first-child {
          margin-left: 0;
          &:not(:last-child) {
              border-bottom-right-radius: 0;
              border-top-right-radius: 0;
e1596b7e   梁灏   add Button UI
299
300
301
302
303
304
          }
      }
  
      > .@{btnClassName}:last-child:not(:first-child) {
          border-bottom-left-radius: 0;
          border-top-left-radius: 0;
e1596b7e   梁灏   add Button UI
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
      }
  
      & > & {
          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;
      }
  }