bolt.diy/app/shared/components/ui/CloseButton.tsx
KevIsDev 4d3222ee96 refactor: reorganize project structure by moving files to a more dev friendly setup
- Move stores/utils/types to their relative directories (i.e chat stores in chat directory)
- Move utility files to shared/utils
- Move component files to shared/components
- Move type definitions to shared/types
- Move stores to shared/stores
- Update import paths across the project
2025-06-16 15:33:59 +01:00

50 lines
1.4 KiB
TypeScript

import React from 'react';
import { motion } from 'framer-motion';
import { classNames } from '~/shared/utils/classNames';
interface CloseButtonProps {
onClick?: () => void;
className?: string;
size?: 'sm' | 'md' | 'lg';
}
/**
* CloseButton component
*
* A button with an X icon used for closing dialogs, modals, etc.
* The button has a transparent background and only shows a background on hover.
*/
export function CloseButton({ onClick, className, size = 'md' }: CloseButtonProps) {
const sizeClasses = {
sm: 'p-1',
md: 'p-2',
lg: 'p-3',
};
const iconSizeClasses = {
sm: 'w-3 h-3',
md: 'w-4 h-4',
lg: 'w-5 h-5',
};
return (
<motion.button
type="button"
onClick={onClick}
className={classNames(
'text-bolt-elements-textTertiary hover:text-bolt-elements-textSecondary dark:text-bolt-elements-textTertiary-dark dark:hover:text-bolt-elements-textSecondary-dark',
'rounded-lg hover:bg-bolt-elements-background-depth-2 dark:hover:bg-bolt-elements-background-depth-3',
'transition-colors duration-200',
'focus:outline-none focus:ring-2 focus:ring-purple-500/50',
sizeClasses[size],
className,
)}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
aria-label="Close"
>
<div className={classNames('i-ph:x', iconSizeClasses[size])} />
</motion.button>
);
}