New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow user to set TOC display preference #6786
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,14 +8,15 @@ import { useTranslation, Trans } from "react-i18next"; | |||||
import { toast } from "sonner"; | ||||||
import { ThemeProvider, useTheme } from "styled-components"; | ||||||
import { buildDarkTheme, buildLightTheme } from "@shared/styles/theme"; | ||||||
import { CustomTheme, TeamPreference } from "@shared/types"; | ||||||
import { CustomTheme, TOCPosition, TeamPreference } from "@shared/types"; | ||||||
import { getBaseDomain } from "@shared/utils/domains"; | ||||||
import Button from "~/components/Button"; | ||||||
import ButtonLink from "~/components/ButtonLink"; | ||||||
import DefaultCollectionInputSelect from "~/components/DefaultCollectionInputSelect"; | ||||||
import Heading from "~/components/Heading"; | ||||||
import Input from "~/components/Input"; | ||||||
import InputColor from "~/components/InputColor"; | ||||||
import InputSelect from "~/components/InputSelect"; | ||||||
import Scene from "~/components/Scene"; | ||||||
import Switch from "~/components/Switch"; | ||||||
import Text from "~/components/Text"; | ||||||
|
@@ -58,6 +59,10 @@ function Details() { | |||||
isHexColor | ||||||
); | ||||||
|
||||||
const [tocPosition, setTocPosition] = useState( | ||||||
team.getPreference(TeamPreference.TocPosition) as TOCPosition | ||||||
); | ||||||
|
||||||
const handleSubmit = React.useCallback( | ||||||
async (event?: React.SyntheticEvent) => { | ||||||
if (event) { | ||||||
|
@@ -73,6 +78,7 @@ function Details() { | |||||
...team.preferences, | ||||||
publicBranding, | ||||||
customTheme, | ||||||
tocPosition, | ||||||
}, | ||||||
}); | ||||||
toast.success(t("Settings saved")); | ||||||
|
@@ -276,6 +282,31 @@ function Details() { | |||||
/> | ||||||
</SettingRow> | ||||||
|
||||||
<SettingRow | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets move this under the "Display" header, it's currently under "Behavior" |
||||||
border={false} | ||||||
label={t("Table of Contents Position")} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
name="tocPosition" | ||||||
description={t( | ||||||
"The side to display the table of contents in relation to the main content." | ||||||
)} | ||||||
> | ||||||
<InputSelect | ||||||
ariaLabel={t("TOC position")} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
options={[ | ||||||
{ | ||||||
label: "Left", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
value: TOCPosition.Left, | ||||||
}, | ||||||
{ | ||||||
label: "Right", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
value: TOCPosition.Right, | ||||||
}, | ||||||
]} | ||||||
value={tocPosition} | ||||||
onChange={(p: TOCPosition) => setTocPosition(p)} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Should work, no? Or is typescript forcing the intermediate function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, Typescript 😅 . |
||||||
/> | ||||||
</SettingRow> | ||||||
|
||||||
<Button type="submit" disabled={team.isSaving || !isValid}> | ||||||
{team.isSaving ? `${t("Saving")}…` : t("Save")} | ||||||
</Button> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets continue to pass
position
down