uni.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * 这里是uni-app内置的常用样式变量
  3. *
  4. * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
  5. * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
  6. *
  7. */
  8. /**
  9. * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
  10. *
  11. * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
  12. */
  13. /* 颜色变量 */
  14. $dominant-color: #E2231A;
  15. $orange-color: #ffb000;
  16. /* 行为相关颜色 */
  17. $uni-color-primary: #007aff;
  18. $uni-color-success: #4cd964;
  19. $uni-color-warning: #f0ad4e;
  20. $uni-color-error: #dd524d;
  21. /* 文字基本颜色 */
  22. $uni-text-color:#333;//基本色
  23. $uni-text-color-inverse:#fff;//反色
  24. $uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
  25. $uni-text-color-placeholder: #808080;
  26. $uni-text-color-disable:#c0c0c0;
  27. /* 背景颜色 */
  28. $uni-bg-color:#ffffff;
  29. $uni-bg-color-grey:#f8f8f8;
  30. $uni-bg-color-hover:#f1f1f1;//点击状态颜色
  31. $uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
  32. /* 边框颜色 */
  33. $uni-border-color:#c8c7cc;
  34. /* 尺寸变量 */
  35. /* 文字尺寸 */
  36. $uni-font-size-sm:24upx;
  37. $uni-font-size-base:28upx;
  38. $uni-font-size-lg:32upx;
  39. /* 图片尺寸 */
  40. $uni-img-size-sm:40upx;
  41. $uni-img-size-base:52upx;
  42. $uni-img-size-lg:80upx;
  43. /* Border Radius */
  44. $uni-border-radius-sm: 4upx;
  45. $uni-border-radius-base: 6upx;
  46. $uni-border-radius-lg: 12upx;
  47. $uni-border-radius-circle: 50%;
  48. /* 水平间距 */
  49. $uni-spacing-row-sm: 10px;
  50. $uni-spacing-row-base: 20upx;
  51. $uni-spacing-row-lg: 30upx;
  52. /* 垂直间距 */
  53. $uni-spacing-col-sm: 8upx;
  54. $uni-spacing-col-base: 16upx;
  55. $uni-spacing-col-lg: 24upx;
  56. /* 透明度 */
  57. $uni-opacity-disabled: 0.3; // 组件禁用态的透明度
  58. /* 文章场景相关 */
  59. $uni-color-title: #2C405A; // 文章标题颜色
  60. $uni-font-size-title:40upx;
  61. $uni-color-subtitle: #555555; // 二级标题颜色
  62. $uni-font-size-subtitle:36upx;
  63. $uni-color-paragraph: #3F536E; // 文章段落颜色
  64. $uni-font-size-paragraph:30upx;
  65. /* start--主题色--start */
  66. $themes: (
  67. default_theme: (
  68. font_color: #FFCC00,
  69. background_color: #FFCC00,
  70. border_color: #FFCC00,
  71. opacify_background_0: rgba(255, 204, 0, 0.09),
  72. text_color:#ffffff
  73. ),red_theme: (
  74. font_color: #e60b30,
  75. background_color: #e60b30,
  76. border_color: #e60b30,
  77. opacify_background_0: rgba(230, 11, 48, 0.05),
  78. text_color:#ffffff
  79. ),
  80. purple_theme: (
  81. font_color: #8f2df3,
  82. background_color: #8f2df3,
  83. border_color: #8f2df3,
  84. opacify_background_0: rgba(143, 45, 243, 0.05),
  85. text_color:#ffffff
  86. ),
  87. blue_theme: (
  88. font_color: #33a7ff,
  89. background_color: #33a7ff,
  90. border_color: #33a7ff,
  91. opacify_background_0: rgba(51, 167, 255, 0.05),
  92. text_color:#ffffff
  93. ),
  94. green_theme: (
  95. font_color: #1fc551,
  96. background_color: #1fc551,
  97. border_color: #1fc551,
  98. opacify_background_0: rgba(31, 197, 81, 0.05),
  99. text_color:#ffffff
  100. ),
  101. orange_theme: (
  102. font_color: #ff7f00,
  103. background_color: #ff7f00,
  104. border_color: #ff7f00,
  105. opacify_background_0: rgba(255, 127, 0, 0.05),
  106. text_color:#ffffff
  107. ),
  108. golden_theme: (
  109. font_color: #caa45a,
  110. background_color: #caa45a,
  111. border_color: #caa45a,
  112. opacify_background_0: rgba(202, 164, 90, 0.05),
  113. text_color:#ffffff
  114. )
  115. );
  116. //遍历主题map
  117. @mixin themeify {
  118. @each $theme-name, $theme-map in $themes {
  119. $theme-map: $theme-map !global;
  120. /* #ifdef MP-ALIPAY */
  121. .#{$theme-name} & {
  122. @content;
  123. }
  124. /* #endif */
  125. /* #ifndef MP-ALIPAY */
  126. [data-theme='#{$theme-name}'] & {
  127. @content;
  128. }
  129. /* #endif */
  130. }
  131. }
  132. @function themed($key) {
  133. @return map-get($theme-map, $key);
  134. }
  135. //获取背景颜色
  136. @mixin background_color($color) {
  137. @include themeify {
  138. background-color: themed($color) !important;
  139. }
  140. }
  141. //获取渐变背景颜色
  142. @mixin background_linear($color,$color1, $deg, $min, $max) {
  143. @include themeify {
  144. background: linear-gradient($deg, themed($color) $min, themed($color1) $max) !important;
  145. }
  146. }
  147. //获取字体颜色
  148. @mixin font_color($color) {
  149. @include themeify {
  150. color: themed($color) !important;
  151. }
  152. }
  153. //获取主题背景下的字体颜色
  154. @mixin text_color($color) {
  155. @include themeify {
  156. color: themed($color) !important;
  157. }
  158. }
  159. //获取边框颜色
  160. @mixin border_color($color) {
  161. @include themeify {
  162. border-color: themed($color) !important;
  163. }
  164. }
  165. /* end--主题色--end */