Skip to content

Commit

Permalink
[frontend] Settings navigation design (#1652)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
f0x52 committed Mar 29, 2023
1 parent 6cf6613 commit 0746ef7
Show file tree
Hide file tree
Showing 20 changed files with 624 additions and 309 deletions.
12 changes: 6 additions & 6 deletions web/source/css/_colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
62 changes: 28 additions & 34 deletions web/source/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -120,7 +119,6 @@ header a {
}

.excerpt-top {
margin-top: -1rem;
margin-bottom: 2rem;
font-style: italic;
font-weight: normal;
Expand Down Expand Up @@ -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;
}
}

Expand Down
15 changes: 8 additions & 7 deletions web/source/settings/admin/emoji/local/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -36,23 +37,23 @@ 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 <Redirect to={base} />;
return <Redirect to={baseUrl} />;
} else {
return (
<div className="emoji-detail">
<Link to={base}><a>&lt; go back</a></Link>
<Link to={baseUrl}><a>&lt; go back</a></Link>
<FormWithData dataQuery={query.useGetEmojiQuery} queryArg={params.emojiId} DataForm={EmojiDetailForm} />
</div>
);
}
};

function EmojiDetailForm({ data: emoji }) {
const baseUrl = useBaseUrl();
const form = {
id: useValue("id", emoji.id),
category: useComboBoxInput("category", { source: emoji }),
Expand All @@ -78,7 +79,7 @@ function EmojiDetailForm({ data: emoji }) {
const [deleteEmoji, deleteResult] = query.useDeleteEmojiMutation();

if (deleteResult.isSuccess) {
return <Redirect to={base} />;
return <Redirect to={baseUrl} />;
}

return (
Expand Down
10 changes: 4 additions & 6 deletions web/source/settings/admin/emoji/local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Switch>
<Route path={`${base}/:emojiId`}>
<EmojiDetail baseUrl={base} />
<Route path={`${baseUrl}/:emojiId`}>
<EmojiDetail />
</Route>
<EmojiOverview baseUrl={base} />
<EmojiOverview />
</Switch>
);
};
12 changes: 7 additions & 5 deletions web/source/settings/admin/emoji/local/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -51,7 +52,7 @@ module.exports = function EmojiOverview({ baseUrl }) {
} else {
content = (
<>
<EmojiList emoji={emoji} baseUrl={baseUrl} />
<EmojiList emoji={emoji} />
<NewEmojiForm emoji={emoji} />
</>
);
Expand All @@ -70,7 +71,7 @@ module.exports = function EmojiOverview({ baseUrl }) {
);
};

function EmojiList({ emoji, baseUrl }) {
function EmojiList({ emoji }) {
const filterField = useTextInput("filter");
const filter = filterField.value;

Expand Down Expand Up @@ -116,7 +117,7 @@ function EmojiList({ emoji, baseUrl }) {
? (
<div className="entries scrolling">
{filteredEmoji.map(([category, entries]) => {
return <EmojiCategory key={category} category={category} entries={entries} baseUrl={baseUrl} />;
return <EmojiCategory key={category} category={category} entries={entries} />;
})}
</div>
)
Expand All @@ -128,7 +129,8 @@ function EmojiList({ emoji, baseUrl }) {
);
}

function EmojiCategory({ category, entries, baseUrl }) {
function EmojiCategory({ category, entries }) {
const baseUrl = useBaseUrl();
return (
<div className="entry">
<b>{category}</b>
Expand Down
3 changes: 2 additions & 1 deletion web/source/settings/admin/emoji/remote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +43,7 @@ module.exports = function RemoteEmoji() {
<>
<h1>Custom Emoji (remote)</h1>
{error &&
<div className="error accent">{error}</div>
<Error error={error} />
}
{isLoading
? <Loading />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = function ImportExportForm({ form, submitParse, parseResult }) {
showError={false}
/>
<label className="button with-icon">
<i class="fa fa-fw " aria-hidden="true" />
<i className="fa fa-fw " aria-hidden="true" />
Import file
<input
type="file"
Expand Down
4 changes: 1 addition & 3 deletions web/source/settings/admin/federation/import-export/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const useFormSubmit = require("../../../lib/form/submit");
const ProcessImport = require("./process");
const ImportExportForm = require("./form");

const baseUrl = "/settings/admin/federation/import-export";

module.exports = function ImportExport() {
module.exports = function ImportExport({ baseUrl }) {
const form = {
domains: useTextInput("domains"),
exportType: useTextInput("exportType", { defaultValue: "plain", dontReset: true })
Expand Down
4 changes: 1 addition & 3 deletions web/source/settings/admin/federation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
const React = require("react");
const { Switch, Route } = require("wouter");

const baseUrl = `/settings/admin/federation`;

const InstanceOverview = require("./overview");
const InstanceDetail = require("./detail");
const InstanceImportExport = require("./import-export");

module.exports = function Federation({ }) {
module.exports = function Federation({ baseUrl }) {
return (
<Switch>
<Route path={`${baseUrl}/import-export/:list?`}>
Expand Down
4 changes: 3 additions & 1 deletion web/source/settings/admin/reports/detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ const { TextArea } = require("../../components/form/inputs");

const MutationButton = require("../../components/form/mutation-button");
const Username = require("./username");
const { useBaseUrl } = require("../../lib/navigation/util");

module.exports = function ReportDetail({ baseUrl }) {
module.exports = function ReportDetail({ }) {
const baseUrl = useBaseUrl();
let [_match, params] = useRoute(`${baseUrl}/:reportId`);
if (params?.reportId == undefined) {
return <Redirect to={baseUrl} />;
Expand Down
12 changes: 6 additions & 6 deletions web/source/settings/admin/reports/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,22 @@ const FormWithData = require("../../lib/form/form-with-data");

const ReportDetail = require("./detail");
const Username = require("./username");
const { useBaseUrl } = require("../../lib/navigation/util");

const baseUrl = "/settings/admin/reports";

module.exports = function Reports() {
module.exports = function Reports({ baseUrl }) {
return (
<div className="reports">
<Switch>
<Route path={`${baseUrl}/:reportId`}>
<ReportDetail baseUrl={baseUrl} />
<ReportDetail />
</Route>
<ReportOverview baseUrl={baseUrl} />
<ReportOverview />
</Switch>
</div>
);
};

function ReportOverview({ _baseUrl }) {
function ReportOverview({ }) {
return (
<>
<h1>Reports</h1>
Expand Down Expand Up @@ -79,6 +78,7 @@ function ReportsList({ data: reports }) {
}

function ReportEntry({ report }) {
const baseUrl = useBaseUrl();
const from = report.account;
const target = report.target_account;

Expand Down
34 changes: 0 additions & 34 deletions web/source/settings/components/nav-button.jsx

This file was deleted.

0 comments on commit 0746ef7

Please sign in to comment.