-
Notifications
You must be signed in to change notification settings - Fork 0
feat(shadcn): #52 swap search AnimalCard/Progress/Form Button #59
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
Changes from all commits
c806363
75ff0cb
01fa96d
0422e22
773b656
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "$schema": "https://ui.shadcn.com/schema.json", | ||
| "style": "default", | ||
| "rsc": true, | ||
| "tsx": true, | ||
| "tailwind": { | ||
| "config": "apps/web/tailwind.config.js", | ||
| "css": "apps/web/app/globals.css", | ||
| "baseColor": "neutral", | ||
| "cssVariables": true | ||
| }, | ||
| "aliases": { | ||
| "components": "front/new-component", | ||
| "ui": "front/new-component/ui", | ||
| "utils": "front/lib/utils", | ||
| "lib": "front/lib", | ||
| "hooks": "front/hooks" | ||
| }, | ||
| "iconLibrary": "lucide" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { clsx, type ClassValue } from 'clsx'; | ||
| import { twMerge } from 'tailwind-merge'; | ||
|
|
||
| export function cn(...inputs: ClassValue[]) { | ||
| return twMerge(clsx(inputs)); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| export * from './form' | ||
| export * from './header' | ||
| export * from './sidebar' | ||
| export * from './bottom' | ||
| export * from './form'; | ||
| export * from './header'; | ||
| export * from './bottom'; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| 'use client'; | ||
|
|
||
| import * as React from 'react'; | ||
| import * as AvatarPrimitive from '@radix-ui/react-avatar'; | ||
|
|
||
| import { cn } from 'front/lib/utils'; | ||
|
|
||
| const Avatar = React.forwardRef< | ||
| React.ElementRef<typeof AvatarPrimitive.Root>, | ||
| React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
| >(({ className, ...props }, ref) => ( | ||
| <AvatarPrimitive.Root | ||
| ref={ref} | ||
| className={cn( | ||
| 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', | ||
| className | ||
| )} | ||
| {...props} | ||
| /> | ||
| )); | ||
| Avatar.displayName = AvatarPrimitive.Root.displayName; | ||
|
|
||
| const AvatarImage = React.forwardRef< | ||
| React.ElementRef<typeof AvatarPrimitive.Image>, | ||
| React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
| >(({ className, ...props }, ref) => ( | ||
| <AvatarPrimitive.Image | ||
| ref={ref} | ||
| className={cn('aspect-square h-full w-full', className)} | ||
| {...props} | ||
| /> | ||
| )); | ||
| AvatarImage.displayName = AvatarPrimitive.Image.displayName; | ||
|
|
||
| const AvatarFallback = React.forwardRef< | ||
| React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
| React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
| >(({ className, ...props }, ref) => ( | ||
| <AvatarPrimitive.Fallback | ||
| ref={ref} | ||
| className={cn( | ||
| 'flex h-full w-full items-center justify-center rounded-full bg-muted', | ||
| className | ||
| )} | ||
| {...props} | ||
| /> | ||
| )); | ||
| AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; | ||
|
|
||
| export { Avatar, AvatarImage, AvatarFallback }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import * as React from 'react'; | ||
| import { Slot } from '@radix-ui/react-slot'; | ||
| import { cva, type VariantProps } from 'class-variance-authority'; | ||
|
|
||
| import { cn } from 'front/lib/utils'; | ||
|
|
||
| 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 | ||
| className={cn(buttonVariants({ variant, size, className }))} | ||
| ref={ref} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
| ); | ||
| Button.displayName = 'Button'; | ||
|
|
||
| export { Button, buttonVariants }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| import { cn } from 'front/lib/utils'; | ||
|
|
||
| const Card = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLDivElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| className={cn( | ||
| 'rounded-lg border bg-card text-card-foreground shadow-sm', | ||
| className | ||
| )} | ||
| {...props} | ||
| /> | ||
| )); | ||
| Card.displayName = 'Card'; | ||
|
|
||
| const CardHeader = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLDivElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| className={cn('flex flex-col space-y-1.5 p-6', className)} | ||
| {...props} | ||
| /> | ||
| )); | ||
| CardHeader.displayName = 'CardHeader'; | ||
|
|
||
| const CardTitle = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLHeadingElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| className={cn( | ||
| 'text-2xl font-semibold leading-none tracking-tight', | ||
| className | ||
| )} | ||
| {...props} | ||
| /> | ||
| )); | ||
| CardTitle.displayName = 'CardTitle'; | ||
|
|
||
| const CardDescription = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLParagraphElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| className={cn('text-sm text-muted-foreground', className)} | ||
| {...props} | ||
| /> | ||
| )); | ||
| CardDescription.displayName = 'CardDescription'; | ||
|
|
||
| const CardContent = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLDivElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div ref={ref} className={cn('p-6 pt-0', className)} {...props} /> | ||
| )); | ||
| CardContent.displayName = 'CardContent'; | ||
|
|
||
| const CardFooter = React.forwardRef< | ||
| HTMLDivElement, | ||
| React.HTMLAttributes<HTMLDivElement> | ||
| >(({ className, ...props }, ref) => ( | ||
| <div | ||
| ref={ref} | ||
| className={cn('flex items-center p-6 pt-0', className)} | ||
| {...props} | ||
| /> | ||
| )); | ||
| CardFooter.displayName = 'CardFooter'; | ||
|
|
||
| export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use client'; | ||
|
|
||
| import * as React from 'react'; | ||
| import * as ProgressPrimitive from '@radix-ui/react-progress'; | ||
|
|
||
| import { cn } from 'front/lib/utils'; | ||
|
|
||
| const Progress = React.forwardRef< | ||
| React.ElementRef<typeof ProgressPrimitive.Root>, | ||
| React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> | ||
| >(({ className, value, ...props }, ref) => ( | ||
| <ProgressPrimitive.Root | ||
| ref={ref} | ||
| className={cn( | ||
| 'relative h-4 w-full overflow-hidden rounded-full bg-secondary', | ||
| className | ||
| )} | ||
| {...props} | ||
| > | ||
| <ProgressPrimitive.Indicator | ||
| className="h-full w-full flex-1 bg-primary transition-all" | ||
| style={{ transform: `translateX(-${100 - (value || 0)}%)` }} | ||
|
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The Because the transform uses Suggested implementation: >(({ className, value = 100, ...props }, ref) => ( className="h-full w-full flex-1 bg-primary transition-all"
style={{ transform: `translateX(-${100 - value}%)` }} |
||
| /> | ||
| </ProgressPrimitive.Root> | ||
| )); | ||
| Progress.displayName = ProgressPrimitive.Root.displayName; | ||
|
|
||
| export { Progress }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): The
CardDescriptiongenerics also mix element types and should be aligned with the rendered element.CardDescriptionmirrors theCardTitleissue: the ref is typed asHTMLDivElement, props asReact.HTMLAttributes<HTMLParagraphElement>, but the component renders a<div>. Please either render a<p>and keepHTMLParagraphElement, or keep the<div>and change the props toReact.HTMLAttributes<HTMLDivElement>so the types match the actual element.