convention.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <table class="demo-typo-size">
  3. <tbody>
  4. <tr>
  5. <td>Level</td>
  6. <td>Font Size</td>
  7. <td class="color-dark-light">Demo</td>
  8. </tr>
  9. <tr
  10. v-for="(fontSize, i) in fontSizes"
  11. :key="i"
  12. :style="`font-size: var(--el-font-size-${fontSize.type})`"
  13. >
  14. <td>{{ fontSize.level }}</td>
  15. <td>
  16. {{
  17. useCssVar(`--el-font-size-${fontSize.type}`).value +
  18. ' ' +
  19. formatType(fontSize.type)
  20. }}
  21. </td>
  22. <td>Build with Element</td>
  23. </tr>
  24. </tbody>
  25. </table>
  26. </template>
  27. <script lang="ts" setup>
  28. import { useCssVar } from '@vueuse/core'
  29. const fontSizes = [
  30. {
  31. level: 'Supplementary text',
  32. type: 'extra-small',
  33. },
  34. {
  35. level: 'Body (small)',
  36. type: 'small',
  37. },
  38. {
  39. level: 'Body',
  40. type: 'base',
  41. },
  42. {
  43. level: 'Small Title',
  44. type: 'medium',
  45. },
  46. {
  47. level: 'Title',
  48. type: 'large',
  49. },
  50. {
  51. level: 'Main Title',
  52. type: 'extra-large',
  53. },
  54. ]
  55. function formatType(type: string) {
  56. return type
  57. .split('-')
  58. .map((item) => item.charAt(0).toUpperCase() + item.slice(1))
  59. .join(' ')
  60. }
  61. </script>