Skip to content

Commit

Permalink
Merge pull request #2372 from Plant-for-the-Planet-org/develop
Browse files Browse the repository at this point in the history
Release hotfix intervention filter
  • Loading branch information
mariahosfeld authored Jan 17, 2025
2 parents dd4a11f + 420384a commit 3973092
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ $layoutPaddingSide: 20px;
gap: 18px;
position: absolute;
z-index: 2;
top: calc($layoutPaddingTop + 70px);
right: calc($layoutPaddingSide + 10px);
}

.dropdownButtonAlignmentAbove {
top: calc($layoutPaddingTop + 75px);
}

.dropdownButtonAlignmentBelow {
top: calc($layoutPaddingTop + 10px);
}

.interventionIconAndTextContainer {
display: flex;
gap: 6px;
Expand Down Expand Up @@ -62,8 +70,7 @@ $layoutPaddingSide: 20px;
font-size: $fontXSmall;
position: absolute;
z-index: 4;
top: 140px;
right: 30px;
right: 30px;
max-height: 42vh;
overflow-y: auto;
scrollbar-width: none; /* Firefox */
Expand All @@ -75,6 +82,15 @@ $layoutPaddingSide: 20px;
width: 100%;
}
}

.interventionListOptionsAbove {
top: calc($layoutPaddingTop + 60px);
}

.interventionListOptionsBelow {
top: calc($layoutPaddingTop + 124px);
}

.listItem {
display: flex;
justify-content: space-between;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ interface InterventionListProps {
setSelectedInterventionType: SetState<INTERVENTION_TYPE>;
setIsMenuOpen: SetState<boolean>;
selectedInterventionData: InterventionData | undefined;
hasProjectSites?: boolean
}
const InterventionList = ({
interventionList,
setSelectedInterventionType,
setIsMenuOpen,
selectedInterventionData,
hasProjectSites
}: InterventionListProps) => {
const tProjectDetails = useTranslations("ProjectDetails.intervention");
const handleFilterSelection = (key: INTERVENTION_TYPE) => {
Expand All @@ -28,19 +30,19 @@ const InterventionList = ({
};

return (
<ul className={styles.interventionListOptions}>
<ul className={`${styles.interventionListOptions} ${!hasProjectSites ? styles.interventionListOptionsAbove : styles.interventionListOptionsBelow}`}>
{interventionList.map((intervention, index) => {
return (
<li
className={`${styles.listItem} ${intervention.value === selectedInterventionData?.value
? styles.selectedItem
: ''
? styles.selectedItem
: ''
}`}
onClick={() => handleFilterSelection(intervention.value)}
key={index}
>
<p>
{tProjectDetails(intervention.value)}
{tProjectDetails(intervention.value)}
</p>
</li>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Props {
isMobile?: boolean;
enableInterventionFilter: () => void;
disableInterventionMenu: boolean;
hasProjectSites?: boolean
}

const InterventionDropdown = ({
Expand All @@ -32,9 +33,10 @@ const InterventionDropdown = ({
enableInterventionFilter,
disableInterventionMenu,
isMobile,
hasProjectSites
}: Props) => {
const tIntervention = useTranslations('ProjectDetails.intervention');

const [isMenuOpen, setIsMenuOpen] = useState(false);
const interventionList = useMemo(() => {
if (!allInterventions) return [];
Expand All @@ -59,7 +61,7 @@ const InterventionDropdown = ({
};
return (
<>
<div className={styles.dropdownButton} onClick={toggleMenu}>
<div className={`${styles.dropdownButton} ${hasProjectSites ? styles.dropdownButtonAlignmentAbove : styles.dropdownButtonAlignmentBelow}`} onClick={toggleMenu}>
<div className={styles.interventionIconAndTextContainer}>
<InterventionIcon />
<>
Expand All @@ -75,7 +77,7 @@ const InterventionDropdown = ({
style={{ marginTop: '5px' }}
>
{truncateString(tIntervention(interventionData?.value), 40)}
</p>
</p>
)}
</div>
)}
Expand All @@ -95,6 +97,7 @@ const InterventionDropdown = ({
setSelectedInterventionType={setSelectedInterventionType}
setIsMenuOpen={setIsMenuOpen}
selectedInterventionData={interventionData}
hasProjectSites={hasProjectSites}
/>
)}
</>
Expand Down
39 changes: 17 additions & 22 deletions src/features/projectsV2/ProjectsMap/MapControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ const MapControls = ({
setSelectedMode && setSelectedMode('list');
};

const layerToggleClass = `${styles.layerToggle} ${
isMobile
? mobileOS === 'android'
? styles.layerToggleAndroid
: styles.layerToggleIos
: styles.layerToggleDesktop
}`;
const layerToggleClass = `${styles.layerToggle} ${isMobile
? mobileOS === 'android'
? styles.layerToggleAndroid
: styles.layerToggleIos
: styles.layerToggleDesktop
}`;

return (
<>
Expand All @@ -132,15 +131,14 @@ const MapControls = ({
<>
{isMobile ? (
<div className={styles.projectDetailsControlsContainer}>
{hasProjectSites && (
<>
<ProjectSiteDropdown {...siteDropdownProps} />
<InterventionDropDown
{...interventionDropDownProps}
isMobile={isMobile}
/>
</>
)}
{hasProjectSites &&
<ProjectSiteDropdown {...siteDropdownProps} />
}
<InterventionDropDown
{...interventionDropDownProps}
isMobile={isMobile}
hasProjectSites={hasProjectSites}
/>
<button
className={styles.exitMapModeButton}
onClick={exitMapMode}
Expand All @@ -150,12 +148,9 @@ const MapControls = ({
</div>
) : (
<>
{hasProjectSites && (
<>
<ProjectSiteDropdown {...siteDropdownProps} />
<InterventionDropDown {...interventionDropDownProps} />
</>
)}
{hasProjectSites && <ProjectSiteDropdown {...siteDropdownProps} />}
<InterventionDropDown {...interventionDropDownProps} hasProjectSites={hasProjectSites}
/>
</>
)}
{canShowSatelliteToggle && (
Expand Down

0 comments on commit 3973092

Please sign in to comment.