4
4
5
5
<nut-row type =" flex" >
6
6
<nut-col :span =" 8" >
7
- <nut-popover
8
- v-model:visible =" visible.lightTheme"
9
- :list =" iconItemList"
10
- location =" bottom-start"
11
- @choose =" chooseItem"
12
- >
7
+ <nut-popover v-model:visible =" lightTheme" :list =" iconItemList" location =" bottom-start" @choose =" chooseItem" >
13
8
<template #reference >
14
9
<nut-button type =" primary" shape =" square" >{{ translate('light') }}</nut-button >
15
10
</template >
16
11
</nut-popover >
17
12
</nut-col >
18
13
<nut-col :span =" 8" >
19
- <nut-popover v-model:visible =" visible. darkTheme" theme =" dark" :list =" iconItemList" >
14
+ <nut-popover v-model:visible =" darkTheme" theme =" dark" :list =" iconItemList" >
20
15
<template #reference >
21
16
<nut-button type =" primary" shape =" square" >{{ translate('dark') }}</nut-button >
22
17
</template >
28
23
29
24
<nut-row type =" flex" >
30
25
<nut-col :span =" 8" >
31
- <nut-popover v-model:visible =" visible. showIcon" theme =" dark" :list =" itemList" >
26
+ <nut-popover v-model:visible =" showIcon" theme =" dark" :list =" itemList" >
32
27
<template #reference >
33
28
<nut-button type =" primary" shape =" square" >{{ translate('showIcon') }}</nut-button >
34
29
</template >
35
30
</nut-popover >
36
31
</nut-col >
37
32
<nut-col :span =" 8" >
38
- <nut-popover v-model:visible =" visible. disableAction" :list =" itemListDisabled" >
33
+ <nut-popover v-model:visible =" disableAction" :list =" itemListDisabled" location = " bottom-end " >
39
34
<template #reference >
40
35
<nut-button type =" primary" shape =" square" >{{ translate('disableAction') }}</nut-button >
41
36
</template >
44
39
</nut-row >
45
40
46
41
<h2 >{{ translate('title2') }}</h2 >
47
- <nut-popover v-model:visible =" visible. Customized" location =" bottom -start" >
42
+ <nut-popover v-model:visible =" Customized" location =" top -start" custom-class = " customClass " >
48
43
<template #reference >
49
44
<nut-button type =" primary" shape =" square" >{{ translate('content') }}</nut-button >
50
45
</template >
61
56
62
57
<h2 >{{ translate('title3') }}</h2 >
63
58
64
- <nut-row type =" flex" justify =" center" >
65
- <nut-col :span =" 24" style =" text-align : center " >
66
- <nut-popover
67
- v-model:visible =" visible.customPositon"
68
- :location =" curPostion"
69
- theme =" dark"
70
- :list =" positionList"
71
- customClass =" brickBox"
72
- >
73
- <template #reference >
74
- <div class =" brick" ></div >
75
- </template >
76
- </nut-popover >
77
- </nut-col >
78
- </nut-row >
79
-
80
- <nut-radiogroup v-model =" curPostion" direction =" horizontal" class =" radiogroup" >
81
- <nut-radio shape =" button" :label =" pos" v-for =" (pos, i) in position" :key =" i" >{{ pos }}</nut-radio >
82
- </nut-radiogroup >
59
+ <nut-cell title =" 点击查看更多方向" @click =" handlePicker" ></nut-cell >
60
+ <nut-picker v-model:visible =" showPicker" :columns =" columns" title =" " @change =" change" :swipe-duration =" 500" >
61
+ <template #top >
62
+ <div class =" brickBox" >
63
+ <nut-popover v-model:visible =" customPositon" :location =" curPostion" theme =" dark" :list =" positionList" >
64
+ <template #reference >
65
+ <div class =" brick" ></div >
66
+ </template >
67
+ </nut-popover >
68
+ </div >
69
+ </template >
70
+ </nut-picker >
83
71
</div >
84
72
</template >
85
73
<script lang="ts">
86
- import { reactive , ref } from ' vue' ;
74
+ import { reactive , ref , toRefs } from ' vue' ;
87
75
import { createComponent } from ' @/packages/utils/create' ;
88
76
const { createDemo, translate } = createComponent (' popover' );
89
77
import { useTranslate } from ' @/sites/assets/util/useTranslate' ;
@@ -116,7 +104,7 @@ const initTranslate = () =>
116
104
export default createDemo ({
117
105
setup() {
118
106
initTranslate ();
119
- const visible = ref ({
107
+ const state = reactive ({
120
108
showIcon: false ,
121
109
placement: false ,
122
110
darkTheme: false ,
@@ -126,22 +114,25 @@ export default createDemo({
126
114
topLocation: false , // 向上弹出
127
115
rightLocation: false , // 向右弹出
128
116
leftLocation: false , // 向左弹出
129
- customPositon: false
117
+ customPositon: false ,
118
+
119
+ showPicker: false
130
120
});
131
121
const curPostion = ref (' top' );
132
- const position = ref ([
133
- ' top' ,
134
- ' top-start' ,
135
- ' top-end' ,
136
- ' right' ,
137
- ' right-start' ,
138
- ' right-end' ,
139
- ' bottom' ,
140
- ' bottom-start' ,
141
- ' bottom-end' ,
142
- ' left' ,
143
- ' left-start' ,
144
- ' left-end'
122
+
123
+ const columns = ref ([
124
+ { text: ' top' , value: ' top' },
125
+ { text: ' top-start' , value: ' top-start' },
126
+ { text: ' top-end' , value: ' top-end' },
127
+ { text: ' right' , value: ' right' },
128
+ { text: ' right-start' , value: ' right-start' },
129
+ { text: ' right-end' , value: ' right-end' },
130
+ { text: ' bottom' , value: ' bottom' },
131
+ { text: ' bottom-start' , value: ' bottom-start' },
132
+ { text: ' bottom-end' , value: ' bottom-end' },
133
+ { text: ' left' , value: ' left' },
134
+ { text: ' left-start' , value: ' left-start' },
135
+ { text: ' left-end' , value: ' left-end' }
145
136
]);
146
137
147
138
const iconItemList = reactive ([
@@ -223,20 +214,32 @@ export default createDemo({
223
214
224
215
const chooseItem = (item : unknown , index : number ) => {
225
216
console .log (item , index );
226
- alert (' selected' );
227
217
};
228
218
219
+ const handlePicker = () => {
220
+ state .showPicker = true ;
221
+ setTimeout (() => {
222
+ state .customPositon = true ;
223
+ });
224
+ };
225
+
226
+ const change = ({ selectedValue }) => {
227
+ curPostion .value = selectedValue [0 ];
228
+ state .customPositon = true ;
229
+ };
229
230
return {
230
231
iconItemList ,
231
232
itemList ,
232
- visible ,
233
+ ... toRefs ( state ) ,
233
234
itemListDisabled ,
234
235
selfContent ,
235
236
chooseItem ,
236
- position ,
237
237
curPostion ,
238
238
positionList ,
239
- translate
239
+ translate ,
240
+ columns ,
241
+ change ,
242
+ handlePicker
240
243
};
241
244
}
242
245
});
@@ -247,10 +250,12 @@ export default createDemo({
247
250
}
248
251
.brickBox {
249
252
margin : 80px 0 ;
253
+ display : flex ;
254
+ justify-content : center ;
250
255
.brick {
251
256
width : 60px ;
252
257
height : 60px ;
253
- background : #1989fa ;
258
+ background : linear-gradient ( 135 deg , #fa2c19 0 % , #fa6419 100 % ) ;
254
259
border-radius : 10px ;
255
260
}
256
261
}
@@ -271,23 +276,32 @@ export default createDemo({
271
276
}
272
277
}
273
278
274
- .self-content {
275
- width : 195px ;
276
- display : flex ;
277
- flex-wrap : wrap ;
278
- & -item {
279
- margin-top : 10px ;
280
- margin-bottom : 10px ;
281
- display : flex ;
282
- justify-content : center ;
283
- align-items : center ;
284
- flex-direction : column ;
279
+ .nut-popover-content {
280
+ width : 120px ;
281
+ }
282
+
283
+ .customClass {
284
+ .nut-popover-content {
285
+ width : auto ;
285
286
}
286
- & -desc {
287
- margin-top : 5px ;
288
- width : 60px ;
289
- font-size : 10px ;
290
- text-align : center ;
287
+ .self-content {
288
+ width : 195px ;
289
+ display : flex ;
290
+ flex-wrap : wrap ;
291
+ & -item {
292
+ margin-top : 10px ;
293
+ margin-bottom : 10px ;
294
+ display : flex ;
295
+ justify-content : center ;
296
+ align-items : center ;
297
+ flex-direction : column ;
298
+ }
299
+ & -desc {
300
+ margin-top : 5px ;
301
+ width : 60px ;
302
+ font-size : 10px ;
303
+ text-align : center ;
304
+ }
291
305
}
292
306
}
293
307
</style >
0 commit comments