Initial commit

This commit is contained in:
2026-08-07 23:53:15 +05:30
commit 90f14a73b2
222 changed files with 35000 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import * as React from 'react';
import { Button } from '@/components/ui/button';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
/**
* IconButton — a square Button carrying only an icon.
*
* It delegates entirely to Button so the two can never diverge, and requires a
* `label`: an icon-only control with no accessible name is a bug, so the API
* makes it impossible to omit. The label doubles as the tooltip.
*/
export const IconButton = React.forwardRef(
({ icon: Icon, label, tooltip = true, size = 'default', side = 'top', ...props }, ref) => {
const sizeMap = {
xs: 'icon-xs',
sm: 'icon-sm',
default: 'icon',
lg: 'icon-lg',
};
const button = (
<Button ref={ref} size={sizeMap[size] || 'icon'} aria-label={label} {...props}>
<Icon aria-hidden="true" />
</Button>
);
if (!tooltip) return button;
return (
<TooltipProvider delayDuration={300}>
<Tooltip>
<TooltipTrigger asChild>{button}</TooltipTrigger>
<TooltipContent side={side}>{label}</TooltipContent>
</Tooltip>
</TooltipProvider>
);
}
);
IconButton.displayName = 'IconButton';