1+ <script setup>
2+ import { ref , computed } from " vue" ;
3+ import LocalVueUiSmiley from ' ../src/components/vue-ui-smiley.vue' ;
4+ import LocalVueDataUi from ' ../src/components/vue-data-ui.vue' ;
5+ import Box from " ./Box.vue" ;
6+ import convertArrayToObject from " ./convertModel" ;
7+ import { useArena } from " ../src/useArena" ;
8+
9+ const { local , build , vduiLocal , vduiBuild } = useArena ()
10+
11+ const dataset = ref ({ rating: {
12+ ' 1' : 12.12356 ,
13+ ' 2' : 43.12356 ,
14+ ' 3' : 27.12356 ,
15+ ' 4' : 19.12356 ,
16+ ' 5' : 29.12356
17+ } });
18+
19+ const model = ref ([
20+ { key: ' readonly' , def: true , type: ' checkbox' },
21+ { key: ' style.itemSize' , def: 32 , type: ' number' , min: 12 , max: 96 },
22+ { key: ' style.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
23+ { key: ' style.icons.filled' , def: false , type: ' checkbox' },
24+ { key: ' style.icons.useGradient' , def: true , type: ' checkbox' },
25+
26+ { key: ' style.title.textAlign' , def: ' center' , type: ' select' , options: [' left' , ' center' , ' right' ] },
27+ { key: ' style.title.fontSize' , def: 20 , type: ' number' , min: 8 , max: 42 },
28+ { key: ' style.title.color' , def: ' #1A1A1A' , type: ' color' },
29+ { key: ' style.title.bold' , def: true , type: ' checkbox' },
30+ { key: ' style.title.text' , def: ' TItle' , type: ' text' },
31+ { key: ' style.title.offsetY' , def: 6 , type: ' number' , min: - 50 , max: 50 },
32+ { key: ' style.title.subtitle.fontSize' , def: 14 , type: ' number' , min: 8 , max: 42 },
33+ { key: ' style.title.subtitle.color' , def: ' #1A1A1A' , type: ' color' },
34+ { key: ' style.title.subtitle.bold' , def: false , type: ' checkbox' },
35+ { key: ' style.title.subtitle.text' , def: ' Subtitle' , type: ' text' },
36+ { key: ' style.title.subtitle.offsetY' , def: 12 , type: ' number' , min: - 50 , max: 50 },
37+
38+ { key: ' style.rating.show' , def: true , type: ' checkbox' },
39+ { key: ' style.rating.fontSize' , def: 28 , type: ' number' , min: 8 , max: 96 },
40+ { key: ' style.rating.bold' , def: true , type: ' checkbox' },
41+ { key: ' style.rating.roundingValue' , def: 1 , type: ' number' , min: 0 , max: 6 },
42+ { key: ' style.rating.position' , def: ' bottom' , type: ' select' , options: [' top' , ' right' , ' bottom' , ' left' ] },
43+ { key: ' style.rating.offsetY' , def: 12 , type: ' number' , min: - 50 , max: 50 },
44+ { key: ' style.rating.offsetX' , def: 0 , type: ' number' , min: - 50 , max: 50 },
45+
46+ { key: ' style.tooltip.show' , def: true , type: ' checkbox' },
47+ { key: ' style.tooltip.fontSize' , def: 14 , type: ' number' , min: 8 , max: 42 },
48+ { key: ' style.tooltip.offsetY' , def: 0 , type: ' number' , min: - 50 , max: 50 },
49+ { key: ' style.tooltip.color' , def: ' #1A1A1A' , type: ' color' },
50+ { key: ' style.tooltip.bold' , def: true , type: ' checkbox' },
51+ { key: ' style.tooltip.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
52+ { key: ' style.tooltip.borderColor' , def: ' #E1E5E8' , type: ' color' },
53+ { key: ' style.tooltip.borderRadius' , def: 4 , type: ' number' , min: 0 , max: 12 },
54+ { key: ' style.tooltip.boxShadow' , def: ' 0 6px 12px -6px rgba(0,0,0,0.2)' , type: ' text' },
55+ { key: ' style.tooltip.roundingValue' , def: 1 , type: ' number' , min: 0 , max: 6 }
56+ ])
57+
58+ const config = computed (() => {
59+ const c = convertArrayToObject (model .value );
60+ return {
61+ ... c,
62+ style: {
63+ ... c .style ,
64+ rating: {
65+ ... c .style .rating ,
66+ // formatter: ({ value }) => {
67+ // return `${value}!`
68+ // }
69+ },
70+ tooltip: {
71+ ... c .style .tooltip ,
72+ // formatter: ({ value }) => {
73+ // return `${value}!`
74+ // }
75+ }
76+ }
77+ }
78+ })
79+
80+ </script >
81+
82+ <template >
83+ <Box comp =" VueUiSmiley" :dataset =" dataset" >
84+ <template #title >VueUiSmiley</template >
85+
86+ <template #local >
87+ <LocalVueUiSmiley :dataset =" dataset" :config =" config" ref =" local" />
88+ </template >
89+
90+ <template #VDUI-local >
91+ <LocalVueDataUi component =" VueUiSmiley" :dataset =" dataset" :config =" config" ref =" vduiLocal" />
92+ </template >
93+
94+ <template #build >
95+ <VueUiSmiley :dataset =" dataset" :config =" config" ref =" build" />
96+ </template >
97+
98+ <template #VDUI-build >
99+ <VueDataUi component =" VueUiSmiley" :dataset =" dataset" :config =" config" ref =" vduiBuild" />
100+ </template >
101+
102+ <template #knobs >
103+ <div
104+ style =" display : flex ; flex-direction : row ; flex-wrap :wrap ; align-items :center ; width : 100% ; color : #CCCCCC ; gap :24px ;" >
105+ <div v-for =" knob in model" >
106+ <label style =" font-size : 10px " >{{ knob.key }}</label >
107+ <div
108+ style =" display :flex ; flex-direction :row ; flex-wrap : wrap ; align-items :center ; gap :6px ; height : 40px " >
109+ <input v-if =" !['none', 'select'].includes(knob.type)" :type =" knob.type" :min =" knob.min ?? 0"
110+ :max =" knob.max ?? 0" v-model =" knob.def" @change =" step += 1" >
111+ <select v-if =" knob.type === 'select'" v-model =" knob.def" @change =" step += 1" >
112+ <option v-for =" opt in knob.options" >{{ opt }}</option >
113+ </select >
114+ </div >
115+ </div >
116+ </div >
117+ </template >
118+
119+ <template #config >
120+ {{ config }}
121+ </template >
122+ </Box >
123+ </template >
0 commit comments