feat: add multiple way to show collections and links

This commit is contained in:
Sonny
2025-08-21 02:27:51 +02:00
parent 18fe979069
commit 4ef2b639b6
41 changed files with 785 additions and 164 deletions

View File

@@ -1,31 +0,0 @@
import { IoListOutline } from 'react-icons/io5';
import { TbHash } from 'react-icons/tb';
import { ValueWithIcon } from '~/components/common/combo_list/combo_list';
import { usePersisted } from '~/hooks/use_persisted';
const listDisplayOptions: ValueWithIcon[] = [
{
label: 'Inline',
value: 'inline',
icon: <TbHash size={20} />,
},
{
label: 'List',
value: 'list',
icon: <IoListOutline size={20} />,
},
];
type ListDisplay = (typeof listDisplayOptions)[number]['value'];
export const useCollectionListSelector = () => {
const [listDisplay, setListDisplay] = usePersisted<ListDisplay>(
'inline',
'list'
);
return {
listDisplay,
listDisplayOptions,
setListDisplay,
};
};

View File

@@ -0,0 +1,7 @@
import { PageProps } from '@adonisjs/inertia/types';
import { usePage } from '@inertiajs/react';
export function useAppUrl() {
const { props } = usePage<PageProps & { appUrl: string }>();
return props.appUrl;
}

View File

@@ -1,9 +0,0 @@
import { useEffect } from 'react';
export const useDisableOverflow = () =>
useEffect(() => {
document.body.style.overflow = 'hidden';
return () => {
document.body.style.overflow = 'auto';
};
}, []);

View File

@@ -0,0 +1,26 @@
import { getDisplayPreferences } from '#shared/lib/display_preferences';
import { DisplayPreferences } from '#shared/types/index';
import { router } from '@inertiajs/react';
import { route } from '@izzyjs/route/client';
import { useAuth } from '~/hooks/use_auth';
export const useDisplayPreferences = () => {
const { user } = useAuth();
const displayPreferences = getDisplayPreferences(user?.displayPreferences);
const handleUpdateDisplayPreferences = (
displayPreferences: Partial<DisplayPreferences>
) => {
router.visit(route('user.update-display-preferences').path, {
method: 'post',
data: {
displayPreferences,
},
});
};
return {
displayPreferences,
handleUpdateDisplayPreferences,
};
};

View File

@@ -0,0 +1,3 @@
import { useMediaQuery } from '@mantine/hooks';
export const useIsMobile = () => useMediaQuery('(max-width: 768px)');