feat: 新增装饰组件01

This commit is contained in:
mtrun 2022-03-31 09:59:42 +08:00
parent bb78d89037
commit d1ea05c2c0
4 changed files with 100 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -4,8 +4,10 @@ import { Decorates01Config } from './index'
import cloneDeep from 'lodash/cloneDeep'
export const option = {
colors: ['#4fd2dd', '#235fa7'],
backgroundColor: '#00000000'
colors: ['#3faacb', '#fff'],
dur: 3,
lineHeight: 2,
endWidth: 5
}
export default class Config extends publicConfig implements CreateComponentType {

View File

@ -1,6 +1,69 @@
<template>
<CollapseItem name="线条" :expanded="true">
<SettingItemBox
:name="`颜色-${index + 1}`"
v-for="(item, index) in optionData.colors"
:key="index"
>
<SettingItem name="颜色">
<n-color-picker
size="small"
:modes="['hex']"
v-model:value="optionData.colors[index]"
></n-color-picker>
</SettingItem>
<SettingItem>
<n-button
size="small"
@click="optionData.colors[index] = option.colors[index]"
>
恢复默认
</n-button>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="具体">
<SettingItem name="线条高度">
<n-input-number
size="small"
v-model:value="optionData.lineHeight"
></n-input-number>
</SettingItem>
<SettingItem name="末端长度">
<n-input-number
size="small"
v-model:value="optionData.endWidth"
></n-input-number>
</SettingItem>
</SettingItemBox>
</CollapseItem>
<CollapseItem name="动画" :expanded="true">
<SettingItemBox name="速度">
<SettingItem>
<n-input-number
v-model:value="optionData.dur"
size="small"
:step="0.5"
:min="0.5"
></n-input-number>
</SettingItem>
</SettingItemBox>
</CollapseItem>
</template>
<script setup lang="ts">
import { PropType } from 'vue'
import {
CollapseItem,
SettingItemBox,
SettingItem
} from '@/components/ChartItemSetting/index'
import { option } from './config'
const props = defineProps({
optionData: {
type: Object as PropType<typeof option>,
required: true
}
})
</script>

View File

@ -1,24 +1,47 @@
<template>
<div>
装饰
</div>
<svg :width="w" :height="h">
<rect :x="rectX" :y="rectY" :width="w" :height="lineHeight" :fill="colors[0]">
<animate
attributeName="width"
from="0"
:to="w"
:dur="`${dur}s`"
calcMode="spline"
keyTimes="0;1"
keySplines=".42,0,.58,1"
repeatCount="indefinite"
/>
</rect>
<rect :x="rectX" :y="rectY" :width="endWidth" :height="lineHeight" :fill="colors[1]">
<animate
attributeName="x"
from="0"
:to="w"
:dur="`${dur}s`"
calcMode="spline"
keyTimes="0;1"
keySplines="0.42,0,0.58,1"
repeatCount="indefinite"
/>
</rect>
</svg>
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { PropType, computed, toRefs, reactive } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
required: true,
},
})
const { w, h } = toRefs(props.chartConfig.attr)
const { colors, dur, endWidth, lineHeight } = toRefs(props.chartConfig.option)
const rectX = computed(() => 0)
const rectY = computed(() => h.value / 2)
</script>
<style lang="scss" scoped>
</style>