🎨 Palette: [UX improvement] - Enhance SectionControls with icons and a11y#385
🎨 Palette: [UX improvement] - Enhance SectionControls with icons and a11y#385aafre wants to merge 2 commits into
Conversation
…a11y Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience and accessibility of the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully enhances the SectionControls component by replacing emojis with SVG icons and adding accessibility features like aria-label and title. The changes improve the user experience and align with modern web practices. My review includes a few suggestions to further improve code quality by addressing a potentially unused dependency, strengthening type safety, and reducing code duplication.
| "@supabase/supabase-js": "^2.89.0", | ||
| "@tanstack/react-query": "^5.90.12", | ||
| "@tanstack/react-query-devtools": "^5.91.1", | ||
| "@tiptap/core": "^3.20.1", |
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| sections: any[]; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| setSections: (sections: any[]) => void; |
There was a problem hiding this comment.
Using any and disabling the linter rule reduces type safety. Since this component doesn't need to know the internal structure of the section items, you can replace any[] with the type-safe unknown[]. This makes the component more robust and maintainable.
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | |
| sections: any[]; | |
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | |
| setSections: (sections: any[]) => void; | |
| sections: unknown[]; | |
| setSections: (sections: unknown[]) => void; |
| <button | ||
| type="button" | ||
| onClick={() => moveSection(sectionIndex, sectionIndex - 1)} | ||
| disabled={sectionIndex === 0} | ||
| className={`px-2 py-1 rounded ${ | ||
| aria-label="Move section up" | ||
| title="Move section up" | ||
| className={`p-2 rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-accent ${ | ||
| sectionIndex === 0 | ||
| ? "bg-gray-300 cursor-not-allowed" | ||
| : "bg-accent hover:bg-accent text-ink" | ||
| ? "text-gray-400 bg-gray-100 cursor-not-allowed" | ||
| : "text-gray-600 hover:text-accent hover:bg-accent/[0.06] active:bg-accent/[0.1]" | ||
| }`} | ||
| > | ||
| ↑ | ||
| <MdArrowUpward className="text-xl" aria-hidden="true" /> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| onClick={() => moveSection(sectionIndex, sectionIndex + 1)} | ||
| disabled={sectionIndex === sections.length - 1} | ||
| className={`px-2 py-1 rounded ${ | ||
| aria-label="Move section down" | ||
| title="Move section down" | ||
| className={`p-2 rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-accent ${ | ||
| sectionIndex === sections.length - 1 | ||
| ? "bg-gray-300 cursor-not-allowed" | ||
| : "bg-accent hover:bg-accent text-ink" | ||
| ? "text-gray-400 bg-gray-100 cursor-not-allowed" | ||
| : "text-gray-600 hover:text-accent hover:bg-accent/[0.06] active:bg-accent/[0.1]" | ||
| }`} | ||
| > | ||
| ↓ | ||
| <MdArrowDownward className="text-xl" aria-hidden="true" /> | ||
| </button> |
There was a problem hiding this comment.
The up and down buttons share a significant amount of Tailwind CSS classes, leading to code duplication. To improve maintainability and ensure consistency, you could extract the common and state-specific classes into variables.
For example:
const baseClasses = "p-2 rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-accent";
const disabledClasses = "text-gray-400 bg-gray-100 cursor-not-allowed";
const enabledClasses = "text-gray-600 hover:text-accent hover:bg-accent/[0.06] active:bg-accent/[0.1]";
// Then apply them like this:
<button
// ...
className={${baseClasses} ${disabled ? disabledClasses : enabledClasses}}
/>
This would make the styling logic cleaner and easier to manage.
…a11y Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
💡 What: Replaced plain text emojis with SVG icons (
MdArrowUpward,MdArrowDownward,MdDeleteOutline) fromreact-icons/mdinSectionControls.tsx. Addedaria-label,title, and explicit hover/focus/active states.🎯 Why: To improve the accessibility, visual consistency, and overall usability of the section controls. The emojis were non-descriptive to screen readers and lacked proper focus indicators for keyboard navigation. The new SVGs align with the application's overall design system.
📸 Before/After: Visual changes apply. (Text Emojis -> React Icons)
♿ Accessibility:
aria-labels for screen reader support.titleattributes for tooltips on hover.focus-visiblestyles (focus-visible:ring-2,focus-visible:ring-accent,focus-visible:ring-red-500) to ensure clear focus indication for keyboard users.PR created automatically by Jules for task 6782404259643635206 started by @aafre