-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(FilterBlock): add block that filters its subblocks #180
Conversation
Preview is ready. |
src/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.tsx
Outdated
Show resolved
Hide resolved
Typecheck failed |
9bab2fd
to
a3b752e
Compare
&__title { | ||
margin-bottom: $indentSM; | ||
|
||
@include centerableTitle(); |
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.
we are trying to use kebab-notation for css mixins
import './FilterBlock.scss'; | ||
|
||
const b = block('filter-block'); | ||
const DEFAULT_ALL_TAG_TITLE = 'All'; |
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.
need to use i18n with text strings like this
: undefined; | ||
const otherButtons: ButtonTabsItemProps[] | undefined = | ||
filterTags && filterTags.map((tag) => ({id: tag.id, title: tag.label})); | ||
return [...(allButton ? [allButton] : []), ...(otherButtons ? otherButtons : [])]; |
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.
allButton ?? : []
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.
Unfortunately cannot change this line as suggested, because we merge here two arrays to omit nulls in final array. Replacing ternary operator with the ?? operator because in this case type of result wont be an array.
return [...(allButton ? [allButton] : []), ...(otherButtons ? otherButtons : [])]; | ||
}, [allTag, filterTags]); | ||
|
||
const [selectedTag, setSelectedTag] = useState(tabButtons.length ? tabButtons[0].id : null); |
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.
can we return null
if there is no tabButtons
to avoid checking it's length below?
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.
Yes we can, but it will make the body of the memo more complex, I believe it's better to leave it as is.
|
||
const [selectedTag, setSelectedTag] = useState(tabButtons.length ? tabButtons[0].id : null); | ||
|
||
const actualTag: string | null = useMemo(() => { |
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.
Didn't catch why do we need this variable? I think selectedTag
is enough, isn't it?
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.
Let's assume that we have 3 ids, 'A', 'B', 'C'. ` We change the value of selected tag to 'C', then remove 'C' from our id list. In this case we should choose a new id to display. The actualTag is this new selected value, or the selectedTag if it still exists.
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.
But how can we reproduce this situation? We don't have multiple tags choice or an opportunity to let no tags be selected
export interface FilterBlockProps extends Animatable, LoadableChildren { | ||
title?: TitleProps | string; | ||
description?: string; | ||
filterTags: FilterTag[]; |
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.
could it be just tags
? filterTags sounds like function name
description?: string; | ||
filterTags: FilterTag[]; | ||
items: FilterItem[]; | ||
tagSize?: ButtonSize; |
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.
tabSize
?
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.
There is no entity named tabs in the block. Maybe buttonSize?
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.
tagButtonSize
=)
blockTypes: [...BlockTypes, ...getCustomBlockTypes(props.custom)], | ||
blockTypes: [...BlockTypes, ...getCustomBlockTypes(custom)], | ||
subBlockTypes: [...SubBlockTypes, ...getCustomSubBlockTypes(custom)], | ||
headerBlockTypes: [...HeaderBlockTypes, ...getCustomHeaderTypes(custom)], |
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.
why do we need subBlockTypes
and headerBlockTypes
in context?
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.
consistency of props of the context and return values of the memo. Avoid returning of same instances differently. In context and outside it.
@@ -32,7 +32,8 @@ import { | |||
} from './common'; | |||
import {ThemeSupporting} from '../../utils'; | |||
import {GridColumnSize, GridColumnSizesType} from '../../grid/types'; | |||
import {BannerCardProps, SubBlock} from './sub-blocks'; | |||
import {BannerCardProps, SubBlock, SubBlockModels} from './sub-blocks'; | |||
import {ButtonSize} from '@gravity-ui/uikit'; |
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.
upper than internal imports
@@ -178,6 +178,7 @@ export interface ButtonProps { | |||
metrikaGoals?: MetrikaGoal; | |||
pixelEvents?: ButtonPixel; | |||
target?: string; | |||
selected?: boolean; |
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.
Why do we need to add this?
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.
Sorry, did not removed after testing one possible solution. Done.
|
||
const [selectedTag, setSelectedTag] = useState(tabButtons.length ? tabButtons[0].id : null); | ||
|
||
const actualTag: string | null = useMemo(() => { |
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.
But how can we reproduce this situation? We don't have multiple tags choice or an opportunity to let no tags be selected
description?: string; | ||
filterTags: FilterTag[]; | ||
items: FilterItem[]; | ||
tagSize?: ButtonSize; |
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.
tagButtonSize
=)
5e69b84
to
b570dce
Compare
No description provided.