Mobile settings layout

This commit is contained in:
Kieran 2023-08-28 16:31:46 +01:00
parent f0f009f4fd
commit efdc57b8c4
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
7 changed files with 32 additions and 13 deletions

View File

@ -409,7 +409,7 @@ export default function ProfilePage() {
)} )}
{isMe ? ( {isMe ? (
<> <>
<button type="button" onClick={() => navigate("/settings/profile")}> <button type="button" onClick={() => navigate("/settings")}>
<FormattedMessage {...messages.Settings} /> <FormattedMessage {...messages.Settings} />
</button> </button>
</> </>

View File

@ -18,7 +18,7 @@ export default function SettingsPage() {
return ( return (
<> <>
<div className="main-content p"> <div className="main-content p">
<h2 onClick={() => navigate("/settings/profile")} className="pointer"> <h2 onClick={() => navigate("/settings")} className="pointer">
<FormattedMessage {...messages.Settings} /> <FormattedMessage {...messages.Settings} />
</h2> </h2>
</div> </div>

View File

@ -14,7 +14,6 @@
.settings .banner { .settings .banner {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-size: cover;
border-radius: 12px; border-radius: 12px;
background: linear-gradient(90deg, #60a5fa 0%, #a78bfa 100%); background: linear-gradient(90deg, #60a5fa 0%, #a78bfa 100%);
} }

View File

@ -167,7 +167,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
{(props.banner ?? true) && ( {(props.banner ?? true) && (
<div <div
style={{ style={{
backgroundImage: (banner?.length ?? 0) > 0 ? `url(${banner})` : undefined, background: (banner?.length ?? 0) > 0 ? `no-repeat center/cover url("${banner}")` : undefined,
}} }}
className="banner"> className="banner">
<AsyncButton type="button" onClick={() => setNewBanner()}> <AsyncButton type="button" onClick={() => setNewBanner()}>

View File

@ -3,11 +3,17 @@
grid-template-columns: 237px auto; grid-template-columns: 237px auto;
} }
@media(max-width: 768px) {
.settings-nav {
grid-template-columns: auto;
}
}
.settings-nav > div { .settings-nav > div {
border: 1px solid var(--gray-superdark); border: 1px solid var(--gray-superdark);
} }
.settings-nav > div:nth-child(2) { .settings-nav > div.content {
padding: 12px 16px; padding: 12px 16px;
} }

View File

@ -1,6 +1,7 @@
import "./Root.css"; import "./Root.css";
import { useEffect, useMemo } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Outlet, useNavigate } from "react-router-dom"; import { Outlet, useLocation, useNavigate } from "react-router-dom";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
import { LoginStore, logout } from "Login"; import { LoginStore, logout } from "Login";
import useLogin from "Hooks/useLogin"; import useLogin from "Hooks/useLogin";
@ -8,10 +9,13 @@ import { unwrap } from "SnortUtils";
import { getCurrentSubscription } from "Subscription"; import { getCurrentSubscription } from "Subscription";
import messages from "./messages"; import messages from "./messages";
import usePageWidth from "Hooks/usePageWidth";
const SettingsIndex = () => { const SettingsIndex = () => {
const login = useLogin(); const login = useLogin();
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation();
const pageWidth = usePageWidth();
const sub = getCurrentSubscription(LoginStore.allSubscriptions()); const sub = getCurrentSubscription(LoginStore.allSubscriptions());
function handleLogout() { function handleLogout() {
@ -19,9 +23,19 @@ const SettingsIndex = () => {
navigate("/"); navigate("/");
} }
useEffect(() => {
if (location.pathname === "/settings" && pageWidth >= 768) {
navigate("/settings/profile", { replace: true });
}
}, [location, pageWidth]);
const [hideMenu, hideContent] = useMemo(() => {
return [location.pathname !== "/settings" && pageWidth < 768, location.pathname === "/settings" && pageWidth < 768];
}, [location, pageWidth]);
return ( return (
<div className="settings-nav"> <div className="settings-nav">
<div> {!hideMenu && <div>
<div className="settings-row" onClick={() => navigate("profile")}> <div className="settings-row" onClick={() => navigate("profile")}>
<Icon name="profile" size={24} /> <Icon name="profile" size={24} />
<FormattedMessage {...messages.Profile} /> <FormattedMessage {...messages.Profile} />
@ -81,10 +95,10 @@ const SettingsIndex = () => {
<FormattedMessage {...messages.LogOut} /> <FormattedMessage {...messages.LogOut} />
<Icon name="arrowFront" size={16} /> <Icon name="arrowFront" size={16} />
</div> </div>
</div> </div>}
<div> {!hideContent && <div className="content">
<Outlet /> <Outlet />
</div> </div>}
</div> </div>
); );
}; };

View File

@ -58,9 +58,9 @@ const config = {
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: isProduction ? "[name].[chunkhash].css" : "[name].css", filename: isProduction ? "[name].[chunkhash].css" : "[name].css",
}), }),
new WorkboxPlugin.InjectManifest({ isProduction ? new WorkboxPlugin.InjectManifest({
swSrc: "./src/service-worker.ts", swSrc: "./src/service-worker.ts"
}), }) : false,
], ],
module: { module: {
rules: [ rules: [