Skip to content

Commit 62a182c

Browse files
Add base info
1 parent 48f9fa7 commit 62a182c

File tree

3 files changed

+79
-35
lines changed

3 files changed

+79
-35
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
.time-span-bar {
2+
border: 1px solid #fae6c6;
3+
padding: 12px 16px;
4+
border-radius: 4px;
5+
display: flex;
6+
flex-direction: column;
7+
gap: 8px;
8+
}
9+
10+
.time-span-bar__content {
211
display: flex;
312
flex-direction: row;
4-
align-items: center;
5-
justify-content: center;
13+
gap: 8px;
614
}

components/TimeSpanBar/TimeSpanBar.stories.tsx

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ const meta: Meta<typeof TimeSpanBar> = {
1212
argTypes: {
1313
startDate: { control: "date" },
1414
endDate: { control: "date" },
15-
width: { control: "number" },
16-
height: { control: "number" },
17-
backgroundColor: { control: "color" },
18-
borderRadius: { control: "number" },
15+
events: {
16+
control: "multi-select",
17+
options: ["Event 1", "Event 2", "Event 3", "Event 4"],
18+
mapping: {
19+
"Event 1": { name: "Event 1", date: new Date("2024-02-15") },
20+
"Event 2": { name: "Event 2", date: new Date("2024-04-20") },
21+
"Event 3": { name: "Event 3", date: new Date("2024-06-10") },
22+
"Event 4": { name: "Event 4", date: new Date("2024-08-30") },
23+
},
24+
},
1925
},
2026
};
2127

@@ -25,32 +31,14 @@ type Story = StoryObj<typeof TimeSpanBar>;
2531
// Basic example
2632
export const Default: Story = {
2733
args: {
28-
startDate: new Date("2024-01-01"),
29-
endDate: new Date("2024-12-31"),
30-
width: 300,
31-
height: 20,
32-
},
33-
};
34-
35-
// Short time span
36-
export const ShortTimeSpan: Story = {
37-
args: {
38-
startDate: new Date("2024-03-01"),
39-
endDate: new Date("2024-03-07"),
40-
width: 300,
41-
height: 20,
42-
backgroundColor: "#e0e0e0",
43-
},
44-
};
45-
46-
// Custom styled
47-
export const CustomStyled: Story = {
48-
args: {
49-
startDate: new Date("2024-01-01"),
50-
endDate: new Date("2024-06-30"),
51-
width: 400,
52-
height: 30,
53-
backgroundColor: "#4CAF50",
54-
borderRadius: 15,
34+
header: "Хрущёв, Никита Сергеевич",
35+
image:
36+
"https://upload.wikimedia.org/wikipedia/commons/c/c5/Bundesarchiv_Bild_183-B0628-0015-035%2C_Nikita_S._Chruschtschow.jpg?uselang=ru",
37+
startDate: new Date("1894-04-15"),
38+
endDate: new Date("1971-09-11"),
39+
events: [
40+
{ name: "Event 1", date: new Date("2024-02-15") },
41+
{ name: "Event 2", date: new Date("2024-04-20") },
42+
],
5543
},
5644
};

components/TimeSpanBar/TimeSpanBar.tsx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,56 @@ import React from "react";
22

33
import "./TimeSpanBar.css";
44

5-
const TimeSpanBar = () => {
6-
return <div className="time-span-bar">TimeSpanBar</div>;
5+
type TimeSpanBarProps = {
6+
startDate: Date;
7+
endDate?: Date;
8+
events: {
9+
name: string;
10+
date: Date;
11+
}[];
12+
header: string;
13+
image: string;
14+
};
15+
16+
const TimeSpanBar = ({
17+
startDate,
18+
endDate,
19+
events,
20+
header,
21+
image,
22+
}: TimeSpanBarProps) => {
23+
return (
24+
<div className="time-span-bar">
25+
<div className="time-span-bar__header">{header}</div>
26+
<div className="time-span-bar__content">
27+
<div className="time-span-bar__start-date">
28+
<div className="time-span-bar__label">Дата рождения</div>
29+
<div className="time-span-bar__date">
30+
{startDate.toLocaleDateString()}
31+
</div>
32+
</div>
33+
<img
34+
width={64}
35+
src={image}
36+
alt={header}
37+
className="time-span-bar__image"
38+
/>
39+
<div className="time-span-bar__events">
40+
{events.map((event) => (
41+
<div className="time-span-bar__event">{event.name}</div>
42+
))}
43+
</div>
44+
{endDate && (
45+
<div className="time-span-bar__end-date">
46+
<div className="time-span-bar__label">Дата смерти</div>
47+
<div className="time-span-bar__date">
48+
{endDate.toLocaleDateString()}
49+
</div>
50+
</div>
51+
)}
52+
</div>
53+
</div>
54+
);
755
};
856

957
export { TimeSpanBar };

0 commit comments

Comments
 (0)