Skip to content

feat: add 'Open in Playground' button to learn modules#877

Open
Atharva7115 wants to merge 2 commits intoaccordproject:mainfrom
Atharva7115:feat/open-playground-button
Open

feat: add 'Open in Playground' button to learn modules#877
Atharva7115 wants to merge 2 commits intoaccordproject:mainfrom
Atharva7115:feat/open-playground-button

Conversation

@Atharva7115
Copy link
Copy Markdown

@Atharva7115 Atharva7115 commented Apr 14, 2026

feat(playground): Add "Open in Playground" button to learning modules

Closes #871

Changes

  • Added "Open in Playground" button in learning modules to directly load sample templates
  • Connected learn → playground using query parameter (?sample=...)
  • Reused existing loadSample logic from store
  • Added sampleName mapping in steps.ts for each module
  • Used theme-based styling (colors.primary) instead of hardcoded values

Flags

  • Minimal and non-breaking change
  • No new dependencies introduced

Screenshots or Video

Preview link :

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option
  • Vital features and changes captured in unit and/or integration tests
  • Commit messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Notes

This implementation uses the existing colors.primary theme token instead of hardcoded color values.

  • Aligns with the design system used across the codebase (Navbar, Footer, ErrorBoundary, etc.)
  • Ensures consistency and maintainability
  • Prevents potential issues if the theme color changes in the future

@Atharva7115 Atharva7115 requested a review from a team as a code owner April 14, 2026 14:04
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2026

Deploy Preview for ap-template-playground ready!

Name Link
🔨 Latest commit 702ebfe
🔍 Latest deploy log https://app.netlify.com/projects/ap-template-playground/deploys/69df085806f91e0008bd3ef4
😎 Deploy Preview https://deploy-preview-877--ap-template-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Signed-off-by: Atharva Chandurkar <atharvachandurkar7115@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a learn → playground bridge by introducing an “Open in Playground” button on learning modules and supporting ?sample=... URL initialization so the Playground can auto-load the relevant sample template.

Changes:

  • Teach the store initializer to load a sample when ?sample=... is present.
  • Add sampleName mappings to learning steps for each module.
  • Render an “Open in Playground” button in learning module content that navigates to /?sample=....

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/store/store.ts Adds support for initializing the app from a sample query param by calling loadSample.
src/constants/learningSteps/steps.ts Associates learn modules with sample names to drive the new navigation behavior.
src/components/Content.tsx Adds the “Open in Playground” CTA to learning module pages and wires it to navigation.

Comment thread src/store/store.ts
Comment on lines 234 to 244
init: async () => {
const params = new URLSearchParams(window.location.search);
const compressedData = params.get("data");
const sampleName = params.get("sample");
if (compressedData) {
await get().loadFromLink(compressedData);
} else if (sampleName) {
await get().loadSample(sampleName);
} else {
await get().rebuild();
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init() now calls loadSample(sampleName) when ?sample=... is present, but loadSample is a no-op when the sample name is unknown. In that case init() will skip rebuild() and the app can remain with agreementHtml unset/empty. Consider making loadSample throw/return a boolean when the sample is not found, and have init() fall back to rebuild() (and/or surface an error) when the sample cannot be loaded.

Copilot uses AI. Check for mistakes.
Comment thread src/store/store.ts
Comment on lines 234 to 244
init: async () => {
const params = new URLSearchParams(window.location.search);
const compressedData = params.get("data");
const sampleName = params.get("sample");
if (compressedData) {
await get().loadFromLink(compressedData);
} else if (sampleName) {
await get().loadSample(sampleName);
} else {
await get().rebuild();
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (loading a sample via ?sample=... in init()) is user-facing and affects initialization flow, but there’s no unit/integration test covering it. Please add a store-level test that sets window.location.search to include sample and asserts loadSample is invoked (or sampleName/editor values update) and agreementHtml is produced after initialization.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +5 to +7
{ title: "Module 1", link: "/learn/module1", sampleName: "Hello World" },
{ title: "Module 2", link: "/learn/module2", sampleName: "Formula Now" },
{ title: "Module 3", link: "/learn/module3", sampleName: "Join" },
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sampleName values are hardcoded strings that must exactly match Sample.NAME values for loadSample to work. This duplicates source-of-truth data and can silently break if sample names change. Consider importing the NAME constants from the relevant src/samples/* modules (or exporting a shared sample ID enum) and referencing those here instead of repeating the strings.

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +118
<div style={{ display: "flex", justifyContent: "flex-end", marginBottom: "12px", gap: "10px" }}>
{steps[currentIndex]?.sampleName && (
<Button
type="primary"
onClick={() => navigate(`/?sample=${encodeURIComponent(steps[currentIndex].sampleName!)}`)}
style={{
backgroundColor: colors.primary,
borderColor: colors.primary,
fontSize: "0.9rem",
height: "auto",
padding: "4px 12px"
}}
>
Open in Playground
</Button>
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new "Open in Playground" button introduces a new learn→playground navigation path, but there’s no component test covering that the button renders for modules with a sampleName and that clicking it navigates to /?sample=.... Given existing component tests in src/tests/components, adding a test for this behavior would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
@mttrbrts
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

@mttrbrts
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

@mttrbrts
Copy link
Copy Markdown
Member

Thanks for this contribution! This appears to be a duplicate of #872 by @karanpatill, which was opened earlier and addresses the same issue (#871).

@Atharva7115 — would you mind helping review #872? Your input would be valuable since you've worked on the same feature.


This comment was generated by AI on behalf of @mttrbrts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Learning Experience by Adding "Open in Playground" for Learn Modules

3 participants