Skip to content

feat: add expand button to categorical legend - #647

Merged
igorDykhta merged 1 commit into
mainfrom
igr/sqlrooms-legends-add-scroll-toggle
May 20, 2026
Merged

igorDykhta merged 1 commit into
mainfrom
igr/sqlrooms-legends-add-scroll-toggle

Conversation

@igorDykhta

@igorDykhta igorDykhta commented May 20, 2026 •

Copy link
Copy Markdown
Collaborator
  • Restore the missing expand/collapse arrow for legends, allowing users to show all category values at once without scrolling or minimize, just to show a few
Screenshot 2026-05-20 at 3 42 24 PM

Summary by CodeRabbit

Release Notes

  • New Features
    • Updated legend expand/collapse icon styling for improved visual consistency.
    • Enhanced legend layer item UI with improved styling and interaction states.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

CustomMapLegend.tsx updates the legend's layer item UI by changing expand/collapse icons from Arrow variants to Chevron icons, removing old inline CSS styling, and introducing scoped CSS styling via a legend-content-wrapper class that customizes the action button appearance and hover states.

Changes

Legend Layer Item UI Styling and Icons

Layer / File(s) Summary
Icon mapping and expanded layer styling
packages/kepler/src/components/CustomMapLegend.tsx
defaultActionIcons is updated to use ChevronDownIcon and ChevronRightIcon for expanded/collapsed states instead of ArrowDown/ArrowRight. The old inline CSS override is removed from the layer item container, and replaced with new scoped CSS injected when a layer is expanded. The .legend-content-wrapper class now wraps the expanded content with styles for the title row flex layout and full customization of .panel--header__action sizing, border radius, cursor, and hover accent colors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • ilyabo

Poem

🐰 Chevrons now guide the way,
Old arrows fade away,
Scoped styles bloom anew,
The legend shines true. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add expand button to categorical legend' directly aligns with the PR's main objective to restore the missing expand/collapse arrow for legends, allowing users to toggle between expanded and collapsed states.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch igr/sqlrooms-legends-add-scroll-toggle

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/kepler/src/components/CustomMapLegend.tsx (1)

183-194: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add accessibility attributes to expand/collapse button.

The expand/collapse button is missing key accessibility attributes:

  • aria-expanded attribute to indicate the current state to screen readers
  • aria-label or aria-labelledby to describe the button's purpose
♿ Proposed accessibility improvements
 <Button
   className="h-7 w-7"
   variant="ghost"
   size="icon"
   onClick={handleToggleExpanded}
+  aria-expanded={isExpanded}
+  aria-label={isExpanded ? "Collapse legend" : "Expand legend"}
 >
   {isExpanded ? (
     <ChevronDownIcon className="h-4 w-4" />
   ) : (
     <ChevronRightIcon className="h-4 w-4" />
   )}
 </Button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kepler/src/components/CustomMapLegend.tsx` around lines 183 - 194,
The expand/collapse Button (the Button element that calls handleToggleExpanded
and renders ChevronDownIcon/ChevronRightIcon based on isExpanded) lacks
accessibility attributes; add aria-expanded={isExpanded} and an aria-label
(e.g., aria-label={isExpanded ? "Collapse legend" : "Expand legend"}) to the
Button, and if the collapsible content has an id (e.g., a panel element you
control), also add aria-controls="<that-panel-id>" on the Button so screen
readers can associate the button with the collapsible legend content.
🧹 Nitpick comments (1)
packages/kepler/src/components/CustomMapLegend.tsx (1)

199-216: ⚖️ Poor tradeoff

Refactor inline style tag to a more maintainable approach.

The inline <style> tag is recreated in the DOM every time a layer expands or collapses (the entire div is conditionally rendered within {isExpanded && (...)}), which creates performance and maintainability issues:

  • Performance: Style tag injection on every expand/collapse cycle
  • Maintainability: CSS rules are embedded in component logic rather than in a dedicated stylesheet
  • Testing: Makes it harder to test styling in isolation

Consider these alternatives:

  • Option 1 (Recommended): Extract to a CSS module or external stylesheet
  • Option 2: Use Tailwind classes if these styles can be expressed with utility classes
  • Option 3: Move styles outside the conditional so they're only injected once
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/kepler/src/components/CustomMapLegend.tsx` around lines 199 - 216,
The inline <style> block inside the conditional rendering of the legend (within
CustomMapLegend's isExpanded branch) causes repeated DOM style injections; move
these rules out of the component into a maintainable stylesheet or CSS module
(or replace with equivalent Tailwind utility classes) and apply the existing
class names (.legend-content-wrapper, .legend--layer_size-title-row,
.panel--header__action) from that stylesheet; alternatively place the <style>
once outside the conditional so it’s injected a single time, ensuring
CustomMapLegend still uses the same class names and behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/kepler/src/components/CustomMapLegend.tsx`:
- Around line 183-194: The expand/collapse Button (the Button element that calls
handleToggleExpanded and renders ChevronDownIcon/ChevronRightIcon based on
isExpanded) lacks accessibility attributes; add aria-expanded={isExpanded} and
an aria-label (e.g., aria-label={isExpanded ? "Collapse legend" : "Expand
legend"}) to the Button, and if the collapsible content has an id (e.g., a panel
element you control), also add aria-controls="<that-panel-id>" on the Button so
screen readers can associate the button with the collapsible legend content.

---

Nitpick comments:
In `@packages/kepler/src/components/CustomMapLegend.tsx`:
- Around line 199-216: The inline <style> block inside the conditional rendering
of the legend (within CustomMapLegend's isExpanded branch) causes repeated DOM
style injections; move these rules out of the component into a maintainable
stylesheet or CSS module (or replace with equivalent Tailwind utility classes)
and apply the existing class names (.legend-content-wrapper,
.legend--layer_size-title-row, .panel--header__action) from that stylesheet;
alternatively place the <style> once outside the conditional so it’s injected a
single time, ensuring CustomMapLegend still uses the same class names and
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0456465a-d943-4832-9cab-720c630613a0

📥 Commits

Reviewing files that changed from the base of the PR and between cb9a590 and c1e70e1.

📒 Files selected for processing (1)
  • packages/kepler/src/components/CustomMapLegend.tsx

@igorDykhta
igorDykhta requested a review from ilyabo May 20, 2026 13:21
@igorDykhta igorDykhta self-assigned this May 20, 2026
@igorDykhta
igorDykhta merged commit 94ca393 into main May 20, 2026
4 checks passed
@igorDykhta
igorDykhta deleted the igr/sqlrooms-legends-add-scroll-toggle branch May 20, 2026 21:13
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