-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-33099) feat(venueMap): filter header v2
- Loading branch information
1 parent
136044b
commit fa6566e
Showing
8 changed files
with
183 additions
and
71 deletions.
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
40 changes: 40 additions & 0 deletions
40
src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.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,40 @@ | ||
import React from 'react' | ||
import styled from 'styled-components/native' | ||
|
||
import { FILTER_BANNER_HEIGHT } from 'features/venueMap/constant' | ||
import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag' | ||
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types' | ||
import { useGetHeaderHeight } from 'ui/components/headers/PageHeaderWithoutPlaceholder' | ||
import { getSpacing } from 'ui/theme' | ||
|
||
import { FilterCategoriesBannerContainer } from './FilterCategoriesBannerContainer' | ||
import { SingleFilterBannerContainer } from './SingleFilterBannerContainer' | ||
|
||
export const FilterBannerContainer = () => { | ||
const headerHeight = useGetHeaderHeight() | ||
|
||
const filterCategoriesActive = useFeatureFlag( | ||
RemoteStoreFeatureFlags.WIP_VENUE_MAP_TYPE_FILTER_V2 | ||
) | ||
|
||
return ( | ||
<Container headerHeight={headerHeight}> | ||
{filterCategoriesActive ? ( | ||
<FilterCategoriesBannerContainer /> | ||
) : ( | ||
<SingleFilterBannerContainer /> | ||
)} | ||
</Container> | ||
) | ||
} | ||
|
||
const Container = styled.View<{ headerHeight: number }>(({ headerHeight }) => ({ | ||
height: FILTER_BANNER_HEIGHT, | ||
position: 'absolute', | ||
zIndex: 1, | ||
top: headerHeight, | ||
left: 0, | ||
right: 0, | ||
paddingHorizontal: getSpacing(6), | ||
paddingVertical: getSpacing(1), | ||
})) |
70 changes: 70 additions & 0 deletions
70
src/features/venueMap/components/FilterBannerContainer/FilterCategoriesBannerContainer.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,70 @@ | ||
import colorAlpha from 'color-alpha' | ||
import React from 'react' | ||
import LinearGradient from 'react-native-linear-gradient' | ||
import styled from 'styled-components/native' | ||
|
||
import { FilterButton } from 'features/search/components/Buttons/FilterButton/FilterButton' | ||
import { SingleFilterButton } from 'features/search/components/Buttons/SingleFilterButton/SingleFilterButton' | ||
import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant' | ||
import { useVenueMapFilters } from 'features/venueMap/hook/useVenueMapFilters' | ||
import { theme } from 'theme' | ||
import { getSpacing } from 'ui/theme' | ||
|
||
const BULLET_SIZE = 12 | ||
|
||
type FilterGroupKey = keyof typeof FILTERS_VENUE_TYPE_MAPPING | ||
|
||
type FilterGroupData = { | ||
id: FilterGroupKey | ||
label: string | ||
color: string | ||
} | ||
const filterGroups: FilterGroupData[] = [ | ||
{ id: 'OUTINGS', label: 'Sorties', color: theme.colors.coral }, | ||
{ id: 'SHOPS', label: 'Boutiques', color: theme.colors.primary }, | ||
{ id: 'OTHERS', label: 'Autres', color: theme.colors.skyBlue }, | ||
] | ||
|
||
export const FilterCategoriesBannerContainer = () => { | ||
const { getSelectedMacroFilters, addMacroFilter, removeMacroFilter } = useVenueMapFilters() | ||
|
||
const selectedGroups = getSelectedMacroFilters() | ||
|
||
const handleCategoryPress = (categoryId: FilterGroupKey) => { | ||
if (selectedGroups.includes(categoryId)) { | ||
removeMacroFilter(categoryId) | ||
} else { | ||
addMacroFilter(categoryId) | ||
} | ||
} | ||
|
||
return ( | ||
<Container> | ||
<FilterButton /> | ||
{filterGroups.map(({ color, id, label }) => ( | ||
<SingleFilterButton | ||
key={id} | ||
testID={id} | ||
icon={<ColoredGradientBullet color={color} />} | ||
label={label} | ||
isSelected={selectedGroups.includes(id)} | ||
onPress={() => handleCategoryPress(id)} | ||
/> | ||
))} | ||
</Container> | ||
) | ||
} | ||
|
||
const Container = styled.View({ | ||
flexDirection: 'row', | ||
columnGap: getSpacing(1), | ||
}) | ||
|
||
const ColoredGradientBullet = styled(LinearGradient).attrs(({ color }: { color: string }) => ({ | ||
colors: [color, colorAlpha(color, 0.7)], | ||
}))<{ color: string }>({ | ||
backgroundColor: 'black', | ||
width: BULLET_SIZE, | ||
height: BULLET_SIZE, | ||
borderRadius: BULLET_SIZE * 0.5, | ||
}) |
57 changes: 57 additions & 0 deletions
57
src/features/venueMap/components/FilterBannerContainer/SingleFilterBannerContainer.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,57 @@ | ||
import React from 'react' | ||
import styled from 'styled-components/native' | ||
|
||
import { SingleFilterButton } from 'features/search/components/Buttons/SingleFilterButton/SingleFilterButton' | ||
import { getVenueTypeLabel } from 'features/venueMap/helpers/getVenueTypeLabel/getVenueTypeLabel' | ||
import { VenueTypeModal } from 'features/venueMap/pages/modals/VenueTypeModal/VenueTypeModal' | ||
import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore' | ||
import { ellipseString } from 'shared/string/ellipseString' | ||
import { Li } from 'ui/components/Li' | ||
import { useModal } from 'ui/components/modals/useModal' | ||
import { Ul } from 'ui/components/Ul' | ||
import { Check } from 'ui/svg/icons/Check' | ||
import { getSpacing } from 'ui/theme' | ||
|
||
const MAX_VENUE_CHARACTERS = 20 | ||
|
||
export const SingleFilterBannerContainer = () => { | ||
const venueTypeCode = useVenueTypeCode() | ||
const venueTypeLabel = getVenueTypeLabel(venueTypeCode) ?? 'Tous les lieux' | ||
|
||
const { | ||
visible: venueTypeModalVisible, | ||
showModal: showVenueTypeModal, | ||
hideModal: hideVenueTypeModal, | ||
} = useModal(false) | ||
|
||
return ( | ||
<React.Fragment> | ||
<StyledUl> | ||
<StyledLi> | ||
<SingleFilterButton | ||
label={ellipseString(venueTypeLabel, MAX_VENUE_CHARACTERS)} | ||
isSelected={venueTypeCode !== null} | ||
onPress={showVenueTypeModal} | ||
icon={venueTypeCode ? <FilterSelectedIcon /> : undefined} | ||
/> | ||
</StyledLi> | ||
</StyledUl> | ||
<VenueTypeModal hideModal={hideVenueTypeModal} isVisible={venueTypeModalVisible} /> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
const StyledUl = styled(Ul)({ | ||
alignItems: 'center', | ||
}) | ||
|
||
const StyledLi = styled(Li)({ | ||
marginLeft: getSpacing(1), | ||
marginVertical: getSpacing(1), | ||
}) | ||
|
||
const FilterSelectedIcon = styled(Check).attrs<{ testID?: string }>(({ theme, testID }) => ({ | ||
size: theme.icons.sizes.extraSmall, | ||
color: theme.colors.black, | ||
testID: testID ? `${testID}Icon` : 'filterButtonIcon', | ||
}))`` |
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