mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-20 18:43:20 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
import { type VariantProps } from 'class-variance-authority';
|
|
import * as React from 'react';
|
|
|
|
import { toggleVariants } from '@/components/ui/toggle';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({
|
|
size: 'default',
|
|
variant: 'default',
|
|
});
|
|
|
|
const ToggleGroup = React.forwardRef<
|
|
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>
|
|
>(({ className, variant, size, children, ...props }, ref) => (
|
|
<ToggleGroupPrimitive.Root ref={ref} className={cn('flex items-center justify-center gap-1', className)} {...props}>
|
|
<ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
|
|
</ToggleGroupPrimitive.Root>
|
|
));
|
|
|
|
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
|
|
const ToggleGroupItem = React.forwardRef<
|
|
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>
|
|
>(({ className, children, variant, size, ...props }, ref) => {
|
|
const context = React.useContext(ToggleGroupContext);
|
|
|
|
return (
|
|
<ToggleGroupPrimitive.Item
|
|
ref={ref}
|
|
className={cn(
|
|
toggleVariants({
|
|
variant: context.variant || variant,
|
|
size: context.size || size,
|
|
}),
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</ToggleGroupPrimitive.Item>
|
|
);
|
|
});
|
|
|
|
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
|
|
export { ToggleGroup, ToggleGroupItem };
|