@@ -8,29 +8,32 @@ import TimelineContext from '../../TimelineContext';
88import { joinClassNames } from '../../utils/classNames' ;
99import LAYOUTS from '../../constants/layouts' ;
1010
11- const Container = styled . div `
12- && {
13- position: relative;
14- display: flex;
15- margin-bottom: ${ props => props . theme . event . marginBottom } ;
16-
17- :nth-child(1) {
18- margin-top: ${ props => props . theme . event . marginBottom } ;
19- }
11+ const Container = styled . div ( props => {
12+ const defaults = {
13+ position : 'relative' ,
14+ display : 'flex' ,
2015
21- :nth-child(even) {
22- flex-direction: row-reverse;
23- }
16+ ' :nth-child(1)' : {
17+ marginTop : props . theme . event . marginBottom ,
18+ } ,
2419
25- &. ${ LAYOUTS . INLINE_EVENTS } , &. ${ LAYOUTS . INLINE_EVENTS_INLINE_DATE } {
26- flex-direction: row !important;
27- }
20+ ':nth-child(even)' : {
21+ flexDirection : ' row-reverse' ,
22+ } ,
2823
29- @media (max-width: 768px) {
30- flex-direction: row !important;
31- }
32- }
33- ` ;
24+ [ `&.${ LAYOUTS . INLINE_EVENTS } , &.${ LAYOUTS . INLINE_EVENTS_INLINE_DATE } ` ] : {
25+ flexDirection : 'row !important' ,
26+ } ,
27+
28+ '@media (max-width: 768px)' : {
29+ flexDirection : 'row !important' ,
30+ } ,
31+ } ;
32+
33+ const style = { ...defaults , ...props . theme . event } ;
34+
35+ return style ;
36+ } ) ;
3437
3538const DateColumn = styled . div ( {
3639 display : 'flex' ,
@@ -63,37 +66,33 @@ const DateColumn = styled.div({
6366 } ,
6467} ) ;
6568
66- const MarkerColumn = styled . div `
67- && {
68- display: flex;
69- flex-direction: column;
70- justify-content: center;
71- align-items: center;
72- flex-basis: 40px;
73- flex-shrink: 0;
74- z-index: 200;
75- }
76- ` ;
77-
78- const CardColumn = styled . div `
79- && {
80- display: flex;
81- flex-direction: column;
82- justify-content: flex-start;
83- flex-basis: 50%;
84- flex-grow: 1;
85-
86- &.${ LAYOUTS . ALTERNATE_EVENTS } , &.${ LAYOUTS . ALTERNATE_EVENTS_INLINE_DATE } {
87- ${ Container } :nth-child(even) & {
88- align-items: flex-end;
89- }
90- }
69+ const MarkerColumn = styled . div ( {
70+ display : 'flex' ,
71+ flexDirection : 'column' ,
72+ justifyContent : 'center' ,
73+ alignItems : 'center' ,
74+ flexBasis : '40px' ,
75+ flexShrink : 0 ,
76+ zIndex : 200 ,
77+ } ) ;
9178
92- @media (max-width: 768px) : {
93- align-items: flex-start !important;
94- }
95- }
96- ` ;
79+ const CardColumn = styled . div ( {
80+ display : 'flex' ,
81+ flexDirection : 'column' ,
82+ justifyContent : 'flex-start' ,
83+ flexBasis : '50%' ,
84+ flexGrow : '1' ,
85+
86+ [ `&.${ LAYOUTS . ALTERNATE_EVENTS } , &.${ LAYOUTS . ALTERNATE_EVENTS_INLINE_DATE } ` ] : {
87+ [ `${ Container } :nth-child(even) &` ] : {
88+ alignItems : 'flex-end' ,
89+ } ,
90+ } ,
91+
92+ '@media (max-width: 768px)' : {
93+ alignItems : 'flex-start !important' ,
94+ } ,
95+ } ) ;
9796
9897export default function Event ( { date, marker, children, className, card } ) {
9998 const { layout } = useContext ( TimelineContext ) ;
0 commit comments