index-pure.less 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @import './mixin';
  4. @btn-prefix-cls: ~'@{ant-prefix}-btn';
  5. // for compatible
  6. @btn-ghost-color: @text-color;
  7. @btn-ghost-bg: transparent;
  8. @btn-ghost-border: @border-color-base;
  9. // Button styles
  10. // -----------------------------
  11. .@{btn-prefix-cls} {
  12. // Fixing https://github.com/ant-design/ant-design/issues/12978
  13. // Fixing https://github.com/ant-design/ant-design/issues/20058
  14. // Fixing https://github.com/ant-design/ant-design/issues/19972
  15. // Fixing https://github.com/ant-design/ant-design/issues/18107
  16. // Fixing https://github.com/ant-design/ant-design/issues/13214
  17. // It is a render problem of chrome, which is only happened in the codesandbox demo
  18. // 0.001px solution works and I don't know why
  19. line-height: @btn-line-height;
  20. .btn();
  21. .btn-default();
  22. // Fix loading button animation
  23. // https://github.com/ant-design/ant-design/issues/24323
  24. > span {
  25. display: inline-block;
  26. }
  27. &-primary {
  28. .btn-primary();
  29. .@{btn-prefix-cls}-group &:not(:first-child):not(:last-child) {
  30. border-right-color: @btn-group-border;
  31. border-left-color: @btn-group-border;
  32. &:disabled {
  33. border-color: @btn-default-border;
  34. }
  35. }
  36. .@{btn-prefix-cls}-group &:first-child {
  37. &:not(:last-child) {
  38. border-right-color: @btn-group-border;
  39. &[disabled] {
  40. border-right-color: @btn-default-border;
  41. }
  42. }
  43. }
  44. .@{btn-prefix-cls}-group &:last-child:not(:first-child),
  45. .@{btn-prefix-cls}-group & + & {
  46. border-left-color: @btn-group-border;
  47. &[disabled] {
  48. border-left-color: @btn-default-border;
  49. }
  50. }
  51. }
  52. &-ghost {
  53. .btn-ghost();
  54. }
  55. &-dashed {
  56. .btn-dashed();
  57. }
  58. // type="danger" will deprecated
  59. // use danger instead
  60. &-danger {
  61. .btn-danger();
  62. }
  63. &-link {
  64. .btn-link();
  65. }
  66. &-text {
  67. .btn-text();
  68. }
  69. &-dangerous {
  70. .btn-danger-default();
  71. }
  72. &-dangerous&-primary {
  73. .btn-danger();
  74. }
  75. &-dangerous&-link {
  76. .btn-danger-link();
  77. }
  78. &-dangerous&-text {
  79. .btn-danger-text();
  80. }
  81. &-icon-only {
  82. .btn-square(@btn-prefix-cls);
  83. vertical-align: -3px;
  84. > .@{iconfont-css-prefix} {
  85. display: flex;
  86. justify-content: center;
  87. }
  88. }
  89. // https://github.com/ant-design/ant-design/issues/32365
  90. a&-icon-only {
  91. vertical-align: -1px;
  92. > .@{iconfont-css-prefix} {
  93. display: inline;
  94. }
  95. }
  96. &-round {
  97. .btn-round(@btn-prefix-cls);
  98. &.@{btn-prefix-cls}-icon-only {
  99. width: auto;
  100. }
  101. }
  102. &-circle {
  103. .btn-circle(@btn-prefix-cls);
  104. }
  105. &::before {
  106. position: absolute;
  107. top: -@btn-border-width;
  108. right: -@btn-border-width;
  109. bottom: -@btn-border-width;
  110. left: -@btn-border-width;
  111. z-index: 1;
  112. display: none;
  113. background: @component-background;
  114. border-radius: inherit;
  115. opacity: 0.35;
  116. transition: opacity 0.2s;
  117. content: '';
  118. pointer-events: none;
  119. }
  120. .@{iconfont-css-prefix} {
  121. transition: margin-left 0.3s @ease-in-out;
  122. // Follow icon blur under windows. Change the render.
  123. // https://github.com/ant-design/ant-design/issues/13924
  124. &.@{iconfont-css-prefix}-plus,
  125. &.@{iconfont-css-prefix}-minus {
  126. > svg {
  127. shape-rendering: optimizespeed;
  128. }
  129. }
  130. }
  131. &&-loading {
  132. position: relative;
  133. cursor: default;
  134. &::before {
  135. display: block;
  136. }
  137. }
  138. & > &-loading-icon {
  139. transition: width 0.3s @ease-in-out, opacity 0.3s @ease-in-out;
  140. .@{iconfont-css-prefix} {
  141. padding-right: @padding-xs;
  142. animation: none;
  143. // for smooth button padding transition
  144. svg {
  145. animation: loadingCircle 1s infinite linear;
  146. }
  147. }
  148. &:only-child {
  149. .@{iconfont-css-prefix} {
  150. padding-right: 0;
  151. }
  152. }
  153. }
  154. &-group {
  155. .btn-group(@btn-prefix-cls);
  156. }
  157. // http://stackoverflow.com/a/21281554/3040605
  158. &:focus > span,
  159. &:active > span {
  160. position: relative;
  161. }
  162. // To ensure that a space will be placed between character and `Icon`.
  163. > .@{iconfont-css-prefix} + span,
  164. > span + .@{iconfont-css-prefix} {
  165. margin-left: @margin-xs;
  166. }
  167. &&-background-ghost {
  168. color: @btn-default-ghost-color;
  169. border-color: @btn-default-ghost-border;
  170. &,
  171. &:hover,
  172. &:active,
  173. &:focus {
  174. background: @btn-default-ghost-bg;
  175. }
  176. &:hover,
  177. &:focus {
  178. color: @primary-color-hover;
  179. border-color: @primary-color-hover;
  180. }
  181. &:active {
  182. color: @primary-color-active;
  183. border-color: @primary-color-active;
  184. }
  185. &[disabled] {
  186. color: @disabled-color;
  187. background: @btn-default-ghost-bg;
  188. border-color: @btn-default-border;
  189. }
  190. }
  191. &-background-ghost&-primary {
  192. .button-variant-ghost(@btn-primary-bg, @btn-primary-bg, @primary-color-hover, @primary-color-active);
  193. }
  194. &-background-ghost&-danger {
  195. .button-variant-ghost(@btn-danger-border, @btn-danger-border, @error-color-hover, @error-color-active);
  196. }
  197. &-background-ghost&-dangerous {
  198. .button-variant-ghost(@btn-danger-border, @btn-danger-border, @error-color-hover, @error-color-active);
  199. }
  200. &-background-ghost&-dangerous&-link {
  201. .button-variant-ghost(@btn-danger-border, transparent, @error-color-hover, @error-color-active);
  202. }
  203. &-two-chinese-chars::first-letter {
  204. letter-spacing: 0.34em;
  205. }
  206. &-two-chinese-chars > *:not(.@{iconfont-css-prefix}) {
  207. margin-right: -0.34em;
  208. letter-spacing: 0.34em;
  209. }
  210. &&-block {
  211. width: 100%;
  212. }
  213. // https://github.com/ant-design/ant-design/issues/12681
  214. // same method as Select
  215. &:empty {
  216. display: inline-block;
  217. width: 0;
  218. visibility: hidden;
  219. content: '\a0';
  220. }
  221. }
  222. a.@{btn-prefix-cls} {
  223. // Fixing https://github.com/ant-design/ant-design/issues/12978
  224. // https://github.com/ant-design/ant-design/issues/29978
  225. // It is a render problem of chrome, which is only happened in the codesandbox demo
  226. // 0.1px for padding-top solution works and I don't why
  227. padding-top: 0.01px !important;
  228. line-height: @btn-height-base - 2px;
  229. &-lg {
  230. line-height: @btn-height-lg - 2px;
  231. }
  232. &-sm {
  233. line-height: @btn-height-sm - 2px;
  234. }
  235. }
  236. @import './rtl';