diff --git a/.changes/fix-prompt.md b/.changes/fix-prompt.md new file mode 100644 index 0000000..1a09dae --- /dev/null +++ b/.changes/fix-prompt.md @@ -0,0 +1,5 @@ +--- +"@matechat/react": patch:fix +--- + +adjust title/description font-size to match the prompt component diff --git a/.changes/pre.json b/.changes/pre.json index d1275a8..30583f9 100644 --- a/.changes/pre.json +++ b/.changes/pre.json @@ -6,6 +6,7 @@ ".changes/bubble-patch.md", ".changes/chore-deps.md", ".changes/file-upload.md", + ".changes/fix-prompt.md", ".changes/fix-sender-lint.md", ".changes/fix-utils-build.md", ".changes/optimize-callback.md", diff --git a/CHANGELOG.md b/CHANGELOG.md index 5726830..380dca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[0.1.0-alpha.6] + +### Bug Fixes + +- [`6358f1b`](https://github.com/DevCloudFE/matechat-react/commit/6358f1b2f285dba029d3be700401809c7d09a06c) adjust title/description font-size to match the prompt component + ## \[0.1.0-alpha.5] ### New Features diff --git a/package.json b/package.json index 9c3a50d..0bc42fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matechat/react", - "version": "0.1.0-alpha.5", + "version": "0.1.0-alpha.6", "packageManager": "pnpm@10.11.0", "description": "Front-end AI scenario solution UI library based on Huawei DevUI Design.", "type": "module", diff --git a/playground/src/Chat.tsx b/playground/src/Chat.tsx index 85d0ab1..67fa6c9 100644 --- a/playground/src/Chat.tsx +++ b/playground/src/Chat.tsx @@ -1,4 +1,4 @@ -import { MessageSquarePlus, MessageSquareWarning } from "lucide-react"; +import { MessageSquarePlus } from "lucide-react"; import { useState } from "react"; import { BubbleList } from "../../dist/bubble"; import { Button } from "../../dist/button"; @@ -73,21 +73,15 @@ export function Chat() { } /> {messages.length === 0 && ( - - - - - Understanding the Transformer Model - + + + Understanding the Transformer Model Give a detailed analysis of the Transformer model. - - - - Understanding the Attention Mechanism - + + Understanding the Attention Mechanism Explain the attention mechanism in neural networks. diff --git a/src/prompt.tsx b/src/prompt.tsx index 6176b34..a24b53f 100644 --- a/src/prompt.tsx +++ b/src/prompt.tsx @@ -5,16 +5,31 @@ import clsx from "clsx"; import type * as React from "react"; import { twMerge } from "tailwind-merge"; +const promptsVariants = cva("flex", { + variants: { + size: { + xs: "gap-2", + sm: "gap-3", + default: "gap-4", + md: "gap-4", + lg: "gap-5", + }, + }, + defaultVariants: { + size: "default", + }, +}); + const promptVariants = cva( - "flex flex-col gap-1 justify-center rounded-md border border-gray-300 shadow-sm", + "flex flex-col justify-center bg-white border border-gray-200 rounded-lg hover:border-gray-300 hover:shadow-sm transition-all duration-150 cursor-pointer", { variants: { size: { - default: "px-4 py-2", - lg: "px-6 py-4 text-lg", - md: "px-4 py-2 text-base", - sm: "px-2 py-1 text-sm", - xs: "px-1 py-0.5 text-xs", + xs: "px-3 py-2 gap-1", + sm: "px-4 py-2.5 gap-1.5", + default: "px-4 py-3 gap-2", + md: "px-5 py-3.5 gap-2", + lg: "px-6 py-4 gap-2.5", }, }, defaultVariants: { @@ -23,11 +38,45 @@ const promptVariants = cva( }, ); -export function Prompts({ className, ...props }: React.ComponentProps<"div">) { +const promptTitleVariants = cva("font-medium text-gray-900", { + variants: { + size: { + xs: "text-sm", + sm: "text-base", + default: "text-base", + md: "text-lg", + lg: "text-xl", + }, + }, + defaultVariants: { + size: "default", + }, +}); + +const promptDescriptionVariants = cva("text-gray-600", { + variants: { + size: { + xs: "text-xs", + sm: "text-sm", + default: "text-sm", + md: "text-base", + lg: "text-base", + }, + }, + defaultVariants: { + size: "default", + }, +}); + +export function Prompts({ + className, + size, + ...props +}: React.ComponentProps<"div"> & VariantProps) { return (
); @@ -35,12 +84,13 @@ export function Prompts({ className, ...props }: React.ComponentProps<"div">) { export function Prompt({ className, - size, + size = "default", ...props }: React.ComponentProps<"div"> & VariantProps) { return (
@@ -49,27 +99,51 @@ export function Prompt({ export function PromptTitle({ className, + size, ...props -}: React.ComponentProps<"h3">) { +}: React.ComponentProps<"h3"> & VariantProps) { + const computedClassName = size + ? twMerge(clsx(promptTitleVariants({ size, className }))) + : twMerge( + clsx( + "font-medium text-gray-900", + "[div[data-size='xs']_&]:text-sm", + "[div[data-size='sm']_&]:text-base", + "[div[data-size='default']_&]:text-base", + "[div[data-size='md']_&]:text-lg", + "[div[data-size='lg']_&]:text-xl", + className, + ), + ); + return ( -

+

); } export function PromptDescription({ className, + size, ...props -}: React.ComponentProps<"p">) { +}: React.ComponentProps<"p"> & VariantProps) { + const computedClassName = size + ? twMerge(clsx(promptDescriptionVariants({ size, className }))) + : twMerge( + clsx( + "text-gray-600", + "[div[data-size='xs']_&]:text-xs", + "[div[data-size='sm']_&]:text-sm", + "[div[data-size='default']_&]:text-sm", + "[div[data-size='md']_&]:text-base", + "[div[data-size='lg']_&]:text-base", + className, + ), + ); + return (

); diff --git a/tests/index.test.tsx b/tests/index.test.tsx index d902d96..d8cf7a8 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -30,6 +30,7 @@ test("single prompt", () => { ); expect(titleElement).toBeInTheDocument(); expect(descriptionElement).toBeInTheDocument(); - expect(titleElement).toHaveClass("inline-flex font-semibold"); + expect(titleElement).toHaveClass("font-medium", "text-gray-900"); expect(titleElement.tagName).toBe("H3"); + expect(descriptionElement).toHaveClass("text-gray-600"); });