@@ -16,8 +16,8 @@ import { stack } from '../../constants/code/Components/stackCode';
1616const StackDemo = ( ) => {
1717 const [ randomRotation , setRandomRotation ] = useState ( false ) ;
1818 const [ sensitivity , setSensitivity ] = useState ( 200 ) ;
19- const [ cardWidth , setCardWidth ] = useState ( 208 ) ;
20- const [ cardHeight , setCardHeight ] = useState ( 208 ) ;
19+ const [ autoplay , setAutoplay ] = useState ( false ) ;
20+ const [ autoplayDelay , setAutoplayDelay ] = useState ( 3000 ) ;
2121 const [ key , forceRerender ] = useForceRerender ( ) ;
2222
2323 const propData = [
@@ -33,50 +33,66 @@ const StackDemo = () => {
3333 default : 200 ,
3434 description : 'Drag sensitivity for sending a card to the back.'
3535 } ,
36- {
37- name : 'cardDimensions' ,
38- type : 'object' ,
39- default : '{ width: 208, height: 208 }' ,
40- description : 'Defines the width and height of the cards.'
41- } ,
4236 {
4337 name : 'sendToBackOnClick' ,
4438 type : 'boolean' ,
4539 default : 'false' ,
46- description : 'When enabled, the also stack shifts to the next card on click.'
40+ description : 'When enabled, the stack also shifts to the next card on click.'
4741 } ,
4842 {
49- name : 'cardsData ' ,
50- type : 'array ' ,
43+ name : 'cards ' ,
44+ type : 'ReactNode[] ' ,
5145 default : '[]' ,
52- description : 'The array of card data, including `id` and `img` properties .'
46+ description : 'The array of card elements to display in the stack .'
5347 } ,
5448 {
5549 name : 'animationConfig' ,
5650 type : 'object' ,
5751 default : '{ stiffness: 260, damping: 20 }' ,
5852 description : "Configures the spring animation's stiffness and damping."
53+ } ,
54+ {
55+ name : 'autoplay' ,
56+ type : 'boolean' ,
57+ default : 'false' ,
58+ description : 'When enabled, the stack automatically cycles through cards.'
59+ } ,
60+ {
61+ name : 'autoplayDelay' ,
62+ type : 'number' ,
63+ default : '3000' ,
64+ description : 'Delay in milliseconds between automatic card transitions.'
5965 }
6066 ] ;
6167
6268 const images = [
63- { id : 1 , img : 'https://images.unsplash.com/photo-1480074568708-e7b720bb3f09?q=80&w=500&auto=format' } ,
64- { id : 2 , img : 'https://images.unsplash.com/photo-1449844908441-8829872d2607?q=80&w=500&auto=format' } ,
65- { id : 3 , img : 'https://images.unsplash.com/photo-1452626212852-811d58933cae?q=80&w=500&auto=format' } ,
66- { id : 4 , img : 'https://images.unsplash.com/photo-1572120360610-d971b9d7767c?q=80&w=500&auto=format' }
69+ 'https://images.unsplash.com/photo-1480074568708-e7b720bb3f09?q=80&w=500&auto=format' ,
70+ 'https://images.unsplash.com/photo-1449844908441-8829872d2607?q=80&w=500&auto=format' ,
71+ 'https://images.unsplash.com/photo-1452626212852-811d58933cae?q=80&w=500&auto=format' ,
72+ 'https://images.unsplash.com/photo-1572120360610-d971b9d7767c?q=80&w=500&auto=format'
6773 ] ;
6874
6975 return (
7076 < TabsLayout >
7177 < PreviewTab >
7278 < Box position = "relative" className = "demo-container" minH = { 400 } overflow = "hidden" >
73- < Stack
74- key = { key }
75- randomRotation = { randomRotation }
76- sensitivity = { sensitivity }
77- cardDimensions = { { width : cardWidth , height : cardHeight } }
78- cardsData = { images }
79- />
79+ < div style = { { width : 208 , height : 208 } } >
80+ < Stack
81+ key = { key }
82+ randomRotation = { randomRotation }
83+ sensitivity = { sensitivity }
84+ autoplay = { autoplay }
85+ autoplayDelay = { autoplayDelay }
86+ cards = { images . map ( ( src , i ) => (
87+ < img
88+ key = { i }
89+ src = { src }
90+ alt = { `card-${ i + 1 } ` }
91+ style = { { width : '100%' , height : '100%' , objectFit : 'cover' } }
92+ />
93+ ) ) }
94+ />
95+ </ div >
8096 </ Box >
8197
8298 < Customize >
@@ -89,6 +105,14 @@ const StackDemo = () => {
89105 } }
90106 />
91107
108+ < PreviewSwitch
109+ title = "Autoplay"
110+ isChecked = { autoplay }
111+ onChange = { checked => {
112+ setAutoplay ( checked ) ;
113+ } }
114+ />
115+
92116 < PreviewSlider
93117 title = "Sensitivity"
94118 min = { 100 }
@@ -102,29 +126,15 @@ const StackDemo = () => {
102126 />
103127
104128 < PreviewSlider
105- title = "Card Width "
106- min = { 150 }
107- max = { 300 }
108- step = { 10 }
109- value = { cardWidth }
129+ title = "Autoplay Delay "
130+ min = { 1000 }
131+ max = { 5000 }
132+ step = { 500 }
133+ value = { autoplayDelay }
110134 onChange = { val => {
111- setCardWidth ( val ) ;
112- forceRerender ( ) ;
113- } }
114- displayValue = { val => `${ val } px` }
115- />
116-
117- < PreviewSlider
118- title = "Card Height"
119- min = { 150 }
120- max = { 300 }
121- step = { 10 }
122- value = { cardHeight }
123- onChange = { val => {
124- setCardHeight ( val ) ;
125- forceRerender ( ) ;
135+ setAutoplayDelay ( val ) ;
126136 } }
127- displayValue = { val => `${ val } px ` }
137+ displayValue = { val => `${ val } ms ` }
128138 />
129139 </ Customize >
130140
0 commit comments