[Website] Fix all broken CodeSandbox examples#9516
Open
weronikaolejniczak wants to merge 15 commits intoelastic:mainfrom
Open
[Website] Fix all broken CodeSandbox examples#9516weronikaolejniczak wants to merge 15 commits intoelastic:mainfrom
weronikaolejniczak wants to merge 15 commits intoelastic:mainfrom
Conversation
427e0e1 to
8650d01
Compare
8650d01 to
90d52bb
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the EUI docs site demos to better support live editing + CodeSandbox exports by attaching required “extra files” (raw source/assets) to demos, and refreshes a few demo dependencies (notably @faker-js/faker).
Changes:
- Bump
@faker-js/faker(website) and update affected docs snippets. - Add
extraFiles(raw-loaded sources/assets) to many MDX demos so CodeSandbox can include referenced local files. - Improve CodeSandbox demo generation by auto-injecting
@elastic/chartstheme CSS when charts are used.
Reviewed changes
Copilot reviewed 49 out of 50 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Updates lockfile for @faker-js/faker version bump. |
| packages/website/src/theme/Demo/actions.tsx | Adds moment-timezone to CodeSandbox dependency set. |
| packages/website/package.json | Bumps @faker-js/faker to ^10.3.0. |
| packages/website/docs/utilities/window-events/index.mdx | Adds raw source as extraFiles for CodeSandbox. |
| packages/website/docs/utilities/text-truncation.mdx | Adds missing imports in snippet. |
| packages/website/docs/utilities/focus-trap/index.mdx | Adds raw source as extraFiles for CodeSandbox. |
| packages/website/docs/utilities/color-palettes/index.mdx | Adds raw source as extraFiles; updates snippet imports. |
| packages/website/docs/utilities/accessibility/index.mdx | Makes snippets self-contained (imports/exports). |
| packages/website/docs/dataviz/types/part-to-whole-comparisons.mdx | Adds raw source extraFiles and adjusts imports in snippets. |
| packages/website/docs/dataviz/types/metric-chart.mdx | Adds raw source extraFiles and adjusts imports in snippets. |
| packages/website/docs/dataviz/theming.mdx | Adds raw source extraFiles and adjusts imports in snippets. |
| packages/website/docs/dataviz/sizing.mdx | Adds raw source extraFiles and adjusts imports in snippets. |
| packages/website/docs/dataviz/accessibility-features.mdx | Adds raw source extraFiles and adjusts imports in snippets. |
| packages/website/docs/components/templates/sitewide-search/index.mdx | Makes snippet self-contained with imports. |
| packages/website/docs/components/templates/page-template/guidelines.mdx | Adds SVG raw sources as extraFiles and imports inside snippet. |
| packages/website/docs/components/tables/basic.mdx | Updates faker API usage and other snippet tweaks. |
| packages/website/docs/components/navigation/facet.mdx | Switches to useEuiPaletteColorBlind hook usage in snippet. |
| packages/website/docs/components/navigation/buttons/group.mdx | Fixes snippet imports to match usage. |
| packages/website/docs/components/navigation/buttons/button.mdx | Fixes import formatting in snippet. |
| packages/website/docs/components/layout/page_components/index.mdx | Adds SVG raw sources as extraFiles and imports inside snippets. |
| packages/website/docs/components/layout/flex/item.mdx | Fixes snippet imports to match usage. |
| packages/website/docs/components/layout/flex/grid.mdx | Corrects demo snippet to use EuiFlexGrid. |
| packages/website/docs/components/forms/text/password.mdx | Wraps demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/text/basic.mdx | Wraps demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/switch.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/super-select.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/radio-and-radio-group.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/combo-box.mdx | Wraps multiple demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/checkbox-and-checkbox-group.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/selection/basic-select.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/search-and-filter/search.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/other/palette-picker.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/other/file-picker.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/other/color-picker.mdx | Wraps demos with extraFiles for shared display_toggles file; snippet import tweaks. |
| packages/website/docs/components/forms/numeric/range-sliders.mdx | Wraps demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/numeric/basic.mdx | Wraps demo with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/layouts/form_control_buttons.mdx | Refactors interactive snippet; adds popover + filtering example. |
| packages/website/docs/components/forms/date-and-time/super-date-picker.mdx | Adjusts imports/snippet structure. |
| packages/website/docs/components/forms/date-and-time/date-picker.mdx | Wraps demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/forms/date-and-time/date-picker-range.mdx | Wraps demos with extraFiles for shared display_toggles file. |
| packages/website/docs/components/editors-and-syntax/markdown/plugins.mdx | Normalizes snippet string quoting/formatting. |
| packages/website/docs/components/editors-and-syntax/markdown/editor.mdx | Removes Docusaurus Link usage in demo snippet; uses EuiLink. |
| packages/website/docs/components/display/icons/index.mdx | Adds raw source extraFiles and makes multiple snippets self-contained. |
| packages/website/docs/components/display/empty-prompt/types_of_empty_states/use_case_images.ts | Adds url-loader mapping for use-case images. |
| packages/website/docs/components/display/empty-prompt/types_of_empty_states/sidebar_snippet.tsx | Reworks demo to use url-loader assets + code string output. |
| packages/website/docs/components/display/empty-prompt/types_of_empty_states/multiple_snippet.tsx | Reworks demo to use url-loader assets + code string output. |
| packages/website/docs/components/display/empty-prompt/types_of_empty_states/empty_snippet.tsx | Reworks demo to use image URL mapping + code string output. |
| packages/website/docs/components/display/empty-prompt/index.mdx | Switches illustration demo to use url/raw loaders and extraFiles. |
| packages/website/docs/components/display/empty-prompt/_multiple_types.tsx | Converts examples to explicit code strings + adds extraFiles/scope for images. |
| packages/docusaurus-theme/src/components/demo/codesandbox/open_action.tsx | Injects @elastic/charts theme CSS imports into CodeSandbox demos. |
Comments suppressed due to low confidence (3)
packages/website/docs/components/forms/other/palette-picker.mdx:21
- This demo's code imports
DisplayTogglesfrom a relative path, but the demo transformer strips allimportstatements for react-live. Without also passingDisplayTogglesvia the<Demo scope={...}>, the interactive preview will throw (undefined component). Consider importingDisplayTogglesin the MDX file and addingscope={{ DisplayToggles }}to the<Demo>props (keepextraFilesfor CodeSandbox).
<Demo extraFiles={{ 'display_toggles.tsx': displayTogglesSource }}>
```tsx interactive
import React, { useState } from 'react';
import {
euiPaletteColorBlind,
euiPaletteForStatus,
packages/website/docs/components/forms/other/file-picker.mdx:17
- This demo's code imports
DisplayTogglesfrom a relative path, but the demo transformer strips allimportstatements for react-live. Without also passingDisplayTogglesvia the<Demo scope={...}>, the interactive preview will throw (undefined component). Consider importingDisplayTogglesin the MDX file and addingscope={{ DisplayToggles }}to the<Demo>props (keepextraFilesfor CodeSandbox).
<Demo extraFiles={{ 'display_toggles.tsx': displayTogglesSource }}>
```tsx interactive
import React, { useState } from 'react';
import {
EuiFilePicker,
EuiFlexGroup,
packages/website/docs/components/forms/numeric/range-sliders.mdx:564
- This demo's code imports
DisplayTogglesfrom a relative path, but the demo transformer strips allimportstatements for react-live. Without also passingDisplayTogglesvia the<Demo scope={...}>, the interactive preview will throw (undefined component). Consider importingDisplayTogglesin the MDX file and addingscope={{ DisplayToggles }}to the<Demo>props (keepextraFilesfor CodeSandbox).
<Demo extraFiles={{ 'display_toggles.tsx': displayTogglesSource }}>
```tsx interactive
import React, { useState } from 'react';
import {
EuiRange,
EuiRangeProps,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/website/docs/components/display/empty-prompt/index.mdx
Outdated
Show resolved
Hide resolved
packages/website/docs/components/forms/layouts/form_control_buttons.mdx
Outdated
Show resolved
Hide resolved
packages/website/docs/components/forms/layouts/form_control_buttons.mdx
Outdated
Show resolved
Hide resolved
packages/website/docs/components/display/empty-prompt/types_of_empty_states/empty_snippet.tsx
Show resolved
Hide resolved
packages/website/docs/components/display/empty-prompt/types_of_empty_states/sidebar_snippet.tsx
Show resolved
Hide resolved
packages/website/docs/components/forms/date-and-time/date-picker-range.mdx
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Collaborator
💚 Build SucceededHistory
|
Collaborator
💚 Build Succeeded
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tip
I recommend reviewing this PR by commits.
Summary
Resolves #9320
Many CodeSandbox examples were broken. This PR fixes all of them.
@faker-js/fakerto^10.3.0to align the docs preview with CodeSandbox, which resolves latest, and updatedfaker.internet.userName()calls tofaker.internet.username()(renamed in v9).useBaseUrl,useChartBaseTheme) not being available in CodeSandbox - replaced with self-contained alternatives.url-loader, passing them throughscope(react-live) andextraFiles(CodeSandbox).Impact Assessment
Impact level: 🟢 None
QA instructions for reviewer
Test all broken examples. If you feel up for it, you could test all examples.
Update
@faker-js/fakerto latestReplace
LinkwithEuiLinkAdd charts CSS imports
Simple cases (missing import, syntax error)
Complex cases
Checklist before marking Ready for Review
Tests: Added/updated Jest, Cypress, and VRTChangelog: Added changelog entryBreaking changes: Addedbreaking changelabel (if applicable)