Skip to content

Commit 82e4ca6

Browse files
committed
Introduce Timeline UI component and integrate Checkpoint functionality into the Home view of the panel
1 parent 81ef0c9 commit 82e4ca6

31 files changed

Lines changed: 615 additions & 118 deletions
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@keyframes wave {
2+
0%,
3+
100% {
4+
transform: translateY(0);
5+
}
6+
25% {
7+
transform: translateY(-2px);
8+
}
9+
75% {
10+
transform: translateY(0);
11+
}
12+
}
13+
.button {
14+
display: flex;
15+
align-items: center;
16+
justify-content: center;
17+
flex-direction: column;
18+
padding: var(--padding-24px) var(--padding-12px) var(--padding-24px)
19+
var(--padding-12px);
20+
border: 1px solid var(--vscode-toolbar-hoverBackground);
21+
border-radius: var(--border-radius-10px);
22+
23+
&:hover {
24+
background-color: var(--vscode-toolbar-hoverBackground);
25+
border-color: transparent;
26+
27+
.button__label-char {
28+
animation: wave 0.5s ease-in-out;
29+
}
30+
}
31+
32+
&__label {
33+
font-family: var(--font-family-accent);
34+
font-size: 22px;
35+
line-height: 1.2;
36+
letter-spacing: 1px;
37+
}
38+
39+
&__label-char {
40+
display: inline-block;
41+
position: relative;
42+
}
43+
44+
&__pre {
45+
opacity: var(--dimmed-opacity);
46+
}
47+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ModeButton } from './ModeButton'
2+
3+
export default {
4+
component: ModeButton
5+
}
6+
7+
export const Primary = () => (
8+
<ModeButton
9+
label="Lorem ipsum"
10+
pre="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
11+
on_click={() => console.log('ModeButton button clicked')}
12+
/>
13+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import styles from './ModeButton.module.scss'
2+
3+
type Props = {
4+
label: string
5+
pre: React.ReactNode
6+
on_click: () => void
7+
}
8+
9+
export const ModeButton: React.FC<Props> = (props) => {
10+
return (
11+
<button className={styles.button} onClick={props.on_click}>
12+
<div className={styles['button__pre']}>{props.pre}</div>
13+
<div className={styles['button__label']}>
14+
{props.label.split('').map((char, index) => (
15+
<span
16+
key={index}
17+
className={styles['button__label-char']}
18+
style={{ animationDelay: `${index * 0.05}s` }}
19+
>
20+
{char == ' ' ? '\u00A0' : char}
21+
</span>
22+
))}
23+
</div>
24+
</button>
25+
)
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ModeButton'
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.timeline {
2+
display: flex;
3+
flex-direction: column;
4+
}
5+
6+
.item {
7+
display: flex;
8+
position: relative;
9+
10+
&:last-child {
11+
.timelineItem__line {
12+
display: none;
13+
}
14+
}
15+
16+
&__time {
17+
font-size: var(--font-size-11px);
18+
color: var(--cwc-text-color-dimmed);
19+
white-space: nowrap;
20+
flex-shrink: 0;
21+
width: 26vw;
22+
text-align: right;
23+
overflow: hidden;
24+
text-overflow: ellipsis;
25+
}
26+
27+
&__connector {
28+
display: flex;
29+
flex-direction: column;
30+
align-items: center;
31+
margin: 0 8px 0 4px;
32+
flex-shrink: 0;
33+
}
34+
35+
&__marker {
36+
width: 20px;
37+
height: 20px;
38+
display: flex;
39+
align-items: center;
40+
justify-content: center;
41+
z-index: 1;
42+
background-color: var(--vscode-sideBar-background);
43+
cursor: pointer;
44+
transform: translateY(-2px);
45+
position: relative;
46+
47+
.codicon-star-full {
48+
color: var(--vscode-list-focusHighlightForeground);
49+
}
50+
}
51+
52+
&__dot {
53+
width: 7px;
54+
height: 7px;
55+
background-color: var(--vscode-foreground);
56+
opacity: 0.5;
57+
border-radius: 50%;
58+
}
59+
60+
&__star-hover {
61+
position: absolute;
62+
opacity: 0;
63+
color: var(--vscode-foreground);
64+
}
65+
66+
&__marker:hover {
67+
.item__dot {
68+
opacity: 0;
69+
}
70+
71+
.item__star-hover {
72+
opacity: 1;
73+
}
74+
}
75+
76+
&__line {
77+
width: 1px;
78+
flex-grow: 1;
79+
background-color: var(--vscode-foreground);
80+
opacity: 0.2;
81+
}
82+
83+
&__content {
84+
position: relative;
85+
display: flex;
86+
flex-direction: column;
87+
gap: var(--padding-2px);
88+
margin-bottom: 12px;
89+
90+
&__label {
91+
cursor: pointer;
92+
&:hover {
93+
text-decoration: underline;
94+
}
95+
}
96+
97+
&__description {
98+
font-size: 12px;
99+
color: var(--cwc-text-color-dimmed);
100+
display: -webkit-box;
101+
-webkit-line-clamp: 2;
102+
-webkit-box-orient: vertical;
103+
overflow: hidden;
104+
}
105+
}
106+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { useState } from 'react'
2+
import { Timeline, TimelineItemProps } from './Timeline'
3+
4+
export default {
5+
component: Timeline
6+
}
7+
8+
const initialItems: TimelineItemProps[] = [
9+
{
10+
id: 1,
11+
timestamp: Date.now() - 5 * 60 * 1000,
12+
label: 'Initial checkpoint',
13+
description: 'Created the basic project structure and initial setup.',
14+
is_starred: true
15+
},
16+
{
17+
id: 2,
18+
timestamp: Date.now() - 15 * 60 * 1000,
19+
label: 'Added Authentication',
20+
description: 'Implemented user login and registration functionality.'
21+
},
22+
{
23+
id: 3,
24+
timestamp: Date.now() - 30 * 60 * 1000,
25+
label: 'Refactored UI components',
26+
description:
27+
'Split large components into smaller, reusable ones. Also improved styling across the application.'
28+
},
29+
{
30+
id: 4,
31+
timestamp: Date.now() - 60 * 60 * 1000,
32+
label: 'Fixed critical bug',
33+
description: 'Resolved an issue where users could not log out properly.',
34+
is_starred: true
35+
},
36+
{
37+
id: 5,
38+
timestamp: Date.now() - 2 * 60 * 60 * 1000,
39+
label: 'Deployed to staging',
40+
description:
41+
'Pushed the latest changes to the staging environment for testing.'
42+
}
43+
]
44+
45+
export const Default = () => {
46+
const [items, set_items] = useState(initialItems)
47+
const handle_toggle_starred = (id: string | number) => {
48+
set_items((prevItems) =>
49+
prevItems.map((item) =>
50+
item.id === id ? { ...item, is_starred: !item.is_starred } : item
51+
)
52+
)
53+
}
54+
return (
55+
<div
56+
style={{
57+
padding: '20px',
58+
backgroundColor: 'var(--vscode-sideBar-background)'
59+
}}
60+
>
61+
<Timeline
62+
items={items}
63+
on_toggle_starred={handle_toggle_starred}
64+
on_label_click={(id) => alert(`Restore checkpoint: ${id}`)}
65+
/>
66+
</div>
67+
)
68+
}
69+
70+
export const SingleItem = () => (
71+
<div
72+
style={{
73+
padding: '20px',
74+
backgroundColor: 'var(--vscode-sideBar-background)'
75+
}}
76+
>
77+
<Timeline items={[initialItems[0]]} />
78+
</div>
79+
)
80+
81+
export const NoDescription = () => (
82+
<div
83+
style={{
84+
padding: '20px',
85+
backgroundColor: 'var(--vscode-sideBar-background)'
86+
}}
87+
>
88+
<Timeline
89+
items={[
90+
{
91+
id: 1,
92+
timestamp: Date.now() - 1 * 60 * 1000,
93+
label: 'Quick save',
94+
is_starred: false
95+
}
96+
]}
97+
/>
98+
</div>
99+
)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import styles from './Timeline.module.scss'
2+
import cn from 'classnames'
3+
import dayjs from 'dayjs'
4+
import relativeTime from 'dayjs/plugin/relativeTime'
5+
import localizedFormat from 'dayjs/plugin/localizedFormat'
6+
7+
dayjs.extend(relativeTime)
8+
dayjs.extend(localizedFormat)
9+
10+
export type TimelineItemProps = {
11+
id: string | number
12+
timestamp: number
13+
label: string
14+
description?: string
15+
is_starred?: boolean
16+
}
17+
18+
type Props = {
19+
items: TimelineItemProps[]
20+
on_toggle_starred?: (id: string | number) => void
21+
on_label_click?: (id: string | number) => void
22+
}
23+
24+
export const Timeline: React.FC<Props> = ({
25+
items,
26+
on_toggle_starred,
27+
on_label_click
28+
}) => {
29+
return (
30+
<div className={styles.timeline}>
31+
{items.map((item) => (
32+
<div key={item.id} className={styles.item}>
33+
<div
34+
className={styles.item__time}
35+
title={dayjs(item.timestamp).format('LLLL')}
36+
>
37+
{dayjs(item.timestamp).fromNow()}
38+
</div>
39+
<div className={styles.item__connector}>
40+
<div
41+
className={styles.item__marker}
42+
onClick={() => on_toggle_starred?.(item.id)}
43+
>
44+
{item.is_starred ? (
45+
<span className={cn('codicon', 'codicon-star-full')} />
46+
) : (
47+
<>
48+
<div className={styles.item__dot} />
49+
<span
50+
className={cn(
51+
'codicon',
52+
'codicon-star',
53+
styles['item__star-hover']
54+
)}
55+
/>
56+
</>
57+
)}
58+
</div>
59+
<div className={styles.item__line} />
60+
</div>
61+
<div className={styles.item__content}>
62+
<div
63+
className={styles.item__content__label}
64+
onClick={() => on_label_click?.(item.id)}
65+
>
66+
{item.label}
67+
</div>
68+
{item.description && (
69+
<div
70+
className={styles.item__content__description}
71+
title={item.description}
72+
>
73+
{item.description}
74+
</div>
75+
)}
76+
</div>
77+
</div>
78+
))}
79+
</div>
80+
)
81+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Timeline'

0 commit comments

Comments
 (0)