1
- import { component$ , useSignal , useStore } from "@qwik.dev/core" ;
1
+ import {
2
+ component$ ,
3
+ useComputed$ ,
4
+ useSignal ,
5
+ useStore ,
6
+ type PropsOf ,
7
+ } from "@qwik.dev/core" ;
2
8
3
9
export const Attributes = component$ ( ( ) => {
4
10
const render = useSignal ( 0 ) ;
@@ -13,6 +19,7 @@ export const Attributes = component$(() => {
13
19
Rerender
14
20
</ button >
15
21
< AttributesChild v = { render . value } key = { render . value } />
22
+ < ProgressParent />
16
23
</ >
17
24
) ;
18
25
} ) ;
@@ -214,3 +221,90 @@ export const Issue4718Null = component$(() => {
214
221
</ button >
215
222
) ;
216
223
} ) ;
224
+
225
+ const ProgressRoot = component$ < { min ?: number } & PropsOf < "div" > > ( ( props ) => {
226
+ const { ...rest } = props ;
227
+
228
+ const minSig = useComputed$ ( ( ) => props . min ?? 0 ) ;
229
+
230
+ const valueLabelSig = useComputed$ ( ( ) => {
231
+ const value = minSig . value ;
232
+ return `${ value * 100 } %` ;
233
+ } ) ;
234
+
235
+ return (
236
+ < >
237
+ < div id = "progress-1" aria-valuetext = { valueLabelSig . value } { ...rest } >
238
+ { valueLabelSig . value }
239
+ </ div >
240
+ </ >
241
+ ) ;
242
+ } ) ;
243
+
244
+ const ProgressRootShowHide = component$ < { min : number } & PropsOf < "div" > > (
245
+ ( { min, ...rest } ) => {
246
+ const show = useSignal ( true ) ;
247
+
248
+ return (
249
+ < >
250
+ { show . value && (
251
+ < div id = "progress-2" aria-valuetext = { min . toString ( ) } { ...rest } >
252
+ { min }
253
+ </ div >
254
+ ) }
255
+
256
+ < button id = "progress-hide" onClick$ = { ( ) => ( show . value = ! show . value ) } >
257
+ show/hide progress
258
+ </ button >
259
+ </ >
260
+ ) ;
261
+ } ,
262
+ ) ;
263
+
264
+ const ProgressRootPromise = component$ < { min ?: number } & PropsOf < "div" > > (
265
+ ( props ) => {
266
+ const { ...rest } = props ;
267
+
268
+ const minSig = useComputed$ ( ( ) => props . min ?? 0 ) ;
269
+
270
+ const valueLabelSig = useComputed$ ( ( ) => {
271
+ const value = minSig . value ;
272
+ return `${ value * 100 } %` ;
273
+ } ) ;
274
+
275
+ return (
276
+ < >
277
+ { Promise . resolve (
278
+ < div id = "progress-3" aria-valuetext = { valueLabelSig . value } { ...rest } >
279
+ { valueLabelSig . value }
280
+ </ div > ,
281
+ ) }
282
+ </ >
283
+ ) ;
284
+ } ,
285
+ ) ;
286
+
287
+ const ProgressParent = component$ ( ( ) => {
288
+ const minGoal = useSignal ( 2000 ) ;
289
+ const computedGoal = useComputed$ ( ( ) => minGoal . value + 100 ) ;
290
+
291
+ return (
292
+ < div >
293
+ < div >
294
+ < span id = "progress-value" > ${ minGoal . value } </ span >
295
+ < button
296
+ id = "progress-btn"
297
+ onClick$ = { ( ) => {
298
+ minGoal . value += 500 ;
299
+ } }
300
+ >
301
+ +
302
+ </ button >
303
+ </ div >
304
+
305
+ < ProgressRoot min = { minGoal . value } />
306
+ < ProgressRootShowHide min = { computedGoal . value } />
307
+ < ProgressRootPromise min = { minGoal . value } />
308
+ </ div >
309
+ ) ;
310
+ } ) ;
0 commit comments