Skip to content

Commit

Permalink
fix: always render floating bar
Browse files Browse the repository at this point in the history
  • Loading branch information
1emu committed Sep 20, 2023
1 parent 729750f commit 7f21918
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/components/FloatingBar/FloatingBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
border: 1px solid var(--black-300);
background: var(--white-900);
box-shadow: 0 0 25px 0 var(--alpha-black-400);
z-index: 200;
padding: 12px 18px 12px 16px;
display: flex;
justify-content: space-between;
align-items: center;
opacity: 0;
transition: all 0.5s ease 0s;
opacity: 1;
z-index: 200;
}

.FloatingBar--visible {
opacity: 1;
.FloatingBar--hidden {
opacity: 0;
z-index: -1;
}

.FloatingBar__ProposalSectionActions {
Expand Down
8 changes: 4 additions & 4 deletions src/components/FloatingBar/FloatingBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ interface FloatingBarProps {
showViewReactions: boolean
scrollToComments: () => void
scrollToReactions: () => void
proposalId: string
discourseTopicId: number
discourseTopicSlug: string
proposalId?: string
discourseTopicId?: number
discourseTopicSlug?: string
}

const FloatingBar: React.FC<FloatingBarProps> = ({
Expand All @@ -38,7 +38,7 @@ const FloatingBar: React.FC<FloatingBarProps> = ({
const { comments, isLoadingComments } = useProposalComments(proposalId)

return (
<div className={classNames('FloatingBar', isVisible && 'FloatingBar--visible')}>
<div className={classNames('FloatingBar', !isVisible && 'FloatingBar--hidden')}>
<div className="FloatingBar__ProposalSectionActions">
{showViewReactions && (
<Link onClick={scrollToReactions} className={'FloatingBar__Action'}>
Expand Down
38 changes: 17 additions & 21 deletions src/pages/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { ErrorClient } from '../clients/ErrorClient'
import { Governance } from '../clients/Governance'
import { SnapshotApi } from '../clients/SnapshotApi'
import CategoryPill from '../components/Category/CategoryPill'
import FloatingBar from '../components/FloatingBar/FloatingBar'
import ProposalVPChart from '../components/Charts/ProposalVPChart'
import FloatingBar from '../components/FloatingBar/FloatingBar'
import ContentLayout, { ContentSection } from '../components/Layout/ContentLayout'
import MaintenanceLayout from '../components/Layout/MaintenanceLayout'
import BidSubmittedModal from '../components/Modal/BidSubmittedModal'
Expand Down Expand Up @@ -209,6 +209,8 @@ export default function ProposalPage() {
}
}
useEffect(() => {
setIsBarVisible(true)

const handleScroll = () => {
const hideBarSectionRef = reactionsSectionRef.current || commentsSectionRef.current
if (hideBarSectionRef) {
Expand Down Expand Up @@ -297,15 +299,11 @@ export default function ProposalPage() {
}, [proposal, account, isDAOCommittee])

useEffect(() => {
updatePageStateRef.current({ showProposalSuccessModal: params.get('new') === 'true' })
}, [params])

useEffect(() => {
updatePageStateRef.current({ showTenderPublishedModal: params.get('pending') === 'true' })
}, [params])

useEffect(() => {
updatePageStateRef.current({ showBidSubmittedModal: params.get('bid') === 'true' })
updatePageStateRef.current({
showProposalSuccessModal: params.get('new') === 'true',
showTenderPublishedModal: params.get('pending') === 'true',
showBidSubmittedModal: params.get('bid') === 'true',
})
}, [params])

useEffect(() => {
Expand Down Expand Up @@ -425,17 +423,15 @@ export default function ProposalPage() {
/>
)}
<ProposalComments proposal={proposal} ref={commentsSectionRef} />
{proposal && !isLoadingSurveyTopics && (
<FloatingBar
isVisible={isBarVisible}
showViewReactions={!!showSurveyResults}
scrollToReactions={scrollToReactions}
scrollToComments={scrollToComments}
proposalId={proposal?.id}
discourseTopicId={proposal?.discourse_topic_id}
discourseTopicSlug={proposal?.discourse_topic_slug}
/>
)}
<FloatingBar
isVisible={isBarVisible}
showViewReactions={!!showSurveyResults}
scrollToReactions={scrollToReactions}
scrollToComments={scrollToComments}
proposalId={proposal?.id}
discourseTopicId={proposal?.discourse_topic_id}
discourseTopicSlug={proposal?.discourse_topic_slug}
/>
</Grid.Column>

<Grid.Column tablet="4" className="ProposalDetailActions">
Expand Down

0 comments on commit 7f21918

Please sign in to comment.