Addon-Docs: Edit JSON button is now accessible at 320x256 viewport (WCAG 2.1 Reflow test)#33707
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughReplaces the Object control's plain "Edit JSON" trigger with an icon-plus-text button, adds responsive container-query and media-rule styling to reflow/hide text on small viewports, centralizes and exports an Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
code/addons/docs/src/blocks/controls/Object.tsx (1)
254-266: ariaLabel implementation looks good, but spacing between icon and text needs explicit definition.The
ariaLabelwith the dynamic name property correctly follows the Button component convention (extends ButtonProps). However, the RawButton styling doesn't explicitly define a gap between the EditIcon and span elements. Add explicit gap spacing to ensure consistent alignment:const RawButton = styled(ToggleButton)({ flexShrink: 0, + gap: '4px', // Hide text on small screens, show only icon for accessibility (WCAG 2.1 Reflow) '@media (max-width: 400px)': { '& > span': { display: 'none', }, }, });The ariaLabel properly ensures accessibility when text is hidden on small screens, and the icon+text pattern is sound.
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 402 KB | 379 KB | 🎉 -23 KB 🎉 |
| Dependency size | 338 KB | 338 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 20.41 MB | 20.39 MB | 🎉 -23 KB 🎉 |
| Dependency size | 16.52 MB | 16.52 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/preact-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 14 | 0 |
| Self size | 13 KB | 13 KB | 🎉 -81 B 🎉 |
| Dependency size | 1.46 MB | 1.45 MB | 🎉 -12 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 183 | 183 | 0 |
| Self size | 779 KB | 775 KB | 🎉 -4 KB 🎉 |
| Dependency size | 67.64 MB | 67.57 MB | 🎉 -69 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 176 | 176 | 0 |
| Self size | 32 KB | 30 KB | 🎉 -2 KB 🎉 |
| Dependency size | 66.17 MB | 66.14 MB | 🎉 -23 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1.04 MB | 1000 KB | 🎉 -44 KB 🎉 |
| Dependency size | 36.94 MB | 36.92 MB | 🎉 -23 KB 🎉 |
| Bundle Size Analyzer | node | node |
@storybook/preact
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 2 | 2 | 0 |
| Self size | 23 KB | 16 KB | 🎉 -7 KB 🎉 |
| Dependency size | 32 KB | 32 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
|
Thank you for opening the PR! As you can see here, it seems like the |
…ns, use column layout on small screens for WCAG 2.1 Reflow
|
Hi @valentinpalkovic, I've updated the implementation based on your feedback. On large screens, I restored the original position: absolute layout, so the Edit JSON button is back in the top-right corner as before. On small screens (320×256, WCAG 2.1 Reflow), the wrapper switches to flex-direction: column, the button becomes position: static with align-self: flex-end, and the text is hidden so only the icon is shown. The layout stays unchanged on normal screens while remaining accessible on small viewports. |
|
Great! Thanks for addressing the feedback. Could you add another set of stories for I would like to get a design review from @MichaelArestad. Questions:
|
|
Thanks! I will add the small viewport stories for Chromatic coverage.
|
|
I added small viewport stories (320px) for Chromatic coverage. |
Sidnioulz
left a comment
There was a problem hiding this comment.
Thanks for tackling this ❤️
We need a few changes to preserve the screenreader experience and to make your change apply more broadly.
Please re-request a review once you've made the changes. Thanks!
| right: 2, | ||
| gap: '4px', | ||
|
|
||
| // On small screens: remove absolute positioning, show only icon (WCAG 2.1 Reflow) |
There was a problem hiding this comment.
Could you also add a container query?, and then add the below media query as a backup for users without container query support?
import { css } from 'storybook/theming'
const styles = css`
@supports (container-type: inline-size) {
container-type: inline-size;
@container (max-width: 400px) {
// your css here
}
}
`This will help the change happen more often when needed.
| position: 'static', | ||
| alignSelf: 'flex-end', | ||
| '& > span': { | ||
| display: 'none', |
There was a problem hiding this comment.
We can't entirely hide the text, or screen readers will fail to properly announce the edit button.
We have a sb-sr-only class available in code/core/src/theming/global.ts. Could you try to export the CSSObject defined for that class and then to inject it to your style here?
e.g.
import { srOnlyStyles } from '../../../ ... ' // or maybe from 'storybook/theming';
'@media (max-width: 400px)': {
// ...
'& > span': srOnlyStyles,
}@ndelangen would you object to us exporting our screenreader-only class in storybook/theming to simplify this kind of use case? It's definitely a piece of code we'll keep very long term, and one which we're unlikely to ever need to adjust.
|
Thanks for the review @Sidnioulz! I have made the requested changes:
|
Closes #24149
Edit JSON button is now accessible at 320x256 viewport (WCAG 2.1 Reflow test).
Changes Made
Related Issue
Fixes #24149
Checklist
Summary by CodeRabbit
New Features
Style
Accessibility