Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Страница всех категорий. Задачи 408 и 409 #418

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/entities/CategoryCard/CategoryCard.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
@use '../../shared/styles/utils/variables' as var;

.category-card {
width: 255px;
height: 183px;
width: 100%;
min-height: 183px;
padding: 5px;
border-radius: 10px;
box-sizing: border-box;
background-color: white;
display: flex;
gap: auto;
flex-direction: column;
justify-content: space-between;
cursor: pointer;
transition: transform 0.3s;

&:hover {
transform: scale(1.05);
}
}

.category-card__img {
Expand Down
23 changes: 17 additions & 6 deletions src/entities/CategoryCard/CategoryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { FC } from 'react'
import { type FC } from 'react'
import { useNavigate } from 'react-router'

import { TCategory } from '@/shared/model/types/CategoryModel'
import defaultCard from '@/assets/images/categoryCards/placeholder-1200x800.png'
import { Routes } from '@/shared/config/routerConfig/routes'
import type { TCategory } from '@/shared/model/types/CategoryModel'
import Paragraph from '@/shared/ui/Paragraph/Paragraph'

import card1 from '../../assets/images/categoryCards/placeholder-1200x800.png'

import styles from './CategoryCard.module.scss'

interface CategoryCardProps {
category: TCategory
}

export const CategoryCard: FC<CategoryCardProps> = ({ category }) => {
const navigate = useNavigate()

const clickHandle = () => {
navigate(`${Routes.CATEGORIES}/${category.slug}?id=${category.id}`)
}

return (
<div className={styles['category-card']}>
<div className={styles['category-card']} onClick={clickHandle}>
{category && (
<>
<img src={category.image || card1} alt={category.name} className={styles['category-card__img']} />
<img
src={category.image || defaultCard}
alt={category.name}
className={styles['category-card__img']}
/>
<Paragraph className={styles['category-card__text']}>{category.name}</Paragraph>
</>
)}
Expand Down
21 changes: 0 additions & 21 deletions src/entities/CategoryCard/getCategoryCard.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/entities/CategoryCard/types.tsx

This file was deleted.

8 changes: 6 additions & 2 deletions src/pages/CategoryPage/CategoryPage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

.category-page {
width: 100%;
margin-left: 15px;
}

.category-page__title {
margin-top: 24px;
margin-bottom: 10px;
font-size: 25px;
line-height: 1.15;
}

.category-page__nav {
Expand All @@ -17,5 +18,8 @@
}

.category-page__subtiitle {
margin-bottom: 30px;
margin: 30px 0;
color: var.$black;
font-size: 20px;
line-height: 1.15;
}
26 changes: 15 additions & 11 deletions src/pages/CategoryPage/CategoryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import Breadcrumbs from '@/shared/ui/Breadcrumbs/Breadcrumbs'
import Heading from '@/shared/ui/Heading/Heading'
import Paragraph from '@/shared/ui/Paragraph/Paragraph'
import Subheading from '@/shared/ui/Subheading/Subheading'
import WrapperForMainContent from '@/shared/ui/WrapperForMainContent/WrapperForMainContent'
import CategoryCardList from '@/widgets/CategoryCardList/CategoryCardList'
import NavigationLink from '@/widgets/NavigationLink/NavigationLink'

import styles from './CategoryPage.module.scss'

const links = [
{ heading: 'Главная', href: '/' },
{ heading: 'Все категории', href: '' }
]

/**
* Страница всех категорий
*/

export const CategoryPage = () => {
return (
<div className={styles['category-page']}>
<Heading className={styles['category-page__title']}>Все категории</Heading>
<div className={styles['category-page__nav']}>
<NavigationLink label={'Главная'} to={'/'} />
<Paragraph> / Все категории</Paragraph>
<WrapperForMainContent>
<div className={styles['category-page']}>
<Heading className={styles['category-page__title']}>Все категории</Heading>
<Breadcrumbs links={links} />
<Subheading className={styles['category-page__subtiitle']}>Категории</Subheading>
<CategoryCardList />
</div>
<Paragraph className={styles['category-page__subtiitle']}>Категории</Paragraph>
<CategoryCardList />
</div>
</WrapperForMainContent>
)
}
18 changes: 9 additions & 9 deletions src/widgets/CategoryCardList/CategoryCardList.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.categoryCardList{
margin-right: 24px;
display: grid;
justify-content: center;
row-gap: 19px;
column-gap: 19px;
grid-template-columns: repeat(auto-fit, 255px);
margin-bottom: 115px;
}
.categoryCardList {
margin-top: 24px;
display: grid;
justify-content: space-between;
row-gap: 19px;
column-gap: 19px;
grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
margin-bottom: 115px;
}
Loading