mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
- Replace .eslintrc.json with eslint.config.mjs - Simplify configuration using @antfu/eslint-config - Add necessary ESLint plugin dependencies - Disable overly strict style rules - Set package.json type to module for ESM support - Fix ESLint disable comment format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
705 B
TypeScript
27 lines
705 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
interface Params {
|
|
ref: React.RefObject<HTMLDivElement>
|
|
hasFooter?: boolean
|
|
}
|
|
|
|
const useToggleExpend = ({ ref, hasFooter = true }: Params) => {
|
|
const [isExpand, setIsExpand] = useState(false)
|
|
const [wrapHeight, setWrapHeight] = useState(ref.current?.clientHeight)
|
|
const editorExpandHeight = isExpand ? wrapHeight! - (hasFooter ? 56 : 29) : 0
|
|
useEffect(() => {
|
|
setWrapHeight(ref.current?.clientHeight)
|
|
}, [isExpand])
|
|
|
|
const wrapClassName = isExpand && 'absolute z-10 left-4 right-6 top-[52px] bottom-0 pb-4 bg-white'
|
|
|
|
return {
|
|
wrapClassName,
|
|
editorExpandHeight,
|
|
isExpand,
|
|
setIsExpand,
|
|
}
|
|
}
|
|
|
|
export default useToggleExpend
|