From f056920bfbe1909a27767d17a9fb93375a902694 Mon Sep 17 00:00:00 2001 From: Andreas Opferkuch Date: Mon, 18 Nov 2024 19:51:18 +0100 Subject: [PATCH] Replace text buttons with icon buttons --- src/app/components/Actions.tsx | 26 ++++++++++++------- src/app/components/Message/CopyButton.tsx | 15 ++++------- src/app/components/Message/index.tsx | 10 +++++-- .../AuthButton/AuthButtonClient.tsx | 14 +++++----- src/components/Button.tsx | 2 +- src/components/IconButton.tsx | 23 ++++++++++++++-- 6 files changed, 58 insertions(+), 32 deletions(-) diff --git a/src/app/components/Actions.tsx b/src/app/components/Actions.tsx index 17dc6b0..e8fb4f6 100644 --- a/src/app/components/Actions.tsx +++ b/src/app/components/Actions.tsx @@ -1,9 +1,9 @@ import { isDev } from "@/utils/consts"; import { css } from "../../../styled-system/css"; import { styled } from "../../../styled-system/jsx"; -import { Button } from "../../components/Button"; import HmrTimestamp from "./HmrTimestamp"; import { AuthButtonClient } from "../login/components/AuthButton/AuthButtonClient"; +import { IconButton } from "@/components/IconButton"; type Props = { disabledHistoryActions: boolean; @@ -46,15 +46,21 @@ export function Actions({ Last update: )} - - - - - + + + + + ); diff --git a/src/app/components/Message/CopyButton.tsx b/src/app/components/Message/CopyButton.tsx index 20d118c..d994442 100644 --- a/src/app/components/Message/CopyButton.tsx +++ b/src/app/components/Message/CopyButton.tsx @@ -1,4 +1,4 @@ -import { Button } from "@/components/Button"; +import { IconButton } from "@/components/IconButton"; import { useState } from "react"; type Props = { @@ -18,7 +18,9 @@ export function CopyButton({ className, content }: Props) { ]; return !clipboardItem ? null : ( - + /> ); } diff --git a/src/app/components/Message/index.tsx b/src/app/components/Message/index.tsx index 0dcfd33..1ab6c27 100644 --- a/src/app/components/Message/index.tsx +++ b/src/app/components/Message/index.tsx @@ -2,10 +2,10 @@ import { type Message as MessageType } from "ai/react"; import { memo } from "react"; import ReactMarkdown from "react-markdown"; import { styled } from "../../../../styled-system/jsx"; -import { Button } from "../../../components/Button"; import { Code } from "./Code"; import { CopyButton } from "./CopyButton"; import { padNewlines } from "./padNewlines"; +import { IconButton } from "@/components/IconButton"; type Props = MessageType & { className?: string; @@ -103,7 +103,13 @@ export function Message({ gap: "12rem", }} > - {onDelete && } + {onDelete && ( + onDelete(id)} + /> + )} {showCopyAll && } diff --git a/src/app/login/components/AuthButton/AuthButtonClient.tsx b/src/app/login/components/AuthButton/AuthButtonClient.tsx index 12849db..774314c 100644 --- a/src/app/login/components/AuthButton/AuthButtonClient.tsx +++ b/src/app/login/components/AuthButton/AuthButtonClient.tsx @@ -7,7 +7,7 @@ import Spinner from "../../../../components/Spinner"; import { ReactNode } from "react"; import { signIn, signOut } from "./authActions"; import { FaGithub } from "react-icons/fa6"; -import { IoLogOut } from "react-icons/io5"; +import { IconButton } from "@/components/IconButton"; function PendingServerAction({ children }: { children: ReactNode }) { const { pending } = useFormStatus(); @@ -39,13 +39,13 @@ export function AuthButtonClient({ return (
- + + )}
); diff --git a/src/components/Button.tsx b/src/components/Button.tsx index a79ee8e..7486c97 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -50,7 +50,7 @@ export const Button = styled("button", { md: { width: "md", height: "md", - padding: "4rem", + padding: "6rem", }, xl: { width: "xl", diff --git a/src/components/IconButton.tsx b/src/components/IconButton.tsx index 3df23c6..f48649a 100644 --- a/src/components/IconButton.tsx +++ b/src/components/IconButton.tsx @@ -1,4 +1,16 @@ -import { MdArrowUpward, MdDelete, MdReplay, MdStop } from "react-icons/md"; +import { + MdCheck, + MdContentCopy, + MdArrowUpward, + MdOutlineDelete, + MdReplay, + MdStop, + MdFileDownload, + MdFileUpload, + MdLogout, + MdHistory, + MdCached, +} from "react-icons/md"; import { Button } from "./Button"; import { css } from "../../styled-system/css"; import { ComponentProps } from "../../styled-system/types"; @@ -8,8 +20,15 @@ type Props = ComponentProps & { }; const iconMap = { - delete: MdDelete, + check: MdCheck, + copy: MdContentCopy, + delete: MdOutlineDelete, + history: MdHistory, + load: MdFileUpload, + logout: MdLogout, replay: MdReplay, + reset: MdCached, + save: MdFileDownload, stop: MdStop, up: MdArrowUpward, } as const;