From 14f779b817d899445d894336ba005d6c785349ce Mon Sep 17 00:00:00 2001 From: dogukan Date: Sat, 30 Mar 2024 23:51:59 +0300 Subject: [PATCH] fix reviews --- components/delete-api-key-button.tsx | 30 +++++--------------------- components/header.tsx | 25 ++++++++------------- components/ui/icons.tsx | 31 ++++++++++++++++++++++++++- lib/styles/sweetalert2CustomStyles.ts | 22 +++++++++++++++++++ 4 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 lib/styles/sweetalert2CustomStyles.ts diff --git a/components/delete-api-key-button.tsx b/components/delete-api-key-button.tsx index 85ee146..45e99aa 100644 --- a/components/delete-api-key-button.tsx +++ b/components/delete-api-key-button.tsx @@ -5,6 +5,7 @@ import { Button, type ButtonProps } from '@/components/ui/button'; import { IconSpinner } from '@/components/ui/icons'; import { cn } from '@/lib/utils'; import Swal from 'sweetalert2'; +import { swalCustomStyles } from '@/lib/styles/sweetalert2CustomStyles'; interface DeleteApiKeyButtonProps extends ButtonProps { text?: string; @@ -18,39 +19,18 @@ export function DeleteApiKeyButton({ const [isLoading, setIsLoading] = React.useState(false); React.useEffect(() => { - const css = ` - :root { - --swal-bg-color: #fff; /* Light mode background */ - --swal-text-color: #000; /* Light mode text */ - } - @media (prefers-color-scheme: dark) { - :root { - --swal-bg-color: #333; /* Dark mode background */ - --swal-text-color: #fff; /* Dark mode text */ - } - } - .swal2-popup { - background-color: var(--swal-bg-color) !important; - color: var(--swal-text-color) !important; - } - .swal2-title { - color: var(--swal-text-color) !important; - } - .swal2-content { - color: var(--swal-text-color) !important; - } - `; const head = document.head || document.getElementsByTagName('head')[0]; const style = document.createElement('style'); - + style.type = 'text/css'; - style.appendChild(document.createTextNode(css)); + style.appendChild(document.createTextNode(swalCustomStyles)); head.appendChild(style); - + return () => { head.removeChild(style); }; }, []); + function deleteApiKey(key: string) { localStorage.removeItem('ai-token'); diff --git a/components/header.tsx b/components/header.tsx index 86a7ce4..5a34888 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -9,13 +9,12 @@ import { auth } from '@/auth' import { clearChats } from '@/app/actions' import { Button, buttonVariants } from '@/components/ui/button' import { Sidebar } from '@/components/sidebar' -import { IconGitHub, IconSeparator } from '@/components/ui/icons' +import { IconBug, IconGitHub, IconSeparator } from '@/components/ui/icons' import { SidebarFooter } from '@/components/sidebar-footer' import { ThemeToggle } from '@/components/theme-toggle' import { ClearHistory } from '@/components/clear-history' import { UserMenu } from '@/components/user-menu' import Logo from '@/assets/logo/logo.svg' -import Bug from '@/assets/logo/bug.svg' import dynamic from 'next/dynamic' const zen_tokyo_zoo = Nunito({ @@ -62,7 +61,7 @@ export async function Header() {
{session?.user ? (
- + zkApp Umstad
@@ -87,19 +86,13 @@ export async function Header() { GitHub - Report a Bug - Report a Bug - + href="https://github.com/UmstadAI/zkAppUmstad/issues" + target="_blank" + className={cn(buttonVariants())} + > + + Report a Bug +
) diff --git a/components/ui/icons.tsx b/components/ui/icons.tsx index 8562b6b..721f866 100644 --- a/components/ui/icons.tsx +++ b/components/ui/icons.tsx @@ -451,6 +451,34 @@ function IconChevronUpDown({ ) } +function IconBug({ className, ...props }: React.ComponentProps<'svg'>) { + return ( + + + + + + ); +} + + export { IconEdit, IconOpenAI, @@ -480,5 +508,6 @@ export { IconUsers, IconExternalLink, IconLogout, - IconChevronUpDown + IconChevronUpDown, + IconBug, } diff --git a/lib/styles/sweetalert2CustomStyles.ts b/lib/styles/sweetalert2CustomStyles.ts new file mode 100644 index 0000000..9568247 --- /dev/null +++ b/lib/styles/sweetalert2CustomStyles.ts @@ -0,0 +1,22 @@ +export const swalCustomStyles = ` + :root { + --swal-bg-color: #fff; /* Light mode background */ + --swal-text-color: #000; /* Light mode text */ + } + @media (prefers-color-scheme: dark) { + :root { + --swal-bg-color: #333; /* Dark mode background */ + --swal-text-color: #fff; /* Dark mode text */ + } + } + .swal2-popup { + background-color: var(--swal-bg-color) !important; + color: var(--swal-text-color) !important; + } + .swal2-title { + color: var(--swal-text-color) !important; + } + .swal2-content { + color: var(--swal-text-color) !important; + } +`;