Skip to content

Commit fcfbea2

Browse files
Merge pull request #29 from steven-mercatante/revert-event-styled-components
revert event styled components
2 parents 7aed825 + 12792e0 commit fcfbea2

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

src/components/events/Event.js

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,32 @@ import TimelineContext from '../../TimelineContext';
88
import { joinClassNames } from '../../utils/classNames';
99
import 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

3538
const 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

9897
export default function Event({ date, marker, children, className, card }) {
9998
const { layout } = useContext(TimelineContext);

0 commit comments

Comments
 (0)