Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add theme toggle button to error overlay #5884

Merged
merged 8 commits into from
Jan 18, 2023

Conversation

MoustaphaDev
Copy link
Member

@MoustaphaDev MoustaphaDev commented Jan 17, 2023

Changes

Add a theme toggle button for the error overlay
ezgif com-gif-maker (1)

Testing

Tested manually

Docs

This is a style change, doesn't need to be documented

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2023

🦋 Changeset detected

Latest commit: dafd26e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 17, 2023
// theme toggle logic
const themeToggleButton = this.root.querySelector<HTMLButtonElement>('#theme-toggle');
if (
localStorage.astroErrorOverlayTheme === 'dark' ||
Copy link
Member Author

@MoustaphaDev MoustaphaDev Jan 17, 2023

Choose a reason for hiding this comment

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

Not sure if it would've been an issue, but I made the name of the key this lengthy so that it'd be unlikely to coincide with a key already in local storage that the developer had set in their main site.

@doodlemarks
Copy link
Contributor

Liking this enhancement!

Just popping in with some design guidance. The placement on the left side above the main title is very prominent in the hierarchy.

I mocked up a more standard toggle switch with it less prominent in the top right here:

https://www.figma.com/file/KM7dKti4BKAprnqhY8EHgI/Error-Messages?node-id=313%3A915&t=ptVVf9yWWcUszwVl-1

Let me know if I can provide any other guidance.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

One small code improvement here but loving where this is heading!

packages/astro/src/core/errors/overlay.ts Outdated Show resolved Hide resolved
MoustaphaDev and others added 3 commits January 18, 2023 00:00
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
@MoustaphaDev
Copy link
Member Author

MoustaphaDev commented Jan 18, 2023

Here's the final result

ezgif com-gif-maker (2)

Copy link
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

That's a great addition to the error overlay, nice work @MoustaphaDev! There are a few a11y issues I made suggestions to fix:

  • Missing label text (so screen readers can explain that the checkbox activates dark mode)

Before: "Checkbox (checked/not checked)"
After: "Use dark theme, checkbox (checked/not checked)"

Tested with NVDA, different screen readers can differ here.

  • No focus styles
Before (Focused) After (Focused)
image image
  • Functionality unclear in high contrast mode
Before After
image image

packages/astro/src/core/errors/overlay.ts Outdated Show resolved Hide resolved
packages/astro/src/core/errors/overlay.ts Show resolved Hide resolved
packages/astro/src/core/errors/overlay.ts Show resolved Hide resolved
packages/astro/src/core/errors/overlay.ts Outdated Show resolved Hide resolved
packages/astro/src/core/errors/overlay.ts Outdated Show resolved Hide resolved
@MoustaphaDev MoustaphaDev changed the title feat: add theme toggle button for error overlay feat: add theme toggle button to error overlay Jan 18, 2023
Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
@MoustaphaDev
Copy link
Member Author

Thanks for the awesome a11y checks @Yan-Thomas!

Copy link
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

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

LGTM! Looks like the MacOS test suite timed out, I think running the tests again should fix.

@MoustaphaDev MoustaphaDev merged commit ce5c5db into main Jan 18, 2023
@MoustaphaDev MoustaphaDev deleted the moustapha/configurable-overlay-2 branch January 18, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants