diff --git a/docs/analytics-events.md b/docs/analytics-events.md index 1b504fe02..f1a5b47cf 100644 --- a/docs/analytics-events.md +++ b/docs/analytics-events.md @@ -221,6 +221,11 @@ Fires once per search session: when results first appear after typing, not per keystroke (300ms debounce) and not again until results are cleared. No params. Search terms are deliberately not sent. +### `ideas_notice_open` + +User opened the dialog, from the notice in the Ideas tab, that explains that +ideas are moving to the home page. No params. + ## Code snippet events Moving code from the documentation into the editor. Drag and copy are the diff --git a/lang/ui.en.json b/lang/ui.en.json index 623b2f942..a6d8538de 100644 --- a/lang/ui.en.json +++ b/lang/ui.en.json @@ -447,6 +447,46 @@ "defaultMessage": "Step counter", "description": "Title of an idea card; matches the idea name in the ideas tab" }, + "ideas-moving-notice": { + "defaultMessage": "Ideas are moving to the Home page. Learn more", + "description": "Notice in the ideas tab header; the link opens a dialog explaining the change" + }, + "ideas-moving-questions": { + "defaultMessage": "Get in touch through our support site.", + "description": "Body of the questions section in the ideas moving dialog; the link opens the support site in a new tab" + }, + "ideas-moving-questions-heading": { + "defaultMessage": "Still have questions?", + "description": "Section heading in the ideas moving dialog" + }, + "ideas-moving-title": { + "defaultMessage": "Ideas are moving to the Home page", + "description": "Title of the dialog explaining that ideas are moving out of the editor to the home page" + }, + "ideas-moving-what": { + "defaultMessage": "Ideas are now on the Home page too. When you create a project from an idea there, the editor opens with that idea in the sidebar. Later, we will remove the option to browse ideas from the sidebar.", + "description": "Body of the what is changing section in the ideas moving dialog" + }, + "ideas-moving-what-heading": { + "defaultMessage": "What is changing?", + "description": "Section heading in the ideas moving dialog" + }, + "ideas-moving-when": { + "defaultMessage": "We will remove the option to browse ideas from the sidebar in mid-2027.", + "description": "Body of the when section in the ideas moving dialog" + }, + "ideas-moving-when-heading": { + "defaultMessage": "When?", + "description": "Section heading in the ideas moving dialog" + }, + "ideas-moving-why": { + "defaultMessage": "Ideas are easier to browse on the Home page. Selecting an idea shows you a preview before you start, and the Home page has other resources and activities as well.", + "description": "Body of the why section in the ideas moving dialog" + }, + "ideas-moving-why-heading": { + "defaultMessage": "Why?", + "description": "Section heading in the ideas moving dialog" + }, "ideas-row-title": { "defaultMessage": "Ideas", "description": "Heading of the home page row of idea cards" diff --git a/src/common/AreaHeading.tsx b/src/common/AreaHeading.tsx index 63b9a9904..c253c01a3 100644 --- a/src/common/AreaHeading.tsx +++ b/src/common/AreaHeading.tsx @@ -10,14 +10,17 @@ import { Box } from "styled-system/jsx"; interface AreaHeadingProps { name: string; description: ReactNode; + /** Rendered below the description. */ + children?: ReactNode; } -const AreaHeading = ({ name, description }: AreaHeadingProps) => ( +const AreaHeading = ({ name, description, children }: AreaHeadingProps) => ( {name} {description} + {children} ); diff --git a/src/documentation/ideas/IdeasDocumentation.tsx b/src/documentation/ideas/IdeasDocumentation.tsx index 24939aeaa..154c64a8d 100644 --- a/src/documentation/ideas/IdeasDocumentation.tsx +++ b/src/documentation/ideas/IdeasDocumentation.tsx @@ -3,10 +3,11 @@ * * SPDX-License-Identifier: MIT */ -import { Link, Text } from "@microbit/ui"; -import { CSSProperties, ReactNode, useCallback, useRef } from "react"; +import { Button, Icon, Link, Text } from "@microbit/ui"; +import { CSSProperties, ReactNode, useCallback, useRef, useState } from "react"; +import { RiInformationLine } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; -import { Box, Grid, Stack } from "styled-system/jsx"; +import { Box, Grid, HStack, Stack } from "styled-system/jsx"; import AreaHeading from "../../common/AreaHeading"; import { docStylesClass, @@ -26,7 +27,11 @@ import DocumentationContent, { } from "../common/DocumentationContent"; import ImageWithFallback from "../common/ImageWithFallback"; import { isV2Only } from "../common/model"; +import { useProjectsDatabaseActive } from "../../fs/storage-status"; +import { useIframeMode } from "../../iframe-mode-hooks"; +import { useLogging } from "../../logging/logging-hooks"; import IdeaCard from "./IdeaCard"; +import IdeasMovingDialog from "./IdeasMovingDialog"; import { Idea } from "./model"; import OfflineImageFallback from "../OfflineImageFallback"; import { microbitOrgMiciProjectsUrl } from "../../external-links"; @@ -149,7 +154,9 @@ const ActiveLevel = ({ + > + + } > { + const [isOpen, setIsOpen] = useState(false); + const learnMoreRef = useRef(null); + const logging = useLogging(); + const iframeMode = useIframeMode(); + const projectsDatabaseActive = useProjectsDatabaseActive(); + if (iframeMode || !projectsDatabaseActive) { + // There is no home page for the ideas to move to. + return null; + } + return ( + // Top-aligned so the icon stays on the first line when the text wraps. + + {/* One line of the text high, to centre the icon on the first line. */} + + + + + ( + + ), + }} + /> + + setIsOpen(false)} + finalFocusRef={learnMoreRef} + /> + + ); +}; + export default IdeasDocumentation; diff --git a/src/documentation/ideas/IdeasMovingDialog.tsx b/src/documentation/ideas/IdeasMovingDialog.tsx new file mode 100644 index 000000000..0e474ae6c --- /dev/null +++ b/src/documentation/ideas/IdeasMovingDialog.tsx @@ -0,0 +1,105 @@ +/** + * (c) 2026, Micro:bit Educational Foundation and contributors + * + * SPDX-License-Identifier: MIT + */ +import { + Button, + Link, + Modal, + ModalBody, + ModalCloseButton, + ModalFooter, + ModalHeader, + Text, +} from "@microbit/ui"; +import { ReactNode, RefObject } from "react"; +import { FormattedMessage } from "react-intl"; +import { Stack } from "styled-system/jsx"; +import { useDeployment } from "../../deployment"; + +const sections = [ + { heading: "ideas-moving-what-heading", body: "ideas-moving-what" }, + { heading: "ideas-moving-why-heading", body: "ideas-moving-why" }, + { heading: "ideas-moving-when-heading", body: "ideas-moving-when" }, +] as const; + +interface IdeasMovingDialogProps { + isOpen: boolean; + onClose: () => void; + finalFocusRef?: RefObject; +} + +const IdeasMovingDialog = ({ + isOpen, + onClose, + finalFocusRef, +}: IdeasMovingDialogProps) => { + const { supportLink } = useDeployment(); + return ( + + + + + + + + {sections.map(({ heading, body }) => ( +
}> + +
+ ))} + {supportLink && ( +
} + > + ( + + {chunks} + + ), + }} + /> +
+ )} +
+
+ + + +
+ ); +}; + +const Section = ({ + heading, + children, +}: { + heading: ReactNode; + children: ReactNode; +}) => ( + + + {heading} + + {children} + +); + +export default IdeasMovingDialog; diff --git a/src/e2e/documentation.test.ts b/src/e2e/documentation.test.ts index a3da31044..8aab254c3 100644 --- a/src/e2e/documentation.test.ts +++ b/src/e2e/documentation.test.ts @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: MIT */ +import { expect } from "@playwright/test"; import { test } from "./app-test-fixtures.js"; test.describe("documentation", () => { @@ -79,6 +80,28 @@ test.describe("documentation", () => { ); }); + test("Ideas tab explains that ideas are moving to the home page", async ({ + app, + }) => { + await app.switchTab("Ideas"); + await expect( + app.page.getByText("Ideas are moving to the Home page.") + ).toBeVisible(); + await app.expectNoNewAccessibilityViolations(); + + const learnMore = app.page.getByRole("button", { name: "Learn more" }); + await learnMore.click(); + const dialog = app.page.getByRole("dialog"); + await expect( + dialog.getByRole("heading", { name: "Ideas are moving to the Home page" }) + ).toBeVisible(); + await app.expectNoNewAccessibilityViolations(); + + await app.page.keyboard.press("Escape"); + await expect(dialog).toBeHidden(); + await expect(learnMore).toBeFocused(); + }); + test("Select an idea", async ({ app }) => { const ideaName = "Emotion badge"; await app.switchTab("Ideas"); diff --git a/src/e2e/iframe.test.ts b/src/e2e/iframe.test.ts index e2f87707e..a96b46523 100644 --- a/src/e2e/iframe.test.ts +++ b/src/e2e/iframe.test.ts @@ -139,4 +139,17 @@ test.describe("iframe controller mode", () => { await app.closeAndExpectBeforeUnloadPrompt(); }); + + test("does not say ideas are moving, as there is no home page", async ({ + app, + }) => { + const frame = await openEmbeddedEditor(app.page); + await frame.getByRole("tab", { name: "Ideas" }).click(); + await expect( + frame.getByRole("heading", { name: "Ideas", exact: true }) + ).toBeVisible(); + await expect( + frame.getByRole("button", { name: "Learn more" }) + ).toBeHidden(); + }); }); diff --git a/src/e2e/storage-errors.test.ts b/src/e2e/storage-errors.test.ts index c89810414..9d0d755a5 100644 --- a/src/e2e/storage-errors.test.ts +++ b/src/e2e/storage-errors.test.ts @@ -57,6 +57,16 @@ test.describe("storage fallback", () => { await app.expectEditorContainText(/PASS1/); }); + test("does not say ideas are moving, as there is no home page", async ({ + app, + }) => { + await app.switchTab("Ideas"); + await app.expectDocumentationTopLevelHeading("Ideas"); + await expect( + app.page.getByRole("button", { name: "Learn more" }) + ).toBeHidden(); + }); + test("opens a #project: link at the root in the editor", async ({ app }) => { await app.page.goto(homeUrl({ fragment: heartProjectLinkFragment })); await app.expectProjectName("Hearts");