theme.scss 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. @import '@/uni.scss';
  2. $theme-map: ();
  3. $primary-key: 'primary';
  4. $success-key: 'success';
  5. $warn-key: 'warn';
  6. $warning-key: 'warning';
  7. $error-key: 'error';
  8. @mixin themeify {
  9. @each $theme-name, $theme-map in $themes {
  10. $theme-map: $theme-map !global;
  11. [data-theme='#{inspect($theme-name)}'] {
  12. @content;
  13. }
  14. }
  15. }
  16. @function getTheme($key) {
  17. @return map-get($theme-map, $key);
  18. }
  19. @mixin uni-button($button-type) {
  20. $button-type-color: getTheme(#{$button-type + '-color'});
  21. uni-button,
  22. button {
  23. &[type='#{$button-type}'] {
  24. background-color: $button-type-color;
  25. &[disabled] {
  26. background-color: opacify($button-type-color, 0.6);
  27. }
  28. &[plain] {
  29. color: $button-type-color;
  30. border-color: $button-type-color;
  31. background-color: transparent;
  32. }
  33. &[loading] {
  34. background-color: $button-type-color;
  35. &[plain] {
  36. color: $button-type-color;
  37. }
  38. }
  39. &.button-hover {
  40. $hover-color: darken(
  41. $color: $button-type-color,
  42. $amount: 10%
  43. );
  44. background-color: $hover-color;
  45. &[plain] {
  46. color: $hover-color;
  47. border-color: $hover-color;
  48. background-color: transparent;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. @mixin uni-switch {
  55. $primary-color: getTheme(#{$primary-key + '-color'});
  56. .uni-switch-input.uni-switch-input-checked {
  57. background-color: $primary-color !important;
  58. border-color: $primary-color !important;
  59. }
  60. }
  61. @mixin uni-ui-checkbox {
  62. $primary-color: getTheme(#{$primary-key + '-color'});
  63. .checklist-box {
  64. &.is-checked {
  65. .checkbox__inner {
  66. border-color: $primary-color !important;
  67. background-color: $primary-color !important;
  68. }
  69. .radio__inner {
  70. border-color: $primary-color !important;
  71. .radio__inner-icon {
  72. background-color: $primary-color !important;
  73. }
  74. }
  75. .checklist-text {
  76. color: $primary-color !important;
  77. }
  78. }
  79. .checkbox__inner:hover {
  80. border-color: $primary-color !important;
  81. }
  82. }
  83. }
  84. @mixin uni-ui-easyinput {
  85. $primary-color: getTheme(#{$primary-key + '-color'});
  86. $error-color: getTheme(#{$error-key + '-color'});
  87. .uni-easyinput {
  88. &.uni-easyinput-error {
  89. color: $error-color !important;
  90. }
  91. .uni-easyinput__content {
  92. &.is-focused {
  93. &.is-input-border {
  94. border-color: $primary-color !important;
  95. }
  96. .uni-icons {
  97. color: $primary-color !important;
  98. }
  99. }
  100. }
  101. }
  102. }
  103. @mixin uni-menu {
  104. $primary-color: getTheme(#{$primary-key + '-color'});
  105. // 左侧菜单
  106. .uni-nav-menu {
  107. .uni-menu-item.is-active {
  108. color: $primary-color;
  109. }
  110. }
  111. // 修改密码
  112. .navbar-menu {
  113. .menu-item.hover-highlight:hover {
  114. color: $primary-color;
  115. }
  116. }
  117. }
  118. @mixin uni-table {
  119. $primary-color: getTheme(#{$primary-key + '-color'});
  120. .uni-table {
  121. .link-btn-color {
  122. color: $primary-color;
  123. }
  124. .uni-table-checkbox {
  125. .checkbox__inner {
  126. &.checkbox--indeterminate,
  127. &.is-checked {
  128. border-color: $primary-color;
  129. background-color: $primary-color;
  130. }
  131. }
  132. .checkbox__inner:hover {
  133. border-color: $primary-color;
  134. }
  135. }
  136. .uni-table-th-content {
  137. .arrow-box {
  138. .arrow.active ::after {
  139. background-color: $primary-color;
  140. }
  141. }
  142. }
  143. // 表格头部搜索按钮
  144. .opera-area {
  145. .btn.btn-submit {
  146. background-color: $primary-color;
  147. }
  148. }
  149. .dropdown-btn {
  150. .icon-search.active {
  151. .icon-search-0 {
  152. border-color: $primary-color;
  153. }
  154. .icon-search-1 {
  155. background-color: $primary-color;
  156. }
  157. }
  158. .icon-calendar.active {
  159. .icon-calendar-0 {
  160. border-color: $primary-color;
  161. }
  162. .icon-calendar-1 {
  163. background-color: $primary-color;
  164. }
  165. }
  166. }
  167. .uni-icons.uni-stat-edit--btn {
  168. color: $primary-color !important;
  169. }
  170. }
  171. .uni-pagination {
  172. .uni-pagination__num-current .page--active {
  173. background-color: $primary-color !important;
  174. }
  175. }
  176. }
  177. @mixin uni-picker {
  178. $primary-color: getTheme(#{$primary-key + '-color'});
  179. .uni-picker-select {
  180. .uni-picker-item.selected {
  181. color: $primary-color;
  182. }
  183. }
  184. }
  185. @mixin uni-calendar {
  186. $primary-color: getTheme(#{$primary-key + '-color'});
  187. .uni-calendar__button-text {
  188. color: $primary-color;
  189. }
  190. .uni-datetime-picker--btn {
  191. background-color: $primary-color;
  192. }
  193. .uni-calendar-item--multiple {
  194. .uni-calendar-item--before-checked,
  195. .uni-calendar-item--after-checked {
  196. background-color: $primary-color;
  197. }
  198. }
  199. .uni-calendar-item__weeks-box {
  200. .uni-calendar-item--checked {
  201. background-color: $primary-color;
  202. }
  203. &-text {
  204. color: darken($color: $primary-color, $amount: 40%);
  205. }
  206. }
  207. }
  208. @mixin uni-popup {
  209. $primary-color: getTheme(#{$primary-key + '-color'});
  210. .uni-popup-dialog {
  211. .uni-button-color {
  212. color: $primary-color;
  213. }
  214. }
  215. }
  216. @mixin uni-tag($tag-type) {
  217. $tag-type-color: getTheme(#{$tag-type + '-color'});
  218. .uni-tag {
  219. &--#{$tag-type} {
  220. &--inverted {
  221. background-color: #fff !important;
  222. color: $tag-type-color !important;
  223. }
  224. background-color: $tag-type-color !important;
  225. border-color: $tag-type-color !important;
  226. }
  227. }
  228. }
  229. body {
  230. @at-root {
  231. @include themeify {
  232. $primary-color: getTheme(#{$primary-key + '-color'});
  233. // 组件
  234. @include uni-button($primary-key);
  235. @include uni-button($warn-key);
  236. @include uni-tag($primary-key);
  237. @include uni-tag($success-key);
  238. @include uni-tag($warning-key);
  239. @include uni-tag($error-key);
  240. @include uni-ui-checkbox;
  241. @include uni-switch;
  242. @include uni-ui-easyinput;
  243. @include uni-menu;
  244. @include uni-table;
  245. @include uni-picker;
  246. @include uni-calendar;
  247. @include uni-popup;
  248. // 页面
  249. .link-btn {
  250. color: $primary-color !important;
  251. }
  252. .uni-stat--tab-item {
  253. &.uni-stat--tab-item-line-active,
  254. &.uni-stat--tab-item-boldLine-active {
  255. color: $primary-color;
  256. border-color: $primary-color;
  257. }
  258. &.uni-stat--tab-item-box-active {
  259. border-color: $primary-color;
  260. }
  261. }
  262. .uni-title.app-list {
  263. color: $primary-color;
  264. border-color: $primary-color;
  265. }
  266. .uni-link {
  267. color: $primary-color;
  268. }
  269. .uni-selector-select .uni-picker-item.selected {
  270. color: $primary-color;
  271. }
  272. .uni-tabs__item.is-active {
  273. color: $primary-color;
  274. }
  275. .uni-modal__btn_primary {
  276. color: $primary-color !important;
  277. }
  278. .uni-radio-input-checked {
  279. background-color: $primary-color !important;
  280. border-color: $primary-color !important;
  281. }
  282. .uni-container {
  283. .icon-item:hover,
  284. .icon-item:hover .icon-text {
  285. color: $primary-color;
  286. }
  287. }
  288. }
  289. }
  290. }