Skip to content

Commit 1ab3312

Browse files
committed
feat: custom-timeline-states
1 parent 51f8e80 commit 1ab3312

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

src/examples/timeline.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const TimelineProgress = () => (
9393
party: "No",
9494
subtitle: "06 Jul 2023 12:00 UTC",
9595
variant: "#ca2314",
96+
state: "loading",
9697
},
9798
]}
9899
/>

src/lib/progress/timeline/bullet.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useRef } from "react";
2-
import styled from "styled-components";
2+
import styled, { css, keyframes } from "styled-components";
33
import Spine, { VariantProp, variantColor } from "./spine";
44
export type { VariantProp };
55
import { h2, p, small } from "../../../styles/common-style";
@@ -8,10 +8,34 @@ export interface SideProp {
88
rightSided?: boolean;
99
}
1010

11-
const Wrapper = styled.div<SideProp>`
11+
export interface StateProp {
12+
state?: "loading" | "disabled" | "active";
13+
}
14+
15+
const loading = keyframes`
16+
0%{
17+
opacity: 1;
18+
}
19+
50%{
20+
opacity: 0.5;
21+
}
22+
100%{
23+
opacity: 1;
24+
}
25+
`;
26+
27+
const Wrapper = styled.div<SideProp & StateProp>`
1228
display: flex;
29+
position: relative;
30+
opacity: ${({ state }) => (!state || state === "active" ? 1 : 0.5)};
1331
justify-content: ${({ rightSided }) =>
1432
rightSided ? "flex-start" : "flex-end"};
33+
${({ state }) =>
34+
state === "loading"
35+
? css`
36+
animation: ${loading} 2s ease-in-out infinite normal;
37+
`
38+
: "none"};
1539
`;
1640

1741
const StyledTitle = styled.h2``;
@@ -78,7 +102,7 @@ const PartyTitleContainer = styled.div<SideProp>`
78102
rightSided ? "flex-start" : "flex-end"};
79103
`;
80104

81-
interface BulletProps extends VariantProp, SideProp {
105+
interface BulletProps extends VariantProp, SideProp, StateProp {
82106
title: string;
83107
party: string | React.ReactElement;
84108
subtitle: string;
@@ -90,14 +114,17 @@ interface BulletProps extends VariantProp, SideProp {
90114

91115
const Bullet: React.FC<BulletProps> = (props) => {
92116
const { title, party, subtitle, ...restProps } = props;
93-
const { rightSided, variant, line, Icon, isLast, ...wrapperProps } =
117+
const { rightSided, variant, line, Icon, isLast, state, ...wrapperProps } =
94118
restProps;
95119
const titleRef = useRef<HTMLHeadingElement>(null);
96120

97121
return (
98-
<Wrapper {...{ rightSided }} {...wrapperProps}>
122+
<Wrapper {...{ rightSided, state }} {...wrapperProps}>
99123
<Spine {...{ variant, line, Icon, titleRef }} />
100-
<TextContainer {...{ variant, rightSided, isLast }}>
124+
<TextContainer
125+
className="text-container"
126+
{...{ variant, rightSided, isLast }}
127+
>
101128
<PartyTitleContainer {...{ rightSided }}>
102129
<StyledTitle ref={titleRef}>{title}</StyledTitle>
103130
{typeof party === `string` ? (

src/lib/progress/timeline/custom.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from "react";
22
import styled from "styled-components";
3-
import Bullet, { SideProp, VariantProp } from "./bullet";
3+
import Bullet, { SideProp, StateProp, VariantProp } from "./bullet";
44
import { borderBox } from "../../../styles/common-style";
55

6-
interface TimelineItem extends SideProp, VariantProp {
6+
interface TimelineItem extends SideProp, VariantProp, StateProp {
77
title: string;
88
party: string | React.ReactElement;
99
subtitle: string;

0 commit comments

Comments
 (0)