Scroll walkthrough

View as Markdown

The <ScrollWalkthrough> component pairs a column of prose steps with a code panel pinned beside them. Each step or substep names a file and a line range. When it scrolls into view, the panel shows that file with the other lines dimmed. Use it for quickstarts and integration guides where successive steps add to the same few files.

Usage

A walkthrough can contain a single file or several. Declare each file once as a fenced code block inside the component, then point steps and substeps at it with file and a line range in focus or highlight. A step or substep that omits file keeps the previously targeted file.

  1. Install the SDK

    Add the Plant Store SDK to your project.

  2. Create the client

    Point the client at your garden with an API key.

    1. Import the client.
    2. Construct it with your API key.
  3. Add a plant

    Create your first plant record. The wateringDays interval drives care reminders.

$npm install @plantstore/sdk
Markdown
1<ScrollWalkthrough>
2 <Step title="Install the SDK" file="Terminal" focus="1">
3 Add the Plant Store SDK to your project.
4 </Step>
5 <Step title="Create the client" file="garden.ts" focus="1-5">
6 Point the client at your garden with an API key.
7 <Substep file="garden.ts" focus="1">Import the client.</Substep>
8 <Substep file="garden.ts" focus="3-5">Construct it with your API key.</Substep>
9 </Step>
10 <Step title="Add a plant" file="garden.ts" focus="7-11">
11 Create your first plant record. The `wateringDays` interval drives care reminders.
12 </Step>
13
14 ```bash Terminal
15 npm install @plantstore/sdk
16 ```
17
18 ```ts garden.ts
19 import { PlantStore } from "@plantstore/sdk";
20
21 const client = new PlantStore({
22 apiKey: process.env.PLANT_API_KEY,
23 });
24
25 await client.plants.create({
26 name: "Monstera deliciosa",
27 light: "bright-indirect",
28 wateringDays: 7,
29 });
30 ```
31</ScrollWalkthrough>

On narrow screens the panel pins to the top of the viewport, step headers stop sticking, and each substep’s code renders inline beneath it.

Variants

Wide layout

Set layout="wide" to narrow the prose column and give the code panel more room. Pair it with panelHeight to set the panel’s height.

  1. Fetch a plant

    Read a single plant by ID.

  2. Log a watering

    Record care events to keep the plant’s schedule accurate.

1const plant = await client.plants.get("monstera-1", {
2 includeCareHistory: true,
3});
4
5await client.plants.logWatering("monstera-1", {
6 wateredAt: new Date().toISOString(),
7 amountMl: 250,
8});
Markdown
1<ScrollWalkthrough layout="wide" panelHeight="20rem">
2 <Step title="Fetch a plant" file="garden.ts" focus="1-3">
3 Read a single plant by ID.
4 </Step>
5 <Step title="Log a watering" file="garden.ts" focus="5-8">
6 Record care events to keep the plant's schedule accurate.
7 </Step>
8
9 ```ts garden.ts
10 const plant = await client.plants.get("monstera-1", {
11 includeCareHistory: true,
12 });
13
14 await client.plants.logWatering("monstera-1", {
15 wateredAt: new Date().toISOString(),
16 amountMl: 250,
17 });
18 ```
19</ScrollWalkthrough>

Bulleted substeps

Set substepStyle="bullet" to mark substeps with dots instead of numbers. Use it when the substeps under a step aren’t ordered.

  1. Configure care defaults

    Each field controls one reminder.

    1. Set the watering interval in days.
    2. Set the fertilizing interval in weeks.
    3. Choose where reminders are delivered.
1await client.gardens.updateDefaults({
2 wateringDays: 7,
3 fertilizingWeeks: 6,
4 remindVia: "email",
5});
Markdown
1<ScrollWalkthrough substepStyle="bullet">
2 <Step title="Configure care defaults" file="garden.ts">
3 Each field controls one reminder.
4 <Substep file="garden.ts" focus="2">Set the watering interval in days.</Substep>
5 <Substep file="garden.ts" focus="3">Set the fertilizing interval in weeks.</Substep>
6 <Substep file="garden.ts" focus="4">Choose where reminders are delivered.</Substep>
7 </Step>
8
9 ```ts garden.ts
10 await client.gardens.updateDefaults({
11 wateringDays: 7,
12 fertilizingWeeks: 6,
13 remindVia: "email",
14 });
15 ```
16</ScrollWalkthrough>

Highlighted lines

focus dims every line outside its range. highlight marks its range with an accent background and leaves the rest of the file at full contrast. Use highlight for steps where the surrounding code still matters.

  1. Configure the client

    Set your API key and a request timeout.

  2. Shorten the watering interval

    Summer growth needs more frequent watering, so drop the interval to five days.

1const client = new PlantStore({
2 apiKey: process.env.PLANT_API_KEY,
3 timeoutMs: 10000,
4});
5
6await client.plants.update("monstera-1", {
7 light: "bright-indirect",
8 wateringDays: 5,
9});
Markdown
1<ScrollWalkthrough>
2 <Step title="Configure the client" file="garden.ts" focus="1-4">
3 Set your API key and a request timeout.
4 </Step>
5 <Step title="Shorten the watering interval" file="garden.ts" highlight="8">
6 Summer growth needs more frequent watering, so drop the interval to five days.
7 </Step>
8
9 ```ts garden.ts
10 const client = new PlantStore({
11 apiKey: process.env.PLANT_API_KEY,
12 timeoutMs: 10000,
13 });
14
15 await client.plants.update("monstera-1", {
16 light: "bright-indirect",
17 wateringDays: 5,
18 });
19 ```
20</ScrollWalkthrough>

Properties

<ScrollWalkthrough> properties

layout
'default' | 'wide'Defaults to default

Column split. wide narrows the prose column to give the code panel more room.

panelHeight
string

Height of the code panel as a CSS length, such as 32rem. Defaults to a viewport-based height.

stickyHeaders
booleanDefaults to true

Whether each step’s header stays pinned while its substeps scroll.

dim
booleanDefaults to true

Whether inactive steps and substeps fade out.

substepStyle
'bullet' | 'step'Defaults to step

Whether substeps are marked with numbers (step) or dots (bullet).

className
string

Additional CSS classes to apply to the walkthrough

<Step> properties

Inside a walkthrough, <Step> accepts these properties:

title
string

The step’s heading

description
string

A short summary rendered under the title

file
string | number

The file this step targets, matching a code block’s title or its 0-based index among the walkthrough’s code blocks. When omitted, the step keeps the previously targeted file.

focus
string | number | number[]

Lines to focus in the targeted file, dimming the rest. Accepts a range string such as 1-5,8, a single line number, or an array of line numbers.

highlight
string | number | number[]

Lines to highlight in the targeted file, using the same formats as focus.

startLine
number

The 1-based line the panel scrolls to when the step becomes active. Defaults to the first focused or highlighted line.

id
string

The unique ID for the step, used for linking. Generated automatically when unset.

<Substep> properties

title
string

A short heading rendered above the substep’s prose

file
string | number

The file this substep targets, matching a code block’s title or its 0-based index. When omitted, the substep inherits the step’s file.

focus
string | number | number[]

Lines to focus in the targeted file, dimming the rest. Accepts a range string such as 1-5,8, a single line number, or an array of line numbers.

highlight
string | number | number[]

Lines to highlight in the targeted file, using the same formats as focus.

startLine
number

The 1-based line the panel scrolls to when the substep becomes active. Defaults to the first focused or highlighted line.

id
string

The unique ID for the substep, used for linking. Generated from the parent step when unset.