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

Add an election progress bar #4556

Merged
merged 32 commits into from
Dec 19, 2023
Merged

Add an election progress bar #4556

merged 32 commits into from
Dec 19, 2023

Conversation

mkbeefcake
Copy link
Contributor

@mkbeefcake mkbeefcake commented Sep 28, 2023

Fixed #4006 : implemented new Progressbar for Election

> Design
> RWD Designs
> Election page
> Story

@vercel
Copy link

vercel bot commented Sep 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dao ✅ Ready (Inspect) Visit Preview Dec 19, 2023 10:41am
pioneer-2 ✅ Ready (Inspect) Visit Preview Dec 19, 2023 10:41am
pioneer-2-storybook ✅ Ready (Inspect) Visit Preview Dec 19, 2023 10:41am

Copy link
Contributor

@chrlschwb chrlschwb left a comment

Choose a reason for hiding this comment

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

I see two problems:

  1. When hovered over, the bar's thickness increases. It's visually unappealing.
  2. It doesn't support mobile view

@mkbeefcake
Copy link
Contributor Author

I see two problems:

  1. When hovered over, the bar's thickness increases. It's visually unappealing.
    https://www.figma.com/file/GlgN8uBRtvtMJtiOsdtDF7/Pioneer-design?type=design&node-id=11664-445586&mode=design
    I followed this figma design, and there is the increasement of bar when hovered
  1. It doesn't support mobile view
    There was no mobile design, and also I guess this pioneer website is not ready for mobile responsive yet... so I only focused about desktop

Copy link
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

@mkbeefcake I approved this PR initially but I just realized that it breaks the election on mobile right now. So it can't be merged ATM.

Here are the RWD for it. Because it's not straight forward to implement I think these should be implemented fully in a follow up PR.

In the meantime this should be released without breaking the election page. Here's what I'm proposing:
Screenshot from 2023-12-07 20-37-07

So basically the widget stays the same but it wrap to the next line. There's a bunch of similar design on other pages (like the proposal preview).

Copy link
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

@mkbeefcake thank you for the extra effort of implementing the full design but there are some 2 issues:

First: this one is not new but I didn't notice it with the desktop designs (also it doesn't happens on Firefox). Watch the "ends on" time. It jumps back and forth from 18:22:06 to 18:22:11 also the value is slowly drifting. I think we should remove the seconds as we can't reliably predict this level of accuracy especially over several days. And this copies shouldn't be changed on every rerender, it should be changed only when the current stage changes.

Second: the items are visibly misaligned vertically:
Screenshot from 2023-12-15 12-10-47

@mkbeefcake
Copy link
Contributor Author

@thesan I have fixed the issues by adding timestamp for GENESIS BLOCK and adjusted the padding for responsive. Please review this again. Thanks

@@ -27,11 +27,12 @@ interface ElectionProgressBarProps extends StatisticItemProps {
electionStage: string
}

const GENESIS_BLOCK_TIMESTAMP = 1670693046000
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to be able to convert block/dates without fetching anything from the network, but Pioneer should avoid hardcoding these kind of data because it should potentially work on other networks too. Also basing the future block date based on a date which is that old is that old makes it less accurate.

@@ -81,8 +82,9 @@ export const ElectionProgressBar = (props: ElectionProgressBarProps) => {
const constants = useCouncilConstants()

const [inactiveEndBlock, announcingEndBlock, votingEndBlock, revealingEndBlock] = periodInformation?.periodEnds ?? []
const endDates = periodInformation?.periodEnds.map((block) => blockToDate(block - currentBlock))
const endDates = periodInformation?.periodEnds.map((block) => blockToDate(block))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead I think this is good enough:

Suggested change
const endDates = periodInformation?.periodEnds.map((block) => blockToDate(block))
const endDates = useMemo(() => periodInformation?.periodEnds.map((block) => blockToDate(block - currentBlock)), [props.electionStage])

When the page is reloaded the time won't be exactly the same but it will actually be more accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to use props.electionStage, at that time sometimes the endDate is calculated as undefined, so I changed it to periodInformation.currentStage.

return new Date(now + msDuration).toLocaleString('en-gb', { timeZone: 'Europe/Paris' })
const blockToDate = (block: number) => {
const msDuration = blockDurationToMs(block)
return new Date(GENESIS_BLOCK_TIMESTAMP + msDuration).toLocaleString('en-gb', { timeZone: 'Europe/Paris' })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Finally here's how to remove the seconds:

Suggested change
return new Date(GENESIS_BLOCK_TIMESTAMP + msDuration).toLocaleString('en-gb', { timeZone: 'Europe/Paris' })
const date = new Date(now + msDuration)
return `${date.toLocaleString('en-gb', { timeZone: 'Europe/Paris', dateStyle: "short", timeStyle: "short" })} CET`

It's closer to the original design and it's a lot better since the time estimation can't be accurate to the second.

Copy link
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

Great work 🙌

const endDates = periodInformation?.periodEnds.map((block) => blockToDate(block))
const endDates = useMemo(
() => periodInformation?.periodEnds.map((block) => blockToDate(block - currentBlock)),
[periodInformation?.currentStage]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good call! periodInformation?.currentStage is better since it will be defined when currentBlock will be defined.

@thesan thesan merged commit 1267cf9 into Joystream:dev Dec 19, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-dev issue suitable for community-dev pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance election lifecycle clarity
5 participants