Skip to content

Commit

Permalink
Merge branch 'main' into gregermendle/scroll-area-horizontal-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn authored Oct 21, 2023
2 parents 9311cf5 + cf0dada commit 611c7cf
Show file tree
Hide file tree
Showing 65 changed files with 638 additions and 117 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-badgers-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

fix code style
5 changes: 5 additions & 0 deletions .changeset/smart-pants-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

use jsconfig for non-ts projects
5 changes: 5 additions & 0 deletions .changeset/sweet-worms-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": minor
---

add support for tailwind.config.ts
18 changes: 18 additions & 0 deletions .kodiak.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# .kodiak.toml
version = 1

[merge]
automerge_label = "automerge"
require_automerge_label = true
method = "squash"
delete_branch_on_merge = true
optimistic_updates = false
prioritize_ready_to_merge = true
notify_on_conflict = true

[merge.message]
title = "pull_request_title"
body = "pull_request_body"
include_pr_number = true
body_type = "markdown"
strip_html_comments = true
14 changes: 14 additions & 0 deletions apps/www/__registry__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ export const Index: Record<string, any> = {
component: React.lazy(() => import("@/registry/default/example/dialog-demo")),
files: ["registry/default/example/dialog-demo.tsx"],
},
"dialog-close-button": {
name: "dialog-close-button",
type: "components:example",
registryDependencies: ["dialog","button"],
component: React.lazy(() => import("@/registry/default/example/dialog-close-button")),
files: ["registry/default/example/dialog-close-button.tsx"],
},
"dropdown-menu-demo": {
name: "dropdown-menu-demo",
type: "components:example",
Expand Down Expand Up @@ -1581,6 +1588,13 @@ export const Index: Record<string, any> = {
component: React.lazy(() => import("@/registry/new-york/example/dialog-demo")),
files: ["registry/new-york/example/dialog-demo.tsx"],
},
"dialog-close-button": {
name: "dialog-close-button",
type: "components:example",
registryDependencies: ["dialog","button"],
component: React.lazy(() => import("@/registry/new-york/example/dialog-close-button")),
files: ["registry/new-york/example/dialog-close-button.tsx"],
},
"dropdown-menu-demo": {
name: "dropdown-menu-demo",
type: "components:example",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function PodcastEmptyPlaceholder() {
You have not added any podcasts. Add one below.
</p>
<Dialog>
<DialogTrigger>
<DialogTrigger asChild>
<Button size="sm" className="relative">
Add Podcast
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/www/components/site-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { buttonVariants } from "@/registry/new-york/ui/button"

export function SiteHeader() {
return (
<header className="supports-backdrop-blur:bg-background/60 sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur">
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="container flex h-14 items-center">
<MainNav />
<MobileNav />
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 @@ -147,6 +147,11 @@ export const docsConfig: DocsConfig = {
href: "/docs/dark-mode/vite",
items: [],
},
{
title: "Astro",
href: "/docs/dark-mode/astro",
items: [],
},
],
},
{
Expand Down
8 changes: 4 additions & 4 deletions apps/www/content/docs/components/accordion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ module.exports = {
extend: {
keyframes: {
"accordion-down": {
from: { height: 0 },
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: 0 },
to: { height: "0" },
},
},
animation: {
Expand Down Expand Up @@ -90,12 +90,12 @@ module.exports = {
extend: {
keyframes: {
"accordion-down": {
from: { height: 0 },
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: 0 },
to: { height: "0" },
},
},
animation: {
Expand Down
6 changes: 6 additions & 0 deletions apps/www/content/docs/components/dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ import {
</Dialog>
```

## Examples

### Custom close button

<ComponentPreview name="dialog-close-button" />

## Notes

To activate the `Dialog` component from within a `Context Menu` or `Dropdown Menu`, you must encase the `Context Menu` or
Expand Down
2 changes: 2 additions & 0 deletions apps/www/content/docs/components/form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Use the `useForm` hook from `react-hook-form` to create a form.
"use client"

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

const formSchema = z.object({
Expand Down Expand Up @@ -177,6 +178,7 @@ We can now use the `<Form />` components to build our form.
"use client"

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

import { Button } from "@/components/ui/button"
Expand Down
121 changes: 121 additions & 0 deletions apps/www/content/docs/dark-mode/astro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: Astro
description: Adding dark mode to your astro app.
---

## Dark mode

<Steps>

### Create an inline theme script

```astro title="src/pages/index.astro"
---
import '../styles/globals.css'
---
<script is:inline>
const getThemePreference = () => {
if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
return localStorage.getItem('theme');
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
};
const isDark = getThemePreference() === 'dark';
document.documentElement.classList[isDark ? 'add' : 'remove']('dark');
if (typeof localStorage !== 'undefined') {
const observer = new MutationObserver(() => {
const isDark = document.documentElement.classList.contains('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
}
</script>
<html lang="en">
<body>
<h1>Astro</h1>
</body>
</html>
</script>
```

### Add a mode toggle

```tsx title="src/components/ModeToggle.tsx"
import * as React from "react"
import { Moon, Sun } from "lucide-react"

import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"

export function ModeToggle() {
const [theme, setThemeState] = React.useState<
"theme-light" | "dark" | "system"
>("theme-light")

React.useEffect(() => {
const isDarkMode = document.documentElement.classList.contains("dark")
setThemeState(isDarkMode ? "dark" : "theme-light")
}, [])

React.useEffect(() => {
const isDark =
theme === "dark" ||
(theme === "system" &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
document.documentElement.classList[isDark ? "add" : "remove"]("dark")
}, [theme])

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="icon">
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setThemeState("theme-light")}>
Light
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setThemeState("dark")}>
Dark
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setThemeState("system")}>
System
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
```

### Display the mode toggle

Place a mode toggle on your site to toggle between light and dark mode.

```astro title="src/pages/index.astro"
---
import '../styles/globals.css'
import { ModeToggle } from '@/components/ModeToggle';
---
<!-- Inline script -->
<html lang="en">
<body>
<h1>Astro</h1>
<ModeToggle client:load />
</body>
</html>
```

</Steps>
13 changes: 13 additions & 0 deletions apps/www/content/docs/dark-mode/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ description: Adding dark mode to your site.
</svg>
<p className="font-medium mt-2">Vite</p>
</LinkedCard>
<LinkedCard href="/docs/dark-mode/astro">
<svg
role="img"
viewBox="0 0 64 79"
xmlns="http://www.w3.org/2000/svg"
className="w-10 h-10"
fill="currentColor"
>
<path d="M19.9924 65.9282C16.1165 62.432 14.9851 55.0859 16.5999 49.7638C19.3998 53.1193 23.2793 54.1822 27.2977 54.7822C33.5013 55.7081 39.5937 55.3618 45.3565 52.5637C46.0158 52.2434 46.625 51.8174 47.3454 51.386C47.8861 52.9341 48.0268 54.497 47.838 56.0877C47.3787 59.9617 45.4251 62.9542 42.3177 65.2227C41.0752 66.13 39.7604 66.9411 38.4771 67.7967C34.5346 70.4262 33.4679 73.5095 34.9494 77.9946C34.9846 78.1038 35.0161 78.2131 35.0957 78.4797C33.0828 77.5909 31.6124 76.2965 30.4921 74.5946C29.3088 72.7984 28.7458 70.8114 28.7162 68.6615C28.7014 67.6152 28.7014 66.5597 28.5588 65.5282C28.2107 63.0135 27.0144 61.8876 24.7608 61.8227C22.4479 61.7561 20.6183 63.1672 20.1331 65.3893C20.0961 65.5597 20.0424 65.7282 19.9887 65.9263L19.9924 65.9282Z" />
<path d="M0.5 51.3932C0.5 51.3932 11.0979 46.2433 21.7254 46.2433L29.7382 21.5069C30.0381 20.3106 30.9141 19.4977 31.9029 19.4977C32.8918 19.4977 33.7677 20.3106 34.0677 21.5069L42.0804 46.2433C54.6672 46.2433 63.3058 51.3932 63.3058 51.3932C63.3058 51.3932 45.3044 2.47586 45.2692 2.37772C44.7526 0.931458 43.8804 0 42.7045 0H21.1032C19.9273 0 19.0903 0.931458 18.5384 2.37772C18.4995 2.47401 0.5 51.3932 0.5 51.3932Z" />
</svg>
<p className="font-medium mt-2">Astro</p>
</LinkedCard>
</div>

## Other frameworks
Expand Down
2 changes: 1 addition & 1 deletion apps/www/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _Use this as a reference to build your own component libraries._

## FAQ

<Accordion type="multiple" collapsible>
<Accordion type="multiple">

<AccordionItem value="faq-1">
<AccordionTrigger>
Expand Down
20 changes: 17 additions & 3 deletions apps/www/content/docs/installation/astro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ Answer `Yes` to all the question prompted by the CLI when installing Tailwind CS

### Edit tsconfig.json file

Add the code below to the tsconfig.json file to resolve paths:
Add the following code to the `tsconfig.json` file to resolve paths:

```json {2-7} showLineNumbers
```ts {4-9} showLineNumbers
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
"@/*": [
"./src/*"
]
}
// ...
}
}
```
Expand Down Expand Up @@ -123,6 +127,16 @@ export default defineConfig({
})
```

### Update tailwind.config.cjs

When running `npx shadcn-ui@latest init`, your tailwind config for content will be overwritten. To fix this, change the `content` section with the code below to your `tailwind.config.cjs` file:

```js {2-4} showLineNumbers
module.exports = {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
}
```

### That's it

You can now start adding components to your project.
Expand Down
2 changes: 1 addition & 1 deletion apps/www/content/docs/installation/gatsby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You will be asked a few questions to configure your project:

### Edit tsconfig.json file

Add the code below to the `tsconfig.json` file to resolve paths:
Add the following code to the `tsconfig.json` file to resolve paths:

```ts {4-9} showLineNumbers
{
Expand Down
4 changes: 2 additions & 2 deletions apps/www/content/docs/installation/manual.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ module.exports = {
},
keyframes: {
"accordion-down": {
from: { height: 0 },
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: 0 },
to: { height: "0" },
},
},
animation: {
Expand Down
Loading

0 comments on commit 611c7cf

Please sign in to comment.