From 337914f169e3c8ad2116e509b340c35d8e327bf3 Mon Sep 17 00:00:00 2001 From: SySagar Date: Thu, 24 Oct 2024 02:16:04 +0530 Subject: [PATCH] fix(docs): chips --- apps/docs/app/ui/IndividialComp.tsx | 19 ++ apps/docs/content/docs/(components)/chips.mdx | 207 ++++++++++++++++++ apps/ui/lib/components/Chip/Chip.tsx | 39 ++-- apps/ui/stories/Chip.stories.tsx | 2 +- 4 files changed, 249 insertions(+), 18 deletions(-) create mode 100644 apps/docs/app/ui/IndividialComp.tsx create mode 100644 apps/docs/content/docs/(components)/chips.mdx diff --git a/apps/docs/app/ui/IndividialComp.tsx b/apps/docs/app/ui/IndividialComp.tsx new file mode 100644 index 0000000..c158aa1 --- /dev/null +++ b/apps/docs/app/ui/IndividialComp.tsx @@ -0,0 +1,19 @@ +'use client'; +import React from 'react'; +import { Chip } from '@groovy-box/ui'; + +const ChipEle = () => { + return ( +
+ alert('Clicked!')}> + Clickable + + alert('Delete clicked!')}>Deletable + + Link + +
+ ); +}; + +export { ChipEle }; diff --git a/apps/docs/content/docs/(components)/chips.mdx b/apps/docs/content/docs/(components)/chips.mdx new file mode 100644 index 0000000..bb5f335 --- /dev/null +++ b/apps/docs/content/docs/(components)/chips.mdx @@ -0,0 +1,207 @@ +--- +title: Chip +description: Various types and configurations of Chip component. +--- + +## Default + +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { Chip, Avatar, AvatarImage, AvatarFallback } from '@/app/ui'; +import ComponenentWrapper from '@/app/ui/ComponenentWrapper'; +import { Star, Mail } from 'lucide-react'; +import { ChipEle } from '@/app/ui/IndividialComp'; + + + + +
+ Default +
+
+
+ + + ```tsx + import { Chip } from "@groovy-box/ui"; + + export function ChipDefault() { + return ( +
+ Default +
+ ); + } + ``` + +
+
+ +## Variants + + + + +
+ Filled + Outlined +
+
+
+ + + ```tsx + import { Chip } from "@groovy-box/ui"; + + export function ChipVariants() { + return ( +
+ Filled + Outlined +
+ ); + } + ``` + +
+
+ +## Sizes + + + + +
+ Small + Medium + Large +
+
+
+ + + ```tsx + import { Chip } from "@groovy-box/ui"; + + export function ChipSizes() { + return ( +
+ Small + Medium + Large +
+ ); + } + ``` + +
+
+ +## With Icons + + + + +
+ + + AB + + } + > + User Chip + + }> + Starred + + } + afterChildren={ + + 99+ + + } + > + Inbox + +
+
+
+ + + ```tsx + import { Chip, Avatar, AvatarImage, AvatarFallback } from "@groovy-box/ui"; + import { Star, Mail } from 'lucide-react'; + + export function ChipWithIcons() { + return ( +
+ + + AB + + } + > + User Chip + + }> + Starred + + } + afterChildren={ + + 99+ + + } + > + Inbox + +
+ ); + } + ``` + +
+
+ +## Interactions + + + + + + + + + + ```tsx + import { Chip } from "@groovy-box/ui"; + + export function ChipInteractions() { + return ( +
+ alert('Clicked!')}>Clickable + alert('Delete clicked!')}>Deletable + Link +
+ ); + } + ``` + +
+
diff --git a/apps/ui/lib/components/Chip/Chip.tsx b/apps/ui/lib/components/Chip/Chip.tsx index db704ab..9053f0c 100644 --- a/apps/ui/lib/components/Chip/Chip.tsx +++ b/apps/ui/lib/components/Chip/Chip.tsx @@ -1,22 +1,22 @@ +'use client'; import * as React from 'react'; import { cva, type VariantProps } from 'class-variance-authority'; import { X as CloseIcon } from 'lucide-react'; -import { Text } from '../Typography'; import { cn } from '@utils/utils'; const chipVariants = cva( - 'grv-inline-flex grv-items-center grv-rounded-full grv-text-sm grv-font-medium grv-transition-colors focus:grv-outline-none focus:grv-ring-2 grv-ring-ring grv-ring-offset-2', + 'grv-inline-flex ui grv-items-center grv-rounded-full grv-text-sm grv-font-medium grv-transition-colors focus:grv-outline-none focus:grv-ring-2 grv-ring-ring grv-ring-offset-2', { variants: { variant: { - filled: 'grv-bg-primary-500', - outlined: 'grv-border-2 grv-border-solid grv-border-accent', + filled: 'grv-bg-primary-500 ui', + outlined: 'grv-border-2 grv-border-solid grv-border-accent ui', }, size: { - sm: 'grv-h-6 grv-px-3', - md: 'grv-h-8 grv-px-4', - lg: 'grv-h-10 grv-px-5', + sm: 'grv-h-6 grv-px-3 ui', + md: 'grv-h-8 grv-px-4 ui', + lg: 'grv-h-10 grv-px-5 ui', }, clickable: { true: 'grv-cursor-pointer', @@ -78,12 +78,21 @@ const Chip = React.forwardRef( const textColor = variant === 'outlined' ? 'grv-text-accent' : 'grv-text-text-primary'; + console.log(size); + + const textSize = + size === 'sm' + ? 'grv-text-[10px]' + : size === 'md' + ? 'grv-text-[12px]' + : 'grv-text-[14px]'; + return ( ( {beforeChildren && (
{beforeChildren}
)} - - {children} - +
{children}
{afterChildren && (
{afterChildren} @@ -113,10 +120,8 @@ const Chip = React.forwardRef( {onDelete && (
{ e.stopPropagation(); diff --git a/apps/ui/stories/Chip.stories.tsx b/apps/ui/stories/Chip.stories.tsx index da794bf..0148df7 100644 --- a/apps/ui/stories/Chip.stories.tsx +++ b/apps/ui/stories/Chip.stories.tsx @@ -33,7 +33,7 @@ const ChipInteractions = () => ( Clickable alert('Delete clicked!')}>Deletable - + Link