From 0746ef741a51bd8f92ca5e07dfb9f35b66f4cf06 Mon Sep 17 00:00:00 2001 From: f0x52 Date: Wed, 29 Mar 2023 12:18:45 +0200 Subject: [PATCH] [frontend] Settings navigation design (#1652) * change header image alignment (cherry picked from commit df1bb339a5c597a2b668cedb3dafec5a390df120) * big mess navigation refactor * bit of cleanup * minor css tweaks * fix error rendering code for remote emoji * refactor navigation structure code * refactor styling * fix className * stash * restructure navigation generation * url wildcard formatting * remove un-implemented User menu entry * remove commented lines * clarify permissions check * invert permissions logic for clarity --- web/source/css/_colors.css | 12 +- web/source/css/base.css | 62 +++--- .../settings/admin/emoji/local/detail.js | 15 +- .../settings/admin/emoji/local/index.js | 10 +- .../settings/admin/emoji/local/overview.js | 12 +- .../settings/admin/emoji/remote/index.js | 3 +- .../admin/federation/import-export/form.jsx | 2 +- .../admin/federation/import-export/index.jsx | 4 +- web/source/settings/admin/federation/index.js | 4 +- web/source/settings/admin/reports/detail.jsx | 4 +- web/source/settings/admin/reports/index.jsx | 12 +- web/source/settings/components/nav-button.jsx | 34 --- .../settings/components/user-logout-card.jsx | 47 ++++ web/source/settings/index.js | 78 ++++--- web/source/settings/lib/get-views.js | 102 --------- .../settings/lib/navigation/components.jsx | 141 ++++++++++++ web/source/settings/lib/navigation/index.js | 138 ++++++++++++ web/source/settings/lib/navigation/util.js | 51 +++++ web/source/settings/style.css | 206 ++++++++++++------ web/template/about.tmpl | 2 +- 20 files changed, 627 insertions(+), 312 deletions(-) delete mode 100644 web/source/settings/components/nav-button.jsx create mode 100644 web/source/settings/components/user-logout-card.jsx delete mode 100644 web/source/settings/lib/get-views.js create mode 100644 web/source/settings/lib/navigation/components.jsx create mode 100644 web/source/settings/lib/navigation/index.js create mode 100644 web/source/settings/lib/navigation/util.js diff --git a/web/source/css/_colors.css b/web/source/css/_colors.css index 6d4b056b8..01f59a55d 100644 --- a/web/source/css/_colors.css +++ b/web/source/css/_colors.css @@ -101,15 +101,15 @@ $input-border: $blue1; $input-error-border: $error3; $input-focus-border: $blue3; -$settings-nav-bg: $bg-accent; -$settings-nav-header-fg: $gray1; -$settings-nav-header-bg: $orange1; +$settings-nav-bg: $bg; +$settings-nav-header-fg: $orange2; $settings-nav-bg-hover: $gray3; -/* $settings-nav-fg-hover: $gray1; */ +$settings-nav-fg-hover: $fg; -$settings-nav-bg-active: $gray2; -/* $settings-nav-fg-active: $orange2; */ +$settings-nav-bg-active: $blue3; +$settings-nav-border-active: $info-bg; +$settings-nav-fg-active: $gray2; $error-fg: $error1; $error-bg: $error2; diff --git a/web/source/css/base.css b/web/source/css/base.css index c30b72373..45b797c64 100644 --- a/web/source/css/base.css +++ b/web/source/css/base.css @@ -97,11 +97,10 @@ header { header a { margin: 2rem; display: flex; - flex-direction: column; flex-wrap: wrap; + gap: 2rem; img { - margin-bottom: 1rem; align-self: center; height: 6rem; } @@ -120,7 +119,6 @@ header a { } .excerpt-top { - margin-top: -1rem; margin-bottom: 2rem; font-style: italic; font-weight: normal; @@ -515,41 +513,37 @@ label { margin-bottom: 0; } - .contact-account-card { - /* display: inline-grid; - grid-template-columns: 4rem auto; - grid-template-rows: 4rem; - gap: 1rem; - padding: 0.5rem; */ - display: inline-grid; - grid-template-columns: auto 1fr; - grid-template-rows: auto auto; - text-decoration: none; - gap: 0.5rem 1rem; - border-radius: $br; - padding: 0.5rem; - min-width: 40%; - margin-bottom: 0.3rem; +} - background: $list-entry-bg; +.account-card { + display: inline-grid; + grid-template-columns: auto 1fr; + grid-template-rows: auto auto; + text-decoration: none; + gap: 0.5rem 1rem; + border-radius: $br; + padding: 0.5rem; + min-width: 40%; + margin-bottom: 0.3rem; - &:hover { - background: $list-entry-alternate-bg; - } + background: $list-entry-bg; - h3 { - align-self: end; - margin: 0; - color: $fg; - } + &:hover { + background: $list-entry-alternate-bg; + } - img.avatar { - border-radius: 0.5rem; - width: 5rem; - height: 5rem; - object-fit: cover; - grid-row: 1 / span 2; - } + h3 { + align-self: end; + margin: 0; + color: $fg; + } + + img.avatar { + border-radius: 0.5rem; + width: 5rem; + height: 5rem; + object-fit: cover; + grid-row: 1 / span 2; } } diff --git a/web/source/settings/admin/emoji/local/detail.js b/web/source/settings/admin/emoji/local/detail.js index 101652686..6b583b0b9 100644 --- a/web/source/settings/admin/emoji/local/detail.js +++ b/web/source/settings/admin/emoji/local/detail.js @@ -28,6 +28,7 @@ const { useComboBoxInput, useFileInput, useValue } = require("../../../lib/form" const { CategorySelect } = require("../category-select"); const useFormSubmit = require("../../../lib/form/submit"); +const { useBaseUrl } = require("../../../lib/navigation/util"); const FakeToot = require("../../../components/fake-toot"); const FormWithData = require("../../../lib/form/form-with-data"); @@ -36,16 +37,15 @@ const { FileInput } = require("../../../components/form/inputs"); const MutationButton = require("../../../components/form/mutation-button"); const { Error } = require("../../../components/error"); -const base = "/settings/custom-emoji/local"; - -module.exports = function EmojiDetailRoute() { - let [_match, params] = useRoute(`${base}/:emojiId`); +module.exports = function EmojiDetailRoute({ }) { + const baseUrl = useBaseUrl(); + let [_match, params] = useRoute(`${baseUrl}/:emojiId`); if (params?.emojiId == undefined) { - return ; + return ; } else { return (
- < go back + < go back
); @@ -53,6 +53,7 @@ module.exports = function EmojiDetailRoute() { }; function EmojiDetailForm({ data: emoji }) { + const baseUrl = useBaseUrl(); const form = { id: useValue("id", emoji.id), category: useComboBoxInput("category", { source: emoji }), @@ -78,7 +79,7 @@ function EmojiDetailForm({ data: emoji }) { const [deleteEmoji, deleteResult] = query.useDeleteEmojiMutation(); if (deleteResult.isSuccess) { - return ; + return ; } return ( diff --git a/web/source/settings/admin/emoji/local/index.js b/web/source/settings/admin/emoji/local/index.js index 3c88f49c3..56695094c 100644 --- a/web/source/settings/admin/emoji/local/index.js +++ b/web/source/settings/admin/emoji/local/index.js @@ -25,15 +25,13 @@ const { Switch, Route } = require("wouter"); const EmojiOverview = require("./overview"); const EmojiDetail = require("./detail"); -const base = "/settings/custom-emoji/local"; - -module.exports = function CustomEmoji() { +module.exports = function CustomEmoji({ baseUrl }) { return ( - - + + - + ); }; diff --git a/web/source/settings/admin/emoji/local/overview.js b/web/source/settings/admin/emoji/local/overview.js index 616c5144b..757729c38 100644 --- a/web/source/settings/admin/emoji/local/overview.js +++ b/web/source/settings/admin/emoji/local/overview.js @@ -29,12 +29,13 @@ const { useTextInput } = require("../../../lib/form"); const query = require("../../../lib/query"); const { useEmojiByCategory } = require("../category-select"); +const { useBaseUrl } = require("../../../lib/navigation/util"); const Loading = require("../../../components/loading"); const { Error } = require("../../../components/error"); const { TextInput } = require("../../../components/form/inputs"); -module.exports = function EmojiOverview({ baseUrl }) { +module.exports = function EmojiOverview({ }) { const { data: emoji = [], isLoading, @@ -51,7 +52,7 @@ module.exports = function EmojiOverview({ baseUrl }) { } else { content = ( <> - + ); @@ -70,7 +71,7 @@ module.exports = function EmojiOverview({ baseUrl }) { ); }; -function EmojiList({ emoji, baseUrl }) { +function EmojiList({ emoji }) { const filterField = useTextInput("filter"); const filter = filterField.value; @@ -116,7 +117,7 @@ function EmojiList({ emoji, baseUrl }) { ? (
{filteredEmoji.map(([category, entries]) => { - return ; + return ; })}
) @@ -128,7 +129,8 @@ function EmojiList({ emoji, baseUrl }) { ); } -function EmojiCategory({ category, entries, baseUrl }) { +function EmojiCategory({ category, entries }) { + const baseUrl = useBaseUrl(); return (
{category} diff --git a/web/source/settings/admin/emoji/remote/index.js b/web/source/settings/admin/emoji/remote/index.js index 757e443a4..bf7113b49 100644 --- a/web/source/settings/admin/emoji/remote/index.js +++ b/web/source/settings/admin/emoji/remote/index.js @@ -25,6 +25,7 @@ const ParseFromToot = require("./parse-from-toot"); const query = require("../../../lib/query"); const Loading = require("../../../components/loading"); +const { Error } = require("../../../components/error"); module.exports = function RemoteEmoji() { // local emoji are queried for shortcode collision detection @@ -42,7 +43,7 @@ module.exports = function RemoteEmoji() { <>

Custom Emoji (remote)

{error && -
{error}
+ } {isLoading ? diff --git a/web/source/settings/admin/federation/import-export/form.jsx b/web/source/settings/admin/federation/import-export/form.jsx index 1cb8d2d74..a6967b8f0 100644 --- a/web/source/settings/admin/federation/import-export/form.jsx +++ b/web/source/settings/admin/federation/import-export/form.jsx @@ -79,7 +79,7 @@ module.exports = function ImportExportForm({ form, submitParse, parseResult }) { showError={false} />