Skip to content

[WEB-4687] feat: propel switch#7629

Merged
sriramveeraghanta merged 7 commits intopreviewfrom
feat-propel-switch
Aug 22, 2025
Merged

[WEB-4687] feat: propel switch#7629
sriramveeraghanta merged 7 commits intopreviewfrom
feat-propel-switch

Conversation

@JayashTripathy
Copy link
Member

@JayashTripathy JayashTripathy commented Aug 22, 2025

Description

added switch to propel

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features

    • Added a new Switch component: controlled toggle with value/onChange, optional accessible label, disabled state, and small/medium/large sizes. Now publicly exposed for consumers.
  • Chores

    • Cleaned up import ordering and removed duplicate/unused imports.
    • Updated package exports to include the new Switch entry; no runtime behavior changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 22, 2025

Walkthrough

Adds a new Switch component and exposes it via a new ./switch export in the Propel package; also performs small import reorder/cleanup in several Propel components and removes a duplicate lodash filter import in a web modal. No runtime behavior changes beyond new export/component.

Changes

Cohort / File(s) Summary
Propel: New Switch export & component
packages/propel/package.json, packages/propel/src/switch/index.ts, packages/propel/src/switch/root.tsx
Adds ./switch export in package.json; introduces Switch React component (props: value, onChange, label?, size?, disabled?, className?) implemented using BaseSwitch.Root/Thumb and re-exported via switch/index.ts.
Propel: Import tidy-ups
packages/propel/src/combobox/combobox.tsx, packages/propel/src/command/command.tsx
Reorders/moves cn and React imports and changes cn import source in one file. No functional/API changes.
Web: Modal import cleanup
apps/web/core/components/core/modals/existing-issues-list-modal.tsx
Adds a top-level lodash/filter import and removes a duplicate import later in the file. No functional changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Consumer
  participant PropelSwitch as Propel.Switch
  participant BaseRoot as BaseSwitch.Root
  participant BaseThumb as BaseSwitch.Thumb

  Consumer->>PropelSwitch: render({value, onChange, label, size, disabled})
  Note right of PropelSwitch #EFEFEF: compute classes via cn (size/state)
  PropelSwitch->>BaseRoot: props {checked=value, disabled, aria-label=label}
  PropelSwitch->>BaseRoot: onCheckedChange = onChange
  BaseRoot->>BaseThumb: render thumb (position/style from value+size+disabled)
  BaseRoot-->>Consumer: invokes onChange(newValue)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🌟improvement, 🌐frontend

Suggested reviewers

  • sriramveeraghanta
  • anmolsinghbhatia
  • vamsikrishnamathala

Poem

I’m a rabbit toggling tiny lights,
A thumb that slides through quiet nights.
New switch, new export — hop, hop, cheer!
I nibble code and hold it near.
Ship the change — a rabbit’s little cheer 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 08f4811 and 8a4e4af.

📒 Files selected for processing (1)
  • packages/propel/src/switch/root.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/propel/src/switch/root.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and lint web apps
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-propel-switch

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@makeplane
Copy link

makeplane bot commented Aug 22, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

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

🧹 Nitpick comments (2)
packages/propel/src/switch.tsx (2)

14-16: Forward the ref to Root to enable focus management and form integrations.

This wrapper currently swallows the ref. Forwarding it is a common requirement for DS components.

Apply this diff:

-const Switch: React.FC<IToggleSwitchProps> = (props) => {
+const Switch = React.forwardRef<React.ElementRef<typeof BaseSwitch.Root>, IToggleSwitchProps>(
+  (props, ref) => {
   const { value, onChange, label, size = "sm", disabled, className } = props;
   return (
     <BaseSwitch.Root
+      ref={ref}
       checked={value}
       disabled={disabled}
       onCheckedChange={onChange}
       className={cn(
@@
-  );
-};
+  );
+});

Also applies to: 17-17, 50-50


22-22: Use design tokens consistently for the off state (optional).

Off state uses bg-gray-700 while other colors use custom tokens. Consider swapping to a custom token for consistency with the design system.

Example:

-        "relative inline-flex flex-shrink-0 cursor-pointer rounded-full border border-custom-border-200 transition-colors duration-200 ease-in-out focus:outline-none",
+        "relative inline-flex flex-shrink-0 cursor-pointer rounded-full border border-custom-border-200 transition-colors duration-200 ease-in-out focus:outline-none",
         // size...
-        // state...
-        disabled
-          ? "cursor-not-allowed bg-custom-background-80"
-          : value
-          ? "bg-custom-primary-100"
-          : "bg-gray-700",
+        // state...
+        disabled
+          ? "cursor-not-allowed bg-custom-background-80"
+          : value
+          ? "bg-custom-primary-100"
+          : "bg-custom-background-90",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d3b2699 and cfeaf37.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/propel/src/switch.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/propel/src/switch.tsx (3)

1-3: Consider marking this as a Client Component.

If Propel is consumed in Next.js app-router (RSC) contexts, this interactive component should be compiled as a client component to avoid runtime errors.

If applicable, add the directive at the very top:

+ "use client";

Please confirm whether Propel components are already wrapped/consumed under client boundaries in the host app; if so, this can be skipped.


52-54: LGTM: displayName and export.

Setting a displayName helps React DevTools, and the named export is consistent with DS patterns.


2-2: Confirm existence of Radix-style subcomponents in @base-ui-components/react/switch

I ran the recommended searches in our repo and observed:

  • The only import of @base-ui-components/react/switch is in packages/propel/src/switch.tsx, with no other occurrences elsewhere.
  • There are no references to Switch.Root or Switch.Thumb in our codebase.
  • Our cn helper is defined in packages/utils/src/common.ts and packages/ui/src/utils/classname.tsx as expected.

Since the absence of references here doesn’t prove whether the external package actually exports Switch.Root and Switch.Thumb, please verify directly against the package’s API:

  • Inspect node_modules/@base-ui-components/react/switch/index.d.ts (or its source repo) to confirm those subcomponent exports.
  • Alternatively, check the package’s published documentation to ensure it provides Switch.Root and Switch.Thumb.

If those subcomponents aren’t exposed, the current imports/rendering will fail at compile- or runtime.

@JayashTripathy JayashTripathy changed the title [WEB-4687] feat: added switch [WEB-4687] Feat propel switch Aug 22, 2025
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

🧹 Nitpick comments (4)
packages/propel/src/switch/root.tsx (2)

14-20: Forward ref and pass-through native props for flexibility (id, name, onBlur, etc.).

Exposing a ref and spreading unhandled props to BaseSwitch.Root improves integration in forms and with focus management. Keep the current API but extend it.

You can adapt as follows (outside the exact lines shown, sketching the approach):

type SwitchRootElement = React.ElementRef<typeof BaseSwitch.Root>;
type SwitchRootProps = React.ComponentPropsWithoutRef<typeof BaseSwitch.Root>;

interface SwitchProps extends Omit<SwitchRootProps, "checked" | "onCheckedChange"> {
  value: boolean;
  onChange: (value: boolean) => void;
  label?: string;
  size?: "sm" | "md" | "lg";
  className?: string;
}

const Switch = React.forwardRef<SwitchRootElement, SwitchProps>(
  ({ value, onChange, label, size = "sm", disabled, className, ...rest }, ref) => (
    <BaseSwitch.Root
      ref={ref}
      checked={value}
      disabled={disabled}
      onCheckedChange={onChange}
      aria-label={label}
      className={cn(/* ...existing classes... */, className)}
      {...rest}
    >
      {label && <span className="sr-only">{label}</span>}
      {/* thumb */}
    </BaseSwitch.Root>
  )
);
Switch.displayName = "plane-ui-switch";

export { Switch };
export type { SwitchProps };

Also applies to: 29-31, 45-46


15-20: A11y: prefer external visible label support via aria-labelledby in addition to aria-label.

Current API only accepts a string label and sets aria-label. Many consumers render a visible text label adjacent to the switch. Consider supporting ariaLabelledBy?: string or passing arbitrary ARIA props through ...rest (see forwardRef suggestion) so consumers can bind an external label element.

Also applies to: 29-31

packages/propel/package.json (1)

25-26: Ensure CSS is retained and consider exporting Switch types

We’ve confirmed that both exported files exist under packages/propel/src and that no sideEffects field is currently set in packages/propel/package.json (it’s reported as “MISSING”). To avoid downstream bundlers tree-shaking away your CSS, add a sideEffects entry. You can opt for a broad or narrow scope:

• In packages/propel/package.json, add:

{
  "sideEffects": [
    "**/*.css"
  ]
}

—or, to be more specific:

{
  "sideEffects": [
    "./src/styles/fonts/index.css"
  ]
}

Optional: expose Switch props as a types entry

If you’d like to make SwitchProps (or other types) directly importable, you can add a types subpath export. For example, in packages/propel/package.json’s exports block:

  "exports": {
    "./switch": "./src/switch/index.ts",
+   "./switch/types": "./src/switch/types.ts"
  }

This lets consumers import props via:

import type { SwitchProps } from 'propel/switch/types'
packages/propel/src/switch/index.ts (1)

1-1: LGTM: clean re-export.

Simple and conventional surface. If you later export SwitchProps, consider adding export type { SwitchProps } from "./root";.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cfeaf37 and 101140a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/web/core/components/core/modals/existing-issues-list-modal.tsx (1 hunks)
  • packages/propel/package.json (1 hunks)
  • packages/propel/src/combobox/combobox.tsx (1 hunks)
  • packages/propel/src/command/command.tsx (1 hunks)
  • packages/propel/src/switch/index.ts (1 hunks)
  • packages/propel/src/switch/root.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/propel/src/command/command.tsx
  • packages/propel/src/combobox/combobox.tsx
  • apps/web/core/components/core/modals/existing-issues-list-modal.tsx
🔇 Additional comments (1)
packages/propel/src/switch/root.tsx (1)

48-50: LGTM on displayName and export.

Display name is helpful for DevTools; the named export matches the package export surface.

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

🧹 Nitpick comments (3)
packages/propel/src/command/command.tsx (3)

7-7: Remove the no-op empty string in cn call

cn("", className) is equivalent to cn(className) and adds noise.

Apply this diff:

-  return <CommandPrimitive data-slot="command" className={cn("", className)} {...props} />;
+  return <CommandPrimitive data-slot="command" className={cn(className)} {...props} />;

22-24: Pass through className to List/Empty/Item (currently destructured but unused)

className is being pulled off props and then dropped, which prevents consumers from styling these subcomponents and may trigger lint warnings.

Apply this diff:

 function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
-  return <CommandPrimitive.List data-slot="command-list" {...props} />;
+  return <CommandPrimitive.List data-slot="command-list" className={className} {...props} />;
 }

 function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
-  return <CommandPrimitive.Empty data-slot="command-empty" {...props} />;
+  return <CommandPrimitive.Empty data-slot="command-empty" {...props} />;
 }

 function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
-  return <CommandPrimitive.Item data-slot="command-item" {...props} />;
+  return <CommandPrimitive.Item data-slot="command-item" className={className} {...props} />;
 }

If styling should intentionally be locked down, remove className from the destructuring to avoid confusion instead.

Also applies to: 26-28, 30-32


4-4: Migrate cn to @plane/utils — confirmed, address redundant cn("", className) patterns

  • No lingering import { cn } from "@plane/ui" in packages/propel (✓).
  • @plane/utils (in packages/utils/src/common.ts) exports
    export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
    matching the prior signature (✓).
  • Detected redundant usages where cn("", className) can be simplified:
    • packages/propel/src/command/command.tsx (line 7)
      <CommandPrimitive  className={cn("", className)}  />
    • packages/propel/src/table/core.tsx (line 26)
      <tbody  className={cn("", className)}  />
    Suggestion: replace cn("", className) with className to improve readability.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 101140a and 08f4811.

📒 Files selected for processing (1)
  • packages/propel/src/command/command.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)

@vamsikrishnamathala vamsikrishnamathala self-requested a review August 22, 2025 14:35
@JayashTripathy JayashTripathy changed the title [WEB-4687] Feat propel switch [WEB-4687] feat: propel switch Aug 22, 2025
@sriramveeraghanta sriramveeraghanta merged commit cf8eeee into preview Aug 22, 2025
5 of 8 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-propel-switch branch August 22, 2025 18:57
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.

3 participants