add some minor ux updates (#2441)

This commit is contained in:
pablodanswer
2024-09-15 01:29:31 -07:00
committed by GitHub
parent 3c934a93cd
commit 290f4f0f8c
5 changed files with 134 additions and 94 deletions

View File

@@ -14,26 +14,6 @@ const AddPromptSchema = Yup.object().shape({
}); });
const AddPromptModal = ({ onClose, onSubmit }: AddPromptModalProps) => { const AddPromptModal = ({ onClose, onSubmit }: AddPromptModalProps) => {
const defaultPrompts = [
{
title: "Email help",
prompt: "Write a professional email addressing the following points:",
},
{
title: "Code explanation",
prompt: "Explain the following code snippet in simple terms:",
},
{
title: "Product description",
prompt: "Write a compelling product description for the following item:",
},
{
title: "Troubleshooting steps",
prompt:
"Provide step-by-step troubleshooting instructions for the following issue:",
},
];
return ( return (
<ModalWrapper onClose={onClose} modalClassName="max-w-xl"> <ModalWrapper onClose={onClose} modalClassName="max-w-xl">
<Formik <Formik
@@ -53,7 +33,7 @@ const AddPromptModal = ({ onClose, onSubmit }: AddPromptModalProps) => {
> >
{({ isSubmitting, setFieldValue }) => ( {({ isSubmitting, setFieldValue }) => (
<Form> <Form>
<h2 className="text-2xl gap-x-2 text-emphasis font-bold mb-3 flex items-center"> <h2 className="w-full text-2xl gap-x-2 text-emphasis font-bold mb-3 flex items-center">
<BookstackIcon size={20} /> <BookstackIcon size={20} />
Add prompt Add prompt
</h2> </h2>

View File

@@ -58,7 +58,7 @@
/* Very light grayish blue */ /* Very light grayish blue */
--background-strong: #eaecef; --background-strong: #eaecef;
/* Light grayish blue */ /* Light grayish blue */
--border: #e5e5e5; --border: #e5e7eb;
/* gray-200 - Light gray */ /* gray-200 - Light gray */
--border-light: #f5f5f5; --border-light: #f5f5f5;
/* gray-100 - Very light gray */ /* gray-100 - Very light gray */
@@ -129,6 +129,62 @@
/* Medium gray for dark scrollbar thumb */ /* Medium gray for dark scrollbar thumb */
--scrollbar-dark-thumb-hover: #c7cdd2; --scrollbar-dark-thumb-hover: #c7cdd2;
/* Light medium gray for dark scrollbar thumb on hover */ /* Light medium gray for dark scrollbar thumb on hover */
/* Adding missing colors from tailwind-themes/tailwind.config.js */
--tremor-brand-faint: #eff6ff;
/* blue-50 */
--tremor-brand-muted: #bfdbfe;
/* blue-200 */
--tremor-brand-subtle: #60a5fa;
/* blue-400 */
--tremor-brand-emphasis: #1d4ed8;
/* blue-700 */
--tremor-brand-inverted: #ffffff;
/* white */
--tremor-background-muted: #f9fafb;
/* gray-50 */
--tremor-background-subtle: #f3f4f6;
/* gray-100 */
--tremor-background-emphasis: #374151;
/* gray-700 */
--tremor-content-subtle: #9ca3af;
/* gray-400 */
--tremor-content-default: #4b5563;
/* gray-600 */
--tremor-content-emphasis: #374151;
/* gray-700 */
--tremor-content-strong: #111827;
/* gray-900 */
--tremor-content-inverted: #ffffff;
/* white */
--dark-tremor-brand-faint: #0b1229;
/* custom */
--dark-tremor-brand-muted: #172554;
/* blue-950 */
--dark-tremor-brand-subtle: #1e40af;
/* blue-800 */
--dark-tremor-brand-emphasis: #60a5fa;
/* blue-400 */
--dark-tremor-brand-inverted: #030712;
/* gray-950 */
--dark-tremor-background-muted: #131a2b;
/* custom */
--dark-tremor-background-subtle: #1f2937;
/* gray-800 */
--dark-tremor-background-default: #111827;
/* gray-900 */
--dark-tremor-background-emphasis: #d1d5db;
/* gray-300 */
--dark-tremor-content-subtle: #6b7280;
/* gray-500 */
--dark-tremor-content-default: #d1d5db;
/* gray-300 */
--dark-tremor-content-emphasis: #f3f4f6;
/* gray-100 */
--dark-tremor-content-strong: #f9fafb;
/* gray-50 */
--dark-tremor-content-inverted: #000000;
/* black */
} }
} }

View File

@@ -1,7 +1,7 @@
"use client"; "use client";
import { Divider } from "@tremor/react"; import { Divider } from "@tremor/react";
import { FiX } from "react-icons/fi"; import { FiX } from "react-icons/fi";
import { IconProps } from "./icons/icons"; import { IconProps, XIcon } from "./icons/icons";
import { useRef } from "react"; import { useRef } from "react";
import { isEventWithinRef } from "@/lib/contains"; import { isEventWithinRef } from "@/lib/contains";
@@ -18,7 +18,6 @@ interface ModalProps {
} }
export function Modal({ export function Modal({
icon,
children, children,
title, title,
onOutsideClick, onOutsideClick,
@@ -27,6 +26,7 @@ export function Modal({
titleSize, titleSize,
hideDividerForTitle, hideDividerForTitle,
noPadding, noPadding,
icon,
}: ModalProps) { }: ModalProps) {
const modalRef = useRef<HTMLDivElement>(null); const modalRef = useRef<HTMLDivElement>(null);
@@ -40,46 +40,50 @@ export function Modal({
onOutsideClick(); onOutsideClick();
} }
}; };
return ( return (
<div> <div
onMouseDown={handleMouseDown}
className={`fixed inset-0 bg-black bg-opacity-25 backdrop-blur-sm
flex items-center justify-center z-50 transition-opacity duration-300 ease-in-out`}
>
<div <div
className={` ref={modalRef}
fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm onClick={(e) => {
flex items-center justify-center z-50 if (onOutsideClick) {
`} e.stopPropagation();
onMouseDown={handleMouseDown} }
}}
className={`bg-background text-emphasis rounded shadow-2xl
transform transition-all duration-300 ease-in-out
${width ?? "w-11/12 max-w-5xl"}
${noPadding ? "" : "p-10"}
${className || ""}`}
> >
<div {onOutsideClick && (
ref={modalRef} <div className="absolute top-2 right-2">
className={` <button
bg-background rounded shadow-lg onClick={onOutsideClick}
relative ${width ?? "w-1/2"} text-sm className="cursor-pointer text-text-500 hover:text-text-700 transition-colors duration-200 p-2"
${noPadding ? "" : "p-8"} aria-label="Close modal"
${className} >
`} <XIcon className="w-5 h-5" />
onClick={(event) => event.stopPropagation()} </button>
> </div>
)}
<div className="flex w-full flex-col justify-stretch">
{title && ( {title && (
<> <>
<div className="flex mb-4"> <div className="flex mb-4">
<h2 <h2
className={ className={`my-auto flex content-start gap-x-4 font-bold ${
"my-auto flex content-start gap-x-4 font-bold " + titleSize || "text-2xl"
(titleSize || "text-2xl") }`}
}
> >
{title} {title}
{icon && icon({ size: 30 })} {icon && icon({ size: 30 })}
</h2> </h2>
{onOutsideClick && (
<div
onClick={onOutsideClick}
className="my-auto ml-auto p-2 hover:bg-hover rounded cursor-pointer"
>
<FiX size={20} />
</div>
)}
</div> </div>
{!hideDividerForTitle && <Divider />} {!hideDividerForTitle && <Divider />}
</> </>

View File

@@ -26,15 +26,12 @@ export const ModalWrapper = ({
onClose(); onClose();
} }
}; };
return ( return (
<div <div
onMouseDown={handleMouseDown} onMouseDown={handleMouseDown}
className={ className={`fixed inset-0 bg-black bg-opacity-25 backdrop-blur-sm
"fixed inset-0 bg-black bg-opacity-30 backdrop-blur-sm " + flex items-center justify-center z-50 transition-opacity duration-300 ease-in-out
"flex items-center justify-center z-50 " + ${bgClassName || ""}`}
(bgClassName || "")
}
> >
<div <div
ref={modalRef} ref={modalRef}
@@ -43,20 +40,23 @@ export const ModalWrapper = ({
e.stopPropagation(); e.stopPropagation();
} }
}} }}
className={ className={`bg-background text-emphasis p-10 rounded shadow-2xl
"bg-background text-emphasis p-8 rounded shadow-xl w-3/4 max-w-3xl shadow " + w-11/12 max-w-3xl transform transition-all duration-300 ease-in-out
(modalClassName || "") relative ${modalClassName || ""}`}
}
> >
{onClose && ( {onClose && (
<div className="w-full cursor-pointer flex justify-end"> <div className="absolute top-2 right-2">
<button onClick={onClose}> <button
<XIcon /> onClick={onClose}
className="cursor-pointer text-text-500 hover:text-text-700 transition-colors duration-200 p-2"
aria-label="Close modal"
>
<XIcon className="w-5 h-5" />
</button> </button>
</div> </div>
)} )}
{children} <div className="flex w-full flex-col justify-stretch">{children}</div>
</div> </div>
</div> </div>
); );

View File

@@ -173,18 +173,18 @@ module.exports = {
// light mode // light mode
tremor: { tremor: {
brand: { brand: {
faint: "#eff6ff", // blue-50 faint: "var(--tremor-brand-faint)",
muted: "#bfdbfe", // blue-200 muted: "var(--tremor-brand-muted)",
subtle: "#60a5fa", // blue-400 subtle: "var(--tremor-brand-subtle)",
DEFAULT: "#3b82f6", // blue-500 DEFAULT: "#3b82f6", // blue-500
emphasis: "#1d4ed8", // blue-700 emphasis: "var(--tremor-brand-emphasis)",
inverted: "#ffffff", // white inverted: "var(--tremor-brand-inverted)",
}, },
background: { background: {
muted: "#f9fafb", // gray-50 muted: "var(--tremor-background-muted)",
subtle: "#f3f4f6", // gray-100 subtle: "var(--tremor-background-subtle)",
DEFAULT: "#ffffff", // white DEFAULT: "#ffffff", // white
emphasis: "#374151", // gray-700 emphasis: "var(--tremor-background-emphasis)",
}, },
border: { border: {
DEFAULT: "#e5e7eb", // gray-200 DEFAULT: "#e5e7eb", // gray-200
@@ -193,28 +193,28 @@ module.exports = {
DEFAULT: "#e5e7eb", // gray-200 DEFAULT: "#e5e7eb", // gray-200
}, },
content: { content: {
subtle: "#9ca3af", // gray-400 subtle: "var(--tremor-content-subtle)",
DEFAULT: "#4b5563", // gray-600 DEFAULT: "var(--tremor-content-default)",
emphasis: "#374151", // gray-700 emphasis: "var(--tremor-content-emphasis)",
strong: "#111827", // gray-900 strong: "var(--tremor-content-strong)",
inverted: "#ffffff", // white inverted: "var(--tremor-content-inverted)",
}, },
}, },
// dark mode // dark mode
"dark-tremor": { "dark-tremor": {
brand: { brand: {
faint: "#0B1229", // custom faint: "var(--dark-tremor-brand-faint)",
muted: "#172554", // blue-950 muted: "var(--dark-tremor-brand-muted)",
subtle: "#1e40af", // blue-800 subtle: "var(--dark-tremor-brand-subtle)",
DEFAULT: "#3b82f6", // blue-500 DEFAULT: "#3b82f6", // blue-500
emphasis: "#60a5fa", // blue-400 emphasis: "var(--dark-tremor-brand-emphasis)",
inverted: "#030712", // gray-950 inverted: "var(--dark-tremor-brand-inverted)",
}, },
background: { background: {
muted: "#131A2B", // custom muted: "var(--dark-tremor-background-muted)",
subtle: "#1f2937", // gray-800 subtle: "var(--dark-tremor-background-subtle)",
DEFAULT: "#111827", // gray-900 DEFAULT: "var(--dark-tremor-background-default)",
emphasis: "#d1d5db", // gray-300 emphasis: "var(--dark-tremor-background-emphasis)",
}, },
border: { border: {
DEFAULT: "#1f2937", // gray-800 DEFAULT: "#1f2937", // gray-800
@@ -223,11 +223,11 @@ module.exports = {
DEFAULT: "#1f2937", // gray-800 DEFAULT: "#1f2937", // gray-800
}, },
content: { content: {
subtle: "#6b7280", // gray-500 subtle: "var(--dark-tremor-content-subtle)",
DEFAULT: "#d1d5db", // gray-300 DEFAULT: "var(--dark-tremor-content-default)",
emphasis: "#f3f4f6", // gray-100 emphasis: "var(--dark-tremor-content-emphasis)",
strong: "#f9fafb", // gray-50 strong: "var(--dark-tremor-content-strong)",
inverted: "#000000", // black inverted: "var(--dark-tremor-content-inverted)",
}, },
}, },
}, },