Skip to content

Commit 8a7e310

Browse files
add wrapper page and examples
1 parent 18b8e37 commit 8a7e310

File tree

3 files changed

+197
-162
lines changed

3 files changed

+197
-162
lines changed

src/wrappers/components/ui/WhatsNewWrapper.svelte

Lines changed: 74 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
* ? Tested - The component's use within products or prototyping (i.e. in a real-use example, using real props) has been tested and approved.
2727
*/
2828
let statusObject = {
29-
progress: "To be developed",
29+
progress: "Baseline completed",
3030
statusRows: [
3131
{
32-
obj: { Accessible: false, Responsive: false, "Prog. enhanced": false },
33-
visibleOnHompepage: false,
32+
obj: { Accessible: false, Responsive: true, "Prog. enhanced": false },
33+
visibleOnHompepage: true,
3434
},
3535
{
3636
obj: { Reviewed: false, Tested: false },
37-
visibleOnHomepage: false,
37+
visibleOnHomepage: true,
3838
},
3939
],
4040
};
@@ -46,10 +46,16 @@
4646
* ? You can add other categories to the detailsArray or, if you need a more flexible solution, edit the WrapperInformation snippet directly.
4747
*
4848
*/
49-
let descriptionArray = ["Explain here what the component does."];
49+
let descriptionArray = [
50+
"The WhatsNew component displays news, updates, and release information in a structured format. It's designed to communicate recent changes, new features, or important announcements to users.",
51+
"The component supports flexible content including dates, descriptions, release notes links, and related component links displayed as bulleted lists.",
52+
];
5053
5154
let contextArray = [
52-
"Explain here the different contexts in which the component should be used.",
55+
"Use the WhatsNew component on homepages or documentation sites to highlight recent updates and changes.",
56+
"Include it in service dashboards to communicate new features or important announcements to users.",
57+
"Use it in component libraries to showcase new components or updates to existing ones.",
58+
"Consider using it in admin interfaces to keep users informed about system updates and improvements.",
5359
];
5460
5561
let detailsArray = [
@@ -70,7 +76,26 @@
7076
/**
7177
* CUSTOMISETHIS Update connectedComponentsArray to provide links to any children, parent or related components.
7278
*/
73-
let connectedComponentsArray = [];
79+
let connectedComponentsArray = [
80+
{
81+
label: "Related UI Components",
82+
arr: [
83+
{
84+
name: "Masthead",
85+
folder: "ui",
86+
},
87+
],
88+
},
89+
{
90+
label: "Layout Components",
91+
arr: [
92+
{
93+
name: "Header",
94+
folder: "layout",
95+
},
96+
],
97+
},
98+
];
7499
</script>
75100

76101
<script>
@@ -91,8 +116,8 @@
91116
92117
import { defaultScreenWidthBreakpoints } from "$lib/config.js";
93118
94-
import WhatsNew from "$lib/components/ui/WhatsNew.svelte";
95-
import Examples from "./whats-new/Examples.svelte";
119+
import WhatsNew from "$lib/components/ui/WhatsNew.svelte";
120+
import Examples from "./whats-new/Examples.svelte";
96121
97122
let { data } = $props();
98123
@@ -157,142 +182,77 @@ import Examples from "./whats-new/Examples.svelte";
157182
let parametersSourceArray = $derived(
158183
addIndexAndInitalValue([
159184
{
160-
name: "componentNameProp",
161-
category: "Input props",
162-
propType: "fixed",
163-
value: pageName,
164-
},
165-
{
166-
name: "textProp",
167-
category: "Input props",
168-
value: `This is a string input - edit me using the UI and see it reflected in the component.`,
185+
name: "title",
186+
category: "Content",
187+
value: "What's new",
169188
description: {
170189
markdown: true,
171190
arr: [
172-
`This prop passes a text string to the <code>${pageName}</code> component.`,
191+
"The main heading text for the news section.",
192+
"This appears as an h2 element at the top of the component.",
173193
],
174194
},
175-
rows: 2,
176195
},
177196
{
178-
name: "numberProp",
179-
category: "Input props",
180-
value: 9,
197+
name: "titleId",
198+
category: "Content",
199+
value: "whats-new",
181200
description: {
182201
markdown: true,
183202
arr: [
184-
`This prop passes a text string to the <code>${pageName}</code> component.`,
203+
"The HTML id attribute for the heading element.",
204+
"Useful for anchor links and accessibility purposes.",
185205
],
186206
},
187-
rows: 5,
188207
},
189208
{
190-
name: "checkboxProp",
191-
category: "Input props",
192-
value: false,
209+
name: "componentLinksIntroText",
210+
category: "Content",
211+
value:
212+
"This initial alpha release includes foundational components for building government services:",
193213
description: {
194214
markdown: true,
195215
arr: [
196-
`This prop passes <code>false</code> to the component when unchecked, <code>true</code> when checked.`,
216+
"Introductory text that appears before component links lists.",
217+
"Set to empty string to hide this text entirely.",
218+
"Only displays when news items have componentLinks arrays.",
197219
],
198220
},
221+
rows: 3,
199222
},
200223
{
201-
name: "dropdownProp",
202-
category: "Input props",
203-
options: ["apple", "banana", "kiwi", "strawberry", "orange"],
204-
description: {
205-
markdown: true,
206-
arr: [
207-
`This prop passes the selected <code>option</code> to the component as a string.`,
208-
],
209-
},
210-
},
211-
{
212-
name: "radioProp",
213-
category: "Input props",
214-
propType: "radio",
215-
options: ["carrot", "potato", "broccoli", "mushroom", "tomato"],
216-
description: {
217-
markdown: true,
218-
arr: [
219-
`This prop passes the selected <code>option</code> to the component as a string.`,
220-
],
221-
},
222-
},
223-
{
224-
name: "jsObjectProp",
225-
category: "Input props",
224+
name: "newsItems",
225+
category: "Content",
226226
value: [
227227
{
228-
name: "Pikachu",
229-
type: "Electric",
230-
color: "#fde047",
231-
},
232-
{
233-
name: "Charmander",
234-
type: "Fire",
235-
color: "#fca5a5",
236-
},
237-
{
238-
name: "Squirtle",
239-
type: "Water",
240-
color: "#93c5fd",
228+
date: "June 2025",
229+
content:
230+
"We launched the MHCLG Svelte Component Library alpha version. This library provides Svelte 5 implementations of GOV.UK Design System components, specifically tailored for data-rich digital products and services.",
231+
releaseNotesUrl:
232+
"https://github.com/communitiesuk/oflog_svelte_component_library/releases/tag/v0.1.16",
233+
releaseVersion: "v0.1.16",
241234
},
242235
{
243-
name: "Bulbasaur",
244-
type: "Grass",
245-
color: "#86efac",
236+
date: "January 2025",
237+
content:
238+
"Development began on the component library infrastructure, establishing the foundation for reusable Svelte components that maintain GOV.UK Design System compliance.",
239+
componentLinks: [
240+
{ text: "Masthead component", href: "/components/ui/masthead" },
241+
{ text: "Button component", href: "/components/ui/button" },
242+
],
246243
},
247244
],
248245
description: {
249246
markdown: true,
250247
arr: [
251-
`This prop passes the selected a JS object to the component.`,
252-
`The object can be directly edited. A notification will alert the user is any edits create an invalid object`,
253-
],
254-
},
255-
},
256-
{
257-
name: "functionProp",
258-
category: "Fixed props",
259-
260-
isRequired: true,
261-
value: function (event, pokemon) {
262-
window.alert(
263-
`The ${this.name} function has been triggered. Open the 'Fixed props' panel to see updated values.`,
264-
);
265-
266-
this.functionElements.counter += 1;
267-
Object.keys(this.functionElements.dataset).forEach((el) => {
268-
this.functionElements.dataset[el] = event.currentTarget.dataset[el];
269-
});
270-
},
271-
functionElements: {
272-
dataset: { role: null, id: null },
273-
counter: 0,
274-
functionAsString: `function (event, pokemon) {
275-
window.alert(
276-
"The \${this.name} function has been triggered. Open the 'Fixed props' panel to see updated values.",
277-
);
278-
279-
this.functionElements.counter += 1;
280-
Object.keys(this.functionElements.dataset).forEach((el) => {
281-
this.functionElements.dataset[el] = event.currentTarget.dataset[el];
282-
});
283-
}`,
284-
},
285-
description: {
286-
markdown: true,
287-
arr: [
288-
`This prop passes a function to the ${pageName} component. It works slightly differently to other props.`,
289-
`Firstly, it is not editable via the UI.`,
290-
`Secondly, the code snippet on the left is not actually based on the value. Instead, it is example code based on the <code>functionElements.functionAsString</code> property, and is optional.`,
291-
,
292-
`For event functions, you can define your function so that it updates the <code>functionElements.counter</code> property each time it runs.`,
293-
`For event functions, you can also define your function so that it grabs data from its target, which are then stored in <code>functionElements.dataset</code> and displayed in the UI (trigger your event to see this in action).`,
248+
"Array of news items to display. Each item can include:",
249+
"• <strong>date</strong>: When the news occurred (required)",
250+
"• <strong>content</strong>: Main description (required)",
251+
"• <strong>releaseNotesUrl & releaseVersion</strong>: For linking to release notes (optional)",
252+
"• <strong>componentLinks</strong>: Array of related component links (optional)",
294253
],
295254
},
255+
rows: 10,
296256
},
297257
]),
298258
);
@@ -435,7 +395,7 @@ Object.keys(this.functionElements.dataset).forEach((el) => {
435395
-->
436396
{#snippet Component()}
437397
<div class="p-8">
438-
<WhatsNew {...parametersObject}></WhatsNew>
398+
<WhatsNew {...parametersObject}></WhatsNew>
439399
</div>
440400
{/snippet}
441401

src/wrappers/components/ui/whats-new/Examples.svelte

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
import CodeBlock from "$lib/package-wrapping/CodeBlock.svelte";
55
import * as codeBlocks from "./codeBlocks.js";
66
7-
import WhatsNew from "$lib/components/ui/WhatsNew.svelte";
7+
import WhatsNew from "$lib/components/ui/WhatsNew.svelte";
88
99
let accordionSnippetSections = [
1010
{
1111
id: "1",
12-
heading: "1. Example 1 - describe the use case here",
12+
heading: "1. Basic usage with default content",
1313
content: Example1,
1414
},
15+
{
16+
id: "2",
17+
heading: "2. Custom title and simple news items",
18+
content: Example2,
19+
},
20+
{
21+
id: "3",
22+
heading: "3. Complex news items with release notes and component links",
23+
content: Example3,
24+
},
1525
];
1626
</script>
1727

@@ -37,32 +47,67 @@ import WhatsNew from "$lib/components/ui/WhatsNew.svelte";
3747

3848
{#snippet Example1()}
3949
<div class="p-5 bg-white">
40-
<Template
41-
componentNameProp="Example 1"
42-
checkboxProp={true}
43-
dropdownProp="Dragonfruit"
44-
jsObjectProp={[
50+
<WhatsNew />
51+
</div>
52+
<CodeBlock code={codeBlocks.codeBlock1} language="svelte"></CodeBlock>
53+
{/snippet}
54+
55+
{#snippet Example2()}
56+
<div class="p-5 bg-white">
57+
<WhatsNew
58+
title="Latest Updates"
59+
titleId="updates"
60+
newsItems={[
4561
{
46-
name: "Borussia Dortmund",
47-
country: "Germany",
48-
color: "#fdff7d",
62+
date: "March 2025",
63+
content:
64+
"We've improved the performance of our data visualization components by 40%.",
4965
},
50-
{ name: "Liverpool FC", country: "UK", color: "#f59fad" },
5166
{
52-
name: "SSC Napoli",
53-
country: "Italy",
54-
color: "#69bfff",
67+
date: "February 2025",
68+
content:
69+
"New accessibility features have been added to all form components.",
70+
},
71+
]}
72+
/>
73+
</div>
74+
<CodeBlock code={codeBlocks.codeBlock2} language="svelte"></CodeBlock>
75+
{/snippet}
76+
77+
{#snippet Example3()}
78+
<div class="p-5 bg-white">
79+
<WhatsNew
80+
title="Component Library Updates"
81+
titleId="component-updates"
82+
componentLinksIntroText="This release includes updates to the following components:"
83+
newsItems={[
84+
{
85+
date: "April 2025",
86+
content:
87+
"Released version 2.1.0 with enhanced chart components and improved TypeScript support.",
88+
releaseNotesUrl: "https://github.com/example/releases/tag/v2.1.0",
89+
releaseVersion: "v2.1.0",
90+
componentLinks: [
91+
{
92+
text: "Line Chart component",
93+
href: "/components/charts/line-chart",
94+
},
95+
{
96+
text: "Bar Chart component",
97+
href: "/components/charts/bar-chart",
98+
},
99+
{ text: "Data Table component", href: "/components/ui/data-table" },
100+
],
55101
},
56102
{
57-
name: "S.L. Benfica",
58-
country: "Portugal",
59-
color: "#ff8c96",
103+
date: "March 2025",
104+
content:
105+
"Minor bug fixes and accessibility improvements across all components.",
106+
releaseNotesUrl: "https://github.com/example/releases/tag/v2.0.1",
107+
releaseVersion: "v2.0.1",
60108
},
61109
]}
62-
functionProp={function () {
63-
window.alert(`Example 1 functionProp has been triggered.`);
64-
}}
65-
></Template>
110+
/>
66111
</div>
67-
<CodeBlock code={codeBlocks.codeBlock1} language="svelte"></CodeBlock>
112+
<CodeBlock code={codeBlocks.codeBlock3} language="svelte"></CodeBlock>
68113
{/snippet}

0 commit comments

Comments
 (0)