From a57e777a6b3b2a04e86e81d41c21f3a555439e1a Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Wed, 1 May 2024 02:21:54 -0400 Subject: [PATCH] feat: completely nuke headlessui and consolidate to aria --- app/components/Attribute.tsx | 3 +- app/components/Dialog.tsx | 22 ++-- app/components/Error.tsx | 82 ++++++------- app/components/Menu.tsx | 29 ++++- app/components/Switch.tsx | 40 +++++++ app/components/TextField.tsx | 1 + app/components/Toaster.tsx | 110 +++++++++++------ app/root.tsx | 2 +- app/routes/_data.acls._index/editor.tsx | 42 +++---- app/routes/_data.acls._index/route.tsx | 151 ++++++++++-------------- app/routes/_data.dns._index/magic.tsx | 2 +- app/routes/_data.dns._index/rename.tsx | 2 +- app/routes/_data.dns._index/route.tsx | 22 +--- app/routes/_data.tsx | 25 ++-- package.json | 4 +- pnpm-lock.yaml | 101 +++++++--------- 16 files changed, 336 insertions(+), 302 deletions(-) create mode 100644 app/components/Switch.tsx diff --git a/app/components/Attribute.tsx b/app/components/Attribute.tsx index 8b89f0f..3cd4f4a 100644 --- a/app/components/Attribute.tsx +++ b/app/components/Attribute.tsx @@ -1,5 +1,6 @@ import { ClipboardIcon } from '@heroicons/react/24/outline' -import toast from 'react-hot-toast/headless' + +import { toast } from './Toaster' type Properties = { readonly name: string; diff --git a/app/components/Dialog.tsx b/app/components/Dialog.tsx index c958604..1243bd0 100644 --- a/app/components/Dialog.tsx +++ b/app/components/Dialog.tsx @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/no-keyword-prefix */ import { type Dispatch, type ReactNode, type SetStateAction } from 'react' import { Button as AriaButton, @@ -20,7 +21,9 @@ function Button(properties: ButtonProperties) { {...properties} aria-label='Dialog' className={cn( - 'outline-none', + 'w-fit text-sm rounded-lg px-4 py-2', + 'bg-main-700 dark:bg-main-800 text-white', + properties.isDisabled && 'opacity-50 cursor-not-allowed', properties.className )} // If control is passed, set the state value @@ -42,11 +45,12 @@ function Action(properties: ActionProperties) { type={properties.variant === 'confirm' ? 'submit' : 'button'} className={cn( 'px-4 py-2 rounded-lg', + properties.isDisabled && 'opacity-50 cursor-not-allowed', properties.variant === 'cancel' ? 'text-ui-700 dark:text-ui-300' - : 'text-ui-950 dark:text-ui-50', + : 'text-ui-300 dark:text-ui-300', properties.variant === 'confirm' - ? 'bg-blue-500 hover:bg-blue-600 pressed:bg-blue-700 text-white' + ? 'bg-main-700 dark:bg-main-700 pressed:bg-main-800 dark:pressed:bg-main-800' : 'bg-ui-200 dark:bg-ui-800 pressed:bg-ui-300 dark:pressed:bg-ui-700', properties.className )} @@ -82,9 +86,10 @@ function Text(properties: React.HTMLProps) { type PanelProperties = { readonly children: (close: () => void) => ReactNode; readonly control?: [boolean, Dispatch>]; + readonly className?: string; } -function Panel({ children, control }: PanelProperties) { +function Panel({ children, control, className }: PanelProperties) { return (