button.scss 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /**Variable**/
  2. @import './helpers/mixin.scss';
  3. $btnThemeList: (
  4. (
  5. name: "primary",
  6. textColor: $vxe-primary-color,
  7. btnColor: #fff,
  8. btnBackground: $vxe-primary-color
  9. ),
  10. (
  11. name: "success",
  12. textColor: $vxe-success-color,
  13. btnColor: #fff,
  14. btnBackground: $vxe-success-color
  15. ),
  16. (
  17. name: "info",
  18. textColor: $vxe-info-color,
  19. btnColor: #fff,
  20. btnBackground: $vxe-info-color
  21. ),
  22. (
  23. name: "warning",
  24. textColor: $vxe-warning-color,
  25. btnColor: #fff,
  26. btnBackground: $vxe-warning-color
  27. ),
  28. (
  29. name: "danger",
  30. textColor: $vxe-danger-color,
  31. btnColor: #fff,
  32. btnBackground: $vxe-danger-color
  33. ),
  34. (
  35. name: "perfect",
  36. textColor: $vxe-table-header-background-color,
  37. btnColor: $vxe-font-color,
  38. btnBackground: $vxe-table-header-background-color
  39. )
  40. );
  41. .vxe-button {
  42. position: relative;
  43. text-align: center;
  44. background-color: $vxe-button-default-background-color;
  45. outline: 0;
  46. font-size: $vxe-font-size;
  47. max-width: $vxe-button-max-width;
  48. line-height: 1.5;
  49. overflow: hidden;
  50. text-overflow: ellipsis;
  51. white-space: nowrap;
  52. white-space: nowrap;
  53. user-select: none;
  54. appearance: none;
  55. @include animatTransition(border, .2s);
  56. &:not(.is--disabled) {
  57. color: $vxe-font-color;
  58. cursor: pointer;
  59. }
  60. &.is--loading {
  61. cursor: progress;
  62. &:before {
  63. content: "";
  64. position: absolute;
  65. left: -1px;
  66. top: -1px;
  67. right: -1px;
  68. bottom: -1px;
  69. border-radius: inherit;
  70. background-color: hsla(0,0%,100%,.35);
  71. pointer-events: none;
  72. }
  73. }
  74. &.is--disabled {
  75. color: $vxe-disabled-color;
  76. &:not(.is--loading) {
  77. cursor: no-drop;
  78. }
  79. }
  80. &.type--text {
  81. text-decoration: none;
  82. border: 0;
  83. padding: 0.1em 0.5em;
  84. background-color: transparent;
  85. &:not(.is--disabled) {
  86. &:focus {
  87. color: darken($vxe-font-color, 20%);
  88. }
  89. &:hover {
  90. color: lighten($vxe-primary-color, 10%);
  91. }
  92. }
  93. @for $index from 0 to length($btnThemeList) {
  94. $item: nth($btnThemeList, $index + 1);
  95. $textColor: map-get($item, textColor);
  96. &.theme--#{map-get($item, name)} {
  97. color: $textColor;
  98. &:not(.is--disabled) {
  99. &:focus {
  100. color: darken($textColor, 10%);
  101. }
  102. &:hover {
  103. color: lighten($textColor, 10%);
  104. }
  105. }
  106. &.is--disabled {
  107. color: lighten($textColor, 20%);
  108. }
  109. }
  110. }
  111. }
  112. &.type--button {
  113. font-family: inherit;
  114. height: $vxe-button-height-default;
  115. line-height: 1;
  116. border: 1px solid $vxe-input-border-color;
  117. &.is--round {
  118. border-radius: $vxe-button-round-border-radius-default;
  119. }
  120. &:not(.is--round) {
  121. border-radius: $vxe-border-radius;
  122. }
  123. &.is--circle {
  124. padding: 0 0.5em;
  125. min-width: $vxe-button-height-default;
  126. border-radius: 50%;
  127. }
  128. &:not(.is--circle) {
  129. padding: 0 1em;
  130. }
  131. &:not(.is--disabled) {
  132. &:hover {
  133. color: lighten($vxe-primary-color, 6%);
  134. }
  135. &:focus {
  136. border-color: $vxe-primary-color;
  137. }
  138. &:active {
  139. color: darken($vxe-primary-color, 3%);
  140. border-color: darken($vxe-primary-color, 3%);
  141. background-color: darken($vxe-button-default-background-color, 3%);
  142. }
  143. }
  144. @for $index from 0 to length($btnThemeList) {
  145. $item: nth($btnThemeList, $index + 1);
  146. $btnColor: map-get($item, btnColor);
  147. $btnBackground: map-get($item, btnBackground);
  148. &.theme--#{map-get($item, name)} {
  149. color: $btnColor;
  150. &:not(.is--disabled) {
  151. border-color: $btnBackground;
  152. background-color: $btnBackground;
  153. &:hover {
  154. color: $btnColor;
  155. background-color: lighten($btnBackground, 6%);
  156. border-color: lighten($btnBackground, 6%);
  157. }
  158. &:active {
  159. color: $btnColor;
  160. background-color: darken($btnBackground, 3%);
  161. border-color: darken($btnBackground, 3%);
  162. }
  163. }
  164. &.is--disabled {
  165. border-color: lighten($btnBackground, 20%);
  166. background-color: lighten($btnBackground, 20%);
  167. }
  168. &.is--loading {
  169. border-color: $btnBackground;
  170. background-color: $btnBackground;
  171. }
  172. }
  173. }
  174. }
  175. &.size--medium {
  176. font-size: $vxe-font-size-medium;
  177. &.type--button {
  178. height: $vxe-button-height-medium;
  179. &.is--circle {
  180. min-width: $vxe-button-height-medium;
  181. }
  182. &.is--round {
  183. border-radius: $vxe-button-round-border-radius-medium;
  184. }
  185. }
  186. .vxe-button--loading-icon,
  187. .vxe-button--icon {
  188. min-width: $vxe-font-size-medium;
  189. }
  190. }
  191. &.size--small {
  192. font-size: $vxe-font-size-small;
  193. &.type--button {
  194. height: $vxe-button-height-small;
  195. &.is--circle {
  196. min-width: $vxe-button-height-small;
  197. }
  198. &.is--round {
  199. border-radius: $vxe-button-round-border-radius-small;
  200. }
  201. }
  202. .vxe-button--loading-icon,
  203. .vxe-button--icon {
  204. min-width: $vxe-font-size-small;
  205. }
  206. }
  207. &.size--mini {
  208. font-size: $vxe-font-size-mini;
  209. &.type--button {
  210. height: $vxe-button-height-mini;
  211. &.is--circle {
  212. min-width: $vxe-button-height-mini;
  213. }
  214. &.is--round {
  215. border-radius: $vxe-button-round-border-radius-mini;
  216. }
  217. }
  218. .vxe-button--loading-icon,
  219. .vxe-button--icon {
  220. min-width: $vxe-font-size-mini;
  221. }
  222. }
  223. }
  224. .vxe-input,
  225. .vxe-button {
  226. &+.vxe-button,
  227. &+.vxe-button--dropdown {
  228. margin-left: 12px;
  229. }
  230. }
  231. .vxe-button--loading-icon,
  232. .vxe-button--icon {
  233. min-width: $vxe-font-size;
  234. &+.vxe-button--content {
  235. margin-left: 4px;
  236. }
  237. }
  238. .vxe-button--wrapper,
  239. .vxe-button--dropdown {
  240. display: inline-block;
  241. }
  242. .vxe-button--dropdown {
  243. position: relative;
  244. &+.vxe-button,
  245. &+.vxe-button--dropdown {
  246. margin-left: 12px;
  247. }
  248. & > .vxe-button {
  249. &.type--button {
  250. @for $index from 0 to length($btnThemeList) {
  251. $item: nth($btnThemeList, $index + 1);
  252. $btnColor: map-get($item, btnColor);
  253. &.theme--#{map-get($item, name)} {
  254. color: $btnColor;
  255. }
  256. }
  257. }
  258. }
  259. &.is--active {
  260. & > .vxe-button {
  261. &:not(.is--disabled) {
  262. color: lighten($vxe-primary-color, 6%);
  263. }
  264. &.type--text {
  265. @for $index from 0 to length($btnThemeList) {
  266. $item: nth($btnThemeList, $index + 1);
  267. $textColor: map-get($item, textColor);
  268. &.theme--#{map-get($item, name)} {
  269. color: lighten($textColor, 10%);
  270. }
  271. }
  272. }
  273. &.type--button {
  274. @for $index from 0 to length($btnThemeList) {
  275. $item: nth($btnThemeList, $index + 1);
  276. $btnColor: map-get($item, btnColor);
  277. $btnBackground: map-get($item, btnBackground);
  278. &.theme--#{map-get($item, name)} {
  279. color: $btnColor;
  280. background-color: lighten($btnBackground, 6%);
  281. border-color: lighten($btnBackground, 6%);
  282. }
  283. }
  284. }
  285. }
  286. .vxe-button--dropdown-arrow {
  287. transform: rotate(180deg);
  288. }
  289. }
  290. }
  291. .vxe-button--dropdown-arrow {
  292. display: inline-block;
  293. font-size: 12px;
  294. margin-left: 4px;
  295. @include animatTransition(transform, .2s);
  296. }
  297. .vxe-button--dropdown-panel {
  298. display: none;
  299. position: absolute;
  300. right: 0;
  301. padding: 4px 0;
  302. &.animat--leave {
  303. display: block;
  304. opacity: 0;
  305. transform: scaleY(0.5);
  306. transition: transform .3s cubic-bezier(.23,1,.32,1), opacity .3s cubic-bezier(.23,1,.32,1);
  307. transform-origin: center top;
  308. backface-visibility: hidden;
  309. transform-style: preserve-3d;
  310. &[placement="top"] {
  311. transform-origin: center bottom;
  312. }
  313. }
  314. &.animat--enter {
  315. opacity: 1;
  316. transform: scaleY(1);
  317. }
  318. }
  319. .vxe-button--dropdown-wrapper {
  320. padding: 5px;
  321. background-color: $vxe-button-dropdown-panel-background-color;
  322. border-radius: $vxe-border-radius;
  323. border: 1px solid $vxe-input-border-color;
  324. box-shadow: 0 1px 6px rgba(0,0,0,.2);
  325. & > .vxe-button {
  326. margin-left: 0;
  327. margin-top: 0.4em;
  328. display: block;
  329. width: 100%;
  330. border: 0;
  331. &.type--text {
  332. padding: 2px 8px;
  333. }
  334. &:first-child {
  335. margin-top: 0;
  336. }
  337. &:last-child {
  338. margin-bottom: 0;
  339. }
  340. }
  341. }