radius.vue 1.5 KB

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