Skip to content

Commit 18b8e37

Browse files
add TS docs
1 parent 00b1234 commit 18b8e37

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

src/lib/components/ui/WhatsNew.svelte

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,75 @@
11
<script lang="ts">
2-
// Define types for news items
2+
/**
3+
* Represents a single news item in the What's New section
4+
*/
35
interface NewsItem {
6+
/** The date of the news item (e.g., "June 2025") */
47
date: string;
8+
/** The main content/description of the news item */
59
content: string;
10+
/** Optional URL to release notes or more information */
611
releaseNotesUrl?: string;
12+
/** Optional version number for releases (e.g., "v0.1.16") */
713
releaseVersion?: string;
14+
/** Optional array of component links to display as a bulleted list */
815
componentLinks?: Array<{
16+
/** Display text for the link */
917
text: string;
18+
/** URL/href for the link */
1019
href: string;
1120
}>;
1221
}
1322
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+
1455
// Define component props with types and default values
1556
let {
57+
/** The main heading text for the news section */
1658
title = "What's new",
59+
/** The HTML id attribute for the heading element (useful for anchor links) */
1760
titleId = "whats-new",
61+
/**
62+
* Introductory text that appears before component links lists.
63+
* Set to empty string to hide this text entirely.
64+
*/
1865
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+
*/
1973
newsItems = [
2074
{
2175
date: "15 May 2025",

0 commit comments

Comments
 (0)