From 3266f501c76ad656a4d85f6c5d645a47f25b1aa5 Mon Sep 17 00:00:00 2001
From: Brent Guffens <16427929+brentguf@users.noreply.github.com>
Date: Tue, 10 Dec 2024 17:30:37 +0100
Subject: [PATCH 01/18] WIP
---
.../IdeasWithFiltersSidebar/ContentRight.tsx | 31 ++--
.../app/containers/ProjectsShowPage/index.tsx | 136 +++++++++++-------
2 files changed, 104 insertions(+), 63 deletions(-)
diff --git a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
index 0de0b9451b76..b907f8f789a8 100644
--- a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
+++ b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React from 'react';
import { Title } from '@citizenlab/cl2-component-library';
import styled from 'styled-components';
@@ -7,6 +7,7 @@ import { IIdeasFilterCounts } from 'api/ideas_filter_counts/types';
import { IdeaSortMethod } from 'api/phases/types';
import { QueryParameters } from 'containers/IdeasIndexPage';
+import { useIsCTABarSticky } from 'containers/ProjectsShowPage';
import { ScreenReaderOnly } from 'utils/a11y';
import { FormattedMessage } from 'utils/cl-intl';
@@ -62,28 +63,28 @@ const ContentRight = ({
onChangeTopics,
onChangeSort,
}: Props) => {
- const [isCTABarVisible, setIsCTABarVisible] = useState(false);
+ const isCTABarSticky = useIsCTABarSticky();
- useEffect(() => {
- function checkCTABarVisibility() {
- if (document.getElementById('project-cta-bar')) {
- setIsCTABarVisible(true);
- return;
- }
+ // useEffect(() => {
+ // function checkCTABarVisibility() {
+ // if (document.getElementById('project-cta-bar')) {
+ // setIsCTABarVisible(true);
+ // return;
+ // }
- setIsCTABarVisible(false);
- }
+ // setIsCTABarVisible(false);
+ // }
- window.addEventListener('scrollend', checkCTABarVisibility);
- return () => window.removeEventListener('scrollend', checkCTABarVisibility);
- }, []);
+ // window.addEventListener('scrollend', checkCTABarVisibility);
+ // return () => window.removeEventListener('scrollend', checkCTABarVisibility);
+ // }, []);
return (
{/*
diff --git a/front/app/containers/ProjectsShowPage/index.tsx b/front/app/containers/ProjectsShowPage/index.tsx
index 4d1407bc7cab..cbacee932b7e 100644
--- a/front/app/containers/ProjectsShowPage/index.tsx
+++ b/front/app/containers/ProjectsShowPage/index.tsx
@@ -1,4 +1,10 @@
-import React, { useEffect, useMemo, useState } from 'react';
+import React, {
+ useEffect,
+ useMemo,
+ useState,
+ createContext,
+ useContext,
+} from 'react';
import {
Box,
@@ -72,9 +78,14 @@ interface Props {
project: IProjectData;
}
+const Context = createContext(false);
+export const useIsCTABarSticky = () => useContext(Context);
+
const ProjectsShowPage = ({ project }: Props) => {
const projectId = project.id;
+ const [isCTABarSticky, setIsCTABarSticky] = useState(false);
+ const isSmallerThanPhone = useBreakpoint('tablet');
const isSmallerThanTablet = useBreakpoint('tablet');
const { formatMessage } = useIntl();
const [mounted, setMounted] = useState(false);
@@ -95,6 +106,33 @@ const ProjectsShowPage = ({ project }: Props) => {
return anyIsUndefined(locale, appConfig, project, phases?.data, events);
}, [locale, appConfig, project, phases, events]);
+ useEffect(() => {
+ const handleScroll = () => {
+ const actionButtonElement = document.getElementById(
+ 'participation-detail'
+ );
+ const actionButtonYOffset = actionButtonElement
+ ? actionButtonElement.getBoundingClientRect().top + window.scrollY
+ : undefined;
+
+ setIsCTABarSticky(
+ !!(
+ actionButtonElement &&
+ actionButtonYOffset &&
+ window.scrollY > actionButtonYOffset - (isSmallerThanTablet ? 14 : 30)
+ )
+ );
+ };
+
+ if (isSmallerThanPhone) {
+ setIsCTABarSticky(true);
+ } else {
+ window.addEventListener('scroll', handleScroll, { passive: true });
+ }
+
+ return () => window.removeEventListener('scroll', handleScroll);
+ }, [isSmallerThanTablet, isSmallerThanPhone]);
+
// Check that all child components are mounted
useEffect(() => {
setMounted(true);
@@ -130,53 +168,55 @@ const ProjectsShowPage = ({ project }: Props) => {
{loading ? (
) : (
-
-
-
-
-
-
-
- {!!events?.data.length && (
-
-
-
-
- )}
-
-
+
+
+
+
+
+
+
+
+ {!!events?.data.length && (
+
+
+
+
+ )}
+
+
+
)}
From c9d507ae3bcfc03684430801a05c06404235aa0b Mon Sep 17 00:00:00 2001
From: brentguf
Date: Tue, 10 Dec 2024 23:03:04 +0100
Subject: [PATCH 02/18] WIP 2
---
.../IdeasWithFiltersSidebar/ContentRight.tsx | 21 +--
front/app/containers/App/index.tsx | 3 -
front/app/containers/PlatformFooter/index.tsx | 145 ++++++++----------
.../ProjectsShowPage/ProjectCTABar/index.tsx | 91 ++++-------
.../app/containers/ProjectsShowPage/index.tsx | 135 ++++++----------
5 files changed, 147 insertions(+), 248 deletions(-)
diff --git a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
index b907f8f789a8..60eecc9f28a3 100644
--- a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
+++ b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
@@ -7,7 +7,6 @@ import { IIdeasFilterCounts } from 'api/ideas_filter_counts/types';
import { IdeaSortMethod } from 'api/phases/types';
import { QueryParameters } from 'containers/IdeasIndexPage';
-import { useIsCTABarSticky } from 'containers/ProjectsShowPage';
import { ScreenReaderOnly } from 'utils/a11y';
import { FormattedMessage } from 'utils/cl-intl';
@@ -63,28 +62,14 @@ const ContentRight = ({
onChangeTopics,
onChangeSort,
}: Props) => {
- const isCTABarSticky = useIsCTABarSticky();
-
- // useEffect(() => {
- // function checkCTABarVisibility() {
- // if (document.getElementById('project-cta-bar')) {
- // setIsCTABarVisible(true);
- // return;
- // }
-
- // setIsCTABarVisible(false);
- // }
-
- // window.addEventListener('scrollend', checkCTABarVisibility);
- // return () => window.removeEventListener('scrollend', checkCTABarVisibility);
- // }, []);
+ const stickyTop = document.getElementById('project-cta-bar-top');
return (
{/*
diff --git a/front/app/containers/App/index.tsx b/front/app/containers/App/index.tsx
index f41b7678cf19..7c8008fe47c3 100644
--- a/front/app/containers/App/index.tsx
+++ b/front/app/containers/App/index.tsx
@@ -333,9 +333,6 @@ const App = ({ children }: Props) => {
-
-
-
diff --git a/front/app/containers/PlatformFooter/index.tsx b/front/app/containers/PlatformFooter/index.tsx
index b031e27bd488..28998967a128 100644
--- a/front/app/containers/PlatformFooter/index.tsx
+++ b/front/app/containers/PlatformFooter/index.tsx
@@ -24,24 +24,11 @@ import { isNilOrError } from 'utils/helperUtils';
import messages from './messages';
-const Container = styled.footer`
- display: flex;
- flex-direction: column;
- align-items: stretch;
- position: relative;
- ${media.tablet`
- margin-top: 0px;
- `}
-`;
-
-const FooterContainer = styled.div`
+const FooterContainer = styled.footer`
display: flex;
align-items: center;
justify-content: space-between;
- padding-left: 28px;
- padding-right: 28px;
- padding-top: 11px;
- padding-bottom: 11px;
+ padding: 11px 28px;
background: #fff;
border-top: solid 1px #ccc;
overflow: hidden;
@@ -295,69 +282,71 @@ const PlatformFooter = ({ className }: Props) => {
};
return (
-
+
);
};
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index 2e47cbdcaf20..43016bd4b0a6 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React from 'react';
import {
Box,
@@ -6,7 +6,6 @@ import {
colors,
useBreakpoint,
} from '@citizenlab/cl2-component-library';
-import { createPortal } from 'react-dom';
import usePhases from 'api/phases/usePhases';
import useProjectById from 'api/projects/useProjectById';
@@ -23,40 +22,11 @@ type ProjectCTABarProps = {
};
const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
- const isSmallerThanTablet = useBreakpoint('tablet');
const isSmallerThanPhone = useBreakpoint('phone');
- // On devices larger than phones, the sticky CTA bar is only visible when the action button is out of view
- const [sticksToTop, setSticksToTop] = useState(false);
- // The CTA bar is always visible on phones
const sticksToBottom = isSmallerThanPhone;
- const portalElement = document.getElementById('topbar-portal');
const { data: phases } = usePhases(projectId);
const { data: project } = useProjectById(projectId);
- useEffect(() => {
- const handleScroll = () => {
- const actionButtonElement = document.getElementById(
- 'participation-detail'
- );
- const actionButtonYOffset = actionButtonElement
- ? actionButtonElement.getBoundingClientRect().top + window.scrollY
- : undefined;
-
- setSticksToTop(
- !!(
- !sticksToBottom &&
- actionButtonElement &&
- actionButtonYOffset &&
- window.scrollY > actionButtonYOffset - (isSmallerThanTablet ? 14 : 30)
- )
- );
- };
-
- window.addEventListener('scroll', handleScroll, { passive: true });
-
- return () => window.removeEventListener('scroll', handleScroll);
- }, [isSmallerThanTablet, sticksToBottom]);
-
const participationMethod = project
? getParticipationMethod(project.data, phases?.data)
: undefined;
@@ -70,37 +40,38 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
phases: phases?.data,
});
- if ((sticksToBottom || sticksToTop) && portalElement) {
- const sharedProps: BoxProps = {
- width: '100vw',
- position: 'fixed',
- zIndex: '1000',
- background: colors.white,
- id: 'project-cta-bar',
- };
- let portalContent: JSX.Element | null = null;
-
- if (sticksToBottom) {
- portalContent = (
-
- {BarContents}
-
- );
- } else if (sticksToTop) {
- portalContent = (
-
-
-
-
- {BarContents}
+ const sharedProps: BoxProps = {
+ width: '100vw',
+ zIndex: '1000',
+ background: colors.white,
+ };
+
+ if (sticksToBottom) {
+ return (
+
+ {BarContents}
+
+ );
+ } else {
+ return (
+
+
+
- );
- }
-
- return createPortal(portalContent, portalElement);
+ {BarContents}
+
+ );
}
-
- return <>{BarContents}>;
};
export default ProjectCTABar;
diff --git a/front/app/containers/ProjectsShowPage/index.tsx b/front/app/containers/ProjectsShowPage/index.tsx
index cbacee932b7e..cff380607767 100644
--- a/front/app/containers/ProjectsShowPage/index.tsx
+++ b/front/app/containers/ProjectsShowPage/index.tsx
@@ -1,10 +1,4 @@
-import React, {
- useEffect,
- useMemo,
- useState,
- createContext,
- useContext,
-} from 'react';
+import React, { useEffect, useMemo, useState } from 'react';
import {
Box,
@@ -78,14 +72,8 @@ interface Props {
project: IProjectData;
}
-const Context = createContext(false);
-export const useIsCTABarSticky = () => useContext(Context);
-
const ProjectsShowPage = ({ project }: Props) => {
const projectId = project.id;
- const [isCTABarSticky, setIsCTABarSticky] = useState(false);
-
- const isSmallerThanPhone = useBreakpoint('tablet');
const isSmallerThanTablet = useBreakpoint('tablet');
const { formatMessage } = useIntl();
const [mounted, setMounted] = useState(false);
@@ -106,33 +94,6 @@ const ProjectsShowPage = ({ project }: Props) => {
return anyIsUndefined(locale, appConfig, project, phases?.data, events);
}, [locale, appConfig, project, phases, events]);
- useEffect(() => {
- const handleScroll = () => {
- const actionButtonElement = document.getElementById(
- 'participation-detail'
- );
- const actionButtonYOffset = actionButtonElement
- ? actionButtonElement.getBoundingClientRect().top + window.scrollY
- : undefined;
-
- setIsCTABarSticky(
- !!(
- actionButtonElement &&
- actionButtonYOffset &&
- window.scrollY > actionButtonYOffset - (isSmallerThanTablet ? 14 : 30)
- )
- );
- };
-
- if (isSmallerThanPhone) {
- setIsCTABarSticky(true);
- } else {
- window.addEventListener('scroll', handleScroll, { passive: true });
- }
-
- return () => window.removeEventListener('scroll', handleScroll);
- }, [isSmallerThanTablet, isSmallerThanPhone]);
-
// Check that all child components are mounted
useEffect(() => {
setMounted(true);
@@ -168,55 +129,51 @@ const ProjectsShowPage = ({ project }: Props) => {
{loading ? (
) : (
-
-
-
-
-
-
-
-
- {!!events?.data.length && (
-
-
-
-
- )}
-
-
-
+
+
+
+
+
+ {!!events?.data.length && (
+
+
+
+
+ )}
+
+
)}
From 4934ba334ebc46b58ab5217f1d2061ae2a96057f Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:00:20 +0100
Subject: [PATCH 03/18] Add padding to platform footer when there's a fixed CTA
bar at the bottom
---
front/app/containers/PlatformFooter/index.tsx | 2 +-
.../ProjectsShowPage/ProjectCTABar/index.tsx | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/front/app/containers/PlatformFooter/index.tsx b/front/app/containers/PlatformFooter/index.tsx
index 28998967a128..28b1d9a8ed9a 100644
--- a/front/app/containers/PlatformFooter/index.tsx
+++ b/front/app/containers/PlatformFooter/index.tsx
@@ -224,7 +224,7 @@ const PlatformFooter = ({ className }: Props) => {
eventEmitter.emit('openConsentManager');
};
- const participationBar = document.getElementById('project-cta-bar');
+ const participationBar = document.getElementById('project-cta-bar-bottom');
useEffect(() => {
setPaddingBottom(
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index 43016bd4b0a6..f2f44a4521a9 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -49,22 +49,18 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
if (sticksToBottom) {
return (
{BarContents}
);
} else {
return (
-
+
From 9e6382328cc00a0bdb29fba3d0b7137e8a58cd14 Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:02:39 +0100
Subject: [PATCH 04/18] Identify top cta bar to push down filters
---
.../containers/ProjectsShowPage/ProjectCTABar/index.tsx | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index f2f44a4521a9..72a8e6cda1be 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -60,7 +60,14 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
);
} else {
return (
-
+
From 29f11e194595dd56a31d178a2e57d969afec59bb Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:04:13 +0100
Subject: [PATCH 05/18] Undo styling changes PlatformFooter
---
front/app/containers/PlatformFooter/index.tsx | 145 ++++++++++--------
1 file changed, 78 insertions(+), 67 deletions(-)
diff --git a/front/app/containers/PlatformFooter/index.tsx b/front/app/containers/PlatformFooter/index.tsx
index 28b1d9a8ed9a..3ec3edebefae 100644
--- a/front/app/containers/PlatformFooter/index.tsx
+++ b/front/app/containers/PlatformFooter/index.tsx
@@ -24,11 +24,24 @@ import { isNilOrError } from 'utils/helperUtils';
import messages from './messages';
-const FooterContainer = styled.footer`
+const Container = styled.footer`
+ display: flex;
+ flex-direction: column;
+ align-items: stretch;
+ position: relative;
+ ${media.tablet`
+ margin-top: 0px;
+ `}
+`;
+
+const FooterContainer = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
- padding: 11px 28px;
+ padding-left: 28px;
+ padding-right: 28px;
+ padding-top: 11px;
+ padding-bottom: 11px;
background: #fff;
border-top: solid 1px #ccc;
overflow: hidden;
@@ -282,71 +295,69 @@ const PlatformFooter = ({ className }: Props) => {
};
return (
-
+
);
};
From 92a37f9de28f8a7f03a5fd10a85d957a3c16f0d8 Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:12:22 +0100
Subject: [PATCH 06/18] Use top instead of stub component to make stickiness
work
---
.../containers/ProjectsShowPage/ProjectCTABar/index.tsx | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index 72a8e6cda1be..fad54e62ecfb 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -4,14 +4,13 @@ import {
Box,
BoxProps,
colors,
+ stylingConsts,
useBreakpoint,
} from '@citizenlab/cl2-component-library';
import usePhases from 'api/phases/usePhases';
import useProjectById from 'api/projects/useProjectById';
-import MainHeader from 'containers/MainHeader';
-
import {
getMethodConfig,
getParticipationMethod,
@@ -65,12 +64,9 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
// (top in ContentRight)
id="project-cta-bar-top"
position="sticky"
- top="0px"
+ top={`${stylingConsts.menuHeight}px`}
{...sharedProps}
>
-
-
-
{BarContents}
);
From e625503c1fdf905339106bb2b7847544b03f4ad6 Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:14:55 +0100
Subject: [PATCH 07/18] Remove unused portal from storybook configs
---
front/.storybook/contexts/index.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/front/.storybook/contexts/index.tsx b/front/.storybook/contexts/index.tsx
index 752e5f36a148..b3df416ec5e9 100644
--- a/front/.storybook/contexts/index.tsx
+++ b/front/.storybook/contexts/index.tsx
@@ -12,7 +12,6 @@ const Portals = () => (
id="modal-portal"
style={{ position: 'absolute', top: 0, left: 0, width: '100%' }}
/>
-
>
);
From d70c400d25c9f4920e14477ce9adf897d4d3a884 Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:28:32 +0100
Subject: [PATCH 08/18] BarContents types warning
---
front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index fad54e62ecfb..1453090e265b 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -34,6 +34,7 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
return null;
}
+ // WARNING: BarContents types are wrong. Can also be null.
const BarContents = getMethodConfig(participationMethod).renderCTABar({
project: project.data,
phases: phases?.data,
@@ -60,9 +61,6 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
} else {
return (
Date: Wed, 11 Dec 2024 11:28:58 +0100
Subject: [PATCH 09/18] Ensure we only push down filters if we render a bar
with content
---
.../ParticipationCTAContent/index.tsx | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index d8a21e2615c5..ac20e0f656d8 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -24,8 +24,9 @@ const ParticipationCTAContent = ({
}: Props) => {
const theme = useTheme();
const isSmallerThanPhone = useBreakpoint('phone');
+ const sticksToBottom = isSmallerThanPhone;
- return isSmallerThanPhone ? (
+ return sticksToBottom ? (
Date: Wed, 11 Dec 2024 11:46:29 +0100
Subject: [PATCH 10/18] Further simplify ProjectCTABar return statement
---
.../ProjectsShowPage/ProjectCTABar/index.tsx | 40 ++++++++-----------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index 1453090e265b..f7d864c43db3 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -39,36 +39,28 @@ const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
project: project.data,
phases: phases?.data,
});
-
const sharedProps: BoxProps = {
width: '100vw',
zIndex: '1000',
background: colors.white,
};
-
- if (sticksToBottom) {
- return (
-
- {BarContents}
-
- );
- } else {
- return (
-
- {BarContents}
-
- );
- }
+ id: 'project-cta-bar-bottom',
+ position: 'fixed',
+ bottom: '0px',
+ }
+ : {
+ position: 'sticky',
+ top: `${stylingConsts.menuHeight}px`,
+ };
+
+ return (
+
+ {BarContents}
+
+ );
};
export default ProjectCTABar;
From bb04f3b98f5e098e41c7551ac2aca824fe0c8808 Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:50:49 +0100
Subject: [PATCH 11/18] Improve comment
---
.../ParticipationCTABars/ParticipationCTAContent/index.tsx | 3 +++
1 file changed, 3 insertions(+)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index ac20e0f656d8..a6e64fda2370 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -59,6 +59,9 @@ const ParticipationCTAContent = ({
// (in ContentRight)
// We should probably move this component to ProjectCTABar (where we split between top and bottom bar)
// instead of here. Then only define the CTAButton part in the config.
+ // Putting this id in ProjectCTABar does not work at the moment, because
+ // the rendered bar (BarContents) can sometimes be null. In that case,
+ // we are telling ContentRight that the top bar is visible, while it is not.
id="project-cta-bar-top"
>
From f646e495e59ebaddc8b01893da45bb02e0437f7c Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:52:03 +0100
Subject: [PATCH 12/18] Turn into multiline comment
---
.../ParticipationCTAContent/index.tsx | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index a6e64fda2370..73b447b9751f 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -55,13 +55,17 @@ const ParticipationCTAContent = ({
bgColor={theme.colors.tenantPrimary}
height="64px"
p="20px"
- // This is is needed to determine how much to push down the input filters
- // (in ContentRight)
- // We should probably move this component to ProjectCTABar (where we split between top and bottom bar)
- // instead of here. Then only define the CTAButton part in the config.
- // Putting this id in ProjectCTABar does not work at the moment, because
- // the rendered bar (BarContents) can sometimes be null. In that case,
- // we are telling ContentRight that the top bar is visible, while it is not.
+ /*
+ This is is needed to determine how much to push down the input filters
+ (in ContentRight).
+
+ We should look into moving this component to ProjectCTABar (where we split between top and bottom bar)
+ instead of here. Then only define the CTAButton part in the config.
+
+ Putting this id in ProjectCTABar does not work at the moment, because
+ the rendered bar (BarContents) can sometimes be null. In that case,
+ we are telling ContentRight that the top bar is visible, while it is not.
+ */
id="project-cta-bar-top"
>
From 92e471c0edd15d3fda911bfc70b7d32be7c0e7ef Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:53:26 +0100
Subject: [PATCH 13/18] Further comment improvement
---
.../ParticipationCTAContent/index.tsx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index 73b447b9751f..e1e814807843 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -58,13 +58,14 @@ const ParticipationCTAContent = ({
/*
This is is needed to determine how much to push down the input filters
(in ContentRight).
-
- We should look into moving this component to ProjectCTABar (where we split between top and bottom bar)
- instead of here. Then only define the CTAButton part in the config.
-
+
Putting this id in ProjectCTABar does not work at the moment, because
the rendered bar (BarContents) can sometimes be null. In that case,
we are telling ContentRight that the top bar is visible, while it is not.
+
+ We can look into moving this component to ProjectCTABar (where we split between top and bottom bar)
+ instead of here. Then only define the CTAButton part in the config, then we can probably
+ move the id in ProjectCTABar.
*/
id="project-cta-bar-top"
>
From ae91d50ea727f71644593f353e0999e7eab9ae3d Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:56:23 +0100
Subject: [PATCH 14/18] sticksToBottom comment
---
.../ParticipationCTABars/ParticipationCTAContent/index.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index e1e814807843..d556f355f2d7 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -24,6 +24,7 @@ const ParticipationCTAContent = ({
}: Props) => {
const theme = useTheme();
const isSmallerThanPhone = useBreakpoint('phone');
+ // If the screen is smaller than a phone, the bar sticks to the bottom. See ProjectCTABar.
const sticksToBottom = isSmallerThanPhone;
return sticksToBottom ? (
From 3f24600baf26afd4ccff1dd7e8644a3a879a433c Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:57:28 +0100
Subject: [PATCH 15/18] sticksToBottom comment improvement
---
.../ParticipationCTABars/ParticipationCTAContent/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index d556f355f2d7..e788ba8b375f 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -24,7 +24,7 @@ const ParticipationCTAContent = ({
}: Props) => {
const theme = useTheme();
const isSmallerThanPhone = useBreakpoint('phone');
- // If the screen is smaller than a phone, the bar sticks to the bottom. See ProjectCTABar.
+ // This is the same condition as we have in ProjectCTABar.
const sticksToBottom = isSmallerThanPhone;
return sticksToBottom ? (
From b6308b083a615a4a888aee14a8a7f75f91a8b22b Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 11:58:00 +0100
Subject: [PATCH 16/18] sticksToBottom comment 3
---
.../ParticipationCTABars/ParticipationCTAContent/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
index e788ba8b375f..968b2b714733 100644
--- a/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
+++ b/front/app/components/ParticipationCTABars/ParticipationCTAContent/index.tsx
@@ -24,7 +24,7 @@ const ParticipationCTAContent = ({
}: Props) => {
const theme = useTheme();
const isSmallerThanPhone = useBreakpoint('phone');
- // This is the same condition as we have in ProjectCTABar.
+ // This is the same condition we have in ProjectCTABar.
const sticksToBottom = isSmallerThanPhone;
return sticksToBottom ? (
From 1c480deb34275a5203d7ed6897b85f8073a7723f Mon Sep 17 00:00:00 2001
From: brentguf
Date: Wed, 11 Dec 2024 18:14:27 +0100
Subject: [PATCH 17/18] Stick CTA bar to bottom for tablets as well
---
front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
index f7d864c43db3..86ae0e102d08 100644
--- a/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
+++ b/front/app/containers/ProjectsShowPage/ProjectCTABar/index.tsx
@@ -21,8 +21,8 @@ type ProjectCTABarProps = {
};
const ProjectCTABar = ({ projectId }: ProjectCTABarProps) => {
- const isSmallerThanPhone = useBreakpoint('phone');
- const sticksToBottom = isSmallerThanPhone;
+ const isSmallerThanTablet = useBreakpoint('tablet');
+ const sticksToBottom = isSmallerThanTablet;
const { data: phases } = usePhases(projectId);
const { data: project } = useProjectById(projectId);
From bb97eab7811c6382ee9f323becbef4626cac84ae Mon Sep 17 00:00:00 2001
From: brentguf
Date: Thu, 12 Dec 2024 10:21:13 +0100
Subject: [PATCH 18/18] Add comments to indicate britleness of cta bar presence
checks
---
.../IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx | 10 +++++++---
front/app/containers/PlatformFooter/index.tsx | 4 ++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
index 60eecc9f28a3..138e791cc07e 100644
--- a/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
+++ b/front/app/components/IdeaCards/IdeasWithFiltersSidebar/ContentRight.tsx
@@ -62,14 +62,18 @@ const ContentRight = ({
onChangeTopics,
onChangeSort,
}: Props) => {
- const stickyTop = document.getElementById('project-cta-bar-top');
+ /*
+ Likely not the most reliable way to determine if the bar is present.
+ Context would probably be better, but this is a quick fix.
+ */
+ const projectCTABarTop = document.getElementById('project-cta-bar-top');
return (
{/*
diff --git a/front/app/containers/PlatformFooter/index.tsx b/front/app/containers/PlatformFooter/index.tsx
index 3ec3edebefae..3eab04dce35a 100644
--- a/front/app/containers/PlatformFooter/index.tsx
+++ b/front/app/containers/PlatformFooter/index.tsx
@@ -237,6 +237,10 @@ const PlatformFooter = ({ className }: Props) => {
eventEmitter.emit('openConsentManager');
};
+ /*
+ Likely not the most reliable way to determine if the bar is present.
+ Context would probably be better, but this is a quick fix.
+ */
const participationBar = document.getElementById('project-cta-bar-bottom');
useEffect(() => {