Skip to content

Add scrollable and loadable from file EditableSketches#1469

Draft
ksen0 wants to merge 4 commits into
mainfrom
bigsketches
Draft

Add scrollable and loadable from file EditableSketches#1469
ksen0 wants to merge 4 commits into
mainfrom
bigsketches

Conversation

@ksen0

@ksen0 ksen0 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Currently the 2.0 switch is blocked by some .todo tutorials. These are blocked by incomplete migration, sometimes due to the presence of external links to sketches that cannot be updated to match 2.0. Currently they can't be copied directly into the body of the tutorial because they are very long. This PR introduces scrollable editable sketch support.

Addresses #1426 processing/p5.js#8870

WIP Docs

  1. Put the .js/.css/.html into .../tutorials/sketches/TUTORIAL_NAME/SKETCH_NAME
  2. use export at top of tutorial .mdx file to load the data
//at the top
import { readFile } from "fs/promises";

export const completeSketchCode = await readFile(
  "src/content/tutorials/sketches/TUTORIAL_NAME/SKETCH_NAME/sketch.js",
  "utf-8"
);
...

// in the doc body - sketch with own CSS+HTML
<SketchEmbed
  height="800px"
  code={sketchCode}
  cssCode={cssCode}
  bodyCode={bodyCode}
/>

// alternatively - editable sketch
<EditableSketch code={sketchCode} />

// editable sketch with own CSS+HTML may have some unexpected ideas about width.
// however explicitly setting width will use "vertical" mode where the code floats on the right.
<SketchEmbed
  height="800px"
  scrollable={true}
  code={sketchCode}
  cssCode={cssCode}
  bodyCode={bodyCode}
/>

Comment thread src/components/CodeEmbed/index.jsx Outdated
value={codeString}
theme="light"
width="100%"
height="300px"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we want to make this optional/opt-in for long sketches?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah yes thanks for the reminder! That's the intent. (For other testers/reviewers looking later: when I add missing tutorials they shouldn't have anything changed except some scrollable sketches where intended.)

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.

2 participants