mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(frontend): improved settings menu design for mobile
This commit is contained in:
@@ -2,6 +2,45 @@ import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
interface SettingsRoute {
|
||||
text: string;
|
||||
route: string;
|
||||
regex: RegExp;
|
||||
}
|
||||
|
||||
const settingsRoutes: SettingsRoute[] = [
|
||||
{
|
||||
text: 'General Settings',
|
||||
route: '/settings/main',
|
||||
regex: /^\/settings(\/main)?$/,
|
||||
},
|
||||
{
|
||||
text: 'Plex',
|
||||
route: '/settings/plex',
|
||||
regex: /^\/settings\/plex/,
|
||||
},
|
||||
{
|
||||
text: 'Services',
|
||||
route: '/settings/services',
|
||||
regex: /^\/settings\/services/,
|
||||
},
|
||||
{
|
||||
text: 'Logs',
|
||||
route: '/settings/logs',
|
||||
regex: /^\/settings\/logs/,
|
||||
},
|
||||
{
|
||||
text: 'Jobs',
|
||||
route: '/settings/jobs',
|
||||
regex: /^\/settings\/jobs/,
|
||||
},
|
||||
{
|
||||
text: 'About',
|
||||
route: '/settings/about',
|
||||
regex: /^\/settings\/about/,
|
||||
},
|
||||
];
|
||||
|
||||
const SettingsLayout: React.FC = ({ children }) => {
|
||||
const router = useRouter();
|
||||
const activeLinkColor =
|
||||
@@ -10,50 +49,71 @@ const SettingsLayout: React.FC = ({ children }) => {
|
||||
const inactiveLinkColor =
|
||||
'border-transparent text-cool-gray-500 hover:text-cool-gray-400 hover:border-cool-gray-300 focus:outline-none focus:text-cool-gray-4700 focus:border-cool-gray-300';
|
||||
|
||||
const settingsLink = ({
|
||||
text,
|
||||
route,
|
||||
regex,
|
||||
}: {
|
||||
text: string;
|
||||
const SettingsLink: React.FC<{
|
||||
route: string;
|
||||
regex: RegExp;
|
||||
}) => {
|
||||
isMobile?: boolean;
|
||||
}> = ({ children, route, regex, isMobile = false }) => {
|
||||
if (isMobile) {
|
||||
return <option value={route}>{children}</option>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link href={route}>
|
||||
<a
|
||||
className={`whitespace-no-wrap pb-4 px-1 border-b-2 font-medium text-sm leading-5 ${
|
||||
className={`whitespace-no-wrap ml-8 first:ml-0 py-4 px-1 border-b-2 border-transparent font-medium text-sm leading-5 ${
|
||||
!!router.pathname.match(regex) ? activeLinkColor : inactiveLinkColor
|
||||
}`}
|
||||
aria-current="page"
|
||||
>
|
||||
{text}
|
||||
{children}
|
||||
</a>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="border-b border-cool-gray-600 mt-10">
|
||||
<div className="space-y-4 sm:flex sm:items-baseline sm:space-y-0 sm:space-x-10">
|
||||
<h3 className="text-lg leading-6 font-medium text-white">Settings</h3>
|
||||
<div>
|
||||
<nav className="-mb-px flex space-x-8">
|
||||
{settingsLink({
|
||||
text: 'General Settings',
|
||||
route: '/settings/main',
|
||||
regex: /^\/settings(\/main)?$/,
|
||||
})}
|
||||
{settingsLink({
|
||||
text: 'Plex',
|
||||
route: '/settings/plex',
|
||||
regex: /^\/settings\/plex/,
|
||||
})}
|
||||
{settingsLink({
|
||||
text: 'Services',
|
||||
route: '/settings/services',
|
||||
regex: /^\/settings\/services/,
|
||||
})}
|
||||
<div className="mt-6">
|
||||
<div className="sm:hidden">
|
||||
<select
|
||||
onChange={(e) => {
|
||||
router.push(e.target.value);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
router.push(e.target.value);
|
||||
}}
|
||||
defaultValue={
|
||||
settingsRoutes.find(
|
||||
(route) => !!router.pathname.match(route.regex)
|
||||
)?.route
|
||||
}
|
||||
aria-label="Selected tab"
|
||||
className="bg-cool-gray-800 text-white mt-1 form-select block w-full pl-3 pr-10 py-2 text-base leading-6 border-cool-gray-700 focus:outline-none focus:shadow-outline-blue focus:border-blue-300 sm:text-sm sm:leading-5 transition ease-in-out duration-150"
|
||||
>
|
||||
{settingsRoutes.map((route, index) => (
|
||||
<SettingsLink
|
||||
route={route.route}
|
||||
regex={route.regex}
|
||||
isMobile
|
||||
key={`mobile-settings-link-${index}`}
|
||||
>
|
||||
{route.text}
|
||||
</SettingsLink>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="hidden sm:block">
|
||||
<div className="border-b border-cool-gray-600">
|
||||
<nav className="-mb-px flex">
|
||||
{settingsRoutes.map((route, index) => (
|
||||
<SettingsLink
|
||||
route={route.route}
|
||||
regex={route.regex}
|
||||
key={`standard-settings-link-${index}`}
|
||||
>
|
||||
{route.text}
|
||||
</SettingsLink>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -13,6 +13,7 @@ module.exports = {
|
||||
variants: {
|
||||
padding: ['first', 'last'],
|
||||
borderWidth: ['first', 'last'],
|
||||
margin: ['first', 'last', 'responsive'],
|
||||
boxShadow: ['group-focus'],
|
||||
opacity: ['disabled'],
|
||||
},
|
||||
|
Reference in New Issue
Block a user