Skip to content

Commit

Permalink
fix(shadcn-ui): add missing deps for Button (#259)
Browse files Browse the repository at this point in the history
* fix: add missing deps for Button

* fix: use correct dep

Co-authored-by: Pablo <[email protected]>

* chore: add changeset

---------

Co-authored-by: Pablo <[email protected]>
Co-authored-by: shadcn <[email protected]>
  • Loading branch information
3 people authored May 13, 2023
1 parent 5a2ce61 commit 87ad14c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-eagles-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

add missing deps for button
1 change: 1 addition & 0 deletions apps/www/config/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const components = [
{
component: "button",
name: "Button",
dependencies: ["@radix-ui/react-slot"],
files: ["components/ui/button.tsx"],
},
{
Expand Down
8 changes: 7 additions & 1 deletion apps/www/content/docs/components/button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ npx shadcn-ui add button
<AccordionTrigger>Manual Installation</AccordionTrigger>
<AccordionContent>

1. Copy and paste the following code into your project.
1. Install the `@radix-ui/react-slot` component from radix-ui:

```bash
npm install @radix-ui/react-slot
```

2.

<ComponentSource src="/components/ui/button.tsx" />

Expand Down
5 changes: 3 additions & 2 deletions apps/www/pages/api/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@
{
"component": "button",
"name": "Button",
"dependencies": ["@radix-ui/react-slot"],
"files": [
{
"name": "button.tsx",
"dir": "components/ui",
"content": "import * as React from \"react\"\nimport { VariantProps, cva } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline:\n \"border border-input hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"underline-offset-4 hover:underline text-primary\",\n },\n size: {\n default: \"h-10 py-2 px-4\",\n sm: \"h-9 px-3 rounded-md\",\n lg: \"h-11 px-8 rounded-md\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, ...props }, ref) => {\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n )\n }\n)\nButton.displayName = \"Button\"\n\nexport { Button, buttonVariants }\n"
"content": "import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { VariantProps, cva } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\n outline:\n \"border border-input hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"underline-offset-4 hover:underline text-primary\",\n },\n size: {\n default: \"h-10 py-2 px-4\",\n sm: \"h-9 px-3 rounded-md\",\n lg: \"h-11 px-8 rounded-md\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, ...props }, ref) => {\n return (\n <button\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n )\n }\n)\nButton.displayName = \"Button\"\n\nexport { Button, buttonVariants }\n"
}
]
},
Expand Down Expand Up @@ -474,4 +475,4 @@
}
]
}
]
]

1 comment on commit 87ad14c

@vercel
Copy link

@vercel vercel bot commented on 87ad14c May 13, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

ui – ./apps/www

ui-git-main-shadcn-pro.vercel.app
ui.shadcn.com
example-playground.vercel.app
ui-shadcn-pro.vercel.app

Please sign in to comment.