From d1d16691e7529147383532116d707022b30d8a0c Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Tue, 9 Sep 2025 10:10:45 +0530 Subject: [PATCH 1/4] dev: toolbar component added to propel --- packages/propel/src/toolbar/index.ts | 2 + packages/propel/src/toolbar/toolbar.tsx | 159 ++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 packages/propel/src/toolbar/index.ts create mode 100644 packages/propel/src/toolbar/toolbar.tsx diff --git a/packages/propel/src/toolbar/index.ts b/packages/propel/src/toolbar/index.ts new file mode 100644 index 00000000000..0ff7414bc0a --- /dev/null +++ b/packages/propel/src/toolbar/index.ts @@ -0,0 +1,2 @@ +export { Toolbar, ToolbarGroup, ToolbarItem, ToolbarSeparator, ToolbarSubmitButton } from "./toolbar"; +export type { ToolbarProps, ToolbarGroupProps, ToolbarItemProps, ToolbarSeparatorProps, ToolbarSubmitButtonProps } from "./toolbar"; \ No newline at end of file diff --git a/packages/propel/src/toolbar/toolbar.tsx b/packages/propel/src/toolbar/toolbar.tsx new file mode 100644 index 00000000000..b1dda9e9719 --- /dev/null +++ b/packages/propel/src/toolbar/toolbar.tsx @@ -0,0 +1,159 @@ +import * as React from "react"; +import { LucideIcon } from "lucide-react"; +import { Tooltip } from "../tooltip"; +import { cn } from "../utils"; + +export interface ToolbarProps extends React.HTMLAttributes { + children: React.ReactNode; + className?: string; +} + +export interface ToolbarGroupProps extends React.HTMLAttributes { + children: React.ReactNode; + className?: string; + isFirst?: boolean; +} + +export interface ToolbarItemProps extends React.ButtonHTMLAttributes { + icon: LucideIcon; + isActive?: boolean; + tooltip?: string; + shortcut?: string[]; + className?: string; + children?: React.ReactNode; +} + +export interface ToolbarSeparatorProps extends React.HTMLAttributes { + className?: string; +} + +export interface ToolbarSubmitButtonProps extends React.ButtonHTMLAttributes { + loading?: boolean; + variant?: "primary" | "secondary" | "outline" | "ghost" | "destructive"; + className?: string; + children: React.ReactNode; +} + +const ToolbarRoot = React.forwardRef(({ className, children, ...props }, ref) => ( +
+ {children} +
+)); + +const ToolbarGroup = React.forwardRef( + ({ className, children, isFirst = false, ...props }, ref) => ( +
+ {children} +
+ ) +); + +const ToolbarItem = React.forwardRef( + ({ icon: Icon, isActive = false, tooltip, shortcut, className, children, ...props }, ref) => { + const button = ( + + ); + + if (tooltip) { + return ( + + {tooltip} + {shortcut && {shortcut.join(" + ")}} + + } + > + {button} + + ); + } + + return button; + } +); + +const ToolbarSeparator = React.forwardRef(({ className, ...props }, ref) => ( +
+)); + +const buttonVariants = { + primary: "bg-custom-primary-100 text-white hover:bg-custom-primary-200 focus:bg-custom-primary-200", + secondary: + "bg-custom-background-100 text-custom-text-200 border border-custom-border-200 hover:bg-custom-background-90 focus:bg-custom-background-90", + outline: + "border border-custom-primary-100 text-custom-primary-100 bg-transparent hover:bg-custom-primary-100/10 focus:bg-custom-primary-100/20", + ghost: "text-custom-text-200 hover:bg-custom-background-90 focus:bg-custom-background-90", + destructive: "bg-red-500 text-white hover:bg-red-600 focus:bg-red-600", +}; + +const ToolbarSubmitButton = React.forwardRef( + ({ loading = false, variant = "primary", className, children, disabled, ...props }, ref) => ( +
+ +
+ ) +); + +ToolbarRoot.displayName = "ToolbarRoot"; +ToolbarGroup.displayName = "ToolbarGroup"; +ToolbarItem.displayName = "ToolbarItem"; +ToolbarSeparator.displayName = "ToolbarSeparator"; +ToolbarSubmitButton.displayName = "ToolbarSubmitButton"; + +// compound components +const Toolbar = Object.assign(ToolbarRoot, { + Group: ToolbarGroup, + Item: ToolbarItem, + Separator: ToolbarSeparator, + SubmitButton: ToolbarSubmitButton, +}); + +export { Toolbar }; From 2e6d0302ce745e88a2522068a3f0794be60c9fc7 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Tue, 9 Sep 2025 10:11:17 +0530 Subject: [PATCH 2/4] dev: toolbar story added --- .../propel/src/toolbar/toolbar.stories.tsx | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 packages/propel/src/toolbar/toolbar.stories.tsx diff --git a/packages/propel/src/toolbar/toolbar.stories.tsx b/packages/propel/src/toolbar/toolbar.stories.tsx new file mode 100644 index 00000000000..f7e7dbbc7c9 --- /dev/null +++ b/packages/propel/src/toolbar/toolbar.stories.tsx @@ -0,0 +1,123 @@ +import type { Meta, StoryObj } from "@storybook/react-vite"; +import { + Bold, + Italic, + Underline, + Strikethrough, + Code, + Link, + List, + ListOrdered, + Quote, + AlignLeft, + AlignCenter, + AlignRight, + Undo, + Redo, + Globe2, + Lock, +} from "lucide-react"; +import { Toolbar } from "./toolbar"; + +const meta: Meta = { + title: "Components/Toolbar", + component: Toolbar, + parameters: { + layout: "fullscreen", + }, + tags: ["autodocs"], +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + render: () => ( +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ ), +}; + +export const WithActiveStates: Story = { + render: () => ( +
+ + + + + + + + + + + + + + + + + +
+ ), +}; + +export const CommentToolbar: Story = { + render: () => ( +
+

Comment Toolbar with Access Control

+
+ + {/* Access Specifier */} +
+ + +
+ +
+
+ + + + + + + + + +
+ Comment +
+
+
+
+ ), +}; From 5fccc18f4b690927f3c4a0d15be9ffdc19cd4d72 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Tue, 9 Sep 2025 10:15:08 +0530 Subject: [PATCH 3/4] chore: propel config updated --- packages/propel/package.json | 1 + packages/propel/tsdown.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/propel/package.json b/packages/propel/package.json index 15933f2af5a..ca3875bcad5 100644 --- a/packages/propel/package.json +++ b/packages/propel/package.json @@ -32,6 +32,7 @@ "./switch": "./dist/switch/index.js", "./table": "./dist/table/index.js", "./tabs": "./dist/tabs/index.js", + "./toolbar": "./dist/toolbar/index.js", "./tooltip": "./dist/tooltip/index.js", "./utils": "./dist/utils/index.js" }, diff --git a/packages/propel/tsdown.config.ts b/packages/propel/tsdown.config.ts index 8f23c301cb8..14fe52ef31d 100644 --- a/packages/propel/tsdown.config.ts +++ b/packages/propel/tsdown.config.ts @@ -17,6 +17,7 @@ export default defineConfig({ "src/switch/index.ts", "src/table/index.ts", "src/tabs/index.ts", + "src/toolbar/index.ts", "src/tooltip/index.ts", "src/utils/index.ts", ], From 469b949d277ce3895795ef67d576f7b57cf19859 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Tue, 9 Sep 2025 10:17:36 +0530 Subject: [PATCH 4/4] chore: code refactor --- packages/propel/src/toolbar/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/propel/src/toolbar/index.ts b/packages/propel/src/toolbar/index.ts index 0ff7414bc0a..da2a48965eb 100644 --- a/packages/propel/src/toolbar/index.ts +++ b/packages/propel/src/toolbar/index.ts @@ -1,2 +1,8 @@ -export { Toolbar, ToolbarGroup, ToolbarItem, ToolbarSeparator, ToolbarSubmitButton } from "./toolbar"; -export type { ToolbarProps, ToolbarGroupProps, ToolbarItemProps, ToolbarSeparatorProps, ToolbarSubmitButtonProps } from "./toolbar"; \ No newline at end of file +export { Toolbar } from "./toolbar"; +export type { + ToolbarProps, + ToolbarGroupProps, + ToolbarItemProps, + ToolbarSeparatorProps, + ToolbarSubmitButtonProps, +} from "./toolbar";