borderRadius.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <section class="config" :key="displayName">
  3. <div class="config-label">
  4. {{displayName}}
  5. </div>
  6. <div class="config-content">
  7. <theme-input
  8. v-if="isGlobal"
  9. :val="value"
  10. @change="onChange"
  11. ></theme-input>
  12. <el-select
  13. v-if="!isGlobal"
  14. v-model="value"
  15. class="select"
  16. @change="onSelectChange"
  17. >
  18. <el-option
  19. v-for="item in options"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value">
  23. </el-option>
  24. </el-select>
  25. </div>
  26. </section>
  27. </template>
  28. <style>
  29. .select {
  30. width: 100%;
  31. }
  32. </style>
  33. <script>
  34. import Mixin from './mixin';
  35. import Input from './input';
  36. import { getStyleDisplayName } from '../utils/utils.js';
  37. export default {
  38. data() {
  39. return {
  40. options: [],
  41. value: ''
  42. };
  43. },
  44. components: {
  45. themeInput: Input
  46. },
  47. mixins: [Mixin],
  48. computed: {
  49. isGlobalInputValue() {
  50. return this.config.value.startsWith('$');
  51. }
  52. },
  53. methods: {
  54. onSelectChange(e) {
  55. this.onChange(e);
  56. },
  57. initSelectOption() {
  58. this.options = [];
  59. const golbalV = this.golbalValue.border;
  60. if (golbalV) {
  61. Object.keys(golbalV).forEach((font) => {
  62. if (font.includes('border-radius')) {
  63. const size = golbalV[font];
  64. this.options.push({
  65. value: size.key,
  66. label: getStyleDisplayName(size)
  67. });
  68. }
  69. });
  70. }
  71. }
  72. },
  73. watch: {
  74. 'mergedValue': {
  75. immediate: true,
  76. handler(value) {
  77. this.initSelectOption();
  78. this.value = this.mergedValue;
  79. }
  80. }
  81. }
  82. };
  83. </script>