Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: proposal render issue #1368

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/Common/MediaQuery/Mobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media (min-width: 768px) {
.MediaQuery__Mobile {
display: none;
}
}
5 changes: 5 additions & 0 deletions src/components/Common/MediaQuery/Mobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import './Mobile.css'

export default function Mobile({ children }: { children: React.ReactNode }) {
return <div className="MediaQuery__Mobile">{children}</div>
}
9 changes: 9 additions & 0 deletions src/components/Common/MediaQuery/NotMobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.MediaQuery__NotMobile {
display: none;
}

@media (min-width: 768px) {
.MediaQuery__NotMobile {
display: block;
}
}
5 changes: 5 additions & 0 deletions src/components/Common/MediaQuery/NotMobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import './NotMobile.css'

export default function NotMobile({ children }: { children: React.ReactNode }) {
return <div className="MediaQuery__NotMobile">{children}</div>
}
2 changes: 1 addition & 1 deletion src/components/Proposal/View/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function ProposalCard({
<span>{' · '}</span>
</>
)}
<span className="ProposalCard__DetailsItem ProposalCard__DetailsOnlyDesktop">
<span className="ProposalCard__DetailsItem">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use NotMobile here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class ProposalCard__DetailsOnlyDesktop didn't exist in a css file 🤷

{showLeadingVP
? t('page.home.open_proposals.leading_vp', {
total: formatNumber(winningChoice.power),
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export function getUncappedRoundedPercentage(value: number, total: number): numb
}

export function getUrlFilters<T>(filterKey: string, params: URLSearchParams, value?: T) {
if (typeof window === 'undefined') {
return ''
}

const newParams = new URLSearchParams(params)
value ? newParams.set(filterKey, String(value)) : newParams.delete(filterKey)
newParams.delete('page')
Expand Down
1 change: 0 additions & 1 deletion src/pages/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Head from 'decentraland-gatsby/dist/components/Head/Head'
import NotFound from 'decentraland-gatsby/dist/components/Layout/NotFound'
import useAuthContext from 'decentraland-gatsby/dist/context/Auth/useAuthContext'
import usePatchState from 'decentraland-gatsby/dist/hooks/usePatchState'
import { Loader } from 'decentraland-ui/dist/components/Loader/Loader'
import { NotMobile, useMobileMediaQuery } from 'decentraland-ui/dist/components/Media/Media'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dcl-ui components are not working for us, maybe we should stop using them. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I agree. We should change it in all files. But I wanted to focus on fixing the issue in the proposals page.


import { ErrorClient } from '../clients/ErrorClient'
Expand Down
42 changes: 19 additions & 23 deletions src/pages/proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import Head from 'decentraland-gatsby/dist/components/Head/Head'
import useAuthContext from 'decentraland-gatsby/dist/context/Auth/useAuthContext'
import { Button } from 'decentraland-ui/dist/components/Button/Button'
import { Loader } from 'decentraland-ui/dist/components/Loader/Loader'
import { Mobile, NotMobile, useTabletAndBelowMediaQuery } from 'decentraland-ui/dist/components/Media/Media'
import { useTabletAndBelowMediaQuery } from 'decentraland-ui/dist/components/Media/Media'
import { Pagination } from 'decentraland-ui/dist/components/Pagination/Pagination'

import RandomBanner from '../components/Banner/RandomBanner'
import CategoryBanner from '../components/Category/CategoryBanner'
import Empty from '../components/Common/Empty'
import Mobile from '../components/Common/MediaQuery/Mobile'
import NotMobile from '../components/Common/MediaQuery/NotMobile'
import ProposalPreviewCard from '../components/Common/ProposalPreviewCard/ProposalPreviewCard'
import Link from '../components/Common/Typography/Link'
import Text from '../components/Common/Typography/Text'
Expand Down Expand Up @@ -98,7 +100,7 @@ export default function ProposalsPage() {
return <MaintenanceLayout title={title} description={description} activeTab={NavigationTab.Proposals} />
}

const isLoading = isLoadingProposals || isLoadingVotes
const isLoading = !proposals || isLoadingProposals || isLoadingVotes

return (
<>
Expand All @@ -111,7 +113,7 @@ export default function ProposalsPage() {
<div className="OnlyDesktop">
<RandomBanner isVisible={!searching} />
</div>
{search && proposals && (
{search && (
<NotMobile>
<SearchTitle />
</NotMobile>
Expand All @@ -127,33 +129,27 @@ export default function ProposalsPage() {
</NotMobile>
</div>
<div className="ProposalsPage__Content">
{proposals && (
{search && (
<Mobile>
<SearchTitle />
</Mobile>
)}
<ActionableLayout
leftAction={
proposals && (
<Text color="secondary" weight="semi-bold" className="ProposalsPage__ProposalCount">
{t('general.count_proposals', { count: proposals.total || 0 })}
</Text>
)
<Text color="secondary" weight="semi-bold" className="ProposalsPage__ProposalCount">
{t('general.count_proposals', { count: proposals?.total || 0 })}
</Text>
}
rightAction={
<>
{proposals && (
<>
<SortingMenu />
<Mobile>
<FilterMenu>
<CategoryFilter filterType={ProposalType} />
<StatusFilter statusType={ProposalStatus} />
<TimeFrameFilter />
</FilterMenu>
</Mobile>
</>
)}
<SortingMenu />
<Mobile>
<FilterMenu>
<CategoryFilter filterType={ProposalType} />
<StatusFilter statusType={ProposalStatus} />
<TimeFrameFilter />
</FilterMenu>
</Mobile>
<Button
primary
size="small"
Expand All @@ -166,14 +162,14 @@ export default function ProposalsPage() {
</>
}
>
{type && !searching && <CategoryBanner type={type} />}
{isLoading && (
<div className="ProposalsPage__LoaderContainer">
<Loader size="medium" active={!proposals || isLoading} />
<Loader size="medium" active={isLoading} />
</div>
)}
{!isLoading && (
<>
{type && !searching && <CategoryBanner type={type} />}
{proposals && proposals.data.length === 0 && (
<Empty
className="ProposalsPage__Empty"
Expand Down
Loading