Skip to content

Commit 2eeb4e7

Browse files
committed
docs: add more timeline stories
1 parent 3c6471f commit 2eeb4e7

File tree

2 files changed

+120
-13
lines changed

2 files changed

+120
-13
lines changed

src/components/Timeline.stories.css

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
.styled-timeline * {
1+
.timeline--styled :where(*) {
22
margin: 0;
33
padding: 0;
44
}
55

6-
.styled-timeline {
7-
--line-width: 2px;
8-
--line-color: gray;
9-
--marker-color: gray;
10-
--card-background: white;
11-
--card-shadow: 2px 2px 5px rgb(0, 0, 0, 0.1);
12-
--card-padding: 2rem;
13-
6+
.timeline--styled {
147
font-family: sans-serif;
158
line-height: 1.4;
169
}
1710

18-
.styled-timeline .timeline-card__title {
11+
.timeline--styled .timeline-card__title {
1912
font-size: 1.5rem;
2013
margin-bottom: 1rem;
21-
font-weight: bold;
2214
}
2315

24-
.styled-timeline img {
16+
.timeline--styled img {
2517
margin-top: 1rem;
2618
}
19+
20+
.pointy {
21+
clip-path: polygon(0% 0%, 0% 100%, 100% 50%);
22+
background-color: red;
23+
height: 1rem;
24+
width: 1rem;
25+
}

src/components/Timeline.stories.tsx

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import './Timeline.stories.css';
12
import { Meta, StoryObj } from '@storybook/react';
23
import { Fragment } from 'react';
34
import { defaultTimelineConfig, Timeline } from './Timeline';
5+
import { TimelineItemsProps } from './TimelineItem';
46

57
export default {
68
component: Timeline,
@@ -13,7 +15,7 @@ export default {
1315
],
1416
} as Meta<typeof Timeline>;
1517

16-
const items = [
18+
const items: TimelineItemsProps = [
1719
{
1820
key: 1,
1921
title: '1 First date',
@@ -154,3 +156,109 @@ const items = [
154156
];
155157

156158
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 &gt;</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

Comments
 (0)