button.scss 9.3 KB

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