Skip to content

Commit 75d0fc3

Browse files
committed
feat: improve customization trough css properties
1 parent e6c3f56 commit 75d0fc3

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

src/components/Timeline.css

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
:where(.timeline) {
22
--line-width: 0.2rem;
33
--line-color: black;
4-
--marker-mark-size: 1rem;
5-
--marker-mark-color: var(--line-color);
6-
--marker-mark-radius: 50%;
7-
--marker-offset: 2rem;
4+
--marker-size: 1rem;
5+
--marker-color: var(--line-color);
6+
--marker-radius: 50%;
7+
--marker-offset: 3rem;
88
--pointer-height: 2rem;
99
--pointer-width: 1rem;
10+
--card-background: whitesmoke;
11+
--card-radius: 0.1rem;
12+
--card-offset: 1rem;
13+
--card-shadow: unset;
14+
--card-padding: 1rem;
1015

1116
position: relative;
1217
}
@@ -26,7 +31,7 @@
2631
display: flex;
2732
align-items: flex-start;
2833
transition: top 0.1s;
29-
gap: 1rem;
34+
gap: var(--card-offset);
3035
}
3136

3237
.timeline-item--left {
@@ -39,10 +44,10 @@
3944
}
4045

4146
.timeline-item__marker {
42-
border-radius: var(--marker-mark-radius);
43-
width: var(--marker-mark-size);
44-
height: var(--marker-mark-size);
45-
background-color: var(--marker-mark-color);
47+
border-radius: var(--marker-radius);
48+
width: var(--marker-size);
49+
height: var(--marker-size);
50+
background-color: var(--marker-color);
4651
margin-top: var(--marker-offset);
4752
}
4853

@@ -54,13 +59,14 @@
5459
}
5560

5661
.timeline-card {
57-
background-color: white;
58-
border: 0.2rem solid black;
59-
padding: 1rem;
62+
background-color: var(--card-background);
63+
border-radius: var(--card-radius);
64+
padding: var(--card-padding);
6065
display: flex;
6166
flex-direction: column;
6267
flex: 1;
6368
position: relative;
69+
filter: drop-shadow(var(--card-shadow));
6470
}
6571

6672
.timeline-card img {
@@ -72,9 +78,13 @@
7278
margin-left: auto;
7379
}
7480

81+
.timeline-card__title {
82+
font-weight: bold;
83+
}
84+
7585
.timeline-card__pointer {
7686
clip-path: polygon(0% 0%, 0% 100%, 100% 50%);
77-
background-color: white;
87+
background-color: var(--card-background);
7888
top: var(--marker-offset);
7989
width: var(--pointer-width);
8090
height: var(--pointer-height);

src/components/Timeline.stories.css

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@
66
.styled-timeline {
77
--line-width: 2px;
88
--line-color: gray;
9-
--marker-inner-color: hotpink;
109
--marker-color: gray;
11-
--marker-size: 1.5rem;
10+
--card-background: white;
11+
--card-shadow: 2px 2px 5px rgb(0, 0, 0, 0.1);
12+
--card-padding: 2rem;
1213

1314
font-family: sans-serif;
1415
line-height: 1.4;
1516
}
1617

17-
.styled-timeline .timeline-card {
18-
border: none;
19-
padding: 2rem;
20-
border-radius: 0.2rem;
21-
filter: drop-shadow(2px 2px 5px rgb(0, 0, 0, 0.2));
22-
}
23-
2418
.styled-timeline .timeline-card__title {
2519
font-size: 1.5rem;
2620
margin-bottom: 1rem;

src/components/Timeline.stories.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const items = [
4949
<Story name="Basic">
5050
<Timeline
5151
items={items}
52+
offset={{ left: 100, right: 200 }}
5253
/>
5354

5455
</Story>

0 commit comments

Comments
 (0)