Skip to content

Commit 4dde72a

Browse files
committed
feat: init ui module
1 parent 1d57d7a commit 4dde72a

File tree

8 files changed

+184
-0
lines changed

8 files changed

+184
-0
lines changed

packages/ui/eslint.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { config } from "@repo/eslint-config/react-internal";
2+
3+
/** @type {import("eslint").Linter.Config} */
4+
export default config;

packages/ui/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "skyroc-ui",
3+
"version": "0.0.1",
4+
"private": true,
5+
"exports": {
6+
"./*": "./src/*.tsx"
7+
},
8+
"scripts": {
9+
"lint": "eslint . --max-warnings 0",
10+
"generate:component": "turbo gen react-component",
11+
"check-types": "tsc --noEmit"
12+
},
13+
"devDependencies": {
14+
"@turbo/gen": "^2.5.0",
15+
"@types/node": "^22.15.3",
16+
"@types/react": "19.1.0",
17+
"@types/react-dom": "19.1.1",
18+
"eslint": "^9.30.0",
19+
"typescript": "5.8.2"
20+
},
21+
"dependencies": {
22+
"@radix-ui/react-slot": "^1.2.3",
23+
"class-variance-authority": "^0.7.1",
24+
"clsx": "^2.1.1",
25+
"react": "^19.1.0",
26+
"react-dom": "^19.1.0",
27+
"tailwind-merge": "^3.3.1"
28+
}
29+
}

packages/ui/src/button.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// @unocss-include
2+
import * as React from "react"
3+
import { Slot } from "@radix-ui/react-slot"
4+
import { cva, type VariantProps } from "class-variance-authority"
5+
6+
import { cn } from './util'
7+
8+
const buttonVariants = cva(
9+
"inline-flex items-center justify-center gap-2 whitespace-nowrap mt-2 rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
10+
{
11+
variants: {
12+
variant: {
13+
default:
14+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
15+
destructive:
16+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
17+
outline:
18+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
19+
secondary:
20+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
21+
ghost: "hover:bg-accent hover:text-accent-foreground",
22+
link: "text-primary underline-offset-4 hover:underline",
23+
},
24+
size: {
25+
default: "h-9 px-4 py-2",
26+
sm: "h-8 rounded-md px-3 text-xs",
27+
lg: "h-10 rounded-md px-8",
28+
icon: "h-9 w-9",
29+
},
30+
},
31+
defaultVariants: {
32+
variant: "default",
33+
size: "default",
34+
},
35+
}
36+
)
37+
38+
export interface ButtonProps
39+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
40+
VariantProps<typeof buttonVariants> {
41+
asChild?: boolean
42+
}
43+
44+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
45+
({ className, variant, size, asChild = false, ...props }, ref) => {
46+
const Comp = asChild ? Slot : "button"
47+
return (
48+
<Comp
49+
className={cn(buttonVariants({ variant, size, className }))}
50+
ref={ref}
51+
{...props}
52+
/>
53+
)
54+
}
55+
)
56+
Button.displayName = "Button"
57+
58+
export { Button, buttonVariants }

packages/ui/src/card.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { type JSX } from "react";
2+
3+
export function Card({
4+
className,
5+
title,
6+
children,
7+
href,
8+
}: {
9+
className?: string;
10+
title: string;
11+
children: React.ReactNode;
12+
href: string;
13+
}): JSX.Element {
14+
return (
15+
<a
16+
className={className}
17+
href={`${href}?utm_source=create-turbo&utm_medium=basic&utm_campaign=create-turbo"`}
18+
rel="noopener noreferrer"
19+
target="_blank"
20+
>
21+
<h2>
22+
{title} <span>-&gt;</span>
23+
</h2>
24+
<p>{children}</p>
25+
</a>
26+
);
27+
}

packages/ui/src/code.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { type JSX } from "react";
2+
3+
export function Code({
4+
children,
5+
className,
6+
}: {
7+
children: React.ReactNode;
8+
className?: string;
9+
}): JSX.Element {
10+
return <code className={className}>{children}</code>;
11+
}

packages/ui/src/util.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { clsx, type ClassValue } from 'clsx'
2+
import { twMerge } from 'tailwind-merge'
3+
4+
export function cn(...inputs: ClassValue[]) {
5+
return twMerge(clsx(inputs))
6+
}

packages/ui/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2017",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"noEmit": true,
9+
"esModuleInterop": true,
10+
"module": "esnext",
11+
"moduleResolution": "bundler",
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"jsx": "preserve",
15+
"incremental": true,
16+
},
17+
"include": ["src/**/*.ts", "src/**/*.tsx"],
18+
"exclude": ["node_modules"]
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { PlopTypes } from "@turbo/gen";
2+
3+
// Learn more about Turborepo Generators at https://turborepo.com/docs/guides/generating-code
4+
5+
export default function generator(plop: PlopTypes.NodePlopAPI): void {
6+
// A simple generator to add a new React component to the internal UI library
7+
plop.setGenerator("react-component", {
8+
description: "Adds a new react component",
9+
prompts: [
10+
{
11+
type: "input",
12+
name: "name",
13+
message: "What is the name of the component?",
14+
},
15+
],
16+
actions: [
17+
{
18+
type: "add",
19+
path: "src/{{kebabCase name}}.tsx",
20+
templateFile: "templates/component.hbs",
21+
},
22+
{
23+
type: "append",
24+
path: "package.json",
25+
pattern: /"exports": {(?<insertion>)/g,
26+
template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",',
27+
},
28+
],
29+
});
30+
}

0 commit comments

Comments
 (0)