Style updates

This commit is contained in:
Sean Edmunds
2025-06-23 16:43:32 -05:00
parent 63e087cdfe
commit 3c3f4072f7
9 changed files with 279 additions and 50 deletions

View File

@@ -135,6 +135,8 @@ export function useMutationAPI() {
queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] }); queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] });
endpoint === 'api/applicationOrder' && endpoint === 'api/applicationOrder' &&
queryClient.refetchQueries({ queryKey: ['GET', 'api/applicationOrder'] }); queryClient.refetchQueries({ queryKey: ['GET', 'api/applicationOrder'] });
endpoint === 'api/bookmarks' &&
queryClient.refetchQueries({ queryKey: ['GET', 'api/themes'] });
}, },
onSuccess: (_, { endpoint }) => { onSuccess: (_, { endpoint }) => {
queryClient.refetchQueries({ queryClient.refetchQueries({
@@ -146,6 +148,8 @@ export function useMutationAPI() {
queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] }); queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] });
endpoint === 'api/applicationOrder' && endpoint === 'api/applicationOrder' &&
queryClient.refetchQueries({ queryKey: ['GET', 'api/applicationOrder'] }); queryClient.refetchQueries({ queryKey: ['GET', 'api/applicationOrder'] });
endpoint === 'api/bookmarks' &&
queryClient.refetchQueries({ queryKey: ['GET', 'api/themes'] });
}, },
}); });
} }

View File

@@ -16,8 +16,8 @@ import {
import { useCommonHooks } from 'hooks'; import { useCommonHooks } from 'hooks';
import { useFileUploadAPI, useMutationAPI } from 'hooks/useAPI'; import { useFileUploadAPI, useMutationAPI } from 'hooks/useAPI';
import { useState } from 'react'; import { useState } from 'react';
import { FiTrash } from 'react-icons/fi'; import { FiEdit, FiTrash } from 'react-icons/fi';
import { modalClasses, scrollAreaClasses } from 'styles'; import { modalClasses, scrollAreaClasses, textInputClasses } from 'styles';
function BackgroundModal({ function BackgroundModal({
backgroundModalOpened, backgroundModalOpened,
@@ -33,8 +33,10 @@ function BackgroundModal({
const [background, setBackground] = useState<File | null>(null); const [background, setBackground] = useState<File | null>(null);
const [fileName, setFileName] = useState<string>(''); const [fileName, setFileName] = useState<string>('');
const [newFileName, setNewFileName] = useState<string>(''); const [newFileName, setNewFileName] = useState<string>('');
const [rename, setRename] = useState<string>('');
const [err, setErr] = useState<boolean>(false); const [err, setErr] = useState<boolean>(false);
const [confirm, setConfirm] = useState<boolean>(false); const [confirm, setConfirm] = useState<boolean>(false);
const [editing, setEditing] = useState<boolean>(false);
const { isMobile } = useCommonHooks(); const { isMobile } = useCommonHooks();
const { mutateAsync: uploadAsync } = useFileUploadAPI(); const { mutateAsync: uploadAsync } = useFileUploadAPI();
const { mutateAsync } = useMutationAPI(); const { mutateAsync } = useMutationAPI();
@@ -56,6 +58,7 @@ function BackgroundModal({
setNewFileName(''); setNewFileName('');
handleBackgroundModalClose(); handleBackgroundModalClose();
setConfirm(false); setConfirm(false);
setEditing(false);
}} }}
fullScreen={isMobile} fullScreen={isMobile}
centered centered
@@ -72,7 +75,7 @@ function BackgroundModal({
</Modal.Header> </Modal.Header>
<Modal.Body p={'1rem'}> <Modal.Body p={'1rem'}>
<Stack align='center' w={'100%'}> <Stack align='center' w={'100%'}>
{confirm ? ( {confirm && (
<Stack <Stack
justify='center' justify='center'
align='center' align='center'
@@ -144,7 +147,105 @@ function BackgroundModal({
</Button> </Button>
</Group> </Group>
</Stack> </Stack>
) : ( )}
{editing && (
<Stack
justify='center'
align='center'
style={{
width: '100%',
height: '30rem',
backgroundColor: 'var(--mantine-color-search-0)',
padding: '1rem',
borderRadius: '.5rem',
backgroundFilter: 'blur(5px)',
}}
>
<Text fw={600} fz={'2rem'}>
Editing {fileName}
</Text>
{inUseBackgrounds.includes(fileName) && (
<Text fw={600} fz={'1.5rem'}>
Updating the name will update the associated themes.
</Text>
)}
<Group h={'100%'} mb={'1rem'}>
<TextInput
className={textInputClasses.settingsItem}
classNames={textInputClasses}
label='New Name'
onChange={(e) => setRename(e.target.value)}
/>
<Card
style={{
aspectRatio: '16/9',
height: '100%',
backgroundImage: `url(../../api/backgroundImages/${fileName})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
padding: '2rem',
margin: '1rem',
}}
/>
</Group>
<Group>
<Button
mt={'auto'}
w={'min-content'}
color='green'
onClick={() => {
if (
!rename.endsWith('.png') &&
!rename.endsWith('.jpg') &&
!rename.endsWith('.jpeg')
) {
mutateAsync({
method: 'PATCH',
endpoint: 'api/backgrounds',
body: {
fileName,
newFileName: `${rename}${fileName.substring(
fileName.lastIndexOf('.'),
fileName.length,
)}`,
},
});
} else {
mutateAsync({
method: 'PATCH',
endpoint: 'api/backgrounds',
body: {
fileName,
newFileName: rename,
},
});
}
setBackground(null);
setFileName('');
setNewFileName('');
setEditing(false);
}}
>
Save
</Button>
<Button
mt={'auto'}
w={'min-content'}
onClick={() => {
setBackground(null);
setFileName('');
setNewFileName('');
setEditing(false);
setFileName('');
}}
>
Cancel
</Button>
</Group>
</Stack>
)}
{!editing && !confirm && (
<ScrollArea <ScrollArea
className={scrollAreaClasses.default} className={scrollAreaClasses.default}
classNames={scrollAreaClasses} classNames={scrollAreaClasses}
@@ -189,6 +290,20 @@ function BackgroundModal({
margin: '1rem', margin: '1rem',
}} }}
/> />
<ActionIcon
style={{
position: 'absolute',
bottom: '.5rem',
right: '2.5rem',
zIndex: 3,
}}
onClick={() => {
setFileName(background);
setEditing(true);
}}
>
<FiEdit />
</ActionIcon>
<ActionIcon <ActionIcon
color='var(--mantine-color-red-6)' color='var(--mantine-color-red-6)'
style={{ style={{
@@ -217,13 +332,14 @@ function BackgroundModal({
justify='space-between' justify='space-between'
p={16} p={16}
> >
{confirm && ( {confirm ||
(editing && (
<Overlay <Overlay
opacity={1} opacity={1}
color='var(--mantine-color-search-0)' color='var(--mantine-color-search-0)'
style={{ borderRadius: '.5rem', backdropFilter: 'blur(5px)' }} style={{ borderRadius: '.5rem', backdropFilter: 'blur(5px)' }}
/> />
)} ))}
<Group gap={0}> <Group gap={0}>
<Stack gap={0} w={'60%'}> <Stack gap={0} w={'60%'}>
<FileInput <FileInput

View File

@@ -89,9 +89,19 @@ function ThemeCard({
h={'115px'} h={'115px'}
disabled={currentTheme === 'random'} disabled={currentTheme === 'random'}
style={{ style={{
background: `linear-gradient(${cardTheme.backgroundColor}33, ${cardTheme.backgroundColor}33), no-repeat center url(../../api/backgroundImages/${cardTheme.backgroundImage})`, backgroundImage:
backgroundSize: 'cover', cardTheme?.backgroundImage.toLocaleLowerCase() !== 'none'
backgroundColor: cardTheme.backgroundColor, ? `linear-gradient(${cardTheme?.backgroundColor}33, ${cardTheme?.backgroundColor}33), url(../../api/backgroundImages/${cardTheme?.backgroundImage})`
: undefined,
backgroundSize:
cardTheme?.backgroundImage.toLocaleLowerCase() !== 'none'
? 'cover'
: undefined,
backgroundColor:
cardTheme?.backgroundImage.toLocaleLowerCase() === 'none'
? cardTheme?.backgroundColor
: undefined,
backgroundPosition: 'center',
border: `solid ${cardTheme.borderColor}`, border: `solid ${cardTheme.borderColor}`,
filter: cardTheme.randomEnabled === 0 ? 'saturate(0)' : undefined, filter: cardTheme.randomEnabled === 0 ? 'saturate(0)' : undefined,
}} }}

View File

@@ -14,9 +14,16 @@ function ThemeMiniCard({ allThemes, item }: { allThemes: Theme[]; item: number }
w={'175px'} w={'175px'}
h={'60px'} h={'60px'}
style={{ style={{
backgroundImage: `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), url(../../api/backgroundImages/${theme?.backgroundImage})`, backgroundImage:
backgroundSize: 'cover', theme?.backgroundImage.toLocaleLowerCase() !== 'none'
backgroundColor: theme?.backgroundColor, ? `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), url(../../api/backgroundImages/${theme?.backgroundImage})`
: undefined,
backgroundSize:
theme?.backgroundImage.toLocaleLowerCase() !== 'none' ? 'cover' : undefined,
backgroundColor:
theme?.backgroundImage.toLocaleLowerCase() === 'none'
? theme?.backgroundColor
: undefined,
backgroundPosition: 'center', backgroundPosition: 'center',
border: `solid ${theme?.borderColor}`, border: `solid ${theme?.borderColor}`,
borderRadius: '8px', borderRadius: '8px',

View File

@@ -18,7 +18,7 @@ export default function ThemeModalContent({ selectedTheme }: { selectedTheme: Th
: undefined, : undefined,
backgroundPosition: 'center', backgroundPosition: 'center',
borderRadius: '10px', borderRadius: '10px',
border: '2px solid', border: '2px solid var(--mantine-color-primary-0)',
}} }}
> >
<Group <Group

View File

@@ -11,7 +11,7 @@ import { useCommonHooks } from 'hooks';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { modalClasses, textInputClasses } from 'styles'; import { modalClasses, textInputClasses } from 'styles';
import type { Theme, ThemePlaylist } from 'types'; import type { Theme, ThemePlaylist } from 'types';
import ThemeMiniCard from './ThemeMiniCard'; import ThemePreviewMiddleware from './ThemePreivewMiddleware';
import TimeOfDay from './TimeOfDay'; import TimeOfDay from './TimeOfDay';
function ThemePlaylistModal({ function ThemePlaylistModal({
@@ -45,6 +45,7 @@ function ThemePlaylistModal({
if (selectedPlaylist?.name === undefined) { if (selectedPlaylist?.name === undefined) {
setSelectedPlaylist(defaultPlaylist); setSelectedPlaylist(defaultPlaylist);
} }
return ( return (
<Modal.Root <Modal.Root
size={'50%'} size={'50%'}
@@ -100,31 +101,15 @@ function ThemePlaylistModal({
allThemes?.map((miniTheme: Theme) => { allThemes?.map((miniTheme: Theme) => {
const newThemeList = themeList; const newThemeList = themeList;
return ( return (
<Group <ThemePreviewMiddleware
key={miniTheme.id} key={miniTheme.id}
style={{ newThemeList={newThemeList}
cursor: 'pointer', miniTheme={miniTheme}
filter: themeList={themeList}
newThemeList && !newThemeList?.includes(miniTheme.id)
? 'saturate(0)'
: undefined,
}}
onClick={() => {
const newSelectedPlaylist = { ...selectedPlaylist };
if (themeList?.includes(miniTheme.id)) {
newThemeList.splice(themeList.indexOf(miniTheme.id), 1);
} else {
newThemeList.push(miniTheme.id);
}
newSelectedPlaylist.themeList = JSON.stringify(newThemeList);
setSelectedPlaylist(newSelectedPlaylist);
}}
>
<ThemeMiniCard
allThemes={allThemes} allThemes={allThemes}
item={Number(miniTheme.id)} selectedPlaylist={selectedPlaylist}
setSelectedPlaylist={setSelectedPlaylist}
/> />
</Group>
); );
})} })}
</SimpleGrid> </SimpleGrid>

View File

@@ -68,6 +68,7 @@ function ThemePlaylists() {
setIsLoading(false); setIsLoading(false);
} }
}, [themePlaylistData, isThemePlaylistDataFetched, debouncedSearch]); }, [themePlaylistData, isThemePlaylistDataFetched, debouncedSearch]);
return ( return (
<Stack> <Stack>
<ThemePlaylistModal <ThemePlaylistModal
@@ -228,7 +229,10 @@ function ThemePlaylists() {
<Box> <Box>
<ThemePlaylistCard <ThemePlaylistCard
cardPlaylist={{ cardPlaylist={{
id: undefined, id:
themePlaylists?.filter(
(a: ThemePlaylist) => a.name === 'Time of Day',
)[0]?.id ?? undefined,
name: 'Time of Day', name: 'Time of Day',
default: 1, default: 1,
themeList: themeList:

View File

@@ -0,0 +1,85 @@
import { Group, Overlay, Popover } from '@mantine/core';
import { useLongPress } from '@mantine/hooks';
import { useState } from 'react';
import ThemeMiniCard from './ThemeMiniCard';
import ThemeModalContent from './ThemeModalContent';
function ThemePreviewMiddleware({
newThemeList,
miniTheme,
themeList,
allThemes,
selectedPlaylist,
setSelectedPlaylist,
}: {
newThemeList: number[];
miniTheme: any;
themeList: number[];
allThemes: any;
selectedPlaylist: any;
setSelectedPlaylist: (selectedPlaylist: any) => void;
}) {
const [pressed, setPressed] = useState<any>(false);
const handlers = useLongPress(() => {
setPressed(true);
});
return (
<Popover
key={miniTheme.id}
withArrow
opened={pressed}
{...handlers}
arrowSize={16}
transitionProps={{ duration: 200, timingFunction: 'ease' }}
>
<Popover.Target>
<Group
style={{
cursor: 'pointer',
filter:
newThemeList && !newThemeList?.includes(miniTheme.id)
? 'saturate(0)'
: undefined,
}}
onClick={() => {
if (!pressed) {
const newSelectedPlaylist = { ...selectedPlaylist };
if (themeList?.includes(miniTheme.id)) {
newThemeList.splice(themeList.indexOf(miniTheme.id), 1);
} else {
newThemeList.push(miniTheme.id);
}
newSelectedPlaylist.themeList = JSON.stringify(newThemeList);
setSelectedPlaylist(newSelectedPlaylist);
} else {
setPressed(false);
}
}}
>
<ThemeMiniCard allThemes={allThemes} item={Number(miniTheme.id)} />
</Group>
</Popover.Target>
<Popover.Dropdown
bg={'var(--mantine-color-primary-0)'}
p={0}
style={{ border: 'none' }}
>
<Overlay
w={'calc(300%)'}
h={'calc(300%)'}
pos={'absolute'}
left={'-100%'}
top={'-100%'}
zIndex={-1}
opacity={0.8}
bg={
'radial-gradient(circle, var(--mantine-color-primary-0) 0%, transparent 60%)'
}
/>
<ThemeModalContent selectedTheme={miniTheme} />
</Popover.Dropdown>
</Popover>
);
}
export default ThemePreviewMiddleware;

View File

@@ -59,9 +59,17 @@ function ThemeSelect({
textAlign: 'center', textAlign: 'center',
height: '60px', height: '60px',
color: theme?.primaryColor, color: theme?.primaryColor,
background: `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), no-repeat center url(../../api/backgroundImages/${theme?.backgroundImage})`, backgroundImage:
backgroundSize: 'cover', theme?.backgroundImage.toLocaleLowerCase() !== 'none'
backgroundColor: theme?.backgroundColor, ? `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), url(../../api/backgroundImages/${theme?.backgroundImage})`
: undefined,
backgroundSize:
theme?.backgroundImage.toLocaleLowerCase() !== 'none' ? 'cover' : undefined,
backgroundColor:
theme?.backgroundImage.toLocaleLowerCase() === 'none'
? theme?.backgroundColor
: undefined,
backgroundPosition: 'center',
border: `solid ${theme?.borderColor}`, border: `solid ${theme?.borderColor}`,
borderRadius: '8px', borderRadius: '8px',
}, },
@@ -78,9 +86,19 @@ function ThemeSelect({
w={'100%'} w={'100%'}
h={'60px'} h={'60px'}
style={{ style={{
background: `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), no-repeat center url(../../api/backgroundImages/${theme?.backgroundImage})`, backgroundImage:
backgroundSize: 'cover', theme?.backgroundImage.toLocaleLowerCase() !== 'none'
backgroundColor: theme?.backgroundColor, ? `linear-gradient(${theme?.backgroundColor}33, ${theme?.backgroundColor}33), url(../../api/backgroundImages/${theme?.backgroundImage})`
: undefined,
backgroundSize:
theme?.backgroundImage.toLocaleLowerCase() !== 'none'
? 'cover'
: undefined,
backgroundColor:
theme?.backgroundImage.toLocaleLowerCase() === 'none'
? theme?.backgroundColor
: undefined,
backgroundPosition: 'center',
border: `solid ${theme?.borderColor}`, border: `solid ${theme?.borderColor}`,
borderRadius: '8px', borderRadius: '8px',
}} }}