-
Notifications
You must be signed in to change notification settings - Fork 582
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: add medium filtering to saved seaches #9412
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
dd9bbb1
feat: create new artwork filter store
MounirDhahri 8330a12
minor: separate filter data type
MounirDhahri 987325e
feat: add filters screen wrapper
MounirDhahri a15f610
feat: prepare your filters section
MounirDhahri bd8ea4c
refactor: move screen to savesearches directory
MounirDhahri efcd1c2
feat: wrap the screen with the new artwork filters store
MounirDhahri bf3f410
feat: add rarity filter functionality
MounirDhahri 766b98b
chore: improve UX of selecting pills 👌
MounirDhahri fb02385
chore: add rarity options tests
MounirDhahri f948d37
chore: minor integrity test improvement
MounirDhahri 50542ae
fix: useDebounce logic in pill
MounirDhahri 555932f
feat: display the applied filters on your filters
MounirDhahri 80217a9
feat: add remove filter action
MounirDhahri b958bec
chore: add note to make sure to implement clear all
MounirDhahri 1e657fe
feat: add your filters tests
MounirDhahri 7101256
feat: add clear all button
MounirDhahri df88d10
chore: add subtle animations: bring the screen to life
MounirDhahri b7b6c5d
fix: revert disabled logic in clear all button
MounirDhahri 2e664bc
chore: remove commented line
MounirDhahri 4db98f6
chore: remove unused fields from store
MounirDhahri 1f8cb9a
refact: use SavedSearchStore for ClearAllButton
MounirDhahri f6b898c
refactor: update Applied fitlers to use SavedSearchStore
MounirDhahri ad7cd74
chore: do not allow artistIDs pills removal
MounirDhahri c03631d
chore: do not count artistIDs for clear all button counts
MounirDhahri 05c067c
refactor: use SavedSearchStoreProvider for rarity
MounirDhahri 3cce67e
refactor: remove new filters store
MounirDhahri f53e10f
fix: rarity filter test
MounirDhahri 37e040e
chore: address review comments
MounirDhahri 806b9a4
feat: add saved searches categories filter
MounirDhahri 9753ed9
fix: remove console.log
MounirDhahri 730e11b
chore: update tests
MounirDhahri a8df6ae
chore: make value less case sensitive
MounirDhahri 5dada65
fix: test
MounirDhahri 75cc6a5
chore: fix broken tests due to mismatching mediums
MounirDhahri 338c007
chore: adjust mediums
MounirDhahri d07c129
chore: update list of mediums
MounirDhahri 0a0134f
fix: broken tests
MounirDhahri 2606035
refactor: move gravity mediums to the same folder as my collection me…
MounirDhahri e0d9b42
refactor: update test names
MounirDhahri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/app/Scenes/SavedSearchAlert/Components/SavedSearchFilterAdditionalGeneIDs.tests.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { OwnerType } from "@artsy/cohesion" | ||
import { fireEvent, waitFor } from "@testing-library/react-native" | ||
import { SavedSearchFilterAdditionalGeneIDs } from "app/Scenes/SavedSearchAlert/Components/SavedSearchFilterAdditionalGeneIDs" | ||
import { | ||
SavedSearchModel, | ||
SavedSearchStoreProvider, | ||
savedSearchModel, | ||
} from "app/Scenes/SavedSearchAlert/SavedSearchStore" | ||
import { gravityArtworkMediumCategories } from "app/utils/artworkMediumCategories" | ||
import { renderWithWrappers } from "app/utils/tests/renderWithWrappers" | ||
|
||
const black100Hex = "#000000" | ||
|
||
describe("SavedSearchFilterAdditionalGeneIDs", () => { | ||
it("shows all available categories unselected", () => { | ||
const { getByText } = renderWithWrappers( | ||
<SavedSearchStoreProvider runtimeModel={initialData}> | ||
<SavedSearchFilterAdditionalGeneIDs /> | ||
</SavedSearchStoreProvider> | ||
) | ||
|
||
gravityArtworkMediumCategories.slice(0, 7).forEach((option) => { | ||
expect(getByText(option.label)).toBeDefined() | ||
expect(getByText(option.label)).toHaveStyle({ | ||
color: black100Hex, | ||
}) | ||
}) | ||
}) | ||
|
||
it("shows the right selected categories", () => { | ||
const { getByText } = renderWithWrappers( | ||
<SavedSearchStoreProvider | ||
runtimeModel={{ ...initialData, attributes: { additionalGeneIDs: ["painting"] } }} | ||
> | ||
<SavedSearchFilterAdditionalGeneIDs /> | ||
</SavedSearchStoreProvider> | ||
) | ||
|
||
gravityArtworkMediumCategories.slice(0, 7).forEach((option) => { | ||
if (option.value === "Painting") { | ||
expect(getByText("Painting")).not.toHaveStyle({ color: black100Hex }) | ||
} else { | ||
expect(getByText(option.label)).toBeDefined() | ||
expect(getByText(option.label)).toHaveStyle({ | ||
color: black100Hex, | ||
}) | ||
} | ||
}) | ||
}) | ||
|
||
it("Updates selected categories filters on press", () => { | ||
const { getByText } = renderWithWrappers( | ||
<SavedSearchStoreProvider runtimeModel={initialData}> | ||
<SavedSearchFilterAdditionalGeneIDs /> | ||
</SavedSearchStoreProvider> | ||
) | ||
|
||
expect(getByText("Work on Paper")).toHaveStyle({ color: black100Hex }) | ||
|
||
fireEvent(getByText("Work on Paper"), "onPress") | ||
|
||
waitFor(() => { | ||
expect(getByText("Work on Paper")).not.toHaveStyle({ color: black100Hex }) | ||
}) | ||
}) | ||
}) | ||
|
||
const initialData: SavedSearchModel = { | ||
...savedSearchModel, | ||
attributes: { | ||
atAuction: true, | ||
}, | ||
entity: { | ||
artists: [{ id: "artistID", name: "Banksy" }], | ||
owner: { | ||
type: OwnerType.artist, | ||
id: "ownerId", | ||
slug: "ownerSlug", | ||
}, | ||
}, | ||
} |
106 changes: 106 additions & 0 deletions
106
src/app/Scenes/SavedSearchAlert/Components/SavedSearchFilterAdditionalGeneIDs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Flex, Spacer, Text } from "@artsy/palette-mobile" | ||
import { SearchCriteria } from "app/Components/ArtworkFilter/SavedSearch/types" | ||
import { SavedSearchFilterPill } from "app/Scenes/SavedSearchAlert/Components/SavedSearchFilterPill" | ||
import { SavedSearchStore } from "app/Scenes/SavedSearchAlert/SavedSearchStore" | ||
import { isValueSelected, useSearchCriteriaAttributes } from "app/Scenes/SavedSearchAlert/helpers" | ||
import { gravityArtworkMediumCategories } from "app/utils/artworkMediumCategories" | ||
import { useState } from "react" | ||
import { LayoutAnimation, TouchableOpacity } from "react-native" | ||
|
||
export const SavedSearchFilterAdditionalGeneIDs = () => { | ||
const [showAll, setShowAll] = useState(false) | ||
|
||
const selectedAttributes = useSearchCriteriaAttributes( | ||
SearchCriteria.additionalGeneIDs | ||
) as string[] | ||
|
||
const setValueToAttributesByKeyAction = SavedSearchStore.useStoreActions( | ||
(actions) => actions.setValueToAttributesByKeyAction | ||
) | ||
const removeValueFromAttributesByKeyAction = SavedSearchStore.useStoreActions( | ||
(actions) => actions.removeValueFromAttributesByKeyAction | ||
) | ||
|
||
const handlePress = (value: string) => { | ||
const isSelected = isValueSelected({ | ||
selectedAttributes, | ||
value: value, | ||
}) | ||
|
||
if (isSelected) { | ||
removeValueFromAttributesByKeyAction({ | ||
key: SearchCriteria.additionalGeneIDs, | ||
value: value, | ||
}) | ||
} else { | ||
const newValues = (selectedAttributes || []).concat(value) | ||
setValueToAttributesByKeyAction({ | ||
key: SearchCriteria.additionalGeneIDs, | ||
value: newValues, | ||
}) | ||
} | ||
} | ||
|
||
return ( | ||
<Flex px={2}> | ||
<Text variant="sm" fontWeight={500}> | ||
Medium | ||
</Text> | ||
<Spacer y={1} /> | ||
<Flex flexDirection="row" flexWrap="wrap"> | ||
{gravityArtworkMediumCategories.slice(0, 7).map((option) => { | ||
return ( | ||
<SavedSearchFilterPill | ||
key={option.value as string} | ||
accessibilityLabel={option.label} | ||
selected={isValueSelected({ | ||
selectedAttributes, | ||
value: option.value, | ||
})} | ||
onPress={() => { | ||
handlePress(option.value as string) | ||
}} | ||
> | ||
{option.label} | ||
</SavedSearchFilterPill> | ||
) | ||
})} | ||
|
||
{showAll | ||
? gravityArtworkMediumCategories | ||
.slice(7, gravityArtworkMediumCategories.length) | ||
.map((option) => { | ||
return ( | ||
<SavedSearchFilterPill | ||
key={option.value as string} | ||
accessibilityLabel={option.label} | ||
selected={isValueSelected({ | ||
selectedAttributes, | ||
value: option.value, | ||
})} | ||
onPress={() => { | ||
handlePress(option.value as string) | ||
}} | ||
> | ||
{option.label} | ||
</SavedSearchFilterPill> | ||
) | ||
}) | ||
: null} | ||
|
||
<TouchableOpacity | ||
onPress={() => { | ||
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) | ||
setShowAll(!showAll) | ||
}} | ||
> | ||
<Flex height={50} justifyContent="center"> | ||
<Text variant="xs" color="blue100"> | ||
Show {showAll ? "less" : "more"} | ||
</Text> | ||
</Flex> | ||
</TouchableOpacity> | ||
</Flex> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
💯