button.scss 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. @import './animation.scss';
  2. @import './variables.scss';
  3. @import './splitButtonGroup.scss';
  4. @import './cssVariables.scss';
  5. $module: #{$prefix}-button;
  6. .#{$module} {
  7. @include shadow-0;
  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-size: $font-button-fontSize;
  21. line-height: $font-button-lineHeight;
  22. font-weight: $font-button-fontWeight;
  23. outline: none;
  24. vertical-align: middle;
  25. white-space: nowrap;
  26. // the specificity of `.#{$module}:focus-visible` may lower than `reset.css` default `focus-visible` style
  27. // so we add a class at the same level
  28. &.#{$module}-primary,
  29. &.#{$module}-secondary,
  30. &.#{$module}-tertiary,
  31. &.#{$module}-warning,
  32. &.#{$module}-danger {
  33. &:focus-visible {
  34. outline: $width-button-outline solid $color-button_primary_outline-focus;
  35. }
  36. }
  37. &-content{
  38. display: flex;
  39. align-items: center;
  40. }
  41. &-danger {
  42. background-color: $color-button_danger-bg-default;
  43. color: $color-button_danger-text-default;
  44. transition: background-color $transition_duration-button_danger-bg $transition_function-button_danger-bg $transition_delay-button_danger-bg,
  45. border $transition_duration-button_danger-border $transition_function-button_danger-border $transition_delay-button_danger-border;
  46. transform: scale($transform-scale-button_danger);
  47. &-disabled {
  48. background-color: $color-button_disabled_danger-bg-default;
  49. &.#{$module}-outline {
  50. background-color: transparent;
  51. border: $width-button_outline-border solid $color-button_disabled_outline-border-default;
  52. }
  53. &.#{$module}-light {
  54. background-color: $color-button_disabled_light_danger-bg-default;
  55. }
  56. }
  57. &:hover {
  58. background-color: $color-button_danger-bg-hover;
  59. }
  60. &:active {
  61. background-color: $color-button_danger-bg-active;
  62. }
  63. &.#{$module}-outline{
  64. background-color: transparent;
  65. border: $width-button_outline-border solid $color-button_danger_outline-border-default;
  66. }
  67. &.#{$module}-light,
  68. &.#{$module}-outline,
  69. &.#{$module}-borderless {
  70. color: $color-button_danger_borderless-text-default;
  71. }
  72. &:not(.#{$module}-borderless):not(.#{$module}-light):focus-visible {
  73. outline: $width-button-outline solid $color-button_danger-outline-focus;
  74. }
  75. }
  76. &-warning {
  77. background-color: $color-button_warning-bg-default;
  78. color: $color-button_warning-text-default;
  79. transition: background-color $transition_duration-button_warning-bg $transition_function-button_warning-bg $transition_delay-button_warning-bg,
  80. border $transition_duration-button_warning-border $transition_function-button_warning-border $transition_delay-button_warning-border;
  81. transform: scale($transform_scale-button_warning);
  82. &-disabled {
  83. background-color: $color-button_disabled_warning-bg-default;
  84. &.#{$module}-outline {
  85. background-color: transparent;
  86. border: $width-button_outline-border solid $color-button_disabled_outline-border-default;
  87. }
  88. &.#{$module}-light {
  89. background-color: $color-button_disabled_light_warning-bg-default;
  90. }
  91. }
  92. &:hover {
  93. background-color: $color-button_warning-bg-hover;
  94. }
  95. &:active {
  96. background-color: $color-button_warning-bg-active;
  97. }
  98. &.#{$module}-outline{
  99. background-color: transparent;
  100. border: $width-button_outline-border solid $color-button_warning_outline-border-default;
  101. }
  102. &.#{$module}-light,
  103. &.#{$module}-outline,
  104. &.#{$module}-borderless {
  105. color: $color-button_warning_borderless-text-default;
  106. }
  107. &:not(.#{$module}-borderless):not(.#{$module}-light):focus-visible {
  108. outline: $width-button-outline solid $color-button_warning-outline-focus;
  109. }
  110. }
  111. &-tertiary {
  112. background-color: $color-button_tertiary-bg-default;
  113. color: $color-button_tertiary-text-default;
  114. transition: background-color $transition_duration-button_tertiary-bg $transition_function-button_tertiary-bg $transition_delay-button_tertiary-bg,
  115. border $transition_duration-button_tertiary-border $transition_function-button_tertiary-border $transition_delay-button_tertiary-border;
  116. transform: scale($transform_scale_button_tertiary);
  117. &.#{$module}-colorful {
  118. &.#{$module}-solid {
  119. background: $color-button_tertiary_solid_colorful-bg-default;
  120. &:hover {
  121. background: $color-button_tertiary_solid_colorful-bg-hover;
  122. }
  123. &:active {
  124. background: $color-button_tertiary_solid_colorful-bg-active;
  125. }
  126. .#{$module}-content-right, .#{$module}-content:not(:has(>.#{$module}-content-right)) {
  127. background: $color-button_tertiary_solid_colorful-text-default;
  128. background-clip: text;
  129. color: transparent;
  130. }
  131. }
  132. }
  133. &-disabled {
  134. background-color: $color-button_disabled_tertiary-bg-default;
  135. &.#{$module}-outline {
  136. background-color: transparent;
  137. border: $width-button_outline-border solid $color-button_disabled_outline-border-default;
  138. }
  139. &.#{$module}-light {
  140. background-color: $color-button_disabled_light_tertiary-bg-default;
  141. }
  142. }
  143. &:hover {
  144. background-color: $color-button_tertiary-bg-hover;
  145. }
  146. &:active {
  147. background-color: $color-button_tertiary-bg-active;
  148. }
  149. &.#{$module}-outline{
  150. background-color: transparent;
  151. border: $width-button_outline-border solid $color-button_tertiary_outline-border-default;
  152. }
  153. &.#{$module}-light,
  154. &.#{$module}-outline,
  155. &.#{$module}-borderless {
  156. color: $color-button_tertiary_solid-text-default;
  157. }
  158. }
  159. &-primary {
  160. background-color: $color-button_primary-bg-default;
  161. color: $color-button_primary-text-default;
  162. transition: background-color $transition_duration-button_primary-bg $transition_function-button_primary-bg $transition_delay-button_primary-bg,
  163. border $transition_duration-button_primary-border $transition_function-button_primary-border $transition_delay-button_primary-border;;
  164. transform: scale($transform_scale-button_primary);
  165. &.#{$module}-colorful {
  166. &.#{$module}-solid {
  167. background: $color-button_primary_solid_colorful-bg-default;
  168. &:not(.#{$module}-borderless):not(.#{$module}-light):not(.#{$module}-outline):hover {
  169. background: $color-button_primary_solid_colorful-bg-hover;
  170. }
  171. &:not(.#{$module}-borderless):not(.#{$module}-light):not(.#{$module}-outline):active {
  172. background: $color-button_primary_solid_colorful-bg-active;
  173. }
  174. }
  175. &.#{$module}-light {
  176. .#{$module}-content-right, .#{$module}-content:not(:has(>.#{$module}-content-right)) {
  177. background: $color-button_primary_light_colorful-text-default;
  178. background-clip: text;
  179. color: transparent;
  180. }
  181. }
  182. &.#{$module}-outline {
  183. color: $color-button_primary_light_outline-text-default;
  184. border-color: $color-button_primary_light_outline-border;
  185. }
  186. &.#{$module}-borderless {
  187. .#{$module}-content-right, .#{$module}-content:not(:has(>.#{$module}-content-right)) {
  188. background: $color-button_primary_light_borderless-text-default;
  189. background-clip: text;
  190. color: transparent;
  191. }
  192. }
  193. }
  194. &-disabled {
  195. background-color: $color-button_disabled_primary-bg-default;
  196. &.#{$module}-light {
  197. background: $color-button_disabled_light_primary-bg-default;
  198. }
  199. &.#{$module}-outline {
  200. background-color: transparent;
  201. border: $width-button_outline-border solid $color-button_disabled_outline-border-default;
  202. }
  203. }
  204. &:not(.#{$module}-borderless):not(.#{$module}-light):not(.#{$module}-outline):hover {
  205. background-color: $color-button_primary-bg-hover;
  206. }
  207. &.#{$module}-outline{
  208. background-color: transparent;
  209. border: $width-button_outline-border solid $color-button_primary_outline-border-default;
  210. }
  211. &:not(.#{$module}-borderless):not(.#{$module}-light):not(.#{$module}-outline):active {
  212. background-color: $color-button_primary-bg-active;
  213. }
  214. &.#{$module}-light,
  215. &.#{$module}-outline,
  216. &.#{$module}-borderless {
  217. color: $color-button_primary_borderless-text-default;
  218. }
  219. }
  220. &-secondary {
  221. background-color: $color-button_secondary-bg-default;
  222. outline-color: $color-button_secondary-border-default;
  223. color: $color-button_secondary-text-default;
  224. transition: background-color $transition_duration-button_secondary-bg $transition_function-button_secondary-bg $transition_delay-button_secondary-bg,
  225. border $transition_duration-button_secondary-border $transition_function-button_secondary-border $transition_delay-button_secondary-border;
  226. transform: scale($transform_scale-button_secondary);
  227. &-disabled {
  228. background-color: $color-button_disabled_secondary-bg-default;
  229. &.#{$module}-outline {
  230. background-color: transparent;
  231. border: $width-button_outline-border solid $color-button_disabled_outline-border-default;
  232. }
  233. &.#{$module}-light {
  234. background-color: $color-button_disabled_light_secondary-bg-default;
  235. }
  236. }
  237. &.#{$module}-outline{
  238. background-color: transparent;
  239. border: $width-button_outline-border solid $color-button_secondary_outline-border-default;
  240. }
  241. &:hover {
  242. background-color: $color-button_secondary-bg-hover;
  243. }
  244. &:active {
  245. background-color: $color-button_secondary-bg-active;
  246. }
  247. &.#{$module}-light,
  248. &.#{$module}-outline,
  249. &.#{$module}-borderless {
  250. color: $color-button_secondary_borderless-text-default;
  251. }
  252. }
  253. &-disabled {
  254. color: $color-button_disabled_solid-text-default;
  255. cursor: not-allowed;
  256. &:not(.#{$module}-borderless):not(.#{$module}-light):not(.#{$module}-outline):hover {
  257. color: $color-button_disabled-text-hover;
  258. }
  259. &.#{$module}-light,
  260. &.#{$module}-borderless {
  261. color: $color-button_disabled-text-default;
  262. }
  263. &.#{$module}-outline {
  264. color: $color-button_disabled_outline_text-default;
  265. }
  266. }
  267. &-borderless {
  268. background-color: transparent;
  269. border: $width-button_borderless-border $color-button_borderless-border-default solid;
  270. transition: background-color $transition_duration-button_borderless-bg $transition_function-button_borderless-bg $transition_delay-button_borderless-bg;
  271. transform: scale($transform_scale-button_borderless);
  272. &:not(.#{$module}-disabled):hover {
  273. background-color: $color-button_borderless-bg-hover;
  274. border: $width-button_borderless-border $color-button_borderless-border-hover solid;
  275. }
  276. &:not(.#{$module}-disabled):active {
  277. background-color: $color-button_borderless-bg-active;
  278. border: $width-button_borderless-border $color-button_borderless-border-active solid;
  279. }
  280. }
  281. &-outline {
  282. background-color: transparent;
  283. &:not(.#{$module}-disabled):hover {
  284. background-color: $color-button_outline-bg-hover;
  285. }
  286. &:not(.#{$module}-disabled):active {
  287. background-color: $color-button_outline-bg-active;
  288. }
  289. }
  290. &-light {
  291. background-color: $color-button_light-bg-default;
  292. border: $width-button_light-border $color-button_light-border-default solid;
  293. transition: background-color $transition_duration-button_light-bg $transition_function-button_light-bg $transition_delay-button_light-bg,
  294. border $transition_duration-button_light-border $transition_function-button_light-border $transition_delay-button_light-border;
  295. transform: scale($transform_scale-button_light);
  296. &:not(.#{$module}-disabled):hover {
  297. background-color: $color-button_light-bg-hover;
  298. border: $width-button_light-border $color-button_light-border-hover solid;
  299. }
  300. &:not(.#{$module}-disabled):active {
  301. background-color: $color-button_light-bg-active;
  302. border: $width-button_light-border $color-button_light-border-active solid;
  303. }
  304. }
  305. &-size-small {
  306. height: $height-button_small;
  307. padding-top: $spacing-button_small-paddingTop;
  308. padding-bottom: $spacing-button_small-paddingBottom;
  309. padding-left: $spacing-button_small-paddingLeft;
  310. padding-right: $spacing-button_small-paddingRight;
  311. font-size: $font-button_small-fontSize;
  312. line-height: $font-button_small-lineHeight;
  313. font-weight: $font-button_small-fontWeight;
  314. }
  315. &-size-large {
  316. height: $height-button_large;
  317. padding-top: $spacing-button_large-paddingTop;
  318. padding-bottom: $spacing-button_large-paddingBottom;
  319. padding-left: $spacing-button_large-paddingLeft;
  320. padding-right: $spacing-button_large-paddingRight;
  321. font-size: $font-button_large-fontSize;
  322. line-height: $font-button_large-lineHeight;
  323. font-weight: $font-button_large-fontWeight;
  324. }
  325. &-block {
  326. width: 100%;
  327. }
  328. &-group {
  329. display: flex;
  330. flex-wrap: wrap;
  331. & > .#{$module} {
  332. margin: 0;
  333. padding-left: 0;
  334. padding-right: 0;
  335. border-radius: 0;
  336. .#{$module}-content {
  337. padding-left: $spacing-button_default-paddingLeft;
  338. padding-right: $spacing-button_default-paddingRight;
  339. }
  340. &-size-large {
  341. .#{$module}-content {
  342. padding-left: $spacing-button_large-paddingLeft;
  343. padding-right: $spacing-button_large-paddingRight;
  344. }
  345. }
  346. &-size-small {
  347. .#{$module}-content {
  348. padding-left: $spacing-button_small-paddingLeft;
  349. padding-right: $spacing-button_small-paddingRight;
  350. }
  351. }
  352. &.#{$module}-with-icon-only {
  353. padding-left: 0;
  354. padding-right: 0;
  355. .#{$module}-content {
  356. padding-left: $spacing-button_iconOnly_default-paddingLeft;
  357. padding-right: $spacing-button_iconOnly_default-paddingRight;
  358. }
  359. &.#{$module}-size {
  360. &-small {
  361. .#{$module}-content {
  362. padding-left: $spacing-button_iconOnly_small-paddingLeft;
  363. padding-right: $spacing-button_iconOnly_small-paddingRight;
  364. }
  365. }
  366. &-large {
  367. .#{$module}-content {
  368. padding-left: $spacing-button_iconOnly_large-paddingLeft;
  369. padding-right: $spacing-button_iconOnly_large-paddingRight;
  370. }
  371. }
  372. }
  373. }
  374. &:first-child {
  375. border-top-left-radius: $radius-button_group;
  376. border-bottom-left-radius: $radius-button_group;
  377. }
  378. &:last-child {
  379. border-top-right-radius: $radius-button_group;
  380. border-bottom-right-radius: $radius-button_group;
  381. }
  382. &-outline:not(:last-child) {
  383. border-right-color: transparent;
  384. margin-right: -1 * $width-button_outline-border;
  385. }
  386. }
  387. &-line {
  388. display: inline-flex;
  389. align-items: center;
  390. background-color: $color-button_group-border-default;
  391. &-primary {
  392. background-color: $color-button_primary-bg-default;
  393. }
  394. &-secondary {
  395. background-color: $color-button_secondary-bg-default;
  396. }
  397. &-tertiary {
  398. background-color: $color-button_tertiary-bg-default;
  399. }
  400. &-warning {
  401. background-color: $color-button_warning-bg-default;
  402. }
  403. &-danger {
  404. background-color: $color-button_danger-bg-default;
  405. }
  406. &-disabled {
  407. background-color: $color-button_disabled-bg-default;
  408. }
  409. &-light {
  410. background-color: $color-button_light-bg-default;
  411. }
  412. &-borderless {
  413. background-color: transparent;
  414. }
  415. &::before {
  416. display: block;
  417. content: '';
  418. width: $width-button_group-border;
  419. height: $height-button_group_line_default;
  420. background-color: $color-button_group-border-default;
  421. }
  422. }
  423. }
  424. }
  425. @import './rtl.scss';