Skip to content

Commit

Permalink
fix(icon folder): cOde clenaup
Browse files Browse the repository at this point in the history
  • Loading branch information
yokesh-ks committed Oct 10, 2023
1 parent b27840b commit 766b3f7
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 37 deletions.
13 changes: 10 additions & 3 deletions src/components/common/mode-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client'

import { MoonIcon, SunIcon } from 'lucide-react'
import { useTheme } from 'next-themes'
import * as React from 'react'

Expand All @@ -12,15 +11,23 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'

import { Icon } from '@/icon'

export function ModeToggle() {
const { setTheme } = useTheme()

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant='ghost' className='h-9 w-9 px-0'>
<SunIcon className='h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />
<MoonIcon className='absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100' />
<Icon
name='SunIcon'
className='h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0'
/>
<Icon
name='MoonIcon'
className='absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100'
/>
<span className='sr-only'>Toggle theme</span>
</Button>
</DropdownMenuTrigger>
Expand Down
8 changes: 6 additions & 2 deletions src/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ChevronDown } from 'lucide-react'
import * as React from 'react'

import * as AccordionPrimitive from '@radix-ui/react-accordion'

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

import { Icon } from '@/icon'

const Accordion = AccordionPrimitive.Root

const AccordionItem = React.forwardRef<
Expand Down Expand Up @@ -33,7 +34,10 @@ const AccordionTrigger = React.forwardRef<
{...props}
>
{children}
<ChevronDown className='h-4 w-4 shrink-0 transition-transform duration-200' />
<Icon
name='ChevronDown'
className='h-4 w-4 shrink-0 transition-transform duration-200'
/>
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
))
Expand Down
7 changes: 4 additions & 3 deletions src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ChevronLeft, ChevronRight } from 'lucide-react'
import * as React from 'react'
import { DayPicker } from 'react-day-picker'

import { buttonVariants } from '@/components/ui/button'

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

import { Icon } from '@/icon'

export type CalendarProps = React.ComponentProps<typeof DayPicker>

function Calendar({
Expand Down Expand Up @@ -51,8 +52,8 @@ function Calendar({
...classNames,
}}
components={{
IconLeft: ({ ...props }) => <ChevronLeft className='h-4 w-4' />,
IconRight: ({ ...props }) => <ChevronRight className='h-4 w-4' />,
IconLeft: () => <Icon name='ChevronLeft' className='h-4 w-4' />,
IconRight: () => <Icon name='ChevronRight' className='h-4 w-4' />,
}}
{...props}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Check } from 'lucide-react'
import * as React from 'react'

import * as CheckboxPrimitive from '@radix-ui/react-checkbox'

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

import { Icon } from '@/icon'

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
Expand All @@ -20,7 +21,7 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
>
<Check className='h-4 w-4' />
<Icon name='Check' className='h-4 w-4' />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/command.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Command as CommandPrimitive } from 'cmdk'
import { Search } from 'lucide-react'
import * as React from 'react'

import { Dialog, DialogContent } from '@/components/ui/dialog'
Expand All @@ -8,6 +7,8 @@ import { DialogProps } from '@radix-ui/react-dialog'

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

import { Icon } from '@/icon'

const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
Expand Down Expand Up @@ -42,7 +43,7 @@ const CommandInput = React.forwardRef<
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className='flex items-center border-b px-3'>
<Search className='mr-2 h-4 w-4 shrink-0 opacity-50' />
<Icon name='Search' className='mr-2 h-4 w-4 shrink-0 opacity-50' />
<CommandPrimitive.Input
ref={ref}
className={cn(
Expand Down
9 changes: 5 additions & 4 deletions src/components/ui/context-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Check, ChevronRight, Circle } from 'lucide-react'
import * as React from 'react'

import * as ContextMenuPrimitive from '@radix-ui/react-context-menu'

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

import { Icon } from '@/icon'

const ContextMenu = ContextMenuPrimitive.Root

const ContextMenuTrigger = ContextMenuPrimitive.Trigger
Expand Down Expand Up @@ -33,7 +34,7 @@ const ContextMenuSubTrigger = React.forwardRef<
{...props}
>
{children}
<ChevronRight className='ml-auto h-4 w-4' />
<Icon name='ChevronRight' className='ml-auto h-4 w-4' />
</ContextMenuPrimitive.SubTrigger>
))
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
Expand Down Expand Up @@ -103,7 +104,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<ContextMenuPrimitive.ItemIndicator>
<Check className='h-4 w-4' />
<Icon name='Check' className='h-4 w-4' />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
Expand All @@ -126,7 +127,7 @@ const ContextMenuRadioItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<ContextMenuPrimitive.ItemIndicator>
<Circle className='h-2 w-2 fill-current' />
<Icon name='Circle' className='h-2 w-2 fill-current' />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { X } from 'lucide-react'
import * as React from 'react'

import * as DialogPrimitive from '@radix-ui/react-dialog'

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

import { Icon } from '@/icon'

const Dialog = DialogPrimitive.Root

const DialogTrigger = DialogPrimitive.Trigger
Expand Down Expand Up @@ -45,7 +46,7 @@ const DialogContent = React.forwardRef<
>
{children}
<DialogPrimitive.Close className='absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground'>
<X className='h-4 w-4' />
<Icon name='X' className='h-4 w-4' />
<span className='sr-only'>Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
Expand Down
9 changes: 5 additions & 4 deletions src/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Check, ChevronRight, Circle } from 'lucide-react'
import * as React from 'react'

import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'

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

import { Icon } from '@/icon'

const DropdownMenu = DropdownMenuPrimitive.Root

const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
Expand Down Expand Up @@ -33,7 +34,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
{...props}
>
{children}
<ChevronRight className='ml-auto h-4 w-4' />
<Icon name='ChevronRight' className='ml-auto h-4 w-4' />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =
Expand Down Expand Up @@ -106,7 +107,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<DropdownMenuPrimitive.ItemIndicator>
<Check className='h-4 w-4' />
<Icon name='Check' className='h-4 w-4' />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
Expand All @@ -129,7 +130,7 @@ const DropdownMenuRadioItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<DropdownMenuPrimitive.ItemIndicator>
<Circle className='h-2 w-2 fill-current' />
<Icon name='Circle' className='h-2 w-2 fill-current' />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
Expand Down
9 changes: 5 additions & 4 deletions src/components/ui/menubar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Check, ChevronRight, Circle } from 'lucide-react'
import * as React from 'react'

import * as MenubarPrimitive from '@radix-ui/react-menubar'

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

import { Icon } from '@/icon'

const MenubarMenu = MenubarPrimitive.Menu

const MenubarGroup = MenubarPrimitive.Group
Expand Down Expand Up @@ -61,7 +62,7 @@ const MenubarSubTrigger = React.forwardRef<
{...props}
>
{children}
<ChevronRight className='ml-auto h-4 w-4' />
<Icon name='ChevronRight' className='ml-auto h-4 w-4' />
</MenubarPrimitive.SubTrigger>
))
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName
Expand Down Expand Up @@ -139,7 +140,7 @@ const MenubarCheckboxItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<MenubarPrimitive.ItemIndicator>
<Check className='h-4 w-4' />
<Icon name='Check' className='h-4 w-4' />
</MenubarPrimitive.ItemIndicator>
</span>
{children}
Expand All @@ -161,7 +162,7 @@ const MenubarRadioItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<MenubarPrimitive.ItemIndicator>
<Circle className='h-2 w-2 fill-current' />
<Icon name='Circle' className='h-2 w-2 fill-current' />
</MenubarPrimitive.ItemIndicator>
</span>
{children}
Expand Down
6 changes: 4 additions & 2 deletions src/components/ui/navigation-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { cva } from 'class-variance-authority'
import { ChevronDown } from 'lucide-react'
import * as React from 'react'

import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'

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

import { Icon } from '@/icon'

const NavigationMenu = React.forwardRef<
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
Expand Down Expand Up @@ -55,7 +56,8 @@ const NavigationMenuTrigger = React.forwardRef<
{...props}
>
{children}{' '}
<ChevronDown
<Icon
name='ChevronDown'
className='relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180'
aria-hidden='true'
/>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/radio-group.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Circle } from 'lucide-react'
import * as React from 'react'

import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'

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

import { Icon } from '@/icon'

const RadioGroup = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
Expand Down Expand Up @@ -33,7 +34,7 @@ const RadioGroupItem = React.forwardRef<
{...props}
>
<RadioGroupPrimitive.Indicator className='flex items-center justify-center'>
<Circle className='h-2.5 w-2.5 fill-current text-current' />
<Icon name='Circle' className='h-2.5 w-2.5 fill-current text-current' />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
)
Expand Down
7 changes: 4 additions & 3 deletions src/components/ui/select.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Check, ChevronDown } from 'lucide-react'
import * as React from 'react'

import * as SelectPrimitive from '@radix-ui/react-select'

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

import { Icon } from '@/icon'

const Select = SelectPrimitive.Root

const SelectGroup = SelectPrimitive.Group
Expand All @@ -25,7 +26,7 @@ const SelectTrigger = React.forwardRef<
>
{children}
<SelectPrimitive.Icon asChild>
<ChevronDown className='h-4 w-4 opacity-50' />
<Icon name='ChevronDown' className='h-4 w-4 opacity-50' />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
))
Expand Down Expand Up @@ -87,7 +88,7 @@ const SelectItem = React.forwardRef<
>
<span className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
<SelectPrimitive.ItemIndicator>
<Check className='h-4 w-4' />
<Icon name='Check' className='h-4 w-4' />
</SelectPrimitive.ItemIndicator>
</span>

Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { type VariantProps, cva } from 'class-variance-authority'
import { X } from 'lucide-react'
import * as React from 'react'

import * as SheetPrimitive from '@radix-ui/react-dialog'

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

import { Icon } from '@/icon'

const Sheet = SheetPrimitive.Root

const SheetTrigger = SheetPrimitive.Trigger
Expand Down Expand Up @@ -68,7 +69,7 @@ const SheetContent = React.forwardRef<
>
{children}
<SheetPrimitive.Close className='absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary'>
<X className='h-4 w-4' />
<Icon name='X' className='h-4 w-4' />
<span className='sr-only'>Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { type VariantProps, cva } from 'class-variance-authority'
import { X } from 'lucide-react'
import * as React from 'react'

import * as ToastPrimitives from '@radix-ui/react-toast'

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

import { Icon } from '@/icon'

const ToastProvider = ToastPrimitives.Provider

const ToastViewport = React.forwardRef<
Expand Down Expand Up @@ -82,7 +83,7 @@ const ToastClose = React.forwardRef<
toast-close=''
{...props}
>
<X className='h-4 w-4' />
<Icon name='X' className='h-4 w-4' />
</ToastPrimitives.Close>
))
ToastClose.displayName = ToastPrimitives.Close.displayName
Expand Down
Loading

0 comments on commit 766b3f7

Please sign in to comment.