1
+ import './Timeline.stories.css' ;
1
2
import { Meta , StoryObj } from '@storybook/react' ;
2
3
import { Fragment } from 'react' ;
3
4
import { defaultTimelineConfig , Timeline } from './Timeline' ;
5
+ import { TimelineItemsProps } from './TimelineItem' ;
4
6
5
7
export default {
6
8
component : Timeline ,
@@ -13,7 +15,7 @@ export default {
13
15
] ,
14
16
} as Meta < typeof Timeline > ;
15
17
16
- const items = [
18
+ const items : TimelineItemsProps = [
17
19
{
18
20
key : 1 ,
19
21
title : '1 First date' ,
@@ -154,3 +156,109 @@ const items = [
154
156
] ;
155
157
156
158
export const Basic : StoryObj < typeof Timeline > = { args : { items, ...defaultTimelineConfig } } ;
159
+
160
+ export const SpacingOptions : StoryObj < typeof Timeline > = {
161
+ args : {
162
+ items,
163
+ ...defaultTimelineConfig ,
164
+ gap : 100 ,
165
+ minMarkerGap : 150 ,
166
+ offset : { left : 150 , right : 50 } ,
167
+ defaultPointerOffset : 60 ,
168
+ } ,
169
+ } ;
170
+
171
+ export const LeftPositioning : StoryObj < typeof Timeline > = { args : { items, ...defaultTimelineConfig , positioning : 'left' } } ;
172
+
173
+ export const RightPositioning : StoryObj < typeof Timeline > = { args : { items, ...defaultTimelineConfig , positioning : 'right' } } ;
174
+
175
+ export const CustomStyle : StoryObj < typeof Timeline > = {
176
+ args : {
177
+ items,
178
+ ...defaultTimelineConfig ,
179
+ styleConfig : {
180
+ card : {
181
+ padding : '2rem' ,
182
+ background : 'white' ,
183
+ radius : '.2rem' ,
184
+ shadow : '.1rem .1rem .5rem rgb(0,0,0,0.1)' ,
185
+ offset : '2rem' ,
186
+ } ,
187
+ line : {
188
+ width : '.1rem' ,
189
+ color : 'gray' ,
190
+ } ,
191
+ marker : {
192
+ color : 'hotpink' ,
193
+ radius : '.2rem' ,
194
+ size : '1.2rem' ,
195
+ } ,
196
+ pointer : {
197
+ width : '2rem' ,
198
+ height : '2rem' ,
199
+ } ,
200
+ } ,
201
+ } ,
202
+ } ;
203
+
204
+ export const CustomCSS : StoryObj < typeof Timeline > = {
205
+ args : {
206
+ items,
207
+ ...defaultTimelineConfig ,
208
+ className : 'timeline--styled' ,
209
+ styleConfig : {
210
+ card : {
211
+ padding : '2rem' ,
212
+ background : 'white' ,
213
+ radius : '.2rem' ,
214
+ shadow : '.1rem .1rem .5rem rgb(0,0,0,0.1)' ,
215
+ } ,
216
+ line : {
217
+ width : '.1rem' ,
218
+ color : 'gray' ,
219
+ } ,
220
+ } ,
221
+ } ,
222
+ } ;
223
+
224
+ export const CustomContent : StoryObj < typeof Timeline > = {
225
+ args : {
226
+ items : [
227
+ {
228
+ key : '1' ,
229
+ date : new Date ( ) ,
230
+ title : 'Lorem, ipsum dolor.' ,
231
+ children : (
232
+ < Fragment >
233
+ < p >
234
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Hic perspiciatis voluptatum at deleniti ut et incidunt eos ab.
235
+ Cumque, atque. < a href = "https://google.com" > Go here!</ a >
236
+ </ p >
237
+ < img
238
+ src = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/SMPTE_Color_Bars.svg/1200px-SMPTE_Color_Bars.svg.png"
239
+ alt = "test"
240
+ />
241
+ < p />
242
+ < button type = "button" > Learn more ></ button >
243
+ </ Fragment >
244
+ ) ,
245
+ } ,
246
+ ] ,
247
+ } ,
248
+ } ;
249
+
250
+ const customItems = [ ...items ] ;
251
+ customItems [ 3 ] = {
252
+ ...items [ 3 ] ,
253
+ customMarker : < span style = { { fontSize : '2rem' } } > 😵💫</ span > ,
254
+ customPointer : < div className = "pointy" style = { { backgroundColor : 'green' } } /> ,
255
+ } ;
256
+
257
+ export const CustomMarkerAndPointer : StoryObj < typeof Timeline > = {
258
+ args : {
259
+ items : customItems ,
260
+ ...defaultTimelineConfig ,
261
+ customMarker : < span style = { { fontSize : '2rem' } } > 🔥</ span > ,
262
+ customPointer : < div className = "pointy" /> ,
263
+ } ,
264
+ } ;
0 commit comments