Skip to content

Commit

Permalink
Merge pull request #2714 from udecode/registry
Browse files Browse the repository at this point in the history
Update Registry
  • Loading branch information
zbeyens authored Oct 24, 2023
2 parents b22b06e + 5cd132d commit b2a1d8a
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 153 deletions.
2 changes: 1 addition & 1 deletion apps/www/public/registry/styles/default/toolbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"files": [
{
"name": "toolbar.tsx",
"content": "'use client';\n\nimport * as React from 'react';\nimport { ReactNode } from 'react';\nimport * as ToolbarPrimitive from '@radix-ui/react-toolbar';\nimport { cva, VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\nimport { Icons } from '@/components/icons';\n\nimport { Separator } from './separator';\nimport { ToggleProps, toggleVariants } from './toggle';\nimport {\n Tooltip,\n TooltipContent,\n TooltipPortal,\n TooltipTrigger,\n} from './tooltip';\n\nconst toolbarVariants = cva(\n 'relative flex select-none items-stretch gap-1 bg-background'\n);\n\nexport const linkVariants = cva('font-medium underline underline-offset-4');\n\nconst ToolbarToggleGroup = ToolbarPrimitive.ToggleGroup;\n\nexport interface ToolbarProps\n extends React.ComponentPropsWithoutRef<typeof Toolbar> {}\n\nconst Toolbar = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Root> &\n VariantProps<typeof toolbarVariants>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Root\n ref={ref}\n className={cn(toolbarVariants(), className)}\n {...props}\n />\n));\nToolbar.displayName = ToolbarPrimitive.Root.displayName;\n\nconst ToolbarLink = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Link>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Link> &\n VariantProps<typeof linkVariants>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Link\n ref={ref}\n className={cn(linkVariants(), className)}\n {...props}\n />\n));\nToolbarLink.displayName = ToolbarPrimitive.Link.displayName;\n\nconst ToolbarSeparator = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Separator\n ref={ref}\n className={cn('shrink-0 bg-border', 'my-1 w-[1px]', className)}\n {...props}\n />\n));\nToolbarSeparator.displayName = ToolbarPrimitive.Separator.displayName;\n\nexport interface ToolbarButtonProps\n extends React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Button>,\n VariantProps<typeof toggleVariants>,\n Omit<ToggleProps, 'type'> {\n buttonType?: 'button' | 'toggle';\n pressed?: boolean;\n tooltip?: ReactNode;\n isDropdown?: boolean;\n}\n\nconst ToolbarButton = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Button>,\n ToolbarButtonProps\n>(\n (\n {\n className,\n variant,\n size = 'sm',\n isDropdown,\n children,\n pressed,\n value,\n tooltip,\n ...props\n },\n ref\n ) => {\n const [isLoaded, setIsLoaded] = React.useState(false);\n\n React.useEffect(() => {\n setIsLoaded(true);\n }, []);\n\n const content =\n typeof pressed === 'boolean' ? (\n <ToolbarToggleGroup\n type=\"single\"\n value={pressed ? 'single' : undefined}\n >\n <ToolbarToggleItem\n ref={ref}\n className={cn(\n toggleVariants({\n variant,\n size,\n }),\n isDropdown && 'my-1 justify-between pr-1',\n className\n )}\n value=\"single\"\n {...props}\n >\n <div className=\"flex flex-1\">{children}</div>\n <div>\n {isDropdown && (\n <Icons.arrowDown className=\"ml-0.5 h-4 w-4\" data-icon />\n )}\n </div>\n </ToolbarToggleItem>\n </ToolbarToggleGroup>\n ) : (\n <ToolbarPrimitive.Button\n ref={ref}\n className={cn(\n toggleVariants({\n variant,\n size,\n }),\n isDropdown && 'pr-1',\n className\n )}\n {...props}\n >\n {children}\n </ToolbarPrimitive.Button>\n );\n\n return isLoaded && tooltip ? (\n <Tooltip>\n <TooltipTrigger>{content}</TooltipTrigger>\n\n <TooltipPortal>\n <TooltipContent>{tooltip}</TooltipContent>\n </TooltipPortal>\n </Tooltip>\n ) : (\n <>{content}</>\n );\n }\n);\nToolbarButton.displayName = ToolbarPrimitive.Button.displayName;\n\nconst ToolbarToggleItem = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.ToggleItem>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.ToggleItem> &\n VariantProps<typeof toggleVariants>\n>(({ className, variant, size, ...props }, ref) => (\n <ToolbarPrimitive.ToggleItem\n ref={ref}\n className={cn(toggleVariants({ variant, size }), className)}\n {...props}\n />\n));\nToolbarToggleItem.displayName = ToolbarPrimitive.ToggleItem.displayName;\n\nconst ToolbarGroup = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & { noSeparator?: boolean }\n>(({ noSeparator, className, children }, ref) => {\n const childArr = React.Children.map(children, (c) => c);\n if (!childArr || childArr.length === 0) return null;\n\n return (\n <div ref={ref} className={cn('flex', className)}>\n {!noSeparator && (\n <div className=\"h-full py-1\">\n <Separator orientation=\"vertical\" />\n </div>\n )}\n\n <div className=\"mx-1 flex items-center gap-1\">{children}</div>\n </div>\n );\n});\nToolbarGroup.displayName = 'ToolbarGroup';\n\nexport {\n Toolbar,\n ToolbarLink,\n ToolbarToggleGroup,\n ToolbarSeparator,\n ToolbarToggleItem,\n ToolbarButton,\n ToolbarGroup,\n};\n"
"content": "'use client';\n\nimport * as React from 'react';\nimport { ReactNode } from 'react';\nimport * as ToolbarPrimitive from '@radix-ui/react-toolbar';\nimport { cva, VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\nimport { Icons } from '@/components/icons';\n\nimport { Separator } from './separator';\nimport { ToggleProps, toggleVariants } from './toggle';\nimport {\n Tooltip,\n TooltipContent,\n TooltipPortal,\n TooltipTrigger,\n} from './tooltip';\n\nconst toolbarVariants = cva(\n 'relative flex select-none items-stretch gap-1 bg-background'\n);\n\nexport const linkVariants = cva('font-medium underline underline-offset-4');\n\nconst ToolbarToggleGroup = ToolbarPrimitive.ToggleGroup;\n\nexport interface ToolbarProps\n extends React.ComponentPropsWithoutRef<typeof Toolbar> {}\n\nconst Toolbar = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Root> &\n VariantProps<typeof toolbarVariants>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Root\n ref={ref}\n className={cn(toolbarVariants(), className)}\n {...props}\n />\n));\nToolbar.displayName = ToolbarPrimitive.Root.displayName;\n\nconst ToolbarLink = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Link>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Link> &\n VariantProps<typeof linkVariants>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Link\n ref={ref}\n className={cn(linkVariants(), className)}\n {...props}\n />\n));\nToolbarLink.displayName = ToolbarPrimitive.Link.displayName;\n\nconst ToolbarSeparator = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <ToolbarPrimitive.Separator\n ref={ref}\n className={cn('shrink-0 bg-border', 'my-1 w-[1px]', className)}\n {...props}\n />\n));\nToolbarSeparator.displayName = ToolbarPrimitive.Separator.displayName;\n\nexport interface ToolbarButtonProps\n extends React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.Button>,\n VariantProps<typeof toggleVariants>,\n Omit<ToggleProps, 'type'> {\n buttonType?: 'button' | 'toggle';\n pressed?: boolean;\n tooltip?: ReactNode;\n isDropdown?: boolean;\n}\n\nconst ToolbarButton = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.Button>,\n ToolbarButtonProps\n>(\n (\n {\n className,\n variant,\n size = 'sm',\n isDropdown,\n children,\n pressed,\n value,\n tooltip,\n ...props\n },\n ref\n ) => {\n const [isLoaded, setIsLoaded] = React.useState(false);\n\n React.useEffect(() => {\n setIsLoaded(true);\n }, []);\n\n const content =\n typeof pressed === 'boolean' ? (\n <ToolbarToggleGroup\n type=\"single\"\n value={pressed ? 'single' : undefined}\n >\n <ToolbarToggleItem\n ref={ref}\n className={cn(\n toggleVariants({\n variant,\n size,\n }),\n isDropdown && 'my-1 justify-between pr-1',\n className\n )}\n value=\"single\"\n {...props}\n >\n <div className=\"flex flex-1\">{children}</div>\n <div>\n {isDropdown && (\n <Icons.arrowDown className=\"ml-0.5 h-4 w-4\" data-icon />\n )}\n </div>\n </ToolbarToggleItem>\n </ToolbarToggleGroup>\n ) : (\n <ToolbarPrimitive.Button\n ref={ref}\n className={cn(\n toggleVariants({\n variant,\n size,\n }),\n isDropdown && 'pr-1',\n className\n )}\n {...props}\n >\n {children}\n </ToolbarPrimitive.Button>\n );\n\n return isLoaded && tooltip ? (\n <Tooltip>\n <TooltipTrigger asChild>{content}</TooltipTrigger>\n\n <TooltipPortal>\n <TooltipContent>{tooltip}</TooltipContent>\n </TooltipPortal>\n </Tooltip>\n ) : (\n <>{content}</>\n );\n }\n);\nToolbarButton.displayName = ToolbarPrimitive.Button.displayName;\n\nconst ToolbarToggleItem = React.forwardRef<\n React.ElementRef<typeof ToolbarPrimitive.ToggleItem>,\n React.ComponentPropsWithoutRef<typeof ToolbarPrimitive.ToggleItem> &\n VariantProps<typeof toggleVariants>\n>(({ className, variant, size, ...props }, ref) => (\n <ToolbarPrimitive.ToggleItem\n ref={ref}\n className={cn(toggleVariants({ variant, size }), className)}\n {...props}\n />\n));\nToolbarToggleItem.displayName = ToolbarPrimitive.ToggleItem.displayName;\n\nconst ToolbarGroup = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & { noSeparator?: boolean }\n>(({ noSeparator, className, children }, ref) => {\n const childArr = React.Children.map(children, (c) => c);\n if (!childArr || childArr.length === 0) return null;\n\n return (\n <div ref={ref} className={cn('flex', className)}>\n {!noSeparator && (\n <div className=\"h-full py-1\">\n <Separator orientation=\"vertical\" />\n </div>\n )}\n\n <div className=\"mx-1 flex items-center gap-1\">{children}</div>\n </div>\n );\n});\nToolbarGroup.displayName = 'ToolbarGroup';\n\nexport {\n Toolbar,\n ToolbarLink,\n ToolbarToggleGroup,\n ToolbarSeparator,\n ToolbarToggleItem,\n ToolbarButton,\n ToolbarGroup,\n};\n"
}
],
"type": "components:plate-ui"
Expand Down
Loading

0 comments on commit b2a1d8a

Please sign in to comment.