Skip to content

Commit

Permalink
style: continued with the creation of the favorites view and other ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
Franqsanz committed Sep 2, 2024
1 parent c78caa2 commit 3e2746e
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/components/aside/AboutCategories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Box, Text } from '@chakra-ui/react';

import { aboutCategories } from '../../data/links';
import { aboutCategories } from '../../constant/constants';

export function AboutCategories({ category }: any) {
const filteredAboutCategories = aboutCategories.filter((item) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/FormEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { BiImageAdd } from 'react-icons/bi';
import { FaCheckCircle } from 'react-icons/fa';
import { IoWarningSharp } from 'react-icons/io5';

import { categories, formats, languages } from '../../data/links';
import { categories, formats, languages } from '../../constant/constants';
import { BookType, MyChangeEvent } from '@components/types';
import { useUpdateBook } from '@hooks/queries';
import { ModalCropper } from '@components/modals/ModalCropper';
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/NewBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { BiImageAdd } from 'react-icons/bi';
import { FaCheckCircle } from 'react-icons/fa';
import { IoWarningSharp } from 'react-icons/io5';

import { categories, formats, languages } from '../../data/links';
import { categories, formats, languages } from '../../constant/constants';
import { BookType, MyChangeEvent } from '@components/types';
import { useMutatePost, useCheckUser } from '@hooks/queries';
import { ModalCropper } from '@components/modals/ModalCropper';
Expand Down Expand Up @@ -180,7 +180,7 @@ export function FormNewBook() {
} else if (error) {
myToast({
title: 'Ha ocurrido un error',
description: 'No se ha podido guardar las modificaciones.',
description: 'No se ha podido realizar la publicación.',
icon: IoWarningSharp,
iconColor: 'red.400',
bgColor: 'black',
Expand Down
41 changes: 23 additions & 18 deletions src/components/nav/DesktopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useDisclosure,
} from '@chakra-ui/react';

import { navLink, accountLinks } from '../../data/links';
import { navLink, accountLinks } from '../../constant/constants';
import { MenuProfile } from '@components/nav/menu/MenuProfile';
import { InputSearch } from '@components/forms/filters/InputSearch';
import { ModalFilter } from '@components/modals/ModalFilter';
Expand Down Expand Up @@ -100,23 +100,28 @@ export function DesktopNav() {
</Box>
<Box>
<List display='flex' alignItems='center'>
{navLink.map(({ name, href }) => (
<ListItem key={name}>
<Link
as={NavLink}
to={href as string}
ml='7'
fontWeight='medium'
_activeLink={{
borderBottom: '2px',
borderColor: 'green.500',
}}
_hover={{ color: 'green.500' }}
>
{name}
</Link>
</ListItem>
))}
{navLink
.filter(({ name }) => {
if (name === 'Mis favoritos' && !data) return false;
return true;
})
.map(({ name, href }) => (
<ListItem key={name}>
<Link
as={NavLink}
to={href as string}
ml='7'
fontWeight='medium'
_activeLink={{
borderBottom: '2px',
borderColor: 'green.500',
}}
_hover={{ color: 'green.500' }}
>
{name}
</Link>
</ListItem>
))}
</List>
</Box>
</Flex>
Expand Down
51 changes: 28 additions & 23 deletions src/components/nav/MobileNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
DrawerFooter,
} from '@chakra-ui/react';

import { navLink, accountLinks } from '../../data/links';
import { navLink, accountLinks } from '../../constant/constants';
import { InputSearch } from '@components/forms/filters/InputSearch';
import { ModalFilter } from '@components/modals/ModalFilter';
import { MenuProfile } from '@components/nav/menu/MenuProfile';
Expand Down Expand Up @@ -196,28 +196,33 @@ export function MobileNav() {
<DrawerCloseButton />
<DrawerBody>
<List mt='10'>
{navLink.map(({ icon, name, href }) => (
<ListItem key={name} my='2'>
<Link
display='flex'
alignItems='center'
onClick={onCloseMenu}
as={NavLink}
to={href as string}
p='3'
rounded='xl'
fontWeight='medium'
_hover={{
bg: 'gray.700',
border: 'none',
color: 'green.500',
}}
>
<Icon as={icon} boxSize='5' mr='5' />
{name}
</Link>
</ListItem>
))}
{navLink
.filter(({ name }) => {
if (name === 'Mis favoritos' && !data) return false;
return true;
})
.map(({ icon, name, href }) => (
<ListItem key={name} my='2'>
<Link
display='flex'
alignItems='center'
onClick={onCloseMenu}
as={NavLink}
to={href as string}
p='3'
rounded='xl'
fontWeight='medium'
_hover={{
bg: 'gray.700',
border: 'none',
color: 'green.500',
}}
>
<Icon as={icon} boxSize='5' mr='5' />
{name}
</Link>
</ListItem>
))}
</List>
</DrawerBody>
<DrawerFooter
Expand Down
9 changes: 7 additions & 2 deletions src/data/links.ts → src/constant/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrHome } from 'react-icons/gr';
import { MdOutlineExplore } from 'react-icons/md';
import { MdOutlineExplore, MdOutlineFavoriteBorder } from 'react-icons/md';
import { ImEyePlus } from 'react-icons/im';
import { RiAccountCircleLine, RiLoginCircleLine } from 'react-icons/ri';

Expand All @@ -8,7 +8,12 @@ import { AboutType, LinkType, SelectBooksType } from '../components/types';
const navLink: Array<LinkType> = [
{ name: 'Inicio', href: '/', icon: GrHome },
{ name: 'Explorar', href: 'explore', icon: MdOutlineExplore },
{ name: 'Más Vistos', href: 'most-viewed', icon: ImEyePlus },
{ name: 'Más vistos', href: 'most-viewed', icon: ImEyePlus },
{
name: 'Mis favoritos',
href: 'my-favorites',
icon: MdOutlineFavoriteBorder,
},
];

const accountLinks: Array<LinkType> = [
Expand Down
88 changes: 53 additions & 35 deletions src/pages/Favorites.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { Flex } from '@chakra-ui/react';

import { useAllFavoriteByUser } from '@hooks/queries';
import { useAuth } from '@contexts/AuthContext';
Expand All @@ -7,6 +8,9 @@ import { Card } from '@components/cards/Card';
import { CardType } from '@components/types';
import { MainHead } from '@components/layout/Head';
import { ContainerTitle } from '@components/layout/ContainerTitle';
import { Aside } from '@components/aside/Aside';
import { ResultLength } from '@components/aside/ResultLength';
import { MySliderCategories } from '@components/ui/MySliderCategories';

export default function Favorites() {
const { currentUser } = useAuth();
Expand All @@ -15,41 +19,55 @@ export default function Favorites() {

return (
<>
<MainHead title='Mis Favoritos | XBuniverse' />
<ContainerTitle title='Mis Favoritos' />
<MySimpleGrid>
{data?.pages.map((page, index) => (
<React.Fragment key={index}>
{page.results.map(
({
id,
category,
language,
title,
authors,
synopsis,
sourceLink,
pathUrl,
image,
}: CardType) => (
<React.Fragment key={id}>
<Card
id={id}
category={category}
language={language}
title={title}
authors={authors}
synopsis={synopsis}
sourceLink={sourceLink}
pathUrl={pathUrl}
image={image}
/>
</React.Fragment>
),
)}
</React.Fragment>
))}
</MySimpleGrid>
<MainHead title='Mis favoritos | XBuniverse' />
<ContainerTitle title='Mis favoritos' />
<MySliderCategories />
<Flex
as='article'
direction={{ base: 'column', md: 'row' }}
maxW={{ base: '1260px', '2xl': '1560px' }}
m='0 auto'
px={{ base: 5, md: 10, '2xl': 16 }}
>
<Aside>
<ResultLength data={data?.pages[0].info.totalBooks} />
{/* {aboutCategoriesUI}
{asideFilter} */}
</Aside>
<MySimpleGrid>
{data?.pages.map((page, index) => (
<React.Fragment key={index}>
{page.results.map(
({
id,
category,
language,
title,
authors,
synopsis,
sourceLink,
pathUrl,
image,
}: CardType) => (
<React.Fragment key={id}>
<Card
id={id}
category={category}
language={language}
title={title}
authors={authors}
synopsis={synopsis}
sourceLink={sourceLink}
pathUrl={pathUrl}
image={image}
/>
</React.Fragment>
),
)}
</React.Fragment>
))}
</MySimpleGrid>
</Flex>
</>
);
}
4 changes: 2 additions & 2 deletions src/pages/MostViewed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function MostViewed() {

return (
<>
<MainHead title='Top 10 Más Vistos | XBuniverse' />
<ContainerTitle title='Top 10 Más Vistos' />
<MainHead title='Top 10 Más vistos | XBuniverse' />
<ContainerTitle title='Top 10 Más vistos' />
<MySliderCategories />
<Flex
maxW={{ base: '1070px', '2xl': '1280px' }}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { FilterDrawer } from '@components/FilterDrawer';
import { ResultLength } from '@components/aside/ResultLength';
import { AboutCategories } from '@components/aside/AboutCategories';
import { Lost } from '@assets/assets';
import { aboutCategories } from '../data/links';
import { aboutCategories } from '../constant/constants';
import { SkeletonAllBooks } from '@components/skeletons/SkeletonABooks';

export default function Search() {
Expand Down

0 comments on commit 3e2746e

Please sign in to comment.