|
1 | 1 | <script lang="ts">
|
2 |
| - // Define types for news items |
| 2 | + /** |
| 3 | + * Represents a single news item in the What's New section |
| 4 | + */ |
3 | 5 | interface NewsItem {
|
| 6 | + /** The date of the news item (e.g., "June 2025") */ |
4 | 7 | date: string;
|
| 8 | + /** The main content/description of the news item */ |
5 | 9 | content: string;
|
| 10 | + /** Optional URL to release notes or more information */ |
6 | 11 | releaseNotesUrl?: string;
|
| 12 | + /** Optional version number for releases (e.g., "v0.1.16") */ |
7 | 13 | releaseVersion?: string;
|
| 14 | + /** Optional array of component links to display as a bulleted list */ |
8 | 15 | componentLinks?: Array<{
|
| 16 | + /** Display text for the link */ |
9 | 17 | text: string;
|
| 18 | + /** URL/href for the link */ |
10 | 19 | href: string;
|
11 | 20 | }>;
|
12 | 21 | }
|
13 | 22 |
|
| 23 | + /** |
| 24 | + * WhatsNew Component |
| 25 | + * |
| 26 | + * A flexible component for displaying news, updates, and release information. |
| 27 | + * Commonly used on homepages or documentation sites to communicate recent changes, |
| 28 | + * new features, or important announcements to users. |
| 29 | + * |
| 30 | + * @example |
| 31 | + * ```svelte |
| 32 | + * <!-- Basic usage with defaults --> |
| 33 | + * <WhatsNew /> |
| 34 | + * |
| 35 | + * <!-- Custom usage --> |
| 36 | + * <WhatsNew |
| 37 | + * title="Latest Updates" |
| 38 | + * titleId="updates" |
| 39 | + * componentLinksIntroText="New components available:" |
| 40 | + * newsItems={[ |
| 41 | + * { |
| 42 | + * date: "June 2025", |
| 43 | + * content: "Released new component library", |
| 44 | + * releaseNotesUrl: "https://github.com/example/releases/tag/v1.0.0", |
| 45 | + * releaseVersion: "v1.0.0", |
| 46 | + * componentLinks: [ |
| 47 | + * { text: "Button component", href: "/components/button" } |
| 48 | + * ] |
| 49 | + * } |
| 50 | + * ]} |
| 51 | + * /> |
| 52 | + * ``` |
| 53 | + */ |
| 54 | +
|
14 | 55 | // Define component props with types and default values
|
15 | 56 | let {
|
| 57 | + /** The main heading text for the news section */ |
16 | 58 | title = "What's new",
|
| 59 | + /** The HTML id attribute for the heading element (useful for anchor links) */ |
17 | 60 | titleId = "whats-new",
|
| 61 | + /** |
| 62 | + * Introductory text that appears before component links lists. |
| 63 | + * Set to empty string to hide this text entirely. |
| 64 | + */ |
18 | 65 | componentLinksIntroText = "This the first step to refresh the GOV.UK brand. It includes updates to the:",
|
| 66 | + /** |
| 67 | + * Array of news items to display. Each item can include: |
| 68 | + * - date: When the news occurred |
| 69 | + * - content: Main description |
| 70 | + * - releaseNotesUrl & releaseVersion: For linking to release notes |
| 71 | + * - componentLinks: For displaying related component links |
| 72 | + */ |
19 | 73 | newsItems = [
|
20 | 74 | {
|
21 | 75 | date: "15 May 2025",
|
|
0 commit comments