123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <template>
- <section class="config" :key="displayName">
- <div class="config-label">
- {{displayName}}
- </div>
- <div class="config-content">
- <el-select
- v-model="value"
- class="select"
- @change="onSelectChange"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </div>
- </section>
- </template>
- <style>
- .select {
- width: 100%;
- }
- </style>
- <script>
- const defaultFontWeight = [
- 'normal',
- 'bold',
- 'bolder',
- 'lighter',
- '100',
- '200',
- '300',
- '400',
- '500',
- '600',
- '700',
- '800',
- '900',
- 'inherit'
- ];
- import Mixin from './mixin';
- import { getStyleDisplayName } from '../utils/utils.js';
- export default {
- props: {
- componentName: {
- type: String
- },
- golbalValue: {
- type: Object
- }
- },
- data() {
- return {
- options: [],
- value: ''
- };
- },
- mixins: [Mixin],
- computed: {
- isGlobalInputValue() {
- return this.config.value.startsWith('$');
- }
- },
- methods: {
- onSelectChange(e) {
- this.onChange(e);
- },
- initSelectOption() {
- this.options = [];
- defaultFontWeight.forEach((weight) => {
- this.options.push({
- value: weight,
- label: weight
- });
- });
- const golbalTypography = this.golbalValue.typography;
- if (this.isGlobalInputValue && golbalTypography) {
- Object.keys(golbalTypography).forEach((font) => {
- if (font.includes('font-weight')) {
- const weight = golbalTypography[font];
- this.options.push({
- value: weight.key,
- label: getStyleDisplayName(weight)
- });
- }
- });
- }
- }
- },
- watch: {
- 'mergedValue': {
- immediate: true,
- handler(value) {
- this.initSelectOption();
- this.value = this.mergedValue;
- }
- }
- }
- };
- </script>
|