1
1
# react-alternating-timeline
2
2
3
- A compact, masonry style alternating timeline react component which is fully customizable.
3
+ A simple and compact, true masonry style alternating timeline react component which is fully customizable and free stylable .
4
4
5
5
![ Demonstration] ( ./docs/demonstration.jpg )
6
6
@@ -57,7 +57,7 @@ The available properties of the `Timeline` component:
57
57
| ` formatDate? ` | ` (date: Date) => string ` | Callback to format date | |
58
58
| ` customMarker? ` | ` ReactElement ` | Custom maker element replacing the default | |
59
59
| ` customPointer? ` | ` ReactElement ` | Custom pointer element replacing the default | |
60
- | ` styleConfig? ` | [ ` StyleConfig ` ] ( #styleconfig ) | Style config object for customizing timeline by setting css custom properties | |
60
+ | ` styleConfig? ` | [ ` StyleConfig ` ] ( #styling ) | Style config object for customizing timeline by setting css custom properties | |
61
61
| ` className? ` | ` string ` | Additional class name | |
62
62
63
63
### TimelineItemsProps
@@ -74,65 +74,94 @@ An array of the following properties:
74
74
| ` customMarker? ` | ` ReactElement ` | Overwriting ` customMarker ` property of parent ` Timeline ` |
75
75
| ` customPointer? ` | ` ReactElement ` | Overwriting ` customPointer ` property of parent ` Timeline ` |
76
76
77
- ### StyleConfig
77
+ ## Styling
78
78
79
- The style can either be passed as a javascript object...
79
+ The style can either be passed as an object through the ` styleConfig ` property ...
80
80
81
81
``` ts
82
82
{
83
83
line ?: {
84
- width?: string ;
85
- color ?: string ;
84
+ width?: CSSProperties [' width' ];
85
+ color ?: CSSProperties [' backgroundColor' ];
86
+ overhang ?: CSSProperties [' paddingBlock' ];
86
87
};
87
- gap ?: string ;
88
- offset ?: {
89
- left?: string ;
90
- right ?: string ;
88
+ item ?: {
89
+ gap?: CSSProperties [' gap' ];
90
+ startOffset ?: {
91
+ left?: CSSProperties [' marginTop' ];
92
+ right ?: CSSProperties [' marginTop' ];
93
+ };
91
94
};
92
95
marker ?: {
93
- size?: string ;
94
- color ?: string ;
95
- radius ?: string ;
96
+ size?: CSSProperties [ ' width ' ] ;
97
+ color ?: CSSProperties [ ' backgroundColor ' ] ;
98
+ radius ?: CSSProperties [ ' borderRadius ' ] ;
96
99
};
97
100
pointer ?: {
98
- height?: string ;
99
- width ?: string ;
100
- offset ?: string ;
101
+ height?: CSSProperties [ ' height ' ] ;
102
+ width ?: CSSProperties [ ' width ' ] ;
103
+ minOffset ?: CSSProperties [ ' marginTop ' ] ;
101
104
};
102
105
card ?: {
103
- background?: string ;
104
- radius ?: string ;
105
- offset ?: string ;
106
- shadow ?: string ;
107
- padding ?: string ;
106
+ background?: CSSProperties [ ' backgroundColor ' ] ;
107
+ radius ?: CSSProperties [ ' borderRadius ' ] ;
108
+ shadow ?: CSSProperties [ ' boxShadow ' ] ;
109
+ padding ?: CSSProperties [ ' padding ' ] ;
110
+ offset ?: CSSProperties [ ' gap ' ] ;
108
111
};
109
- };
112
+ }
110
113
```
111
114
112
- ...or the custom properties can be set directly in css
115
+ ...or can be set as custom properties directly in css
113
116
114
117
``` css
115
118
.timeline {
116
119
--line-width : 0.2rem ;
117
120
--line-color : black ;
121
+ --line-overhang : 1rem ;
122
+ --item-gap : 1rem ;
123
+ --item-start-offset-left : 0 ;
124
+ --item-start-offset-right : 5rem ;
118
125
--marker-size : 1rem ;
119
126
--marker-color : var (--line-color );
120
127
--marker-radius : 50% ;
121
128
--pointer-height : 2rem ;
122
129
--pointer-width : 1rem ;
123
- --pointer-offset : 5rem ;
130
+ --pointer-min- offset : 5rem ;
124
131
--card-background : whitesmoke ;
125
132
--card-radius : 0.1rem ;
126
- --card-offset : 1rem ;
127
133
--card-shadow : unset ;
128
134
--card-padding : 1rem ;
129
- --gap : 1rem ;
130
- --offset-left : 0 ;
131
- --offset-right : 5rem ;
135
+ --card-offset : 1rem ;
132
136
}
133
137
```
134
138
135
- (These are the default values)
139
+ ### StyleConfig
140
+
141
+ | Name | Description | Default |
142
+ | :------------------------- | :------------------------------------------------------------------------------------------------------------- | :------------ |
143
+ | ** Line** | The line the timeline items are place around/beside | |
144
+ | – ` line-width ` | Width of the line | ` 0.2rem ` |
145
+ | – ` line-color ` | Color of the line | ` black ` |
146
+ | – ` line-overhang ` | How much the line should overhang the beginning and end of the timeline component | ` 1rem ` |
147
+ | ** Item** | The timeline item as a whole, including the card, pointer and marker | |
148
+ | – ` item-gap ` | The vertical space between the items | ` 1rem ` |
149
+ | – ` item-start-offset-left ` | How much the items on the left side should be offset from the top | ` 0 ` |
150
+ | – ` item-start-offset-left ` | How much the items on the right side should be offset from the top | ` 5rem ` |
151
+ | ** Marker** | The markers on the line which marks the chronological order of the timeline items | ` 1rem ` |
152
+ | – ` marker-size ` | Size of the default marker | ` 1rem ` |
153
+ | – ` marker-color ` | Color of the default marker | ` line-color ` |
154
+ | – ` marker-radius ` | Border radius (roundness) of the marker edges | ` 50% ` (round) |
155
+ | ** Pointer** | The pointers pointing from the item cards to the markers on the line | |
156
+ | – ` pointer-height ` | Height of the default pointer | ` 2rem ` |
157
+ | – ` pointer-width ` | Width of the default pointer | ` 1rem ` |
158
+ | – ` pointer-min-offset ` | Minimum offset of the pointer to the top of the card. The actual offset depends on the ` minMarkerGap ` property | ` 5rem ` |
159
+ | ** Card** | The cards in which the timeline item content is displayed | |
160
+ | – ` card-background ` | Background color of the card | ` whitesmoke ` |
161
+ | – ` card-radius ` | Border radius of the card edges | ` 0.1rem ` |
162
+ | – ` card-shadow ` | Configure drop shadow of the card | ` unset ` |
163
+ | – ` card-padding ` | Padding of the card content | ` 1rem ` |
164
+ | – ` card-offset ` | Space between the card and the timeline line | ` 1rem ` |
136
165
137
166
## Demo
138
167
0 commit comments