Skip to content

Conversation

@jagarnica
Copy link
Contributor

This PR adds

  • Adds Storybook to ease development of TryItNow and other components
  • Adds new JSON object navigation via console-feed library
Screenshot 2025-07-01 at 9 20 01 AM

@jagarnica jagarnica marked this pull request as ready for review July 1, 2025 16:32
@jagarnica jagarnica requested a review from nebrius July 1, 2025 16:32
Comment on lines 21 to 57
const encodeLog = (log: SandpackConsoleData): Message => {
// deep copy the log.data array
if (!log.data) {
return Decode([]) as Message;
}
const modifiedDataArray = log.data as [Message, string];
if (Array.isArray(modifiedDataArray)) {
// Due to formatting changes with console-feed's encode function in v3.4
// we need to manually add in the remainder key to note that there
// are no more items remaining
modifiedDataArray.push("__console_feed_remaining__0");
// Objects all need to have a constructor property now too
// unless it is null
modifiedDataArray.forEach((dataItem) => {
if (
typeof dataItem !== "string" &&
(dataItem as unknown as SandpackEncodedLog)?.["@t"]
) {
const sandpackEncodedLog = dataItem as unknown as SandpackEncodedLog;
if (sandpackEncodedLog["@t"] === "[[undefined]]") {
return;
}

// Hey keep going and actually write this as a function to note
// that we are essentially an adapter for v3.3 and the newest version of console-feed
const constructorType = sandpackEncodedLog?.["@t"]?.slice(2, -2);
Object.assign(dataItem, {
constructor: {
name: constructorType,
},
});
delete sandpackEncodedLog["@t"];
}
});
}
return Decode([{ ...log, data: modifiedDataArray }]) as Message;
};
Copy link
Contributor Author

@jagarnica jagarnica Jul 1, 2025

Choose a reason for hiding this comment

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

This is the adapter required to go from v3.3 to v3.8 or newer. Sandpack already encodes the console messages with console-feed but using v3.3, causing some odd crashes and type issues since we are using 3.8 to decode. We could also use v3.3 for console-feed but we lose React 19 support.

Comment on lines +78 to +80
background: "var(--sp-colors-surface1)",
lineHeight: "var(--sp-font-lineHeight)",
}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tokens will be replaced in the following PR for styles.

Comment on lines +83 to +87
export const ConsoleOutputWithDifferentDataTypes: Story = {
args: {
defaultValue: `// Console output with different data types
// This story stress tests the console output with various JavaScript data types
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds a stress test for the console output.

Comment on lines +38 to +44
// Disable unused exports rule for Storybook files
{
files: ["**/*.stories.{ts,tsx}", ".storybook/*.{ts,tsx}"],
rules: {
"fast-import/no-unused-exports": "off",
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disabling these rules just for storybook files

Copy link
Contributor

@nebrius nebrius left a comment

Choose a reason for hiding this comment

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

Meant to hit approve. Looks good aside from two small things.

@jagarnica jagarnica added this pull request to the merge queue Jul 1, 2025
Merged via the queue into main with commit 11966c5 Jul 1, 2025
1 check passed
pschutz93 pushed a commit that referenced this pull request Oct 25, 2025
* add basic storybook setup

* add basic nesting view to jsonViewer

* add indentation levels and basic color mapping

* add nesting example and fix comma bug

* add no wrap to avoid breaking spaces

* add null syntax coloring

* fix expansion bug with duplicate keys

* refactor for perf improvements

* add proper color theming to json viewer

* update dependencies

* add console-feed and console-feed adapter

* removing testing output

* add more comments

* update package-lock

* remove ref from SandpackPreview

* disable import rules for eslint

* remove storybook from tsconfig

* ignore bootstrap storybook files in eslint

* remove unneeded type and add image types to lfs gitattributes
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.

3 participants