WIP on Mantine v6

This commit is contained in:
ajnart
2023-03-03 01:13:23 +09:00
parent 5dae500ac3
commit 387f155b29
4 changed files with 17 additions and 27 deletions

View File

@@ -4,5 +4,5 @@ import { useMediaQuery } from '@mantine/hooks';
export const useScreenLargerThan = (size: MantineSize | number) => { export const useScreenLargerThan = (size: MantineSize | number) => {
const { breakpoints } = useMantineTheme(); const { breakpoints } = useMantineTheme();
const pixelCount = typeof size === 'string' ? breakpoints[size] : size; const pixelCount = typeof size === 'string' ? breakpoints[size] : size;
return useMediaQuery(`(min-width: ${pixelCount}px)`); return useMediaQuery('(min-width: 500px)');
}; };

View File

@@ -55,7 +55,7 @@ const useStyles = createStyles((theme) => ({
description: { description: {
maxWidth: 540, maxWidth: 540,
margin: 'auto', margin: 'auto',
marginTop: parseInt(theme.spacing.xl, 10), marginTop: theme.spacing.xl,
marginBottom: `calc(${theme.spacing.xl} * 1.5)`, marginBottom: `calc(${theme.spacing.xl} * 1.5)`,
}, },
})); }));

View File

@@ -1,5 +1,6 @@
import { Box, Indicator, IndicatorProps, Popover } from '@mantine/core'; import { Box, Indicator, IndicatorProps, Popover, useMantineTheme } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks'; import { useDisclosure } from '@mantine/hooks';
import { isToday } from '../../tools/isToday';
import { MediaList } from './MediaList'; import { MediaList } from './MediaList';
import { MediasType } from './type'; import { MediasType } from './type';
@@ -10,6 +11,7 @@ interface CalendarDayProps {
export const CalendarDay = ({ date, medias }: CalendarDayProps) => { export const CalendarDay = ({ date, medias }: CalendarDayProps) => {
const [opened, { close, open }] = useDisclosure(false); const [opened, { close, open }] = useDisclosure(false);
const { colorScheme, colors } = useMantineTheme();
if (medias.totalCount === 0) { if (medias.totalCount === 0) {
return <div>{date.getDate()}</div>; return <div>{date.getDate()}</div>;
@@ -29,7 +31,17 @@ export const CalendarDay = ({ date, medias }: CalendarDayProps) => {
opened={opened} opened={opened}
> >
<Popover.Target> <Popover.Target>
<Box onClick={open}> <Box
onClick={open}
style={{
margin: 5,
backgroundColor: isToday(date)
? colorScheme === 'dark'
? colors.dark[5]
: colors.gray[0]
: undefined,
}}
>
<DayIndicator color="red" position="bottom-start" medias={medias.books}> <DayIndicator color="red" position="bottom-start" medias={medias.books}>
<DayIndicator color="yellow" position="top-start" medias={medias.movies}> <DayIndicator color="yellow" position="top-start" medias={medias.movies}>
<DayIndicator color="blue" position="top-end" medias={medias.tvShows}> <DayIndicator color="blue" position="top-end" medias={medias.tvShows}>

View File

@@ -72,36 +72,14 @@ function CalendarTile({ widget }: CalendarTileProps) {
return ( return (
<Group grow style={{ height: '100%' }}> <Group grow style={{ height: '100%' }}>
<Calendar <Calendar
m={0}
p={0}
defaultDate={new Date()} defaultDate={new Date()}
// Should be offset 5px to the left
style={{ position: 'relative', top: -15 }}
onPreviousMonth={setMonth} onPreviousMonth={setMonth}
onNextMonth={setMonth} onNextMonth={setMonth}
size="xs" size="xs"
locale={i18n?.resolvedLanguage ?? 'en'} locale={i18n?.resolvedLanguage ?? 'en'}
firstDayOfWeek={widget.properties.sundayStart ? 0 : 1} firstDayOfWeek={widget.properties.sundayStart ? 0 : 1}
hideWeekdays hideWeekdays
styles={{ date={month}
day: {
margin: -1,
backgroundColor: isToday(new Date())
? colorScheme === 'dark'
? colors.dark[5]
: colors.gray[0]
: undefined,
},
weekday: {
margin: 0,
padding: 0,
},
calendarHeader: {
position: 'relative',
margin: 0,
padding: 0,
},
}}
hasNextLevel={false} hasNextLevel={false}
renderDay={(date) => ( renderDay={(date) => (
<CalendarDay date={date} medias={getReleasedMediasForDate(medias, date, widget)} /> <CalendarDay date={date} medias={getReleasedMediasForDate(medias, date, widget)} />