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

a11y Improvements #255

Merged
merged 4 commits into from
Nov 26, 2024
Merged

a11y Improvements #255

merged 4 commits into from
Nov 26, 2024

Conversation

wazeerc
Copy link
Contributor

@wazeerc wazeerc commented Nov 26, 2024

  • Enhance keyboard accessibility in nav bar, by toggling the About sub-menu on focus. This provides visual feedback and lets the user see what is being selected when using the Tab key to navigate.
  • Added Focus effects (similar to hover) when using the Keyboard/Tab to navigate the event cards.

frontendmu-a11y-kb

  • Added aria-labels to the social media menu items & refactored the component for lesser code repetition.
    Before vs After:

before after

Summary by CodeRabbit

  • New Features

    • Enhanced accessibility for the event card component with improved focus styles.
    • Dynamic rendering of social media links in the Left Menu for better maintainability.
    • Added aria attributes to Menu Item for improved accessibility and user experience.
  • Bug Fixes

    • Updated CSS for hover and focus states to ensure dropdown menus are accessible via keyboard navigation.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The pull request introduces several modifications across three Vue components. In event-card-modern.vue, class attributes are updated to improve focus styles for accessibility. The LeftMenu.vue component undergoes significant refactoring to dynamically render social media links using a new constant, enhancing maintainability. Lastly, MenuItem.vue sees the addition of an aria-haspopup attribute for improved accessibility and updates to CSS for hover and focus states, ensuring better keyboard navigation and user experience.

Changes

File Path Change Summary
packages/frontendmu-nuxt/components/cards/event-card-modern.vue Updated class attributes for focus styles on container and title elements.
packages/frontendmu-nuxt/components/site/LeftMenu.vue Refactored social media links to use a dynamic socialMediaPlatforms constant with v-for.
packages/frontendmu-nuxt/components/site/MenuItem.vue Added aria-haspopup attribute for accessibility and modified CSS for hover and focus states.

Possibly related PRs

Poem

In the garden of code, where rabbits play,
We hop and we tweak, making bright the day.
With links that now dance and focus that shines,
Our components are ready, with style that aligns.
So let’s celebrate changes, both big and small,
For a better experience, we’ll share with all! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (5)
packages/frontendmu-nuxt/components/site/LeftMenu.vue (2)

4-11: LGTM! Consider minor improvements for maintainability.

The introduction of socialMediaPlatforms constant is a good refactoring that centralizes URLs and enables dynamic rendering.

Consider these minor improvements:

+// Map of social media platform names to their respective URLs
 const socialMediaPlatforms: Record<string, string> = {
+  // Platforms sorted alphabetically for better maintainability
   discord: DISCORD_URL,
   github: GITHUB_URL,
   instagram: INSTAGRAM_URL,
   linkedin: LINKEDIN_URL,
   twitter: TWITTER_URL,
   whatsapp: WHATSAPP_URL,
 }

25-30: Consider additional accessibility enhancements for icons.

The icons are currently decorative and supplement the aria-labels. To prevent duplicate announcements and improve accessibility:

-      <IconDiscord v-if="platform === 'discord'" class="w-6" />
+      <IconDiscord v-if="platform === 'discord'" class="w-6" aria-hidden="true" />
-      <IconGithub v-if="platform === 'github'" class="w-6" />
+      <IconGithub v-if="platform === 'github'" class="w-6" aria-hidden="true" />
-      <IconWhatsappCommunity v-if="platform === 'whatsapp'" class="w-6" />
+      <IconWhatsappCommunity v-if="platform === 'whatsapp'" class="w-6" aria-hidden="true" />
-      <IconSocialTwitter v-if="platform === 'twitter'" class="w-6" />
+      <IconSocialTwitter v-if="platform === 'twitter'" class="w-6" aria-hidden="true" />
-      <IconInstagram v-if="platform === 'instagram'" class="w-6" />
+      <IconInstagram v-if="platform === 'instagram'" class="w-6" aria-hidden="true" />
-      <IconLinkedin v-if="platform === 'linkedin'" class="w-6" />
+      <IconLinkedin v-if="platform === 'linkedin'" class="w-6" aria-hidden="true" />

Also, consider adding a prefers-reduced-motion media query for the bounce animation to respect user motion preferences:

-      class="text-verse-500 dark:text-verse-200 text-sm md:text-normal hover:animate-bounce hover:ease-in-out hover:delay-200"
+      class="text-verse-500 dark:text-verse-200 text-sm md:text-normal motion-safe:hover:animate-bounce hover:ease-in-out hover:delay-200"
packages/frontendmu-nuxt/components/site/MenuItem.vue (2)

Line range hint 71-83: Enhance focus visibility for better keyboard navigation

The addition of :focus-within improves keyboard accessibility, but the visual feedback could be enhanced.

Consider these CSS improvements:

 &:focus-within,
 &:hover {
+    outline: 2px solid currentColor;
+    outline-offset: 2px;
 
     .menu-dropdown {
         display: block;
         opacity: 1;
         clip-path: circle(100%);
         transform: translateY(0px);
         padding-top: 7px;
         transform-origin: left -100px;
+        transition: all 0.3s ease;
     }
 }

Accessibility improvements need enhancement

The current implementation has some gaps in accessibility that should be addressed:

  • The aria-haspopup attribute is only applied for the "About" menu item, but it should be applied to all menu items with children
  • The dropdown menu lacks proper ARIA attributes (aria-expanded, aria-controls) to indicate its state
  • No keyboard navigation handlers are implemented for the dropdown menu, making it inaccessible for keyboard users

Required changes:

  • Update the aria-haspopup binding to: :aria-haspopup="links[item].children ? 'true' : undefined"
  • Add :aria-expanded binding to track dropdown state
  • Add aria-controls attribute linking the dropdown to its trigger
  • Implement keyboard navigation handlers for the dropdown menu
🔗 Analysis chain

Line range hint 29-83: Verify accessibility with external links and theme changes

Please ensure that the accessibility improvements work consistently across different scenarios.


Let me gather more specific information about the accessibility implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other potential accessibility issues in the codebase

# Look for other dropdown menus that might need similar improvements
ast-grep --pattern 'class="menu-dropdown"'

# Check for consistent aria-haspopup usage
rg -l 'aria-haspopup'

# Look for other focus-related styles that might need updating
rg -l ':focus-within'

Length of output: 196


Script:

#!/bin/bash
# Check the complete MenuItem.vue file to understand the full context
cat packages/frontendmu-nuxt/components/site/MenuItem.vue

# Look for any ARIA attributes in the codebase
rg -l 'aria-' packages/frontendmu-nuxt/

# Check for keyboard navigation related handlers
rg -l '@keydown|@keyup|@keypress' packages/frontendmu-nuxt/

Length of output: 3827

packages/frontendmu-nuxt/components/cards/event-card-modern.vue (1)

Line range hint 47-52: Consider enhancing the focus indicator

The focus styles look good and match the hover states. However, consider adding a visible focus outline or ring effect specifically for keyboard navigation to enhance accessibility further.

Consider adding these Tailwind classes to the NuxtLink:

-<NuxtLink :href="`/meetup/${event.id}`" class="w-[300px] md:w-96 focus:outline-none">
+<NuxtLink :href="`/meetup/${event.id}`" class="w-[300px] md:w-96 focus:outline-none focus-visible:ring-2 focus-visible:ring-verse-400 focus-visible:ring-offset-2 rounded">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dcc24a4 and e8961f7.

📒 Files selected for processing (3)
  • packages/frontendmu-nuxt/components/cards/event-card-modern.vue (2 hunks)
  • packages/frontendmu-nuxt/components/site/LeftMenu.vue (1 hunks)
  • packages/frontendmu-nuxt/components/site/MenuItem.vue (2 hunks)
🔇 Additional comments (1)
packages/frontendmu-nuxt/components/site/LeftMenu.vue (1)

15-24: Great accessibility improvements with semantic HTML and ARIA labels!

The refactoring improves accessibility through:

  • Proper use of nav element
  • Addition of aria-label for screen readers
  • Secure external link attributes

@MrSunshyne
Copy link
Member

beautiful! merging.

thx @wazeerc

@MrSunshyne MrSunshyne merged commit 083b278 into frontendmu:main Nov 26, 2024
2 checks passed
@wazeerc wazeerc deleted the ux/improvements branch November 26, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants