basic-tokens-preview.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <style lang="scss">
  2. .component-preview {
  3. .heading>div{
  4. margin-bottom: 15px;
  5. }
  6. .title {
  7. font-size: 18px;
  8. font-weight:400;
  9. padding: 0 20px
  10. }
  11. .paragraph {
  12. padding: 0 20px
  13. }
  14. .demo-color-box {
  15. margin: 0;
  16. }
  17. .color {
  18. margin-right: -12%;
  19. }
  20. }
  21. </style>
  22. <template>
  23. <div class="component-preview">
  24. <h4>Color</h4>
  25. <div class="color">
  26. <el-row :gutter="12">
  27. <el-col :span="4" v-for="(color, key) in colorLine" :key="key">
  28. <div class="demo-color-box" :style="{ background: dataProxy(color) }">
  29. {{color}}
  30. <div class="value">{{dataProxy(color)}}</div>
  31. <div class="bg-color-sub">
  32. <div
  33. class="bg-success-sub-item"
  34. v-for="(item, key) in Array(2)"
  35. :key="key"
  36. :style="{ background: tintColor(dataProxy(color), (key + 8) / 10) }"
  37. ></div>
  38. </div>
  39. </div>
  40. </el-col>
  41. </el-row>
  42. <el-row :gutter="12">
  43. <el-col :span="4">
  44. <div class="demo-color-box demo-color-box-other" :style="{ background: color_text_primary }">
  45. Primary Text
  46. <div class="value">{{color_text_primary}}</div>
  47. </div>
  48. </el-col>
  49. <el-col :span="4">
  50. <div class="demo-color-box demo-color-box-other" :style="{ background: color_text_regular }">
  51. Regular Text
  52. <div class="value">{{color_text_regular}}</div>
  53. </div>
  54. </el-col>
  55. <el-col :span="4">
  56. <div class="demo-color-box demo-color-box-other" :style="{ background: color_text_secondary }">
  57. Secondary Text
  58. <div class="value">{{color_text_secondary}}</div>
  59. </div>
  60. </el-col>
  61. <el-col :span="4">
  62. <div class="demo-color-box demo-color-box-other" :style="{ background: color_text_placeholder }">
  63. Placeholder
  64. <div class="value">{{color_text_placeholder}}</div>
  65. </div>
  66. </el-col>
  67. </el-row>
  68. <el-row :gutter="12">
  69. <el-col :span="4">
  70. <div
  71. class="demo-color-box demo-color-box-other demo-color-box-lite"
  72. :style="{ background: border_color_base }"
  73. >
  74. Border Base
  75. <div class="value">{{border_color_base}}</div>
  76. </div>
  77. </el-col>
  78. <el-col :span="4">
  79. <div
  80. class="demo-color-box demo-color-box-other demo-color-box-lite"
  81. :style="{ background: border_color_light }"
  82. >
  83. Border Light
  84. <div class="value">{{border_color_light}}</div>
  85. </div>
  86. </el-col>
  87. <el-col :span="4">
  88. <div
  89. class="demo-color-box demo-color-box-other demo-color-box-lite"
  90. :style="{ background: border_color_lighter }"
  91. >
  92. Border Lighter
  93. <div class="value">{{border_color_lighter}}</div>
  94. </div>
  95. </el-col>
  96. <el-col :span="4">
  97. <div
  98. class="demo-color-box demo-color-box-other demo-color-box-lite"
  99. :style="{ background: border_color_extra_light }"
  100. >
  101. Border Extralight
  102. <div class="value">{{border_color_extra_light}}</div>
  103. </div>
  104. </el-col>
  105. </el-row>
  106. <el-row :gutter="12">
  107. <el-col :span="4">
  108. <div class="demo-color-box demo-color-box-other" :style="{ background: color_black }">
  109. Background B
  110. <div class="value">{{color_black}}</div>
  111. </div>
  112. </el-col>
  113. <el-col :span="4">
  114. <div
  115. class="demo-color-box demo-color-box-other"
  116. :style="{ background: color_white, color: '#303133', border: '1px solid #eee' }"
  117. >
  118. Background W
  119. <div class="value">{{color_white}}</div>
  120. </div>
  121. </el-col>
  122. <el-col :span="4">
  123. <div class="demo-color-box demo-color-box-other bg-transparent">
  124. Background
  125. <div class="value">Transparent</div>
  126. </div>
  127. </el-col>
  128. </el-row>
  129. </div>
  130. <h4>Typography</h4>
  131. <el-row :gutter="12">
  132. <el-col :span="6" class="heading">
  133. <div :style="{ fontSize: font_size_extra_large }">Heading1</div>
  134. <div :style="{ fontSize: font_size_large }">Heading2</div>
  135. <div :style="{ fontSize: font_size_medium }">Heading3</div>
  136. <div :style="{ fontSize: font_size_base }">Heading4</div>
  137. <div :style="{ fontSize: font_size_small }">Heading5</div>
  138. <div :style="{ fontSize: font_size_extra_small }">Heading6</div>
  139. </el-col>
  140. <el-col :span="9">
  141. <div class="title">Example body text</div>
  142. <p
  143. class="paragraph"
  144. :style="{
  145. fontSize: font_size_base,
  146. fontWeight: font_weight_primary,
  147. lineHeight: font_line_height_primary
  148. }" >
  149. With MySpace becoming more popular every day, there is the constant need to be different. There are millions of users. If MySpace layouts are chosen well, then you can enhance your profile a great deal.</p>
  150. </el-col>
  151. <el-col :span="9">
  152. <div class="title">Example small text</div>
  153. <p
  154. class="paragraph"
  155. :style="{
  156. fontSize: font_size_small,
  157. fontWeight: font_weight_secondary,
  158. lineHeight: font_line_height_secondary
  159. }" >
  160. Computers have become ubiquitous in almost every facet of our lives. At work, desk jockeys spend hours in front of their desktops, while delivery people scan bar codes with handhelds and workers in the field stay in touch with the central office via their notebooks. Computer hardware weaves itself through the fabric of our lives.</p>
  161. </el-col>
  162. </el-row>
  163. </div>
  164. </template>
  165. <script>
  166. import bus from '../../bus';
  167. import { tintColor } from '../../color.js';
  168. import {
  169. ACTION_COMPONECT_SELECT,
  170. ACTION_USER_CONFIG_UPDATE
  171. } from './constant.js';
  172. const original = {
  173. 'color_primary': '#409EFF',
  174. 'color_success': '#67C23A',
  175. 'color_warning': '#E6A23C',
  176. 'color_danger': '#F56C6C',
  177. 'color_info': '#909399',
  178. 'color_white': '#FFFFFF',
  179. 'color_black': '#000000',
  180. 'color_text_primary': '#303133',
  181. 'color_text_regular': '#606266',
  182. 'color_text_secondary': '#909399',
  183. 'color_text_placeholder': '#C0C4CC',
  184. 'border_color_base': '#DCDFE6',
  185. 'border_color_light': '#E4E7ED',
  186. 'border_color_lighter': '#EBEEF5',
  187. 'border_color_extra_light': '#F2F6FC',
  188. 'font_size_extra_large': '20px',
  189. 'font_size_large': '18px',
  190. 'font_size_medium': '16px',
  191. 'font_size_base': '14px',
  192. 'font_size_small': '13px',
  193. 'font_size_extra_small': '12px',
  194. 'font_weight_primary': 500,
  195. 'font_weight_secondary': 100,
  196. 'font_line_height_primary': '24px',
  197. 'font_line_height_secondary': '16px'
  198. };
  199. export default {
  200. created() {
  201. bus.$on(ACTION_USER_CONFIG_UPDATE, this.setGlobal);
  202. bus.$on(ACTION_COMPONECT_SELECT, (val) => {
  203. this.$nextTick(() => {
  204. const getSelectElement = Array.from(document.querySelectorAll('h4')).filter((el) => (el.innerText.toLowerCase() === val));
  205. if (getSelectElement[0]) {
  206. const elementTop = getSelectElement[0].getBoundingClientRect().top;
  207. window.scrollTo(0, window.pageYOffset + elementTop - 20); // 20 for padding
  208. }
  209. });
  210. });
  211. },
  212. mounted() {
  213. this.setGlobal();
  214. },
  215. methods: {
  216. tintColor(a, b) {
  217. return tintColor(a, b);
  218. },
  219. dataProxy(value) {
  220. return this[`color_${value.toLowerCase()}`];
  221. },
  222. setGlobal() {
  223. if (window.userThemeConfig) {
  224. this.global = window.userThemeConfig.global;
  225. }
  226. }
  227. },
  228. watch: {
  229. global: {
  230. immediate: true,
  231. handler(value) {
  232. Object.keys(original).forEach((v) => {
  233. const key = `$--${v.replace(/_/g, '-')}`;
  234. if (value[key]) {
  235. this[v] = value[key];
  236. } else {
  237. this[v] = original[v];
  238. }
  239. });
  240. }
  241. }
  242. },
  243. data() {
  244. return {
  245. global: {},
  246. colorLine: ['Primary', 'Success', 'Warning', 'Danger', 'Info'],
  247. 'color_primary': '',
  248. 'color_success': '',
  249. 'color_warning': '',
  250. 'color_danger': '',
  251. 'color_info': '',
  252. 'color_white': '',
  253. 'color_black': '',
  254. 'color_text_primary': '',
  255. 'color_text_regular': '',
  256. 'color_text_secondary': '',
  257. 'color_text_placeholder': '',
  258. 'border_color_base': '',
  259. 'border_color_light': '',
  260. 'border_color_lighter': '',
  261. 'border_color_extra_light': '',
  262. 'font_size_extra_large': '',
  263. 'font_size_large': '',
  264. 'font_size_medium': '',
  265. 'font_size_base': '',
  266. 'font_size_small': '',
  267. 'font_size_extra_small': '',
  268. 'font_weight_primary': 0,
  269. 'font_weight_secondary': 0,
  270. 'font_line_height_primary': '',
  271. 'font_line_height_secondary': ''
  272. };
  273. }
  274. };
  275. </script>