Skip to content

UI: Ensure preview error displays use a readable text color#33580

Merged
ndelangen merged 3 commits into
nextfrom
sidnioulz/issue-32749
Jan 20, 2026
Merged

UI: Ensure preview error displays use a readable text color#33580
ndelangen merged 3 commits into
nextfrom
sidnioulz/issue-32749

Conversation

@Sidnioulz
Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz commented Jan 19, 2026

Closes #32749

What I did

Sets CSS selectors with high specificty on all nodes of both Preview Error displays:

  • "No preview" which triggers when there are no stories
  • The error wrapper that shows a title, message and stack trace

This PR may have side effects on existing users' CSS customisations to the aforementioned UIs. We need to decide if we consider that a potential breaking change.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  1. Visit http://localhost:6006/?path=/story/preview-errors--my-error-with-custom-css
  2. Visit http://localhost:6006/?path=/story/preview-errors--missing-with-custom-css

Documentation

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Style

    • Improved error display visual styling with updated colors and enhanced readability
    • Refined preview block spacing and formatting consistency
  • Tests

    • Added new error display story variants with custom styling scenarios

✏️ Tip: You can customize this high-level summary in your review settings.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit dea343c

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 11m 10s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 16:22:43 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 0c924be


☁️ Nx Cloud last updated this comment at 2026-01-19 12:35:53 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 0c924be

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ⏳ In Progress ... View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 12:47:17 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

Updates CSS selectors and visual styling in the base preview HTML file to refine error display formatting and color schemes. Introduces two new story variants in the error stories file to demonstrate custom CSS styling application.

Changes

Cohort / File(s) Summary
Preview HTML Styling
code/core/assets/server/base-preview-head.html
CSS selector formatting normalization (removed spaces around combinators); visual theme adjustments for error/nopreview blocks (background color rgb(247,247,247), explicit text colors); new .sb-errordisplay_main and .sb-errordisplay_code blocks with layout, borders, and monospace typography; universal color resets for readability.
Story Variants
code/core/src/preview-api/Errors.stories.tsx
Added internal StyleDecorator utility; introduced two new story exports (MyErrorWithCustomCSS, MissingWithCustomCSS) that extend existing stories with custom CSS styling via decorators.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented Jan 19, 2026

Package Benchmarks

Commit: dea343c, ran on 19 January 2026 at 16:21:57 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 49 49 0
Self size 20.30 MB 20.31 MB 🚨 +10 KB 🚨
Dependency size 16.52 MB 16.52 MB 🎉 -4 B 🎉
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 159 159 0
Self size 30 KB 30 KB 🚨 +8 B 🚨
Dependency size 23.00 MB 23.12 MB 🚨 +115 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 183 183 0
Self size 775 KB 775 KB 🚨 +139 B 🚨
Dependency size 67.38 MB 67.46 MB 🚨 +80 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 176 176 0
Self size 30 KB 30 KB 🎉 -4 B 🎉
Dependency size 65.95 MB 66.03 MB 🚨 +80 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 50 50 0
Self size 1000 KB 999 KB 🎉 -48 B 🎉
Dependency size 36.82 MB 36.83 MB 🚨 +10 KB 🚨
Bundle Size Analyzer node node

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User's global preview styles affects the error overlay

3 participants