Skip to content

Commit 616684d

Browse files
committed
Rotate placeholder to highlight functionality
1 parent d6bf84d commit 616684d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

web/src/components/common/MentionTextarea.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface MentionTextareaProps extends Omit<TextareaProps, 'onChange'> {
1717
}
1818

1919
export const MentionTextarea = forwardRef<HTMLDivElement, MentionTextareaProps>(
20-
({ mentionItems, value, onChange, onKeyDown, placeholder = 'Ask Anything!', ...props }, ref) => {
20+
({ mentionItems, value, onChange, onKeyDown, placeholder, ...props }, ref) => {
2121
const editableRef = useRef<HTMLDivElement>(null)
2222
const [showDropdown, setShowDropdown] = useState(false)
2323
const [filteredItems, setFilteredItems] = useState<MentionItem[]>([])
@@ -27,6 +27,20 @@ export const MentionTextarea = forwardRef<HTMLDivElement, MentionTextareaProps>(
2727
const [mentionStart, setMentionStart] = useState(-1)
2828
const typingTimerRef = useRef<NodeJS.Timeout>()
2929

30+
// Rotating placeholder
31+
const [placeholderIndex, setPlaceholderIndex] = useState(0)
32+
const placeholders = ['Ask Anything!', 'Tip: Use @ to mention tables and models']
33+
34+
useEffect(() => {
35+
const interval = setInterval(() => {
36+
setPlaceholderIndex(prev => (prev + 1) % placeholders.length)
37+
}, 10000)
38+
39+
return () => clearInterval(interval)
40+
}, [])
41+
42+
const currentPlaceholder = placeholder || placeholders[placeholderIndex]
43+
3044
// Forward ref to the contenteditable div
3145
useImperativeHandle(ref, () => editableRef.current!, [])
3246

@@ -306,7 +320,7 @@ export const MentionTextarea = forwardRef<HTMLDivElement, MentionTextareaProps>(
306320
textAlign="left"
307321
_empty={{
308322
_before: {
309-
content: `"${placeholder}"`,
323+
content: `"${currentPlaceholder}"`,
310324
color: 'gray.400',
311325
pointerEvents: 'none'
312326
}

0 commit comments

Comments
 (0)