Skip to content

feat: DR-7298 Add switch component#7550

Open
carlagn wants to merge 9 commits intomainfrom
feat/DR-7298-switch
Open

feat: DR-7298 Add switch component#7550
carlagn wants to merge 9 commits intomainfrom
feat/DR-7298-switch

Conversation

@carlagn
Copy link
Contributor

@carlagn carlagn commented Feb 24, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Switch component with full documentation and comprehensive examples.
    • Supports multiple sizes, disabled states, controlled/uncontrolled modes, accessibility features, and keyboard navigation.
    • Dark mode compatible with form element integration.
  • Chores

    • Added Radix UI dependency.

@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Mar 6, 2026 3:14pm
docs Ready Ready Preview, Comment Mar 6, 2026 3:14pm
eclipse Ready Ready Preview, Comment Mar 6, 2026 3:14pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Walkthrough

This pull request introduces a new Switch component to the design system by adding a Radix UI-based implementation, comprehensive MDX documentation with live examples, updating the atoms registry, adding the required radix-ui dependency, and exporting the component from the main API surface.

Changes

Cohort / File(s) Summary
Switch Component Implementation
packages/eclipse/src/components/switch.tsx, packages/eclipse/src/components/index.ts
New Switch component wrapping Radix UI with size variants ("sm" | "default"), state-driven styling, and proper className merging. Component is exported from the main barrel for public API access.
Design System Documentation
apps/eclipse/content/design-system/atoms/switch.mdx, apps/eclipse/content/design-system/atoms/meta.json
New MDX documentation file covering Switch usage, props, accessibility, keyboard support, form integration, dark mode, and multiple examples (BasicSwitch, WithLabel, ControlledSwitch, SwitchSizes, DisabledSwitch). Registry updated to include "switch" in atoms pages list.
Dependencies & Tooling
packages/eclipse/package.json, apps/eclipse/src/app/layout.tsx
Adds radix-ui ^1.4.3 as a runtime dependency. Layout component attributes reformatted across multiple lines without behavioral changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: DR-7298 Add switch component' directly and clearly summarizes the main change: introducing a new Switch component to the codebase.

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


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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

🍈 Lychee Link Check Report

3664 links: ✅ 2994 OK | 🚫 4 errors | 🔀 0 redirects | 👻 664 excluded

❌ Errors

./apps/docs/content/docs.v6/guides/permit-io-access-control.mdx

./apps/docs/content/docs.v6/orm/prisma-client/client-extensions/shared-extensions/permit-rbac.mdx

./apps/docs/content/docs/guides/integrations/permit-io.mdx

./apps/docs/content/docs/orm/prisma-client/client-extensions/shared-extensions/permit-rbac.mdx


Full Statistics Table
Status Count
✅ Successful 2994
🔀 Redirected 0
👻 Excluded 664
🚫 Errors 4
⛔ Unsupported 2
⏳ Timeouts 0
❓ Unknown 0

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: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/eclipse/content/design-system/atoms/switch.mdx`:
- Around line 467-477: The doc's styling tokens/sizes for the Switch component
are out of sync with the implementation; inspect the Switch component
implementation (named Switch) and either update this MDX (switch.mdx) to match
the actual classes (e.g., replace bg-input/bg-primary/thumb tokens with the
current bg-background-neutral-* classes and the actual Tailwind size utilities
used for heights/widths and thumb sizes) or change the component to use the
documented design tokens (bg-input, bg-primary, bg-background,
bg-primary-foreground, ring-ring/50, rounded-full, and the exact pixel sizes for
sm/default); ensure the MDX lists the same token names and pixel dimensions as
the component's classnames and that the focus ring, border (transparent with
shadow), and size variants (sm/default) exactly match the implementation.
- Around line 12-24: The examples render an unlabeled Switch which is
inaccessible; update the BasicSwitch component and the live example to provide
an accessible label by either passing an aria-label prop to the Switch (e.g.,
aria-label="Enable feature") or pairing the Switch with an explicit label
element and id. Specifically modify the BasicSwitch function (export function
BasicSwitch) to render <Switch aria-label="..."> (or wrap Switch with a <label
htmlFor="..."> and give the Switch an id) and update the inline Live Example
<Switch /> inside the demo div the same way so both examples show accessible
usage.

In `@packages/eclipse/src/components/switch.tsx`:
- Around line 14-27: The small variant lacks size classes so
SwitchPrimitive.Root and SwitchPrimitive.Thumb render without dimensions; add
matching data-[size=sm] rules alongside the existing data-[size=default] ones:
on SwitchPrimitive.Root add data-[size=sm]:h-... and data-[size=sm]:w-... (and
any disabled/outline equivalents) and on SwitchPrimitive.Thumb add
data-[size=sm] sizing (width/height) and adjust the translate-x for
data-[state=checked] for the sm thumb to correctly move to the end; update the
cn calls where data-[size=default] appears to include the corresponding
data-[size=sm] tokens so the small variant gets proper root and thumb dimensions
and translations.
- Around line 1-4: Add the client directive and correct Radix import: this file
uses the Radix Switch primitive so add "use client" as the first line of
packages/eclipse/src/components/switch.tsx, and change the import from
"radix-ui" to the scoped package "@radix-ui/react-switch" (the existing import
alias SwitchPrimitive should be preserved), ensuring the Switch component and
any references to SwitchPrimitive continue to work with the updated import.
- Line 2: Replace the import of SwitchPrimitive from the aggregator "radix-ui"
with the scoped package "@radix-ui/react-switch" and add
"@radix-ui/react-switch" to package.json dependencies; specifically update the
import statement that currently reads like `import { Switch as SwitchPrimitive }
from "radix-ui";` to import from "@radix-ui/react-switch" and run your package
install so SwitchPrimitive resolves the same way as other components
(tooltip/dialog/checkbox) in the codebase.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2427d3 and b70d2ba.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/eclipse/content/design-system/atoms/meta.json
  • apps/eclipse/content/design-system/atoms/switch.mdx
  • apps/eclipse/src/app/layout.tsx
  • packages/eclipse/package.json
  • packages/eclipse/src/components/index.ts
  • packages/eclipse/src/components/switch.tsx

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 5, 2026
Update stylings
remove size prop
@argos-ci
Copy link

argos-ci bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 removed Mar 6, 2026, 3:15 PM

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.

1 participant