Skip to content

Commit

Permalink
feat: mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Nov 30, 2023
1 parent 6444d18 commit 53bea83
Show file tree
Hide file tree
Showing 24 changed files with 2,115 additions and 220 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default antfu(
{
ignores: [
// eslint ignore globs here
'playground/package.json',
],
},
{
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
"typecheck": "tsc --noEmit",
"prepare": "simple-git-hooks"
},
"peerDependencies": {
"unocss": "^0.57.7"
},
"dependencies": {
"@unocss/preset-mini": "^0.57.7"
},
"devDependencies": {
"@antfu/eslint-config": "^2.1.2",
"@antfu/ni": "^0.21.12",
Expand Down
24 changes: 24 additions & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
16 changes: 16 additions & 0 deletions playground/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
},
"rsc": false,
"style": "default",
"tailwind": {
"baseColor": "neutral",
"config": "tailwind.config.js",
"css": "app/globals.css",
"cssVariables": true
},
"tsx": true
}
12 changes: 12 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@unocss/reset": "^0.57.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"lucide-react": "^0.294.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^2.0.0",
"unocss-preset-shadcn": "workspace:^"
},
"devDependencies": {
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@vitejs/plugin-react": "^4.2.0",
"typescript": "^5.2.2",
"unocss": "^0.57.7",
"vite": "^5.0.0"
},
"name": "playground",
"private": true,
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"preview": "vite preview"
},
"type": "module"
}
5 changes: 5 additions & 0 deletions playground/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Button } from '@/components/ui/button'

Check failure on line 1 in playground/src/App.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module '@/components/ui/button' or its corresponding type declarations.

export default function ButtonDemo() {
return <Button>Button</Button>

Check failure on line 4 in playground/src/App.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot use JSX unless the '--jsx' flag is provided.
}
56 changes: 56 additions & 0 deletions playground/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from 'react'
import { Slot } from '@radix-ui/react-slot'
import { type VariantProps, cva } from 'class-variance-authority'

import { cn } from '@/lib/utils'

Check failure on line 5 in playground/src/components/ui/button.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module '@/lib/utils' or its corresponding type declarations.

const buttonVariants = cva(
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
},
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button'
return (
<Comp

Check failure on line 46 in playground/src/components/ui/button.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot use JSX unless the '--jsx' flag is provided.
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
},
)
Button.displayName = 'Button'

export { Button, buttonVariants }
7 changes: 7 additions & 0 deletions playground/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ClassValue } from 'clsx'
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
11 changes: 11 additions & 0 deletions playground/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'

Check failure on line 3 in playground/src/main.tsx

View workflow job for this annotation

GitHub Actions / typecheck

An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled.

Check failure on line 3 in playground/src/main.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Module './App.tsx' was resolved to '/home/runner/work/unocss-preset-shadcn/unocss-preset-shadcn/playground/src/App.tsx', but '--jsx' is not set.
import '@unocss/reset/tailwind.css'
import 'virtual:uno.css'

ReactDOM.createRoot(document.getElementById('root')!).render(

Check failure on line 7 in playground/src/main.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
<React.StrictMode>

Check failure on line 8 in playground/src/main.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot use JSX unless the '--jsx' flag is provided.
<App />

Check failure on line 9 in playground/src/main.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot use JSX unless the '--jsx' flag is provided.
</React.StrictMode>,
)
1 change: 1 addition & 0 deletions playground/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
27 changes: 27 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "ES2020",
"jsx": "react-jsx",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,
"baseUrl": ".",
"module": "ESNext",
"moduleResolution": "bundler",
"paths": {
"@/*": [
"./src/*"
]
},
"resolveJsonModule": true,
"allowImportingTsExtensions": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["src"]
}
10 changes: 10 additions & 0 deletions playground/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}
11 changes: 11 additions & 0 deletions playground/uno.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig, presetUno } from 'unocss'
import { presetShadcn } from 'unocss-preset-shadcn'

Check failure on line 2 in playground/uno.config.ts

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module 'unocss-preset-shadcn' or its corresponding type declarations.

export default defineConfig({
presets: [
presetUno(),
presetShadcn({
color: 'red',
}),
],
})
13 changes: 13 additions & 0 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import UnoCSS from 'unocss/vite'

export default defineConfig({
plugins: [react(), UnoCSS()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})
Loading

0 comments on commit 53bea83

Please sign in to comment.