-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enhancement 139 blog fsd #190
Changes from all commits
22f295b
14184e1
16b9099
33ee7a0
77b51bc
e47c717
6934587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Этот компонент почему остался в components? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ import styles from './blog-categories.module.scss' | |
import { FC, useMemo } from 'react' | ||
import type { PropsCategories } from '@/models/PropsBlog' | ||
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading' | ||
import Paragraph from '@/shared/ui/Paragraph/Paragraph' | ||
import { TBlogItem } from '@/models/BlogItemModel' | ||
|
||
const BlogCategories: FC<PropsCategories> = props => { | ||
const { cards, filterItems } = props | ||
const { cards } = props | ||
|
||
const cat = useMemo( | ||
() => | ||
|
@@ -15,7 +17,7 @@ const BlogCategories: FC<PropsCategories> = props => { | |
) | ||
|
||
const result: { | ||
key?: string | ||
key: string | ||
count: number | ||
}[] = [] | ||
// Create a unique list of items to loop over | ||
|
@@ -40,16 +42,24 @@ const BlogCategories: FC<PropsCategories> = props => { | |
key={item.key} | ||
className={styles.cats__item} | ||
onClick={() => { | ||
filterItems(item.key) | ||
filterCategories(item.key, cards) | ||
}}> | ||
{item.key} | ||
<p className={styles.cats__count}>{item.count}</p> | ||
<Paragraph className={styles.cats__count}>{item.count}</Paragraph> | ||
</button> | ||
) | ||
}), | ||
[[...new Set(cat)]] | ||
) | ||
|
||
const filterCategories = (curcat: string, cards: TBlogItem[]) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. эту функцию можно вынести из компонента в utils |
||
const newItems = cards.filter(newVal => { | ||
return newVal.category === curcat | ||
// comparing category for displaying data | ||
}) | ||
return newItems | ||
} | ||
|
||
return ( | ||
<div className={styles.cats}> | ||
<section className={styles.cats__container}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
К этому компоненту такой же вопрос