button.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. @import './animation.scss';
  2. @import './variables.scss';
  3. @import './splitButtonGroup.scss';
  4. $module: #{$prefix}-button;
  5. .#{$module} {
  6. @include shadow-0;
  7. @include font-size-regular;
  8. height: $height-button_default;
  9. display: inline-flex;
  10. align-items: center;
  11. justify-content: center;
  12. cursor: pointer;
  13. user-select: none;
  14. border: $width-button-border $color-button_primary-border-default solid;
  15. border-radius: $radius-button;
  16. padding-left: $spacing-button_default-paddingLeft;
  17. padding-right: $spacing-button_default-paddingRight;
  18. padding-top: $spacing-button_default-paddingTop;
  19. padding-bottom: $spacing-button_default-paddingTop;
  20. font-weight: $font-button-fontWeight;
  21. outline: none;
  22. vertical-align: middle;
  23. white-space: nowrap;
  24. // the specificity of `.#{$module}:focus-visible` may lower than `reset.css` default `focus-visible` style
  25. // so we add a class at the same level
  26. &.#{$module}-primary,
  27. &.#{$module}-secondary,
  28. &.#{$module}-tertiary,
  29. &.#{$module}-warning,
  30. &.#{$module}-danger {
  31. &:focus-visible {
  32. outline: $width-button-outline solid $color-button_primary-outline-focus;
  33. }
  34. }
  35. &-danger {
  36. background-color: $color-button_danger-bg-default;
  37. color: $color-button_danger-text-default;
  38. transition: background-color $transition_duration-button_danger-bg $transition_function-button_danger-bg $transition_delay-button_danger-bg,
  39. border $transition_duration-button_danger-border $transition_function-button_danger-border $transition_delay-button_danger-border;
  40. transform: scale($transform-scale-button_danger);
  41. &:hover {
  42. background-color: $color-button_danger-bg-hover;
  43. }
  44. &:active {
  45. background-color: $color-button_danger-bg-active;
  46. }
  47. &.#{$module}-light,
  48. &.#{$module}-borderless {
  49. color: $color-button_danger_borderless-text-default;
  50. }
  51. &:not(.#{$module}-borderless):not(.#{$module}-light):focus-visible {
  52. outline: $width-button-outline solid $color-button_danger-outline-focus;
  53. }
  54. }
  55. &-warning {
  56. background-color: $color-button_warning-bg-default;
  57. color: $color-button_warning-text-default;
  58. transition: background-color $transition_duration-button_warning-bg $transition_function-button_warning-bg $transition_delay-button_warning-bg,
  59. border $transition_duration-button_warning-border $transition_function-button_warning-border $transition_delay-button_warning-border;
  60. transform:scale($transform_scale-button_warning);
  61. &:hover {
  62. background-color: $color-button_warning-bg-hover;
  63. }
  64. &:active {
  65. background-color: $color-button_warning-bg-active;
  66. }
  67. &.#{$module}-light,
  68. &.#{$module}-borderless {
  69. color: $color-button_warning_borderless-text-default;
  70. }
  71. &:not(.#{$module}-borderless):not(.#{$module}-light):focus-visible {
  72. outline: $width-button-outline solid $color-button_warning-outline-focus;
  73. }
  74. }
  75. &-tertiary {
  76. background-color: $color-button_tertiary-bg-default;
  77. color: $color-button_tertiary-text-default;
  78. transition: background-color $transition_duration-button_tertiary-bg $transition_function-button_tertiary-bg $transition_delay-button_tertiary-bg,
  79. border $transition_duration-button_tertiary-border $transition_function-button_tertiary-border $transition_delay-button_tertiary-border;
  80. transform:scale($transform_scale_button_tertiary);
  81. &:hover {
  82. background-color: $color-button_tertiary-bg-hover;
  83. }
  84. &:active {
  85. background-color: $color-button_tertiary-bg-active;
  86. }
  87. &.#{$module}-light,
  88. &.#{$module}-borderless {
  89. color: $color-button_tertiary_solid-text-default;
  90. }
  91. }
  92. &-primary {
  93. background-color: $color-button_primary-bg-default;
  94. color: $color-button_primary-text-default;
  95. transition: background-color $transition_duration-button_primary-bg $transition_function-button_primary-bg $transition_delay-button_primary-bg,
  96. border $transition_duration-button_primary-border $transition_function-button_primary-border $transition_delay-button_primary-border;;
  97. transform:scale($transform_scale-button_primary);
  98. &:not(.#{$module}-borderless):not(.#{$module}-light):hover {
  99. background-color: $color-button_primary-bg-hover;
  100. }
  101. &:not(.#{$module}-borderless):not(.#{$module}-light):active {
  102. background-color: $color-button_primary-bg-active;
  103. }
  104. &.#{$module}-light,
  105. &.#{$module}-borderless {
  106. color: $color-button_primary_borderless-text-default;
  107. }
  108. }
  109. &-secondary {
  110. background-color: $color-button_secondary-bg-default;
  111. outline-color: $color-button_secondary-border-default;
  112. color: $color-button_secondary-text-default;
  113. transition: background-color $transition_duration-button_secondary-bg $transition_function-button_secondary-bg $transition_delay-button_secondary-bg,
  114. border $transition_duration-button_secondary-border $transition_function-button_secondary-border $transition_delay-button_secondary-border;
  115. transform:scale($transform_scale-button_secondary);
  116. &:hover {
  117. background-color: $color-button_secondary-bg-hover;
  118. }
  119. &:active {
  120. background-color: $color-button_secondary-bg-active;
  121. }
  122. &.#{$module}-light,
  123. &.#{$module}-borderless {
  124. color: $color-button_secondary_borderless-text-default;
  125. }
  126. }
  127. &-disabled {
  128. color: $color-button_disabled_solid-text-default;
  129. background-color: $color-button_disabled-bg-default;
  130. &:not(.#{$module}-borderless):not(.#{$module}-light):hover {
  131. color: $color-button_disabled-text-hover;
  132. background-color: $color-button_disabled-bg-hover;
  133. }
  134. cursor: not-allowed;
  135. &.#{$module}-light,
  136. &.#{$module}-borderless {
  137. color: $color-button_disabled-text-default;
  138. }
  139. }
  140. &-borderless {
  141. background-color: transparent;
  142. border: $width-button_borderless-border $color-button_borderless-border-default solid;
  143. transition:background-color $transition_duration-button_borderless-bg $transition_function-button_borderless-bg $transition_delay-button_borderless-bg;
  144. transform:scale($transform_scale-button_borderless);
  145. &:not(.#{$module}-disabled):hover {
  146. background-color: $color-button_borderless-bg-hover;
  147. border: $width-button_borderless-border $color-button_borderless-border-hover solid;
  148. }
  149. &:not(.#{$module}-disabled):active {
  150. background-color: $color-button_borderless-bg-active;
  151. border: $width-button_borderless-border $color-button_borderless-border-active solid;
  152. }
  153. }
  154. &-light {
  155. background-color: $color-button_light-bg-default;
  156. border: $width-button_light-border $color-button_light-border-default solid;
  157. transition: background-color $transition_duration-button_light-bg $transition_function-button_light-bg $transition_delay-button_light-bg,
  158. border $transition_duration-button_light-border $transition_function-button_light-border $transition_delay-button_light-border;
  159. transform:scale($transform_scale-button_light);
  160. &:not(.#{$module}-disabled):hover {
  161. background-color: $color-button_light-bg-hover;
  162. border: $width-button_light-border $color-button_light-border-hover solid;
  163. }
  164. &:not(.#{$module}-disabled):active {
  165. background-color: $color-button_light-bg-active;
  166. border: $width-button_light-border $color-button_light-border-active solid;
  167. }
  168. }
  169. &-size-small {
  170. height: $height-button_small;
  171. padding-top: $spacing-button_small-paddingTop;
  172. padding-bottom: $spacing-button_small-paddingBottom;
  173. padding-left: $spacing-button_small-paddingLeft;
  174. padding-right: $spacing-button_small-paddingRight;
  175. }
  176. &-size-large {
  177. height: $height-button_large;
  178. padding-top: $spacing-button_large-paddingTop;
  179. padding-bottom: $spacing-button_large-paddingBottom;
  180. padding-left: $spacing-button_large-paddingLeft;
  181. padding-right: $spacing-button_large-paddingRight;
  182. }
  183. &-block {
  184. width: 100%;
  185. }
  186. &-group {
  187. display: flex;
  188. flex-wrap: wrap;
  189. & > .#{$module} {
  190. margin: 0;
  191. padding-left: 0;
  192. padding-right: 0;
  193. border-radius: 0;
  194. .#{$module}-content {
  195. padding-left: $spacing-button_default-paddingLeft;
  196. padding-right: $spacing-button_default-paddingRight;
  197. }
  198. &-size-large {
  199. .#{$module}-content {
  200. padding-left: $spacing-button_large-paddingLeft;
  201. padding-right: $spacing-button_large-paddingRight;
  202. }
  203. }
  204. &-size-small {
  205. .#{$module}-content {
  206. padding-left: $spacing-button_small-paddingLeft;
  207. padding-right: $spacing-button_small-paddingRight;
  208. }
  209. }
  210. &.#{$module}-with-icon-only {
  211. padding-left: 0;
  212. padding-right: 0;
  213. .#{$module}-content {
  214. padding-left: $spacing-button_iconOnly_default-paddingLeft;
  215. padding-right: $spacing-button_iconOnly_default-paddingRight;
  216. }
  217. &.#{$module}-size {
  218. &-small {
  219. .#{$module}-content {
  220. padding-left: $spacing-button_iconOnly_small-paddingLeft;
  221. padding-right: $spacing-button_iconOnly_small-paddingRight;
  222. }
  223. }
  224. &-large {
  225. .#{$module}-content {
  226. padding-left: $spacing-button_iconOnly_large-paddingLeft;
  227. padding-right: $spacing-button_iconOnly_large-paddingRight;
  228. }
  229. }
  230. }
  231. }
  232. &:first-child {
  233. border-top-left-radius: $radius-button_group;
  234. border-bottom-left-radius: $radius-button_group;
  235. }
  236. &:last-child {
  237. border-top-right-radius: $radius-button_group;
  238. border-bottom-right-radius: $radius-button_group;
  239. }
  240. }
  241. &-line {
  242. display: inline-flex;
  243. align-items: center;
  244. background-color: $color-button_group-border-default;
  245. &-primary {
  246. background-color: $color-button_primary-bg-default;
  247. }
  248. &-secondary {
  249. background-color: $color-button_secondary-bg-default;
  250. }
  251. &-tertiary {
  252. background-color: $color-button_tertiary-bg-default;
  253. }
  254. &-warning {
  255. background-color: $color-button_warning-bg-default;
  256. }
  257. &-danger {
  258. background-color: $color-button_danger-bg-default;
  259. }
  260. &-disabled {
  261. background-color: $color-button_disabled-bg-default;
  262. }
  263. &-light {
  264. background-color: $color-button_light-bg-default;
  265. }
  266. &-borderless {
  267. background-color: transparent;
  268. }
  269. &::before {
  270. display: block;
  271. content: '';
  272. width: $width-button_group-border;
  273. height: $height-button_group_line_default;
  274. background-color: $color-button_group-border-default;
  275. }
  276. }
  277. }
  278. }
  279. @import './rtl.scss';