radius.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <el-row :gutter="12" class="demo-radius">
  3. <el-col
  4. v-for="(radius, i) in radiusGroup"
  5. :key="i"
  6. :span="6"
  7. :xs="{ span: 12 }"
  8. >
  9. <div class="title">{{ radius.name }}</div>
  10. <div class="value">
  11. <code>border-radius: {{ getValue(radius.type) || '0px' }}</code>
  12. </div>
  13. <div
  14. class="radius"
  15. :style="{
  16. borderRadius: radius.type
  17. ? `var(--el-border-radius-${radius.type})`
  18. : '',
  19. }"
  20. />
  21. </el-col>
  22. </el-row>
  23. </template>
  24. <script lang="ts" setup>
  25. import { ref } from 'vue'
  26. const radiusGroup = ref([
  27. {
  28. name: 'No Radius',
  29. type: '',
  30. },
  31. {
  32. name: 'Small Radius',
  33. type: 'small',
  34. },
  35. {
  36. name: 'Large Radius',
  37. type: 'base',
  38. },
  39. {
  40. name: 'Round Radius',
  41. type: 'round',
  42. },
  43. ])
  44. const getValue = (type: string) => {
  45. const getCssVarValue = (prefix, type) =>
  46. getComputedStyle(document.documentElement).getPropertyValue(
  47. `--el-${prefix}-${type}`
  48. )
  49. return getCssVarValue('border-radius', type)
  50. }
  51. </script>
  52. <style scoped>
  53. .demo-radius .title {
  54. color: var(--el-text-color-regular);
  55. font-size: 18px;
  56. margin: 10px 0;
  57. }
  58. .demo-radius .value {
  59. color: var(--el-text-color-primary);
  60. font-size: 16px;
  61. margin: 10px 0;
  62. }
  63. .demo-radius .radius {
  64. height: 40px;
  65. width: 70%;
  66. border: 1px solid var(--el-border-color);
  67. border-radius: 0;
  68. margin-top: 20px;
  69. }
  70. </style>