mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-10 04:22:00 +10:00
Add width option to page menu
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { ActionIcon, Menu, Tooltip } from "@mantine/core";
|
||||
import { ActionIcon, Group, Menu, Tooltip } from "@mantine/core";
|
||||
import {
|
||||
IconArrowsHorizontal,
|
||||
IconDots,
|
||||
IconHistory,
|
||||
IconLink,
|
||||
@ -19,6 +20,7 @@ import { getAppUrl } from "@/lib/config.ts";
|
||||
import { extractPageSlugId } from "@/lib";
|
||||
import { treeApiAtom } from "@/features/page/tree/atoms/tree-api-atom.ts";
|
||||
import { useDeletePageModal } from "@/features/page/hooks/use-delete-page-modal.tsx";
|
||||
import { PageWidthToggle } from "@/features/user/components/page-width-pref.tsx";
|
||||
|
||||
interface PageHeaderMenuProps {
|
||||
readOnly?: boolean;
|
||||
@ -95,6 +97,13 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
||||
Copy link
|
||||
</Menu.Item>
|
||||
<Menu.Divider />
|
||||
|
||||
<Menu.Item leftSection={<IconArrowsHorizontal size={16} stroke={2} />}>
|
||||
<Group wrap="nowrap">
|
||||
<PageWidthToggle label="Full width" />
|
||||
</Group>
|
||||
</Menu.Item>
|
||||
|
||||
<Menu.Item
|
||||
leftSection={<IconHistory size={16} stroke={2} />}
|
||||
onClick={openHistoryModal}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Group, Text, Switch } from "@mantine/core";
|
||||
import { Group, Text, Switch, MantineSize } from "@mantine/core";
|
||||
import { useAtom } from "jotai/index";
|
||||
import { userAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { updateUser } from "@/features/user/services/user-service.ts";
|
||||
@ -14,12 +14,16 @@ export default function PageWidthPref() {
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<WidthToggle />
|
||||
<PageWidthToggle />
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
|
||||
function WidthToggle() {
|
||||
interface PageWidthToggleProps {
|
||||
size?: MantineSize;
|
||||
label?: string;
|
||||
}
|
||||
export function PageWidthToggle({ size, label }: PageWidthToggleProps) {
|
||||
const [user, setUser] = useAtom(userAtom);
|
||||
const [checked, setChecked] = useState(
|
||||
user.settings?.preferences?.fullPageWidth,
|
||||
@ -34,6 +38,9 @@ function WidthToggle() {
|
||||
|
||||
return (
|
||||
<Switch
|
||||
size={size}
|
||||
label={label}
|
||||
labelPosition="left"
|
||||
defaultChecked={checked}
|
||||
onChange={handleChange}
|
||||
aria-label="Toggle full page width"
|
||||
|
||||
Reference in New Issue
Block a user