modal-dialog - React:styled-components 模态警报成功图标
问题描述
我在我的应用程序中使用 react-typescript。对于样式,我使用style-components。我正在创建一个模态警报组件。我的模态警报已准备就绪,看起来像这样,Image。我正在检查这个甜蜜的警报网站。在那里他们有成功的图标。我想在我的模态警报组件中使用它。但我不知道在哪里可以找到这个图标以及如何在我的模态警报组件中使用它。
这是我的模态警报组件
import React from 'react';
import iconX from './close.svg';
import styled from 'styled-components';
export const Modals = styled.div`
position: fixed;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
`
const ModalOverlay = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .8);
cursor: pointer;
`
const ModalBox = styled.div`
position: relative;
width: 80%;
margin: 0 10%;
padding: 50px;
box-sizing: border-box;
border-radius: 10px;
background-color: white;
cursor: auto;`
const ModalTitle = styled.div`
color: #9E25FC;
font-size: 30px;
text-align: center;
`
const ModalContent = styled.div`
margin-top: 30px;
color: #6B6B6B;
font-size: 16px;`
const ModalClose = styled.button`
position: absolute;
top: 20px;
right: 20px;
transition: transform 250ms ease-in-out;
transform-origin: 50% 50%;
&:hover {
transform: rotate(180deg);
}
`
interface IModalProps {
title: string;
isOpen: boolean;
onClose: () => void;
children?: JSX.Element | string[] | string;
icon?: JSX.Element; //This is icon i am declaring. I am not sure is it JSX.Element.
}
export default ({ title, isOpen, onClose, children }: IModalProps) => {
const outsideRef = React.useRef(null);
const handleCloseOnOverlay = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
if (e.target === outsideRef.current) {
onClose();
}
}
return isOpen ? (
<Modals>
<ModalOverlay
ref={outsideRef}
onClick={handleCloseOnOverlay}
/>
<ModalBox>
<ModalClose
onClick={onClose}
>
<img src={iconX} alt={'close'} />
</ModalClose >
<ModalTitle>
// I want to use it in here the success icon.
{title}
</ModalTitle>
<ModalContent>
{children}
</ModalContent>
</ModalBox>
</Modals>
) : null;
};
解决方案
推荐阅读
- javascript - 延迟加载vue时向用户显示加载屏幕
- python - 最受欢迎的嵌套类别
- linux - 如何为我的 AMD Linux 系统构建 Tensorflow?
- azure-devops - 阻止 azure 管道运行我的模板文件
- c# - 是否可以在不启用子属性隐式验证的情况下使用 FluentValidation 验证可枚举模型?
- java - Java IO 控制台
- angular - 为什么角度在spring boot api中的日期变量中发送空值
- css-grid - 交互式复制中的 CSS Grid 意外分布
- swift - 在 SwiftUI 中呈现没有动画的弹出框
- reactjs - 如何在 React 中访问嵌套数组对象