chore: refine bookmarking

This commit is contained in:
Ibrahima G. Coulibaly
2025-07-15 14:01:38 +01:00
parent afc61e6f4c
commit 1031db7ed2
4 changed files with 47 additions and 37 deletions

View File

@@ -23,6 +23,7 @@ import {
isBookmarked, isBookmarked,
toggleBookmarked toggleBookmarked
} from '@utils/bookmark'; } from '@utils/bookmark';
import IconButton from '@mui/material/IconButton';
const GroupHeader = styled('div')(({ theme }) => ({ const GroupHeader = styled('div')(({ theme }) => ({
position: 'sticky', position: 'sticky',
@@ -167,13 +168,15 @@ export default function Hero() {
</Typography> </Typography>
</Box> </Box>
</Stack> </Stack>
<Icon <IconButton
fontSize={20}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
toggleBookmarked(option.path); toggleBookmarked(option.path);
setBookmarkedToolPaths(getBookmarkedToolPaths()); setBookmarkedToolPaths(getBookmarkedToolPaths());
}} }}
>
<Icon
fontSize={20}
color={ color={
isBookmarked(option.path) isBookmarked(option.path)
? theme.palette.primary.main ? theme.palette.primary.main
@@ -185,6 +188,7 @@ export default function Hero() {
: 'mdi:bookmark-plus-outline' : 'mdi:bookmark-plus-outline'
} }
/> />
</IconButton>
</Stack> </Stack>
</Box> </Box>
)} )}
@@ -194,9 +198,6 @@ export default function Hero() {
} }
}} }}
/> />
{bookmarkedToolPaths.length > 0 && (
<Typography fontSize={{ xs: 20, md: 25 }}>Bookmarked tools:</Typography>
)}
<Grid container spacing={2} mt={2}> <Grid container spacing={2} mt={2}>
{displayedTools.map((tool) => ( {displayedTools.map((tool) => (
<Grid <Grid
@@ -223,23 +224,28 @@ export default function Hero() {
cursor: 'pointer', cursor: 'pointer',
'&:hover': { '&:hover': {
backgroundColor: 'background.hover' backgroundColor: 'background.hover'
} },
height: '100%'
}} }}
> >
<Stack direction={'row'} spacing={2} alignItems={'center'}> <Stack direction={'row'} spacing={1} alignItems={'center'}>
<Typography>{tool.label}</Typography> <Typography textAlign={'center'}>{tool.label}</Typography>
{bookmarkedToolPaths.length > 0 && ( {bookmarkedToolPaths.length > 0 && (
<Icon <IconButton
icon={'mdi:close'}
color={theme.palette.grey[500]}
fontSize={20}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
const path = tool.url.substring(1); const path = tool.url.substring(1);
toggleBookmarked(path); toggleBookmarked(path);
setBookmarkedToolPaths(getBookmarkedToolPaths()); setBookmarkedToolPaths(getBookmarkedToolPaths());
}} }}
size={'small'}
>
<Icon
icon={'mdi:close'}
color={theme.palette.grey[500]}
fontSize={15}
/> />
</IconButton>
)} )}
</Stack> </Stack>
</Box> </Box>

View File

@@ -8,6 +8,7 @@ import { categoriesColors } from '../config/uiConfig';
import { getToolsByCategory } from '@tools/index'; import { getToolsByCategory } from '@tools/index';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { isBookmarked, toggleBookmarked } from '@utils/bookmark'; import { isBookmarked, toggleBookmarked } from '@utils/bookmark';
import IconButton from '@mui/material/IconButton';
const StyledButton = styled(Button)(({ theme }) => ({ const StyledButton = styled(Button)(({ theme }) => ({
backgroundColor: 'white', backgroundColor: 'white',
@@ -107,6 +108,12 @@ export default function ToolHeader({
<Typography mb={2} fontSize={30} color={'primary'}> <Typography mb={2} fontSize={30} color={'primary'}>
{title} {title}
</Typography> </Typography>
<IconButton
onClick={(e) => {
toggleBookmarked(path);
setBookmarked(!bookmarked);
}}
>
<Icon <Icon
fontSize={30} fontSize={30}
color={ color={
@@ -114,12 +121,9 @@ export default function ToolHeader({
? theme.palette.primary.main ? theme.palette.primary.main
: theme.palette.grey[500] : theme.palette.grey[500]
} }
onClick={(e) => {
toggleBookmarked(path);
setBookmarked(!bookmarked);
}}
icon={bookmarked ? 'mdi:bookmark' : 'mdi:bookmark-plus-outline'} icon={bookmarked ? 'mdi:bookmark' : 'mdi:bookmark-plus-outline'}
/> />
</IconButton>
</Stack> </Stack>
<Typography fontSize={20}>{description}</Typography> <Typography fontSize={20}>{description}</Typography>
<ToolLinks /> <ToolLinks />

View File

@@ -14,13 +14,13 @@ export default function ToolLayout({
description, description,
icon, icon,
type, type,
path fullPath
}: { }: {
title: string; title: string;
description: string; description: string;
icon?: IconifyIcon | string; icon?: IconifyIcon | string;
type: string; type: string;
path: string; fullPath: string;
children: ReactNode; children: ReactNode;
}) { }) {
const otherCategoryTools = const otherCategoryTools =
@@ -51,7 +51,7 @@ export default function ToolLayout({
description={description} description={description}
icon={icon} icon={icon}
type={type} type={type}
path={path} path={fullPath}
/> />
{children} {children}
<Separator backgroundColor="#5581b5" margin="50px" /> <Separator backgroundColor="#5581b5" margin="50px" />

View File

@@ -74,7 +74,7 @@ export const defineTool = (
description={description} description={description}
icon={icon} icon={icon}
type={basePath} type={basePath}
path={`${basePath}/${path}`} fullPath={`${basePath}/${path}`}
> >
<Component title={name} longDescription={longDescription} /> <Component title={name} longDescription={longDescription} />
</ToolLayout> </ToolLayout>