-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: floating bar WIP * feat: scroll to survey results or comments depending on availability * chore: internationalization * chore: replace figma colors with the theme ones * chore: remove forum button * refactor: useSurvey hook * chore: floating bar comments loader * chore: replace svg with png, add opacity animation to floating bar * fix: always render floating bar
- Loading branch information
Showing
15 changed files
with
283 additions
and
100 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,62 @@ | ||
.FloatingBar { | ||
position: sticky; | ||
bottom: 30px; | ||
width: 100%; | ||
height: 48px; | ||
border-radius: 6px; | ||
border: 1px solid var(--black-300); | ||
background: var(--white-900); | ||
box-shadow: 0 0 25px 0 var(--alpha-black-400); | ||
padding: 12px 18px 12px 16px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
transition: all 0.5s ease 0s; | ||
opacity: 1; | ||
z-index: 200; | ||
} | ||
|
||
.FloatingBar--hidden { | ||
opacity: 0; | ||
z-index: -1; | ||
} | ||
|
||
.FloatingBar__ProposalSectionActions { | ||
display: flex; | ||
justify-content: space-between; | ||
padding-right: 24px; | ||
width: 100%; | ||
} | ||
|
||
.FloatingBar__Action { | ||
color: var(--black-600); | ||
font-size: 13px; | ||
line-height: 24px; | ||
font-weight: var(--weight-semi-bold); | ||
text-transform: uppercase; | ||
gap: 5px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.FloatingBar__ReactionsImg { | ||
height: 24px; | ||
width: 36px; | ||
} | ||
|
||
.FloatingBar__JoinDiscussion { | ||
min-width: 138px !important; | ||
padding: 0 !important; | ||
display: flex !important; | ||
align-items: center; | ||
gap: 8px; | ||
} | ||
|
||
.FloatingBar__LoaderLeft { | ||
left: 32px !important; | ||
} | ||
|
||
.FloatingBar__LoaderRight { | ||
margin-right: 84px !important; | ||
position: relative !important; | ||
} |
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,85 @@ | ||
import React from 'react' | ||
|
||
import classNames from 'classnames' | ||
import { Button } from 'decentraland-ui/dist/components/Button/Button' | ||
import { Loader } from 'decentraland-ui/dist/components/Loader/Loader' | ||
|
||
import { forumUrl } from '../../entities/Proposal/utils' | ||
import useFormatMessage from '../../hooks/useFormatMessage' | ||
import useProposalComments from '../../hooks/useProposalComments' | ||
import Link from '../Common/Typography/Link' | ||
import Forum from '../Icon/Forum' | ||
import Open from '../Icon/Open' | ||
|
||
import './FloatingBar.css' | ||
|
||
const reactions = require('../../images/reactions.png').default | ||
|
||
interface FloatingBarProps { | ||
isVisible: boolean | ||
showViewReactions: boolean | ||
scrollToComments: () => void | ||
scrollToReactions: () => void | ||
proposalId?: string | ||
discourseTopicId?: number | ||
discourseTopicSlug?: string | ||
isLoadingProposal: boolean | ||
} | ||
|
||
const FloatingBar: React.FC<FloatingBarProps> = ({ | ||
proposalId, | ||
discourseTopicId, | ||
discourseTopicSlug, | ||
showViewReactions, | ||
isVisible, | ||
scrollToComments, | ||
scrollToReactions, | ||
isLoadingProposal, | ||
}) => { | ||
const t = useFormatMessage() | ||
const { comments, isLoadingComments } = useProposalComments(proposalId) | ||
const showTotalComments = !isLoadingComments && !isLoadingProposal | ||
return ( | ||
<div className={classNames('FloatingBar', !isVisible && !isLoadingProposal && 'FloatingBar--hidden')}> | ||
<div className="FloatingBar__ProposalSectionActions"> | ||
{showViewReactions && ( | ||
<Link onClick={scrollToReactions} className={'FloatingBar__Action'}> | ||
{t('component.floating_bar.view_reactions_label')} | ||
<img src={reactions} className="FloatingBar__ReactionsImg" /> | ||
</Link> | ||
)} | ||
<Link onClick={scrollToComments} className={'FloatingBar__Action'}> | ||
{!showTotalComments && ( | ||
<Loader | ||
active | ||
size="tiny" | ||
className={classNames( | ||
!showViewReactions && 'FloatingBar__LoaderLeft', | ||
showViewReactions && 'FloatingBar__LoaderRight' | ||
)} | ||
/> | ||
)} | ||
{showTotalComments && ( | ||
<> | ||
<Forum color={'var(--black-600)'} /> | ||
{t('component.floating_bar.total_comments_label', { count: comments?.totalComments || 0 })} | ||
</> | ||
)} | ||
</Link> | ||
</div> | ||
<Button | ||
basic | ||
disabled={!discourseTopicId} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href={(discourseTopicId && forumUrl(discourseTopicSlug, discourseTopicId)) || ''} | ||
className="FloatingBar__JoinDiscussion" | ||
> | ||
{t('component.floating_bar.forum_label')} | ||
<Open /> | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
export default FloatingBar |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import React from 'react' | ||
import React, { Ref, forwardRef } from 'react' | ||
|
||
import { ProposalAttributes } from '../../../entities/Proposal/types' | ||
import useProposalComments from '../../../hooks/useProposalComments' | ||
import Comments from '../../Comments/Comments' | ||
|
||
type ProposalComments = { | ||
type ProposalCommentsProps = { | ||
proposal: ProposalAttributes | null | ||
} | ||
|
||
export default function ProposalComments({ proposal }: ProposalComments) { | ||
const ProposalComments = forwardRef(({ proposal }: ProposalCommentsProps, ref: Ref<HTMLDivElement>) => { | ||
const { comments, isLoadingComments } = useProposalComments(proposal?.id) | ||
|
||
return ( | ||
<Comments | ||
comments={comments} | ||
isLoading={isLoadingComments} | ||
topicId={proposal?.discourse_topic_id} | ||
topicSlug={proposal?.discourse_topic_slug} | ||
topicType="proposal" | ||
/> | ||
<div ref={ref}> | ||
<Comments | ||
comments={comments} | ||
isLoading={isLoadingComments} | ||
topicId={proposal?.discourse_topic_id} | ||
topicSlug={proposal?.discourse_topic_slug} | ||
topicType="proposal" | ||
/> | ||
</div> | ||
) | ||
} | ||
}) | ||
|
||
export default ProposalComments |
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
import { ProposalAttributes } from '../entities/Proposal/types' | ||
import { Vote } from '../entities/Votes/types' | ||
|
||
import useSurveyTopics from './useSurveyTopics' | ||
|
||
const SURVEY_FEATURE_LAUNCH = new Date(2023, 3, 5, 0, 0) | ||
|
||
export default function useSurvey( | ||
proposal?: ProposalAttributes | null, | ||
votes?: Record<string, Vote> | null, | ||
isLoadingVotes?: boolean, | ||
isMobile?: boolean | ||
) { | ||
const { surveyTopics, isLoadingSurveyTopics } = useSurveyTopics(proposal?.id) | ||
const voteWithSurvey = | ||
!isLoadingSurveyTopics && | ||
!!surveyTopics && | ||
surveyTopics.length > 0 && | ||
!!proposal && | ||
proposal.created_at > SURVEY_FEATURE_LAUNCH | ||
const hasVotes = votes && Object.keys(votes).length > 0 && !isLoadingVotes | ||
const hasSurveyTopics = surveyTopics && surveyTopics?.length > 0 && !isLoadingSurveyTopics | ||
const showSurveyResults = proposal && voteWithSurvey && !isMobile && hasVotes && hasSurveyTopics | ||
return { surveyTopics, isLoadingSurveyTopics, voteWithSurvey, showSurveyResults } | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.