button.scss 9.3 KB

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