Skip to content

Commit

Permalink
Setup ui components package #3
Browse files Browse the repository at this point in the history
- Formatted all files with prettier

Resolve #3
  • Loading branch information
hyukkwonepic committed Feb 10, 2024
1 parent 34da7ac commit fdda0c1
Show file tree
Hide file tree
Showing 64 changed files with 6,673 additions and 3,834 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
/.nx/cache
.next
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.formatOnSave": true
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Notes

- `pnpm add <package name> --filter <app name</app> --workspace` to add a package to a workspace
- e.g. `pnpm add ui --filter dailyscrum --workspace`
- e.g. `pnpm add ui --filter dailyscrum --workspace`
14 changes: 7 additions & 7 deletions apps/dailyscrum/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
import 'ui/dist/style.css';
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import "ui/dist/style.css";

const inter = Inter({ subsets: ['latin'] });
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
Expand Down
12 changes: 6 additions & 6 deletions apps/dailyscrum/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Image from 'next/image';
import Image from "next/image";

export default function Home() {
return (
Expand All @@ -15,7 +15,7 @@ export default function Home() {
target="_blank"
rel="noopener noreferrer"
>
By{' '}
By{" "}
<Image
src="/vercel.svg"
alt="Vercel Logo"
Expand Down Expand Up @@ -45,7 +45,7 @@ export default function Home() {
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{' '}
Docs{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
Expand All @@ -62,7 +62,7 @@ export default function Home() {
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{' '}
Learn{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
Expand All @@ -79,7 +79,7 @@ export default function Home() {
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
Templates{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
Expand All @@ -96,7 +96,7 @@ export default function Home() {
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{' '}
Deploy{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
Expand Down
6 changes: 3 additions & 3 deletions apps/dailyscrum/src/app/samples/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use client';
"use client";

import { Button } from 'ui/button';
import { Button } from "ui/button";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from 'ui/shadcn-ui/accordion';
} from "ui/shadcn-ui/accordion";

export default function Page() {
return (
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "dailyscrum",
"version": "1.0.0",
"description": "",
"scripts": {},
"scripts": {
"prettify": "prettier --write ."
},
"keywords": [],
"devDependencies": {
"@nx/eslint": "17.3.1",
Expand Down
18 changes: 9 additions & 9 deletions packages/ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
'@typescript-eslint/no-unused-vars': 'off',
"@typescript-eslint/no-unused-vars": "off",
},
};
6 changes: 3 additions & 3 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ If you are developing a production application, we recommend updating the config
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# UI

- Shadcn ui components are generated with [email protected]
- Shadcn ui components are generated with [email protected]
20 changes: 10 additions & 10 deletions packages/ui/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import * as ShadcnButton from './shadcn-ui/button';
import { cn } from '@/lib/utils';
import { type VariantProps } from 'class-variance-authority';
import React from "react";
import * as ShadcnButton from "./shadcn-ui/button";
import { cn } from "@/lib/utils";
import { type VariantProps } from "class-variance-authority";

type BaseButtonVariants = VariantProps<typeof ShadcnButton.buttonVariants>;

type ExtendedButtonVariants = Omit<BaseButtonVariants, 'size'> & {
size?: BaseButtonVariants['size'] | 'icon-sm';
type ExtendedButtonVariants = Omit<BaseButtonVariants, "size"> & {
size?: BaseButtonVariants["size"] | "icon-sm";
};

const buttonVariants = (inputVariants: ExtendedButtonVariants) => {
const adjustedVariants = {
...inputVariants,
size: inputVariants.size === 'icon-sm' ? null : inputVariants.size,
size: inputVariants.size === "icon-sm" ? null : inputVariants.size,
};
return ShadcnButton.buttonVariants(adjustedVariants);
};
Expand All @@ -28,13 +28,13 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
return (
<ShadcnButton.Button
ref={ref}
className={cn(className, [size === 'icon-sm' ? 'h-9 w-9' : null])}
size={size === 'icon-sm' ? null : size}
className={cn(className, [size === "icon-sm" ? "h-9 w-9" : null])}
size={size === "icon-sm" ? null : size}
{...props}
/>
);
}
);
Button.displayName = 'Button';
Button.displayName = "Button";

export { Button, buttonVariants };
18 changes: 9 additions & 9 deletions packages/ui/src/components/shadcn-ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';
"use client";

import * as React from 'react';
import * as AccordionPrimitive from '@radix-ui/react-accordion';
import { ChevronDown } from 'lucide-react';
import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react";

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

const Accordion = AccordionPrimitive.Root;

Expand All @@ -14,11 +14,11 @@ const AccordionItem = React.forwardRef<
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn('border-b', className)}
className={cn("border-b", className)}
{...props}
/>
));
AccordionItem.displayName = 'AccordionItem';
AccordionItem.displayName = "AccordionItem";

const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
Expand All @@ -28,7 +28,7 @@ const AccordionTrigger = React.forwardRef<
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
Expand All @@ -49,7 +49,7 @@ const AccordionContent = React.forwardRef<
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn('pb-4 pt-0', className)}>{children}</div>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
</AccordionPrimitive.Content>
));

Expand Down
30 changes: 15 additions & 15 deletions packages/ui/src/components/shadcn-ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';
"use client";

import * as React from 'react';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";

import { cn } from '@/lib/utils';
import { buttonVariants } from '@/components/shadcn-ui/button';
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/shadcn-ui/button";

const AlertDialog = AlertDialogPrimitive.Root;

Expand All @@ -18,7 +18,7 @@ const AlertDialogOverlay = React.forwardRef<
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
Expand All @@ -36,7 +36,7 @@ const AlertDialogContent = React.forwardRef<
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
Expand All @@ -51,35 +51,35 @@ const AlertDialogHeader = ({
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col space-y-2 text-center sm:text-left',
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
);
AlertDialogHeader.displayName = 'AlertDialogHeader';
AlertDialogHeader.displayName = "AlertDialogHeader";

const AlertDialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
);
AlertDialogFooter.displayName = 'AlertDialogFooter';
AlertDialogFooter.displayName = "AlertDialogFooter";

const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold', className)}
className={cn("text-lg font-semibold", className)}
{...props}
/>
));
Expand All @@ -91,7 +91,7 @@ const AlertDialogDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
Expand All @@ -117,8 +117,8 @@ const AlertDialogCancel = React.forwardRef<
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
buttonVariants({ variant: 'outline' }),
'mt-2 sm:mt-0',
buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0",
className
)}
{...props}
Expand Down
Loading

0 comments on commit fdda0c1

Please sign in to comment.