-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add export dropdown for diagram downloads #11
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
Conversation
Summary of ChangesHello @harley, 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 refactors the diagram download functionality by replacing individual SVG and PNG download buttons with a unified 'Export' dropdown menu. This change aims to streamline the user interface, improve usability, and ensure consistent styling and behavior across different themes and diagram states. It also includes necessary updates to documentation to reflect the new workflow. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully replaces the separate SVG and PNG download buttons with a more compact 'Export' dropdown menu. The implementation correctly handles UI state, theme changes, and user interactions. I've identified a few areas for improvement, primarily related to accessibility and code simplification. I've provided specific suggestions for each of these points. Overall, this is a great enhancement to the UI.
menu.addEventListener('keydown', (event) => { | ||
if (event.key === 'Tab') { | ||
closeMenu() | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dropdown menu is not fully keyboard accessible. It should allow navigation between items using the ArrowUp and ArrowDown keys. The current implementation only handles closing on 'Tab', which is insufficient for keyboard navigation within the menu.
menu.addEventListener('keydown', (event) => {
if (event.key === 'Tab') {
closeMenu()
return
}
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
event.preventDefault()
const menuItems = [svgItem, pngItem]
const currentFocus = doc.activeElement
const currentIndex = menuItems.findIndex((item) => item === currentFocus)
let nextIndex: number
if (event.key === 'ArrowDown') {
nextIndex = currentIndex >= 0 ? (currentIndex + 1) % menuItems.length : 0
} else { // ArrowUp
nextIndex = currentIndex > 0 ? currentIndex - 1 : menuItems.length - 1
}
menuItems[nextIndex]?.focus()
}
})
|
||
function createExportMenuItem(doc: Document, label: string): HTMLButtonElement { | ||
const button = doc.createElement('button') | ||
button.type = 'button' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better accessibility, this button, which acts as a menu item, should have the role="menuitem"
attribute. This helps screen readers understand its purpose within the parent menu, which correctly has role="menu"
.
button.type = 'button' | |
button.type = 'button' | |
button.setAttribute('role', 'menuitem') |
button.disabled = false | ||
updateExportMenuItemState(button) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68de2ed7f85c832ba43b83d5c60a6735