|
| 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 | +) |
0 commit comments