- Implemented Skeleton component for loading states. - Added Slider component using Radix UI for customizable sliders. - Created Toaster component for notifications with theme support. - Developed Switch component for toggle functionality. - Introduced Table component with subcomponents for structured data display. - Built Tabs component for tabbed navigation. - Added Textarea component for multi-line text input. - Implemented Toggle Group and Toggle components for grouped toggle buttons. - Created Tooltip component for displaying additional information on hover. - Added User Avatar component for displaying user images with fallback. - Implemented useIsMobile hook for responsive design. - Created API utility functions for user and thought data fetching. - Added utility function for class name merging. - Updated package.json with new dependencies for UI components and utilities. - Added TypeScript configuration for path aliasing.
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
|
|
import { type VariantProps } from "class-variance-authority"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { toggleVariants } from "@/components/ui/toggle"
|
|
|
|
const ToggleGroupContext = React.createContext<
|
|
VariantProps<typeof toggleVariants>
|
|
>({
|
|
size: "default",
|
|
variant: "default",
|
|
})
|
|
|
|
function ToggleGroup({
|
|
className,
|
|
variant,
|
|
size,
|
|
children,
|
|
...props
|
|
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
VariantProps<typeof toggleVariants>) {
|
|
return (
|
|
<ToggleGroupPrimitive.Root
|
|
data-slot="toggle-group"
|
|
data-variant={variant}
|
|
data-size={size}
|
|
className={cn(
|
|
"group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
{children}
|
|
</ToggleGroupContext.Provider>
|
|
</ToggleGroupPrimitive.Root>
|
|
)
|
|
}
|
|
|
|
function ToggleGroupItem({
|
|
className,
|
|
children,
|
|
variant,
|
|
size,
|
|
...props
|
|
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
VariantProps<typeof toggleVariants>) {
|
|
const context = React.useContext(ToggleGroupContext)
|
|
|
|
return (
|
|
<ToggleGroupPrimitive.Item
|
|
data-slot="toggle-group-item"
|
|
data-variant={context.variant || variant}
|
|
data-size={context.size || size}
|
|
className={cn(
|
|
toggleVariants({
|
|
variant: context.variant || variant,
|
|
size: context.size || size,
|
|
}),
|
|
"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</ToggleGroupPrimitive.Item>
|
|
)
|
|
}
|
|
|
|
export { ToggleGroup, ToggleGroupItem }
|