Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shadcn/registry #6339

Merged
merged 11 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .changeset/sour-hotels-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn": minor
---

add schema
9 changes: 6 additions & 3 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand All @@ -113,4 +113,7 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm --filter=shadcn build

- run: pnpm typecheck
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
auto-install-peers=true
link-workspace-packages=true
11 changes: 11 additions & 0 deletions apps/www/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json.schemastore.org/eslintrc",
"overrides": [
{
"files": ["scripts/**/*.{ts,mts}"],
"parserOptions": {
"project": "tsconfig.scripts.json"
}
}
]
}
2 changes: 1 addition & 1 deletion apps/www/components/block-display.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from "react"
import { registryItemFileSchema } from "shadcn/registry"
import { z } from "zod"

import { highlightCode } from "@/lib/highlight-code"
Expand All @@ -7,7 +8,6 @@ import {
getRegistryItem,
} from "@/lib/registry"
import { BlockViewer } from "@/components/block-viewer"
import { registryItemFileSchema } from "@/registry/schema"

export async function BlockDisplay({ name }: { name: string }) {
const item = await getCachedRegistryItem(name)
Expand Down
2 changes: 1 addition & 1 deletion apps/www/components/block-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Terminal,
} from "lucide-react"
import { ImperativePanelHandle } from "react-resizable-panels"
import { registryItemFileSchema, registryItemSchema } from "shadcn/registry"
import { z } from "zod"

import { trackEvent } from "@/lib/events"
Expand Down Expand Up @@ -51,7 +52,6 @@ import {
ToggleGroupItem,
} from "@/registry/new-york/ui/toggle-group"
import { Style } from "@/registry/registry-styles"
import { registryItemFileSchema, registryItemSchema } from "@/registry/schema"

type BlockViewerContext = {
item: z.infer<typeof registryItemSchema>
Expand Down
2 changes: 1 addition & 1 deletion apps/www/components/chart-display.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from "react"
import { registryItemSchema } from "shadcn/registry"
import { z } from "zod"

import { highlightCode } from "@/lib/highlight-code"
import { getRegistryItem } from "@/lib/registry"
import { cn } from "@/lib/utils"
import { ChartToolbar } from "@/components/chart-toolbar"
import { registryItemSchema } from "@/registry/schema"

export type Chart = z.infer<typeof registryItemSchema> & {
highlightedCode: string
Expand Down
2 changes: 1 addition & 1 deletion apps/www/lib/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use server"

import { registryItemSchema } from "shadcn/registry"
import { z } from "zod"

import { Style } from "@/registry/registry-styles"
import { registryItemSchema } from "@/registry/schema"

export async function getAllBlockIds(
types: z.infer<typeof registryItemSchema>["type"][] = [
Expand Down
2 changes: 1 addition & 1 deletion apps/www/lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { promises as fs } from "fs"
import { tmpdir } from "os"
import path from "path"
import { Index } from "@/__registry__"
import { registryItemFileSchema, registryItemSchema } from "shadcn/registry"
import { Project, ScriptKind, SourceFile, SyntaxKind } from "ts-morph"
import { z } from "zod"

import { Style } from "@/registry/registry-styles"
import { registryItemFileSchema, registryItemSchema } from "@/registry/schema"

export const DEFAULT_REGISTRY_STYLE = "new-york" satisfies Style["name"]

Expand Down
1 change: 1 addition & 0 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"react-resizable-panels": "^2.0.22",
"react-wrap-balancer": "^0.4.1",
"recharts": "2.12.7",
"shadcn": "2.1.8",
"sharp": "^0.31.3",
"sonner": "^1.2.3",
"swr": "2.2.6-beta.3",
Expand Down
20 changes: 20 additions & 0 deletions apps/www/public/r/facebook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/registry.json",
"name": "facebook",
"type": "registry:block",
"registryDependencies": [],
"dependencies": ["motion"],
"devDependencies": [],
"tailwind": {},
"cssVars": {
"light": {},
"dark": {}
},
"files": [
{
"path": "facebook.tsx",
"content": "'use client';\n\nimport type { Variants } from 'motion/react';\nimport { motion, useAnimation } from 'motion/react';\n\nconst facebookVariants: Variants = {\n normal: {\n opacity: 1,\n pathLength: 1,\n pathOffset: 0,\n transition: {\n duration: 0.4,\n opacity: { duration: 0.1 },\n },\n },\n animate: {\n opacity: [0, 1],\n pathLength: [0, 1],\n pathOffset: [1, 0],\n transition: {\n duration: 0.6,\n ease: 'linear',\n opacity: { duration: 0.1 },\n },\n },\n};\n\nconst FacebookIcon = () => {\n const controls = useAnimation();\n\n return (\n <div\n className=\"cursor-pointer select-none p-2 hover:bg-accent rounded-md transition-colors duration-200 flex items-center justify-center\"\n onMouseEnter={() => {\n controls.start('animate');\n }}\n onMouseLeave={() => {\n controls.start('normal');\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <motion.path\n variants={facebookVariants}\n animate={controls}\n initial=\"normal\"\n d=\"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z\"\n />\n </svg>\n </div>\n );\n};\n\nexport { FacebookIcon };\n",
"type": "registry:ui"
}
]
}
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/accordion-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "accordion-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"accordion"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/accordion.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "accordion",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"dependencies": [
"@radix-ui/react-accordion"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/alert-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "alert-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"alert"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/alert-destructive.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "alert-destructive",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"alert"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/alert-dialog-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "alert-dialog-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"alert-dialog",
"button"
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/alert-dialog.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "alert-dialog",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"dependencies": [
"@radix-ui/react-alert-dialog"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/alert.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "alert",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"files": [
{
"path": "ui/alert.tsx",
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/aspect-ratio-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "aspect-ratio-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"aspect-ratio"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/aspect-ratio.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "aspect-ratio",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"dependencies": [
"@radix-ui/react-aspect-ratio"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/avatar-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "avatar-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"avatar"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/avatar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "avatar",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"dependencies": [
"@radix-ui/react-avatar"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/badge-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "badge-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"badge"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/badge-destructive.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "badge-destructive",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"badge"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/badge-outline.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "badge-outline",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"badge"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/badge-secondary.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "badge-secondary",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"badge"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/badge.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "badge",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"files": [
{
"path": "ui/badge.tsx",
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-dropdown.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-dropdown",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-ellipsis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-ellipsis",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-link.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-link",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-responsive.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-responsive",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb-separator.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb-separator",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"breadcrumb"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/breadcrumb.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "breadcrumb",
"type": "registry:ui",
"author": "shadcn (https://ui.shadcn.com)",
"dependencies": [
"@radix-ui/react-slot"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/button-as-child.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button-as-child",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"button"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/button-demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button-demo",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"button"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/button-destructive.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button-destructive",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"button"
],
Expand Down
2 changes: 2 additions & 0 deletions apps/www/public/r/styles/default/button-ghost.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button-ghost",
"type": "registry:example",
"author": "shadcn (https://ui.shadcn.com)",
"registryDependencies": [
"button"
],
Expand Down
Loading
Loading