Header & responsive layout polish; add read-only status badge for shared links - #109
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the header UI and read-only mode indicators. Key changes include replacing the manual share indicator with a dedicated status badge component, improving layout responsiveness and text truncation handling in the header, and updating button labels and accessibility attributes. CSS was also cleaned up to remove unused classes and adjust component sizing. I have no feedback to provide as no review comments were submitted.
There was a problem hiding this comment.
Pull request overview
Refines the header’s shared-link read-only indicator by reusing an existing status badge element and updating it via class selection, improving consistency and enabling better responsive/accessibility behavior.
Changes:
- Update header markup to remove the
id-based status badge hook and keep a class-based.header-status-badgeelement witharia-live. - Update
checkSharedLink()to set the read-only text (僅供檢視) on all.header-status-badgeelements instead of targeting a single#headerStatusBadge.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| public/index.html | Adjusts the status badge element to be class-based (removes id) while keeping an ARIA live region. |
| frontend/share.js | Updates shared-link detection to set read-only status text on .header-status-badge elements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <div class="subtitle-row"> | ||
| <p class="subtitle" id="examTitle">--</p> | ||
| <span class="header-status-badge" id="headerStatusBadge" aria-live="polite"></span> | ||
| <span class="header-status-badge" aria-live="polite"></span> |
There was a problem hiding this comment.
Because the JS now updates all .header-status-badge elements, having aria-live on each badge instance can cause duplicate announcements if multiple badges exist on the page. Consider making only one dedicated live region (e.g., add role=\"status\" and optionally aria-atomic=\"true\" on a single badge), and mark any additional visible duplicates as aria-hidden=\"true\" so screen readers announce the status only once.
| document.querySelectorAll('.header-status-badge') | ||
| .forEach((headerStatusBadge) => { | ||
| headerStatusBadge.textContent = '僅供檢視'; | ||
| }); |
There was a problem hiding this comment.
If the intent is to have a single status badge, updating a NodeList via querySelectorAll(...).forEach(...) is unnecessary and slightly obscures intent. Prefer selecting a single element (or explicitly documenting that multiple badges are expected) to keep the DOM contract clear and avoid accidentally updating badges in other parts of the UI that reuse the same class.
| document.querySelectorAll('.header-status-badge') | |
| .forEach((headerStatusBadge) => { | |
| headerStatusBadge.textContent = '僅供檢視'; | |
| }); | |
| const headerStatusBadge = document.querySelector('.header-status-badge'); | |
| if (headerStatusBadge) { | |
| headerStatusBadge.textContent = '僅供檢視'; | |
| } |
Motivation
Description
checkSharedLinkinfrontend/share.jsto set the text of existing.header-status-badgeelements to僅供檢視instead of creating and inserting a new indicator element..header-status-badgeelement into the header markup inpublic/index.htmland addaria-livesupport for status updates; addaria-labelattributes and adjust the import/share button text.frontend/styles/header.css,frontend/styles/compatibility.css,frontend/styles/responsive.css, andfrontend/styles/utilities.cssto refine header padding/gaps, icon sizes, truncation behavior, read-only mode visuals, responsive wrapping behavior, and the new badge styling.readonly-badgeusage and wire read-only visibility viabody.read-only-moderules while ensuring the data-time box layout adapts on small screens.public/index.htmlto the new built CSS/JS filenames.Testing
npm run buildto produce production assets and the build completed successfully.npm run lintand automated linting passed without errors.Codex Task