学习笔记jira项目23useauth切换登录和非登录信息

import React, { useState } from "react";
import { RegisterScreen } from "unauthenticated-app/register";
import { LoginScreen } from "unauthenticated-app/login";
import { Button, Card, Divider } from "antd";
import styled from "@emotion/styled";
import logo from "assets/logo.svg";
import left from "assets/left.svg";
import right from "assets/right.svg";
import { useDocumentTitle } from "utils";
import { ErrorBox } from "components/lib";
export default function UnauthenticatedApp() {
const [isRegister, setIsRegister] = useState(false);
const [error, setError] = useState<Error | null>(null);
useDocumentTitle("请登录注册以继续");
return (
<Container>
<Header />
<Background />
<ShadowCard>
<Title>{isRegister ? "请注册" : "请登录"}</Title>
<ErrorBox error={error} />
{isRegister ? (
<RegisterScreen onError={setError} />
) : (
<LoginScreen onError={setError} />
)}
<Divider />
<Button type={"link"} onClick={() => setIsRegister(!isRegister)}>
{isRegister ? "已经有账号了?直接登录" : "没有账号?注册新账号"}
</Button>
</ShadowCard>
</Container>
);
}
export const LongButton = styled(Button)`
width: 100%;
`;
const Title = styled.h2`
margin-bottom: 2.4rem;
color: rgb(94, 108, 132);
`;
const Background = styled.div`
position: absolute;
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: left bottom, right bottom;
background-size: calc(((100vw - 40rem) / 2) - 3.2rem),
calc(((100vw - 40rem) / 2) - 3.2rem), cover;
background-image: url(${left}), url(${right});
`;
const Header = styled.header`
background: url(${logo}) no-repeat center;
padding: 5rem 0;
background-size: 8rem;
width: 100%;
`;
const ShadowCard = styled(Card)`
width: 40rem;
min-height: 56rem;
padding: 3.2rem 4rem;
border-radius: 0.3rem;
box-sizing: border-box;
box-shadow: rgba(0, 0, 0, 0.1) 0 0 10px;
text-align: center;
`;
const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
`;

posted @   前端导师歌谣  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
点击右上角即可分享
微信分享提示