Skip to content

Commit

Permalink
Merge branch 'main' into add-test-for-add-command
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Sato1995 authored Sep 5, 2023
2 parents eadd2a2 + c21ecfb commit f027744
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-jeans-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

remove duplicate vi call
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,40 @@ When adding or modifying components, please ensure that:
2. You update the documentation.
3. You run `pnpm build:registry` to update the registry.

## Commit Convention

Before you create a Pull Request, please check whether your commits comply with
the commit conventions used in this repository.

When you create a commit we kindly ask you to follow the convention
`category(scope or module): message` in your commit message while using one of
the following categories:

- `feat / feature`: all changes that introduce completely new code or new
features
- `fix`: changes that fix a bug (ideally you will additionally reference an
issue if present)
- `refactor`: any code related change that is not a fix nor a feature
- `docs`: changing existing or creating new documentation (i.e. README, docs for
usage of a lib or cli usage)
- `build`: all changes regarding the build of the software, changes to
dependencies or the addition of new dependencies
- `test`: all changes regarding tests (adding new tests or changing existing
ones)
- `ci`: all changes regarding the configuration of continuous integration (i.e.
github actions, ci system)
- `chore`: all changes to the repository that do not fit into any of the above
categories

e.g. `feat(components): add new prop to the avatar component`


If you are interested in the detailed specification you can visit
https://www.conventionalcommits.org/ or check out the
[Angular Commit Message Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines).



## Requests for new components

If you have a request for a new component, please open a discussion on GitHub. We'll be happy to help you out.
Expand Down
5 changes: 5 additions & 0 deletions apps/www/config/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export const docsConfig: DocsConfig = {
href: "/docs/installation/astro",
items: [],
},
{
title: "Laravel",
href: "/docs/installation/laravel",
items: [],
},
{
title: "Manual",
href: "/docs/installation/manual",
Expand Down
8 changes: 8 additions & 0 deletions apps/www/content/docs/dark-mode/next.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ description: Adding dark mode to your next app.

<Steps>

### Install next-themes

Start by installing `next-themes`:

```bash
npm install next-themes
```

### Create a theme provider

```tsx title="components/theme-provider.tsx"
Expand Down
16 changes: 9 additions & 7 deletions apps/www/content/docs/dark-mode/vite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ description: Adding dark mode to your vite app.
```tsx title="components/theme-provider.tsx"
import { createContext, useContext, useEffect, useState } from "react"

type Theme = "dark" | "light" | "system"

type ThemeProviderProps = {
children: React.ReactNode
defaultTheme?: string
defaultTheme?: Theme
storageKey?: string
}

type ThemeProviderState = {
theme: string
setTheme: (theme: string) => void
theme: Theme
setTheme: (theme: Theme) => void
}

const initialState = {
const initialState: ThemeProviderState = {
theme: "system",
setTheme: () => null,
}
Expand All @@ -36,8 +38,8 @@ export function ThemeProvider({
storageKey = "vite-ui-theme",
...props
}: ThemeProviderProps) {
const [theme, setTheme] = useState(
() => localStorage.getItem(storageKey) || defaultTheme
const [theme, setTheme] = useState<Theme>(
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme
)

useEffect(() => {
Expand All @@ -60,7 +62,7 @@ export function ThemeProvider({

const value = {
theme,
setTheme: (theme: string) => {
setTheme: (theme: Theme) => {
localStorage.setItem(storageKey, theme)
setTheme(theme)
},
Expand Down
12 changes: 12 additions & 0 deletions apps/www/content/docs/installation/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ description: How to install dependencies and structure your app.
</svg>
<p className="font-medium mt-2">Astro</p>
</LinkedCard>
<LinkedCard href="/docs/installation/laravel">
<svg
role="img"
viewBox="0 0 62 65"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
className="w-10 h-10"
>
<path d="M61.8548 14.6253C61.8778 14.7102 61.8895 14.7978 61.8897 14.8858V28.5615C61.8898 28.737 61.8434 28.9095 61.7554 29.0614C61.6675 29.2132 61.5409 29.3392 61.3887 29.4265L49.9104 36.0351V49.1337C49.9104 49.4902 49.7209 49.8192 49.4118 49.9987L25.4519 63.7916C25.3971 63.8227 25.3372 63.8427 25.2774 63.8639C25.255 63.8714 25.2338 63.8851 25.2101 63.8913C25.0426 63.9354 24.8666 63.9354 24.6991 63.8913C24.6716 63.8838 24.6467 63.8689 24.6205 63.8589C24.5657 63.8389 24.5084 63.8215 24.456 63.7916L0.501061 49.9987C0.348882 49.9113 0.222437 49.7853 0.134469 49.6334C0.0465019 49.4816 0.000120578 49.3092 0 49.1337L0 8.10652C0 8.01678 0.0124642 7.92953 0.0348998 7.84477C0.0423783 7.8161 0.0598282 7.78993 0.0697995 7.76126C0.0884958 7.70891 0.105946 7.65531 0.133367 7.6067C0.152063 7.5743 0.179485 7.54812 0.20192 7.51821C0.230588 7.47832 0.256763 7.43719 0.290416 7.40229C0.319084 7.37362 0.356476 7.35243 0.388883 7.32751C0.425029 7.29759 0.457436 7.26518 0.498568 7.2415L12.4779 0.345059C12.6296 0.257786 12.8015 0.211853 12.9765 0.211853C13.1515 0.211853 13.3234 0.257786 13.475 0.345059L25.4531 7.2415H25.4556C25.4955 7.26643 25.5292 7.29759 25.5653 7.32626C25.5977 7.35119 25.6339 7.37362 25.6625 7.40104C25.6974 7.43719 25.7224 7.47832 25.7523 7.51821C25.7735 7.54812 25.8021 7.5743 25.8196 7.6067C25.8483 7.65656 25.8645 7.70891 25.8844 7.76126C25.8944 7.78993 25.9118 7.8161 25.9193 7.84602C25.9423 7.93096 25.954 8.01853 25.9542 8.10652V33.7317L35.9355 27.9844V14.8846C35.9355 14.7973 35.948 14.7088 35.9704 14.6253C35.9792 14.5954 35.9954 14.5692 36.0053 14.5405C36.0253 14.4882 36.0427 14.4346 36.0702 14.386C36.0888 14.3536 36.1163 14.3274 36.1375 14.2975C36.1674 14.2576 36.1923 14.2165 36.2272 14.1816C36.2559 14.1529 36.292 14.1317 36.3244 14.1068C36.3618 14.0769 36.3942 14.0445 36.4341 14.0208L48.4147 7.12434C48.5663 7.03694 48.7383 6.99094 48.9133 6.99094C49.0883 6.99094 49.2602 7.03694 49.4118 7.12434L61.3899 14.0208C61.4323 14.0457 61.4647 14.0769 61.5021 14.1055C61.5333 14.1305 61.5694 14.1529 61.5981 14.1803C61.633 14.2165 61.6579 14.2576 61.6878 14.2975C61.7103 14.3274 61.7377 14.3536 61.7551 14.386C61.7838 14.4346 61.8 14.4882 61.8199 14.5405C61.8312 14.5692 61.8474 14.5954 61.8548 14.6253ZM59.893 27.9844V16.6121L55.7013 19.0252L49.9104 22.3593V33.7317L59.8942 27.9844H59.893ZM47.9149 48.5566V37.1768L42.2187 40.4299L25.953 49.7133V61.2003L47.9149 48.5566ZM1.99677 9.83281V48.5566L23.9562 61.199V49.7145L12.4841 43.2219L12.4804 43.2194L12.4754 43.2169C12.4368 43.1945 12.4044 43.1621 12.3682 43.1347C12.3371 43.1097 12.3009 43.0898 12.2735 43.0624L12.271 43.0586C12.2386 43.0275 12.2162 42.9888 12.1887 42.9539C12.1638 42.9203 12.1339 42.8916 12.114 42.8567L12.1127 42.853C12.0903 42.8156 12.0766 42.7707 12.0604 42.7283C12.0442 42.6909 12.023 42.656 12.013 42.6161C12.0005 42.5688 11.998 42.5177 11.9931 42.4691C11.9881 42.4317 11.9781 42.3943 11.9781 42.3569V15.5801L6.18848 12.2446L1.99677 9.83281ZM12.9777 2.36177L2.99764 8.10652L12.9752 13.8513L22.9541 8.10527L12.9752 2.36177H12.9777ZM18.1678 38.2138L23.9574 34.8809V9.83281L19.7657 12.2459L13.9749 15.5801V40.6281L18.1678 38.2138ZM48.9133 9.14105L38.9344 14.8858L48.9133 20.6305L58.8909 14.8846L48.9133 9.14105ZM47.9149 22.3593L42.124 19.0252L37.9323 16.6121V27.9844L43.7219 31.3174L47.9149 33.7317V22.3593ZM24.9533 47.987L39.59 39.631L46.9065 35.4555L36.9352 29.7145L25.4544 36.3242L14.9907 42.3482L24.9533 47.987Z" />
</svg>
<p className="font-medium mt-2">Laravel</p>
</LinkedCard>
<LinkedCard href="/docs/installation/manual">
<svg
role="img"
Expand Down
153 changes: 153 additions & 0 deletions apps/www/content/docs/installation/laravel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
title: Laravel
description: Install and configure Laravel with Inertia
---

<Steps>

### Create project

Start by creating a new Laravel project with Inertia and React using the laravel installer `laravel new my-app`:

```bash
laravel new my-app --typescript --breeze --stack=react --git --no-interaction
```

### Run the CLI

Run the `shadcn-ui` init command to setup your project:

```bash
npx shadcn-ui@latest init
```

### Configure components.json

You will be asked a few questions to configure `components.json`:

```txt showLineNumbers
Would you like to use TypeScript (recommended)? no / yes
Which style would you like to use? › Default
Which color would you like to use as base color? › Slate
Where is your global CSS file? › resources/css/app.css
Do you want to use CSS variables for colors? › no / yes
Where is your tailwind.config.js located? › tailwind.config.js
Configure the import alias for components: › @/Components
Configure the import alias for utils: › @/lib/utils
Are you using React Server Components? › no / yes
```

### Update tailwind.config.js

The `shadcn-ui` CLI will automatically overwrite your `tailwind.config.js`. Update it to look like this:

```js
import forms from "@tailwindcss/forms"
import defaultTheme from "tailwindcss/defaultTheme"

/** @type {import('tailwindcss').Config} */
export default {
darkMode: "class",
content: [
"./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php",
"./storage/framework/views/*.php",
"./resources/views/**/*.blade.php",
"./resources/js/**/*.tsx",
],

theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: `var(--radius)`,
md: `calc(var(--radius) - 2px)`,
sm: "calc(var(--radius) - 4px)",
},
fontFamily: {
sans: ["Figtree", ...defaultTheme.fontFamily.sans],
},
keyframes: {
"accordion-down": {
from: { height: 0 },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: 0 },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},

plugins: [forms, require("tailwindcss-animate")],
}
```

### That's it

You can now start adding components to your project.

```bash
npx shadcn-ui@latest add button
```

The command above will add the `Button` component to your project. You can then import it like this:

```tsx {1,6} showLineNumbers
import { Button } from "@/Components/ui/button"

export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}
```

</Steps>
14 changes: 10 additions & 4 deletions apps/www/registry/default/example/cards/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export function CardsChat() {
content: "I can't log in.",
},
])
const [input, setInput] = React.useState("")
const inputLength = input.trim().length

return (
<>
Expand All @@ -115,6 +117,7 @@ export function CardsChat() {
onClick={() => setOpen(true)}
>
<Plus className="h-4 w-4" />
<span className="sr-only">New message</span>
</Button>
</TooltipTrigger>
<TooltipContent sideOffset={10}>New message</TooltipContent>
Expand Down Expand Up @@ -142,24 +145,27 @@ export function CardsChat() {
<form
onSubmit={(event) => {
event.preventDefault()
if (inputLength === 0) return
setMessages([
...messages,
{
role: "user",
content: event.currentTarget.message.value,
content: input,
},
])

event.currentTarget.message.value = ""
setInput("")
}}
className="flex w-full items-center space-x-2"
>
<Input
id="message"
placeholder="Type your message..."
className="flex-1"
autoComplete="off"
value={input}
onChange={(event) => setInput(event.target.value)}
/>
<Button type="submit" size="icon">
<Button type="submit" size="icon" disabled={inputLength === 0}>
<Send className="h-4 w-4" />
<span className="sr-only">Send</span>
</Button>
Expand Down
6 changes: 3 additions & 3 deletions apps/www/registry/default/example/scroll-area-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default function ScrollAreaDemo() {
<div className="p-4">
<h4 className="mb-4 text-sm font-medium leading-none">Tags</h4>
{tags.map((tag) => (
<React.Fragment>
<div className="text-sm" key={tag}>
<>
<div key={tag} className="text-sm">
{tag}
</div>
<Separator className="my-2" />
</React.Fragment>
</>
))}
</div>
</ScrollArea>
Expand Down
4 changes: 0 additions & 4 deletions apps/www/registry/default/example/textarea-form.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"use client"

import Link from "next/link"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import * as z from "zod"

import { Button } from "@/registry/default/ui/button"
import { Checkbox } from "@/registry/default/ui/checkbox"
import {
Form,
FormControl,
Expand All @@ -16,8 +14,6 @@ import {
FormLabel,
FormMessage,
} from "@/registry/default/ui/form"
import { RadioGroup, RadioGroupItem } from "@/registry/default/ui/radio-group"
import { Switch } from "@/registry/default/ui/switch"
import { Textarea } from "@/registry/default/ui/textarea"
import { toast } from "@/registry/default/ui/use-toast"

Expand Down
Loading

0 comments on commit f027744

Please sign in to comment.