Repository navigation
feat(composer)!: draw the placeholder through ::before on the editable (UI-77) #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@intentface/ui": minor | ||
| --- | ||
|
|
||
| - [Composer] [Breaking] `Composer.Textarea`'s `placeholder` no longer renders an overlay. It stamps `data-placeholder` on the editable while the editor is empty, so add the `[data-composer-editor][data-placeholder]::before` rule from the docs and set its colour. | ||
| - [Composer] [Breaking] Remove `Composer.Placeholder`. Pass a string through `Composer.Textarea`'s `placeholder`, or your own element as its `children` for rich content. | ||
| - [Composer] [Breaking] `Composer.Textarea` renders its `children` always, not only while empty. Pass a function to receive `{ disabled, filled, composing }` and hide them yourself. | ||
| - [Composer] Add `data-composing` on the `Composer.Textarea` wrapper during an IME composition. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -714,6 +714,26 @@ type ChatInputInnerProps = { | |
| status: ChatStatus; | ||
| }; | ||
|
|
||
| const ROTATING_PLACEHOLDERS = [ | ||
| "Ask me anything...", | ||
| "Recall past conversations...", | ||
| "Search the web...", | ||
| "Generate a report...", | ||
| "Explain a concept...", | ||
| "Help with a project...", | ||
| "Give a tutorial...", | ||
| "Provide a recommendation...", | ||
| "Translate text...", | ||
| "Summarize a document...", | ||
| "Write a story...", | ||
| "Create a presentation...", | ||
| ]; | ||
|
|
||
| const getInputPlaceholder = (isAskUser: boolean, hasSubmitted: boolean) => { | ||
| if (isAskUser) return "Or type your own answer..."; | ||
| return hasSubmitted ? "Ask a follow-up question..." : "Ask me anything..."; | ||
| }; | ||
|
|
||
| const ChatInputInner = memo(({ panelState, status }: ChatInputInnerProps) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partly addressed in a5c9e83. The placeholder ternary this PR added now lives in a module-level Generated by Claude Code |
||
| const { | ||
| chatId, | ||
|
|
@@ -830,6 +850,11 @@ const ChatInputInner = memo(({ panelState, status }: ChatInputInnerProps) => { | |
| const isAskUser = panelState.type === "ask-user" || demoQuestions != null; | ||
| const askUserQuestions = panelState.type === "ask-user" ? panelState.questions : null; | ||
|
|
||
| // The rotating hint is a custom overlay; while it shows, the string is only | ||
| // the accessible placeholder. | ||
| const rotatesPlaceholder = !isAskUser && !hasSubmitted && loopingPlaceholder; | ||
| const placeholder = getInputPlaceholder(isAskUser, hasSubmitted); | ||
|
|
||
| const handleSubmit = useCallback( | ||
| async (data: ComposerSubmitData) => { | ||
| if (data.kind === "answers") { | ||
|
|
@@ -986,31 +1011,8 @@ const ChatInputInner = memo(({ panelState, status }: ChatInputInnerProps) => { | |
| </Composer.ContextWindow> | ||
| <Composer.Container> | ||
| <Composer.Attachments /> | ||
| <Composer.Textarea autoFocus submitOn={submitOn}> | ||
| <Composer.Placeholder | ||
| placeholder={ | ||
| isAskUser | ||
| ? "Or type your own answer..." | ||
| : !hasSubmitted | ||
| ? loopingPlaceholder | ||
| ? [ | ||
| "Ask me anything...", | ||
| "Recall past conversations...", | ||
| "Search the web...", | ||
| "Generate a report...", | ||
| "Explain a concept...", | ||
| "Help with a project...", | ||
| "Give a tutorial...", | ||
| "Provide a recommendation...", | ||
| "Translate text...", | ||
| "Summarize a document...", | ||
| "Write a story...", | ||
| "Create a presentation...", | ||
| ] | ||
| : "Ask me anything..." | ||
| : "Ask a follow-up question..." | ||
| } | ||
| /> | ||
| <Composer.Textarea autoFocus submitOn={submitOn} placeholder={placeholder}> | ||
| {rotatesPlaceholder && <Composer.Placeholder placeholder={ROTATING_PLACEHOLDERS} />} | ||
| </Composer.Textarea> | ||
| {isAskUser ? ( | ||
| <Composer.Actions className="flex items-center justify-end gap-2"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Intentface/intentface-ui
Length of output: 6653
Correct the
Composer.Textareachildren API in COMPOSER.md.This document names
@/components/ai/composeras the import. That wrapper declareschildren?: ReactNode. It does not accept a state callback. The table row at line 94 and the example at lines 111-119 use a function child. Readers who copy the example get a type error.Document
ReactNodechildren for this wrapper. Show an element insideComposer.Placeholder. The wrapper hides its children while the editor is filled or composing, so the element needs no extra guard. If the document also covers the primitive API with the(state) => ReactNodeform, name the primitive import explicitly.Table row: children type and behavior
Example: replace the function child