center UI

This commit is contained in:
2023-02-16 23:55:05 +08:00
parent 3b01c2ec76
commit 7738e061fc
2 changed files with 66 additions and 43 deletions

View File

@@ -229,10 +229,7 @@ const Timetable = ({
main(); main();
}, []); }, []);
return ( const DownloadMarks = async () => {
<>
<button
onClick={async () => {
console.log("download marks", marks); console.log("download marks", marks);
const data = { const data = {
user, user,
@@ -250,19 +247,24 @@ const Timetable = ({
} }
console.log(data); console.log(data);
downloadObjectAsJson(data, user); downloadObjectAsJson(data, user);
}} };
>
DownloadSelection return (
</button> <>
<span>Login as {user}</span> <h2 style={{textAlign: 'center'}}>Login as {user}</h2>
<div <div
ref={ref} ref={ref}
contentEditable={editable} contentEditable={editable}
style={{ style={{
overflow: "scroll", overflow: "scroll",
display: 'flex',
justifyContent: 'center',
}} }}
onInput={handleInput} onInput={handleInput}
></div>{" "} ></div>{" "}
<p style={{ display: "flex", justifyContent: "center" }}>
<button onClick={DownloadMarks}>Download Selection</button>
</p>
<div style={{ display: "none" }} id="download-dom"></div> <div style={{ display: "none" }} id="download-dom"></div>
</> </>
); );

View File

@@ -1,3 +1,4 @@
import { NodeNextRequest } from "next/dist/server/base-http/node";
import React from "react"; import React from "react";
const UserInputWrap = ({ children, setUser }) => { const UserInputWrap = ({ children, setUser }) => {
@@ -11,13 +12,32 @@ const UserInputWrap = ({ children, setUser }) => {
return ( return (
<> <>
{!begin && ( {!begin && (
<div
style={{
display: "grid",
placeItems: "center",
alignItems: "center",
minHeight: "100vh",
}}
>
<div> <div>
<input <input
placeholder="在这输你的名字" style={{
margin: "0.5em",
padding: "0.5em",
borderRadius: "0.39em",
}}
placeholder="你的名字..."
value={inputUser} value={inputUser}
onChange={(event) => setInputUser(event.target.value)} onChange={(event) => setInputUser(event.target.value)}
size={10}
/> />
<button <button
style={{
margin: "0.5em",
padding: "0.5em",
backgroundColor: "#39ceff",
}}
onClick={() => { onClick={() => {
if (inputUser.trim() === "") { if (inputUser.trim() === "") {
alert("姓名不能为空"); alert("姓名不能为空");
@@ -31,6 +51,7 @@ const UserInputWrap = ({ children, setUser }) => {
Login Login
</button> </button>
</div> </div>
</div>
)} )}
{begin && children} {begin && children}
</> </>