react写一个从下往上划出的弹框弹窗组件

arco的弹窗还是不够丰富啊 , 还是自己造吧 。 看着垃圾 , 但可塑性强呀 ,拿去改改就能用 , 乱七八糟的ui组件库太多 ,轮子还是慢慢造吧

组件的样式使用的是tailwindcss ,有需要自查吧 ,但大概也是能够看出 ,什么css属性 , ,,写

复制代码
import { useState, useEffect} from "react"

const SlideUpWindow = ({ children, isOpen, onClose }) => {
    const [isVisible, setIsVisible] = useState(false);

    useEffect(() => {
        setIsVisible(isOpen);
    }, [isOpen]);

    const handleClose = () => {
        setIsVisible(false);
        if (onClose) {
            onClose();
        }
    };

    return (
        <div
            style={{border:'1px solid red'}}
            className={`fixed bottom-0 right-0 w-[37%] transition-transform duration-300 h-[580px] ${isVisible ? 'translate-y-0  right-[3%] bottom-[4%]' : 'translate-y-full'
                }`}
        >
            <div className="flex justify-end">
                <button
                    onClick={handleClose}
                    className="p-2 text-white bg-gray-700 rounded-full focus:outline-none focus:bg-gray-800"
                >
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        className="w-6 h-6"
                        fill="none"
                        viewBox="0 0 24 24"
                        stroke="currentColor"
                    >
                        <path
                            strokeLinecap="round"
                            strokeLinejoin="round"
                            strokeWidth={2}
                            d="M6 18L18 6M6 6l12 12"
                        />
                    </svg>
                </button>
            </div>
            <div className="bg-white rounded-t-lg shadow-lg">{children}</div>
        </div>
    );
};
export default SlideUpWindow;
相关推荐
xnkyn1 分钟前
frp内网穿透https访问本地服务,frpee客户端https教程
前端·后端·网络协议·http·https
布局呆星1 小时前
Vue3 计算属性|从基础缓存到可读写
前端·javascript·vue.js
ZPC82108 小时前
如何创建一个单例类 (Singleton)
开发语言·前端·人工智能
紫_龙9 小时前
最新版vue3+TypeScript开发入门到实战教程之重要详解readonly/shallowReadOnly
前端·javascript·typescript
roamingcode10 小时前
前端 AI Agent 多智能体协作架构:从对抗式排查到工作流解耦
前端·人工智能·架构·agent·team
蓝莓味的口香糖11 小时前
【vue】初始化 Vue 项目
前端·javascript·vue.js
aikongmeng11 小时前
【Ai】Claude Code 初始化引导
javascript
光影少年12 小时前
数组去重方法
开发语言·前端·javascript
我命由我1234512 小时前
浏览器的 JS 模块化支持观察记录
开发语言·前端·javascript·css·html·ecmascript·html5
weixin_4434785112 小时前
Flutter第三方常用组件包之路由管理
前端·javascript·flutter