LibreChat/client/src/components/ui/AlertDialog.tsx

135 lines
5 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
2023-03-03 15:52:06 -05:00
import { cn } from '../../utils';
2023-03-03 15:52:06 -05:00
const AlertDialog = AlertDialogPrimitive.Root;
2023-03-03 15:52:06 -05:00
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
2023-03-03 15:52:06 -05:00
const AlertDialogPortal = ({
className = '',
2023-03-03 15:52:06 -05:00
children,
...props
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
{children}
</div>
</AlertDialogPrimitive.Portal>
);
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-gray-500/90 transition-opacity animate-in fade-in dark:bg-gray-800/90',
className,
2023-03-03 15:52:06 -05:00
)}
{...props}
ref={ref}
/>
));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
'fixed z-50 grid w-full max-w-lg scale-100 gap-4 bg-white p-6 opacity-100 animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full',
'dark:bg-slate-900',
className,
2023-03-03 15:52:06 -05:00
)}
{...props}
/>
</AlertDialogPortal>
));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogHeader = ({ className = '', ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
);
AlertDialogHeader.displayName = 'AlertDialogHeader';
2023-03-03 15:52:06 -05:00
const AlertDialogFooter = ({ className = '', ...props }: React.HTMLAttributes<HTMLDivElement>) => (
2023-03-03 15:52:06 -05:00
<div
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
2023-03-03 15:52:06 -05:00
{...props}
/>
);
AlertDialogFooter.displayName = 'AlertDialogFooter';
2023-03-03 15:52:06 -05:00
const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold text-slate-900', 'dark:text-slate-50', className)}
2023-03-03 15:52:06 -05:00
{...props}
/>
));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPrimitive.Description
ref={ref}
className={cn('text-sm text-slate-500', 'dark:text-slate-400', className)}
2023-03-03 15:52:06 -05:00
{...props}
/>
));
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPrimitive.Action
ref={ref}
className={cn(
Refactor UI styles & configurations (#324) * Refactor UI styles & configurations - Modify button styles and their color schemes to create a consistent user experience when interacting with buttons. - Adjust the design of the search bar to a more user-friendly layout by changing its background color and styling. - Create a responsive mobile behavior for the navigation bar to hide it behind a menu icon instead of permanently displaying it. * Update .gitignore to exclude unnecessary files for Meilisearch Update .gitignore to exclude meilisearch.exe and data.ms/*, which are not necessary for Meilisearch. * feat: Add getCurrentBreakpoint function to get current breakpoint This commit adds a getCurrentBreakpoint function to determine the current breakpoint of the viewport. The function uses fullConfig to determine the biggest breakpoint value of the window, and returns the corresponding breakpoint. It also updates the useEffect function to use getCurrentBreakpoint instead of checking if the userAgent matches a mobile regex. * Update tailwind import path in Nav component The import path for the tailwind config was updated in the Nav component to match the new project structure. This ensures that the correct Tailwind styles are applied to the component and improves maintainability. * Add ThemeContext and cn utility function to Nav component This commit adds the ThemeContext and cn utility function to the Nav component's dependencies with useContext and import respectively. It also modifies a class name with a ternary operator that toggles based on the theme value passed via ThemeContext. * Update Nav button styles for better visibility Changed the button styles for the Nav close and open buttons to enhance visibility. The text color for both buttons will now change when hovering to gray and gray-600 respectively. * Improve message header styles and add transition effects This commit updates the MessageHeader component styles by adjusting the text color, as well as adding transition effects to enhance the hover experience. The commit also tweaks mobile styles by adding a transition effect to `.nav` when resizing the window to mobile size. * Refactor the message header component styling for better visual contrast The message header component was refactored to improve its visual contrast by changing the text color for better readability. The styles of the component were modified to improve hover behavior as well as transition effects. The setSaveAsDialogShow method was shifted to the onClick prop to only execute when the endpoint is not 'chatGPTBrowser'. * refactor: Update styling of MessageHeader and Nav buttons The commit message describes changes made to the MessageHeader and Nav components. It summarizes the code changes as a refactor of the CSS styling for the buttons in both components, specifically updating the text and hover colors for the dark and light themes.
2023-05-19 20:21:34 +05:30
'inline-flex h-10 items-center justify-center rounded-md bg-slate-900 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-slate-200 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900',
className,
2023-03-03 15:52:06 -05:00
)}
{...props}
/>
));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
2023-03-03 15:52:06 -05:00
const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
>(({ className = '', ...props }, ref) => (
2023-03-03 15:52:06 -05:00
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
Refactor UI styles & configurations (#324) * Refactor UI styles & configurations - Modify button styles and their color schemes to create a consistent user experience when interacting with buttons. - Adjust the design of the search bar to a more user-friendly layout by changing its background color and styling. - Create a responsive mobile behavior for the navigation bar to hide it behind a menu icon instead of permanently displaying it. * Update .gitignore to exclude unnecessary files for Meilisearch Update .gitignore to exclude meilisearch.exe and data.ms/*, which are not necessary for Meilisearch. * feat: Add getCurrentBreakpoint function to get current breakpoint This commit adds a getCurrentBreakpoint function to determine the current breakpoint of the viewport. The function uses fullConfig to determine the biggest breakpoint value of the window, and returns the corresponding breakpoint. It also updates the useEffect function to use getCurrentBreakpoint instead of checking if the userAgent matches a mobile regex. * Update tailwind import path in Nav component The import path for the tailwind config was updated in the Nav component to match the new project structure. This ensures that the correct Tailwind styles are applied to the component and improves maintainability. * Add ThemeContext and cn utility function to Nav component This commit adds the ThemeContext and cn utility function to the Nav component's dependencies with useContext and import respectively. It also modifies a class name with a ternary operator that toggles based on the theme value passed via ThemeContext. * Update Nav button styles for better visibility Changed the button styles for the Nav close and open buttons to enhance visibility. The text color for both buttons will now change when hovering to gray and gray-600 respectively. * Improve message header styles and add transition effects This commit updates the MessageHeader component styles by adjusting the text color, as well as adding transition effects to enhance the hover experience. The commit also tweaks mobile styles by adding a transition effect to `.nav` when resizing the window to mobile size. * Refactor the message header component styling for better visual contrast The message header component was refactored to improve its visual contrast by changing the text color for better readability. The styles of the component were modified to improve hover behavior as well as transition effects. The setSaveAsDialogShow method was shifted to the onClick prop to only execute when the endpoint is not 'chatGPTBrowser'. * refactor: Update styling of MessageHeader and Nav buttons The commit message describes changes made to the MessageHeader and Nav components. It summarizes the code changes as a refactor of the CSS styling for the buttons in both components, specifically updating the text and hover colors for the dark and light themes.
2023-05-19 20:21:34 +05:30
'mt-2 inline-flex h-10 items-center justify-center rounded-md border border-slate-200 bg-transparent px-4 py-2 text-sm font-semibold text-slate-900 transition-colors hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-100 dark:hover:bg-gray-900 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 sm:mt-0',
className,
2023-03-03 15:52:06 -05:00
)}
{...props}
/>
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
2023-03-03 15:52:06 -05:00
export {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
};