|
| 1 | +import React, { useState, useEffect } from 'react'; |
| 2 | + |
| 3 | +export interface ReleaseNote { |
| 4 | + version: string; |
| 5 | + date: string; |
| 6 | + changes: string[]; |
| 7 | +} |
| 8 | + |
| 9 | +export const ReleaseNotes: React.FC = () => { |
| 10 | + const [notes, setNotes] = useState<ReleaseNote[]>([]); |
| 11 | + const [loading, setLoading] = useState(true); |
| 12 | + |
| 13 | + useEffect(() => { |
| 14 | + // Simulate fetching release notes |
| 15 | + const fetchNotes = async () => { |
| 16 | + try { |
| 17 | + // Mock data |
| 18 | + const data: ReleaseNote[] = [ |
| 19 | + { |
| 20 | + version: '1.2.0', |
| 21 | + date: '2026-05-30', |
| 22 | + changes: ['Added Lazy Loading support', 'Improved performance', 'Fixed bugs'], |
| 23 | + }, |
| 24 | + { |
| 25 | + version: '1.1.0', |
| 26 | + date: '2026-05-15', |
| 27 | + changes: ['Added Release Notes feature', 'Updated dependencies'], |
| 28 | + }, |
| 29 | + ]; |
| 30 | + |
| 31 | + // Simulate network delay |
| 32 | + await new Promise(resolve => setTimeout(resolve, 500)); |
| 33 | + setNotes(data); |
| 34 | + } catch (error) { |
| 35 | + console.error('Failed to fetch release notes:', error); |
| 36 | + } finally { |
| 37 | + setLoading(false); |
| 38 | + } |
| 39 | + }; |
| 40 | + |
| 41 | + fetchNotes(); |
| 42 | + }, []); |
| 43 | + |
| 44 | + if (loading) { |
| 45 | + return <div className="p-4 animate-pulse bg-gray-100 dark:bg-gray-800 rounded-lg h-32" data-testid="loading-skeleton"></div>; |
| 46 | + } |
| 47 | + |
| 48 | + return ( |
| 49 | + <div className="release-notes space-y-4 p-4 border rounded-lg shadow-sm bg-white dark:bg-gray-900 dark:border-gray-700"> |
| 50 | + <h2 className="text-2xl font-bold mb-4">Release Notes</h2> |
| 51 | + {notes.length === 0 ? ( |
| 52 | + <p>No release notes available.</p> |
| 53 | + ) : ( |
| 54 | + <ul className="space-y-4"> |
| 55 | + {notes.map((note) => ( |
| 56 | + <li key={note.version} className="border-b pb-4 last:border-b-0 dark:border-gray-800"> |
| 57 | + <h3 className="text-lg font-semibold text-blue-600 dark:text-blue-400"> |
| 58 | + v{note.version} <span className="text-sm font-normal text-gray-500 dark:text-gray-400">({note.date})</span> |
| 59 | + </h3> |
| 60 | + <ul className="list-disc pl-5 mt-2 space-y-1"> |
| 61 | + {note.changes.map((change, idx) => ( |
| 62 | + <li key={idx} className="text-gray-700 dark:text-gray-300">{change}</li> |
| 63 | + ))} |
| 64 | + </ul> |
| 65 | + </li> |
| 66 | + ))} |
| 67 | + </ul> |
| 68 | + )} |
| 69 | + </div> |
| 70 | + ); |
| 71 | +}; |
| 72 | + |
| 73 | +export default ReleaseNotes; |
0 commit comments