Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/analytics-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions lang/ui.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. <link>Learn more</link>",
"description": "Notice in the ideas tab header; the link opens a dialog explaining the change"
},
"ideas-moving-questions": {
"defaultMessage": "Get in touch through our <link>support site</link>.",
"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"
Expand Down
5 changes: 4 additions & 1 deletion src/common/AreaHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<Box p="5" pt="3">
<Text as="h2" fontSize="3xl" fontWeight="semibold">
{name}
</Text>
<Text fontSize="md">{description}</Text>
{children}
</Box>
);

Expand Down
62 changes: 58 additions & 4 deletions src/documentation/ideas/IdeasDocumentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";
Expand Down Expand Up @@ -149,7 +154,9 @@ const ActiveLevel = ({
<AreaHeading
name={headingString}
description={intl.formatMessage({ id: "ideas-tab-description" })}
/>
>
<IdeasMovingNotice />
</AreaHeading>
}
>
<Grid
Expand Down Expand Up @@ -195,4 +202,51 @@ const ActiveLevel = ({
);
};

const IdeasMovingNotice = () => {
const [isOpen, setIsOpen] = useState(false);
const learnMoreRef = useRef<HTMLButtonElement>(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.
<HStack gap="1.5" mt="2" alignItems="flex-start" fontSize="md">
{/* One line of the text high, to centre the icon on the first line. */}
<Box display="flex" alignItems="center" h="1lh" flexShrink={0}>
<Icon as={RiInformationLine} />
</Box>
<Text fontSize="md">
<FormattedMessage
id="ideas-moving-notice"
values={{
link: (chunks: ReactNode) => (
<Button
ref={learnMoreRef}
variant="link"
// In prose, so marked by more than colour.
css={{ color: "brand.500", textDecoration: "underline" }}
onPress={() => {
logging.event({ type: "ideas_notice_open" });
setIsOpen(true);
}}
>
{chunks}
</Button>
),
}}
/>
</Text>
<IdeasMovingDialog
isOpen={isOpen}
onClose={() => setIsOpen(false)}
finalFocusRef={learnMoreRef}
/>
</HStack>
);
};

export default IdeasDocumentation;
105 changes: 105 additions & 0 deletions src/documentation/ideas/IdeasMovingDialog.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLButtonElement | null>;
}

const IdeasMovingDialog = ({
isOpen,
onClose,
finalFocusRef,
}: IdeasMovingDialogProps) => {
const { supportLink } = useDeployment();
return (
<Modal
isOpen={isOpen}
onClose={onClose}
size="lg"
finalFocusRef={finalFocusRef}
>
<ModalCloseButton />
<ModalHeader css={{ fontWeight: "bold" }}>
<FormattedMessage id="ideas-moving-title" />
</ModalHeader>
<ModalBody>
<Stack gap="5">
{sections.map(({ heading, body }) => (
<Section key={heading} heading={<FormattedMessage id={heading} />}>
<FormattedMessage id={body} />
</Section>
))}
{supportLink && (
<Section
heading={<FormattedMessage id="ideas-moving-questions-heading" />}
>
<FormattedMessage
id="ideas-moving-questions"
values={{
link: (chunks: ReactNode) => (
<Link
href={supportLink}
target="_blank"
rel="noopener"
color="brand.500"
textDecoration="underline"
>
{chunks}
</Link>
Comment thread
microbit-matt-hillsdon marked this conversation as resolved.
Resolved
),
}}
/>
</Section>
)}
</Stack>
</ModalBody>
<ModalFooter>
<Button variant="primary" size="lg" onPress={onClose}>
<FormattedMessage id="close-action" />
</Button>
</ModalFooter>
</Modal>
);
};

const Section = ({
heading,
children,
}: {
heading: ReactNode;
children: ReactNode;
}) => (
<Stack gap="1">
<Text as="h3" fontSize="lg" fontWeight="semibold">
{heading}
</Text>
<Text>{children}</Text>
</Stack>
);

export default IdeasMovingDialog;
23 changes: 23 additions & 0 deletions src/e2e/documentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: MIT
*/
import { expect } from "@playwright/test";
import { test } from "./app-test-fixtures.js";

test.describe("documentation", () => {
Expand Down Expand Up @@ -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");
Expand Down
13 changes: 13 additions & 0 deletions src/e2e/iframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
10 changes: 10 additions & 0 deletions src/e2e/storage-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down