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;

相关推荐

  1. react一个组件

    2024-04-28 20:38:05       10 阅读
  2. 【WPF】一个并显示一个列表

    2024-04-28 20:38:05       42 阅读
  3. 【前端】组件

    2024-04-28 20:38:05       33 阅读
  4. vue 消息

    2024-04-28 20:38:05       8 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-28 20:38:05       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-28 20:38:05       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-28 20:38:05       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-28 20:38:05       18 阅读

热门阅读

  1. redis 键常用命令

    2024-04-28 20:38:05       11 阅读
  2. AI作画算法原理详解

    2024-04-28 20:38:05       10 阅读
  3. [GN] 车300笔试记

    2024-04-28 20:38:05       10 阅读
  4. Linux制作docker镜像

    2024-04-28 20:38:05       12 阅读
  5. 前端初学者必读的 Web Workers指南

    2024-04-28 20:38:05       11 阅读
  6. AI生成音乐

    2024-04-28 20:38:05       12 阅读
  7. 2024年通信安全员题库及答案

    2024-04-28 20:38:05       11 阅读