Implement settings
This commit is contained in:
parent
b7618c4192
commit
2af602dad4
|
|
@ -62,16 +62,16 @@ export default function App() {
|
||||||
<NavbarButton>About</NavbarButton>
|
<NavbarButton>About</NavbarButton>
|
||||||
{userIDStorageHandler.userIDValue ? (
|
{userIDStorageHandler.userIDValue ? (
|
||||||
<>
|
<>
|
||||||
|
<NavbarButton>BlogEditor</NavbarButton>
|
||||||
|
<NavbarButton>Settings</NavbarButton>
|
||||||
|
<NavbarButton>Logout</NavbarButton>
|
||||||
<NavbarUserInfo
|
<NavbarUserInfo
|
||||||
userID={userIDStorageHandler.userIDValue}
|
userID={userIDStorageHandler.userIDValue}
|
||||||
></NavbarUserInfo>
|
></NavbarUserInfo>
|
||||||
<NavbarButton>Logout</NavbarButton>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<NavbarButton>Login</NavbarButton>
|
<NavbarButton>Login</NavbarButton>
|
||||||
)}
|
)}
|
||||||
<NavbarButton>Settings</NavbarButton>
|
|
||||||
<NavbarButton>BlogEditor</NavbarButton>
|
|
||||||
</Navbar>
|
</Navbar>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<Routes>
|
<Routes>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
settingName: string;
|
||||||
|
currentSettingHook: object;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SettingButton({
|
||||||
|
settingName,
|
||||||
|
currentSettingHook,
|
||||||
|
}: Props) {
|
||||||
|
function onSettingButtonClicked() {
|
||||||
|
currentSettingHook.setCurrentSetting(settingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button onClick={onSettingButtonClicked}>{settingName}</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -10,11 +10,11 @@ export default function Navbar({ children, titlebarName }: Props) {
|
||||||
<>
|
<>
|
||||||
<div className="standardTilingBox">
|
<div className="standardTilingBox">
|
||||||
{titlebarName ? (
|
{titlebarName ? (
|
||||||
<div className="standardTilingTitlebar">
|
<div className="standardTilingBoxTitlebar">
|
||||||
<p>{titlebarName}</p>
|
<p>{titlebarName}</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{children}
|
<div className="standardTilingBoxContents">{children}</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ body,
|
||||||
--blog-card-height: 20rem;
|
--blog-card-height: 20rem;
|
||||||
--border-radii: 5px;
|
--border-radii: 5px;
|
||||||
--blog-card-image-radius: 1px;
|
--blog-card-image-radius: 1px;
|
||||||
|
--tiling-box-titlebar-height: 20px;
|
||||||
--tiling-gap: 10px;
|
--tiling-gap: 10px;
|
||||||
|
--tiling-box-padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
|
@ -59,8 +61,8 @@ a {
|
||||||
|
|
||||||
.standardHorizontalTilingGrid {
|
.standardHorizontalTilingGrid {
|
||||||
display: grid;
|
display: grid;
|
||||||
width: 100%;
|
width: calc(100% - var(--tiling-gap) * 2);
|
||||||
height: 100%;
|
height: calc(100% - var(--tiling-gap) * 2);
|
||||||
max-width: calc(100% - var(--tiling-gap) * 2);
|
max-width: calc(100% - var(--tiling-gap) * 2);
|
||||||
max-height: calc(100% - var(--tiling-gap) * 2);
|
max-height: calc(100% - var(--tiling-gap) * 2);
|
||||||
gap: var(--tiling-gap);
|
gap: var(--tiling-gap);
|
||||||
|
|
@ -70,8 +72,8 @@ a {
|
||||||
|
|
||||||
.standardVerticalTilingGrid {
|
.standardVerticalTilingGrid {
|
||||||
display: grid;
|
display: grid;
|
||||||
width: 100%;
|
width: calc(100% - var(--tiling-gap) * 2);
|
||||||
height: 100%;
|
height: calc(100% - var(--tiling-gap) * 2);
|
||||||
max-width: calc(100% - var(--tiling-gap) * 2);
|
max-width: calc(100% - var(--tiling-gap) * 2);
|
||||||
max-height: calc(100% - var(--tiling-gap) * 2);
|
max-height: calc(100% - var(--tiling-gap) * 2);
|
||||||
gap: var(--tiling-gap);
|
gap: var(--tiling-gap);
|
||||||
|
|
@ -85,12 +87,33 @@ a {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: scroll;
|
/* overflow-y: scroll; */
|
||||||
border-radius: var(--border-radii);
|
border-radius: var(--border-radii);
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standardTilingTitlebar {
|
.standardTilingBoxContents {
|
||||||
|
width: calc(100% - var(--tiling-box-padding) * 2);
|
||||||
|
height: calc(100% - var(--tiling-box-padding) * 2);
|
||||||
|
max-width: calc(100% - var(--tiling-box-padding) * 2);
|
||||||
|
max-height: calc(100% - var(--tiling-box-padding) * 2);
|
||||||
|
padding: var(--tiling-box-padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
.standardTilingBoxContents p {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.standardTilingBoxContents hr {
|
||||||
|
margin-left: 0px;
|
||||||
|
margin-right: 0px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.standardTilingBoxTitlebar {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 20px;
|
max-height: 20px;
|
||||||
|
|
@ -99,12 +122,43 @@ a {
|
||||||
background: black;
|
background: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standardTilingTitlebar > p {
|
.standardTilingBoxTitlebar > p {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.userSettings {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.userSettingsList {
|
||||||
|
display: flex;
|
||||||
|
overflow-y: scroll;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-right: var(--tiling-box-padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
.userSettingsList ul {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.userSettingsList button {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.currentSetting {
|
||||||
|
padding-left: var(--tiling-box-padding);
|
||||||
|
}
|
||||||
|
|
||||||
.blogEntryGrid {
|
.blogEntryGrid {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ export default function Home() {
|
||||||
<>
|
<>
|
||||||
<div className="standardHorizontalTilingGrid">
|
<div className="standardHorizontalTilingGrid">
|
||||||
<TilingItem titlebarName="testing"></TilingItem>
|
<TilingItem titlebarName="testing"></TilingItem>
|
||||||
<TilingItem></TilingItem>
|
<TilingItem>
|
||||||
|
<p>Testing</p>
|
||||||
|
</TilingItem>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,31 @@ import { Navigate } from "react-router-dom";
|
||||||
import { authTokenStorageHandlerInit } from "../components/storageHandler.ts";
|
import { authTokenStorageHandlerInit } from "../components/storageHandler.ts";
|
||||||
|
|
||||||
import TilingItem from "../components/TilingItem.tsx";
|
import TilingItem from "../components/TilingItem.tsx";
|
||||||
|
import SettingButton from "../components/SettingButton.tsx";
|
||||||
|
import AccountSetting from "./settings/Account.tsx";
|
||||||
|
import SecuritySetting from "./settings/Security.tsx";
|
||||||
|
import NotFoundSetting from "./settings/NotFound.tsx";
|
||||||
|
|
||||||
|
function renderCurrentSetting(setting: string) {
|
||||||
|
switch (setting) {
|
||||||
|
case "Account":
|
||||||
|
return <AccountSetting></AccountSetting>;
|
||||||
|
case "Security":
|
||||||
|
return <SecuritySetting></SecuritySetting>;
|
||||||
|
default:
|
||||||
|
return <NotFoundSetting></NotFoundSetting>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const settings = ["Account", "Security"];
|
||||||
|
const [currentSetting, setCurrentSetting] = React.useState(settings[0]);
|
||||||
|
/* Make object to pass by reference */
|
||||||
|
const currentSettingHook = {
|
||||||
|
currentSetting,
|
||||||
|
setCurrentSetting,
|
||||||
|
};
|
||||||
|
|
||||||
const authTokenStorageHandler = authTokenStorageHandlerInit();
|
const authTokenStorageHandler = authTokenStorageHandlerInit();
|
||||||
|
|
||||||
if (!authTokenStorageHandler.authTokenValue) {
|
if (!authTokenStorageHandler.authTokenValue) {
|
||||||
|
|
@ -14,7 +37,26 @@ export default function Home() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="standardHorizontalTilingGrid">
|
<div className="standardHorizontalTilingGrid">
|
||||||
<TilingItem></TilingItem>
|
<TilingItem>
|
||||||
|
<div className="userSettings">
|
||||||
|
<div className="userSettingsList">
|
||||||
|
<p>USER SETTINGS</p>
|
||||||
|
<ul>
|
||||||
|
{settings.map((value, index) => (
|
||||||
|
<SettingButton
|
||||||
|
settingName={value}
|
||||||
|
currentSettingHook={currentSettingHook}
|
||||||
|
key={index}
|
||||||
|
></SettingButton>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<hr></hr>
|
||||||
|
<div className="currentSetting">
|
||||||
|
{renderCurrentSetting(currentSetting)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</TilingItem>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default function AccountSetting() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1>Account</h1>
|
||||||
|
<hr></hr>
|
||||||
|
<p>Now on account!</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default function NotFoundSetting() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1>Error!</h1>
|
||||||
|
<hr></hr>
|
||||||
|
<p>Settings page requested not found.</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export default function SecuritySetting() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1>Security</h1>
|
||||||
|
<hr></hr>
|
||||||
|
<p>Now on security!</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue