From c63f83bc9d8c0e28a4052e07b385bb814ab94534 Mon Sep 17 00:00:00 2001 From: Edoardo Abati <29585319+EdAbati@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:30:32 +0100 Subject: [PATCH] Add Focus Mode to the new CFP review pages Reviewers go through proposals one at a time, fewest votes first. The screen shows the proposal, the speaker, the other reviewers' votes and the community ranking, with a vote bar pinned at the bottom: one button per score option plus No vote, a comment, Previous and Skip for now. The current proposal and hidden tags live in the URL, so a link opens the same proposal. --- .../review-beta/focus/collapsible-card.tsx | 33 +++ .../review-beta/focus/focus-mode.graphql | 116 +++++++++++ .../review-beta/focus/focus-mode.tsx | 182 +++++++++++++++++ .../review-beta/focus/proposal-facts.tsx | 44 ++++ .../review-beta/focus/proposal-panel.tsx | 87 ++++++++ .../review-beta/focus/proposal-review.tsx | 88 ++++++++ .../review-beta/focus/score-color.ts | 8 + .../components/review-beta/focus/section.tsx | 41 ++++ .../review-beta/focus/speaker-card.tsx | 192 ++++++++++++++++++ .../review-beta/focus/tag-filter.tsx | 66 ++++++ .../components/review-beta/focus/url-state.ts | 31 +++ .../review-beta/focus/use-is-wide.ts | 18 ++ .../components/review-beta/focus/vote-bar.tsx | 175 ++++++++++++++++ .../review-beta/focus/votes-list.tsx | 88 ++++++++ .../components/review-beta/my-review-root.tsx | 3 +- .../src/components/review-beta/nav.tsx | 10 + 16 files changed, 1181 insertions(+), 1 deletion(-) create mode 100644 backend/custom_admin/src/components/review-beta/focus/collapsible-card.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/focus-mode.graphql create mode 100644 backend/custom_admin/src/components/review-beta/focus/focus-mode.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/proposal-facts.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/proposal-panel.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/proposal-review.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/score-color.ts create mode 100644 backend/custom_admin/src/components/review-beta/focus/section.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/speaker-card.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/tag-filter.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/url-state.ts create mode 100644 backend/custom_admin/src/components/review-beta/focus/use-is-wide.ts create mode 100644 backend/custom_admin/src/components/review-beta/focus/vote-bar.tsx create mode 100644 backend/custom_admin/src/components/review-beta/focus/votes-list.tsx diff --git a/backend/custom_admin/src/components/review-beta/focus/collapsible-card.tsx b/backend/custom_admin/src/components/review-beta/focus/collapsible-card.tsx new file mode 100644 index 0000000000..89bb38c819 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/collapsible-card.tsx @@ -0,0 +1,33 @@ +import { Card, Flex } from "@radix-ui/themes"; +import { Disclosure } from "./section"; +import { useIsWide } from "./use-is-wide"; + +type Props = { + summary: React.ReactNode; + children: React.ReactNode; +}; + +export const CollapsibleCard = ({ summary, children }: Props) => { + const isWide = useIsWide(); + + if (isWide) { + return ( + + + {summary} + {children} + + + ); + } + + return ( + + + + {children} + + + + ); +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/focus-mode.graphql b/backend/custom_admin/src/components/review-beta/focus/focus-mode.graphql new file mode 100644 index 0000000000..3fbdb452c3 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/focus-mode.graphql @@ -0,0 +1,116 @@ +fragment ReviewProposalFragment on ReviewProposal { + id + title { + en + it + } + elevatorPitchHtml { + en + it + } + abstractHtml { + en + it + } + notes + tags { + id + name + } + type + audienceLevel + duration + languages + rankings { + tag + rank + total + } + websiteUrl + adminUrl + isMine + speaker { + id + fullName + gender + country + photoUrl + bio + website + twitterHandle + instagramHandle + mastodonHandle + linkedinUrl + facebookUrl + speakerLevel + previousTalkVideo + participantAdminUrl + grant { + status + adminUrl + } + proposalsCount + maxProposals + otherProposals { + id + title + } + } + votes { + id + reviewerName + isMine + scoreLabel + scoreValue + comment + } + myVote { + scoreOptionId + comment + } +} + +query FocusReviewSession($reviewSessionId: ID!) { + reviewSession(reviewSessionId: $reviewSessionId) { + id + scoreOptions { + id + label + numericValue + } + tags { + id + name + } + } +} + +query NextProposalToReview( + $reviewSessionId: ID! + $excludeTags: [ID!]! + $seen: [ID!]! +) { + nextProposalToReview( + reviewSessionId: $reviewSessionId + excludeTags: $excludeTags + seen: $seen + ) +} + +query ReviewProposal($reviewSessionId: ID!, $proposalId: ID!) { + reviewProposal(reviewSessionId: $reviewSessionId, proposalId: $proposalId) { + ...ReviewProposalFragment + } +} + +mutation VoteProposal($input: VoteProposalInput!) { + voteProposal(input: $input) { + __typename + ... on ReviewProposal { + ...ReviewProposalFragment + } + ... on NotFound { + message + } + } +} diff --git a/backend/custom_admin/src/components/review-beta/focus/focus-mode.tsx b/backend/custom_admin/src/components/review-beta/focus/focus-mode.tsx new file mode 100644 index 0000000000..eb9fa6e7d4 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/focus-mode.tsx @@ -0,0 +1,182 @@ +import { useApolloClient } from "@apollo/client"; +import { + Box, + Button, + Callout, + Flex, + Link, + Spinner, + Text, +} from "@radix-ui/themes"; +import { Suspense, useEffect, useState } from "react"; +import { createPortal } from "react-dom"; +import { useArgs } from "../../shared/args"; +import { useNavActionsSlot } from "../nav"; +import type { Screen } from "../types"; +import { + NextProposalToReviewDocument, + type NextProposalToReviewQuery, + type NextProposalToReviewQueryVariables, + useFocusReviewSessionSuspenseQuery, +} from "./focus-mode.generated"; +import { ProposalReview } from "./proposal-review"; +import { TagFilter } from "./tag-filter"; +import { readUrlState, writeUrlState } from "./url-state"; + +export const FocusMode = () => ( + }> + + +); + +const FocusModeContent = () => { + const { reviewSessionId, screens } = useArgs() as { + reviewSessionId: number; + screens: Screen[]; + }; + const client = useApolloClient(); + const { + data: { reviewSession }, + } = useFocusReviewSessionSuspenseQuery({ + variables: { reviewSessionId: String(reviewSessionId) }, + }); + + const navActions = useNavActionsSlot(); + const [initialState] = useState(readUrlState); + const [excludeTags, setExcludeTags] = useState(initialState.excludeTags); + const [history, setHistory] = useState( + initialState.proposalId ? [initialState.proposalId] : [], + ); + const [position, setPosition] = useState(0); + const [loadingNext, setLoadingNext] = useState(!initialState.proposalId); + + const currentId = history[position] ?? null; + const shortlistUrl = screens.find((screen) => screen.id === "shortlist")?.url; + + const fetchNext = async (seen: string[]) => { + setLoadingNext(true); + const { data } = await client.query< + NextProposalToReviewQuery, + NextProposalToReviewQueryVariables + >({ + query: NextProposalToReviewDocument, + variables: { + reviewSessionId: String(reviewSessionId), + excludeTags, + seen, + }, + fetchPolicy: "network-only", + }); + const nextId = data.nextProposalToReview; + const newHistory = nextId ? [...seen, nextId] : seen; + setHistory(newHistory); + setPosition(nextId ? newHistory.length - 1 : newHistory.length); + setLoadingNext(false); + }; + + useEffect(() => { + if (!initialState.proposalId) { + fetchNext([]); + } + }, []); + + useEffect(() => { + writeUrlState({ proposalId: currentId, excludeTags }); + }, [currentId, excludeTags]); + + const goForward = () => { + if (position < history.length - 1) { + setPosition(position + 1); + return; + } + fetchNext(history); + }; + + const goBack = () => setPosition(Math.max(position - 1, 0)); + + const [toast, setToast] = useState(null); + useEffect(() => { + if (!toast) { + return; + } + const timeout = setTimeout(() => setToast(null), 3000); + return () => clearTimeout(timeout); + }, [toast]); + + const onVoted = (message: string) => { + setToast(message); + goForward(); + }; + + if (reviewSession.scoreOptions.length === 0) { + return ( + + + This review session has no score options yet. An admin must add them + in the review session page before anyone can vote. + + + ); + } + + return ( + + {toast && ( + + + โœ“ {toast} + + + )} + {navActions && + createPortal( + , + navActions, + )} + {loadingNext && } + {!loadingNext && currentId && ( + }> + 0} + onVoted={onVoted} + onSkip={goForward} + onBack={goBack} + /> + + )} + {!loadingNext && !currentId && ( + + + You've reviewed everything + + + {history.length > 0 && ( + + )} + {shortlistUrl && ( + Go to the Shortlist + )} + + + )} + + ); +}; + +const Loading = () => ( + + + +); diff --git a/backend/custom_admin/src/components/review-beta/focus/proposal-facts.tsx b/backend/custom_admin/src/components/review-beta/focus/proposal-facts.tsx new file mode 100644 index 0000000000..8a1b0c63a8 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/proposal-facts.tsx @@ -0,0 +1,44 @@ +import { Badge, Flex } from "@radix-ui/themes"; +import type { ReviewProposalFragmentFragment } from "./focus-mode.generated"; + +const LANGUAGES: Record = { + en: { flag: "๐Ÿ‡ฌ๐Ÿ‡ง", name: "English" }, + it: { flag: "๐Ÿ‡ฎ๐Ÿ‡น", name: "Italiano" }, +}; + +const TYPE_ICONS: Record = { + talk: "๐ŸŽค", + tutorial: "๐Ÿ› ๏ธ", + workshop: "๐Ÿ› ๏ธ", + keynote: "โญ", +}; + +type Props = { proposal: ReviewProposalFragmentFragment }; + +export const ProposalFacts = ({ proposal }: Props) => ( + + + + {TYPE_ICONS[proposal.type.toLowerCase()] ?? "๐Ÿ“„"} {proposal.type} + + + ๐Ÿ“ถ {proposal.audienceLevel} + + + โฑ {proposal.duration} min + + {proposal.languages.map((code) => ( + + {LANGUAGES[code]?.flag} {LANGUAGES[code]?.name ?? code} + + ))} + + + {proposal.tags.map((tag) => ( + + {tag.name} + + ))} + + +); diff --git a/backend/custom_admin/src/components/review-beta/focus/proposal-panel.tsx b/backend/custom_admin/src/components/review-beta/focus/proposal-panel.tsx new file mode 100644 index 0000000000..38014d11b8 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/proposal-panel.tsx @@ -0,0 +1,87 @@ +import { Box, Button, Flex, Heading, Separator, Text } from "@radix-ui/themes"; +import type { ReviewProposalFragmentFragment } from "./focus-mode.generated"; +import { ProposalFacts } from "./proposal-facts"; +import { Disclosure, SectionLabel } from "./section"; + +type Props = { proposal: ReviewProposalFragmentFragment }; + +export const ProposalPanel = ({ proposal }: Props) => { + const languageVersions = (["en", "it"] as const).filter( + (code) => proposal.title[code] !== null, + ); + + return ( + + + + {languageVersions.map((code, index) => ( + + {index > 0 && } + {languageVersions.length > 1 && ( + + {code === "en" ? "ENGLISH" : "ITALIANO"} + + )} + + + {proposal.title[code]} + + {index === 0 && ( + + + + + )} + + + + Elevator pitch + + + + + Abstract + + + + ))} + + {proposal.notes && } + {proposal.notes && ( + Notes from the author} + > + + {proposal.notes} + + + )} + + ); +}; + +const Html = ({ html }: { html: string | null }) => ( + +); diff --git a/backend/custom_admin/src/components/review-beta/focus/proposal-review.tsx b/backend/custom_admin/src/components/review-beta/focus/proposal-review.tsx new file mode 100644 index 0000000000..65974bbf47 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/proposal-review.tsx @@ -0,0 +1,88 @@ +import { Button, Callout, Flex, Grid } from "@radix-ui/themes"; +import { useArgs } from "../../shared/args"; +import { useReviewProposalSuspenseQuery } from "./focus-mode.generated"; +import { ProposalPanel } from "./proposal-panel"; +import { SpeakerCard } from "./speaker-card"; +import { VoteBar } from "./vote-bar"; +import { VotesList } from "./votes-list"; + +type ScoreOption = { id: string; label: string; numericValue: number }; + +type Props = { + proposalId: string; + scoreOptions: ScoreOption[]; + canGoBack: boolean; + onVoted: (message: string) => void; + onSkip: () => void; + onBack: () => void; +}; + +export const ProposalReview = ({ + proposalId, + scoreOptions, + canGoBack, + onVoted, + onSkip, + onBack, +}: Props) => { + const { reviewSessionId } = useArgs(); + const { + data: { reviewProposal: proposal }, + } = useReviewProposalSuspenseQuery({ + variables: { reviewSessionId: String(reviewSessionId), proposalId }, + fetchPolicy: "cache-and-network", + }); + + if (!proposal) { + return ( + + + + This proposal isn't in this review session, or it was cancelled. + + + + {canGoBack && ( + + )} + + + + ); + } + + return ( + + {proposal.isMine && ( + + This is your proposal. Press No vote. + + )} + + + + + + + + + + ); +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/score-color.ts b/backend/custom_admin/src/components/review-beta/focus/score-color.ts new file mode 100644 index 0000000000..a5ee744706 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/score-color.ts @@ -0,0 +1,8 @@ +const SCORE_COLORS = ["green", "lime", "amber", "orange", "red"] as const; + +export const scoreColor = (index: number, total: number) => + SCORE_COLORS[ + total < 2 + ? 0 + : Math.round((index / (total - 1)) * (SCORE_COLORS.length - 1)) + ]; diff --git a/backend/custom_admin/src/components/review-beta/focus/section.tsx b/backend/custom_admin/src/components/review-beta/focus/section.tsx new file mode 100644 index 0000000000..9f12478340 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/section.tsx @@ -0,0 +1,41 @@ +import { Text } from "@radix-ui/themes"; + +export const SectionLabel = ({ + children, + inline = false, +}: { + children: React.ReactNode; + inline?: boolean; +}) => ( + + {children} + +); + +export const Disclosure = ({ + summary, + children, +}: { + summary: React.ReactNode; + children: React.ReactNode; +}) => ( +
+ + + โ–ธ + +
{summary}
+
+ {children} +
+); diff --git a/backend/custom_admin/src/components/review-beta/focus/speaker-card.tsx b/backend/custom_admin/src/components/review-beta/focus/speaker-card.tsx new file mode 100644 index 0000000000..edbce1aeb5 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/speaker-card.tsx @@ -0,0 +1,192 @@ +import { + Avatar, + Button, + DataList, + Flex, + Heading, + Link, + Separator, + Text, +} from "@radix-ui/themes"; +import { useLayoutEffect, useRef, useState } from "react"; +import { useArgs } from "../../shared/args"; +import type { Screen } from "../types"; +import { CollapsibleCard } from "./collapsible-card"; +import type { ReviewProposalFragmentFragment } from "./focus-mode.generated"; +import { SectionLabel } from "./section"; + +type Props = { speaker: ReviewProposalFragmentFragment["speaker"] }; + +export const SpeakerCard = ({ speaker }: Props) => { + const { screens } = useArgs() as { screens: Screen[] }; + const focusUrl = screens.find((screen) => screen.id === "focus")?.url; + const socialLinks = [ + ["Website", speaker.website], + [ + "Twitter", + speaker.twitterHandle && `https://twitter.com/${speaker.twitterHandle}`, + ], + [ + "Instagram", + speaker.instagramHandle && + `https://instagram.com/${speaker.instagramHandle}`, + ], + ["LinkedIn", speaker.linkedinUrl], + ["Facebook", speaker.facebookUrl], + ].filter((social): social is [string, string] => Boolean(social[1])); + const details = [speaker.gender, speaker.country].filter(Boolean).join(" ยท "); + + const facts: [string, React.ReactNode][] = [ + ["Speaking experience", speaker.speakerLevel], + [ + "Previous talk", + speaker.previousTalkVideo && ( + + Watch video + + ), + ], + [ + "Grant", + speaker.grant ? ( + + {speaker.grant.status} + + ) : ( + "Not requested" + ), + ], + ].filter((fact): fact is [string, React.ReactNode] => Boolean(fact[1])); + + return ( + + + + + + {speaker.fullName} + + {details && ( + + {details} + + )} + + + {speaker.participantAdminUrl && ( + + )} + + } + > + {speaker.bio && } + + {(socialLinks.length > 0 || speaker.mastodonHandle) && ( + + {socialLinks.map(([label, url]) => ( + + {label} + + ))} + {speaker.mastodonHandle && ( + + Mastodon: {speaker.mastodonHandle} + + )} + + )} + + + + + {facts.map(([label, value]) => ( + + {label} + {value} + + ))} + + + + + + Proposals sent ยท{" "} + {speaker.maxProposals + ? `${speaker.proposalsCount} of ${speaker.maxProposals}` + : speaker.proposalsCount} + + {speaker.otherProposals.map((other) => ( + + {other.title} + + ))} + + + ); +}; + +const Bio = ({ text }: { text: string }) => { + const ref = useRef(null); + const [expanded, setExpanded] = useState(false); + const [clamped, setClamped] = useState(false); + + useLayoutEffect(() => { + const element = ref.current; + if (element && !expanded) { + setClamped(element.scrollHeight > element.clientHeight); + } + }, [expanded]); + + return ( + + + {text} + + {(clamped || expanded) && ( + + )} + + ); +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/tag-filter.tsx b/backend/custom_admin/src/components/review-beta/focus/tag-filter.tsx new file mode 100644 index 0000000000..868103966e --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/tag-filter.tsx @@ -0,0 +1,66 @@ +import { Button, Checkbox, Flex, Popover, Text } from "@radix-ui/themes"; + +type Tag = { id: string; name: string }; + +type Props = { + tags: Tag[]; + excluded: string[]; + onChange: (excluded: string[]) => void; +}; + +export const TagFilter = ({ tags, excluded, onChange }: Props) => { + const toggle = (tagId: string, hide: boolean) => + onChange( + hide ? [...excluded, tagId] : excluded.filter((id) => id !== tagId), + ); + + return ( + + + + + + + Don't show me these tags + + + Proposals with any of these tags are skipped in your queue. + + + + + + + {tags.map((tag) => ( + + + + toggle(tag.id, checked === true) + } + /> + {tag.name} + + + ))} + + + Applies from the next proposal. + + + + ); +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/url-state.ts b/backend/custom_admin/src/components/review-beta/focus/url-state.ts new file mode 100644 index 0000000000..9faacb10af --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/url-state.ts @@ -0,0 +1,31 @@ +const readList = (name: string) => + (new URLSearchParams(window.location.search).get(name) ?? "") + .split(",") + .filter(Boolean); + +export const readUrlState = () => ({ + proposalId: readList("proposal")[0] ?? null, + excludeTags: readList("exclude"), +}); + +export const writeUrlState = ({ + proposalId, + excludeTags, +}: { + proposalId: string | null; + excludeTags: string[]; +}) => { + const params = new URLSearchParams(); + if (proposalId) { + params.set("proposal", proposalId); + } + if (excludeTags.length > 0) { + params.set("exclude", excludeTags.join(",")); + } + const query = params.toString(); + window.history.replaceState( + null, + "", + `${window.location.pathname}${query ? `?${query}` : ""}`, + ); +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/use-is-wide.ts b/backend/custom_admin/src/components/review-beta/focus/use-is-wide.ts new file mode 100644 index 0000000000..d7cd2fd554 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/use-is-wide.ts @@ -0,0 +1,18 @@ +import { useEffect, useState } from "react"; + +const WIDE_QUERY = "(min-width: 1024px)"; + +export const useIsWide = () => { + const [isWide, setIsWide] = useState( + () => window.matchMedia(WIDE_QUERY).matches, + ); + + useEffect(() => { + const query = window.matchMedia(WIDE_QUERY); + const onChange = () => setIsWide(query.matches); + query.addEventListener("change", onChange); + return () => query.removeEventListener("change", onChange); + }, []); + + return isWide; +}; diff --git a/backend/custom_admin/src/components/review-beta/focus/vote-bar.tsx b/backend/custom_admin/src/components/review-beta/focus/vote-bar.tsx new file mode 100644 index 0000000000..55e6e494a9 --- /dev/null +++ b/backend/custom_admin/src/components/review-beta/focus/vote-bar.tsx @@ -0,0 +1,175 @@ +import { + Box, + Button, + Callout, + Flex, + Strong, + Text, + TextArea, +} from "@radix-ui/themes"; +import { useState } from "react"; +import { useArgs } from "../../shared/args"; +import { + type ReviewProposalFragmentFragment, + useVoteProposalMutation, +} from "./focus-mode.generated"; +import { scoreColor } from "./score-color"; + +const NO_VOTE = "no-vote"; + +type ScoreOption = { id: string; label: string; numericValue: number }; + +type Props = { + proposalId: string; + proposalTitle: string; + myVote: ReviewProposalFragmentFragment["myVote"]; + scoreOptions: ScoreOption[]; + canGoBack: boolean; + onVoted: (message: string) => void; + onSkip: () => void; + onBack: () => void; +}; + +export const VoteBar = ({ + proposalId, + proposalTitle, + myVote, + scoreOptions, + canGoBack, + onVoted, + onSkip, + onBack, +}: Props) => { + const { reviewSessionId } = useArgs(); + const [choice, setChoice] = useState( + myVote ? (myVote.scoreOptionId ?? NO_VOTE) : null, + ); + const [comment, setComment] = useState(myVote?.comment ?? ""); + const [error, setError] = useState(null); + const [voteProposal, { loading }] = useVoteProposalMutation(); + const labelOf = (id: string | null) => + id === NO_VOTE + ? "No vote" + : scoreOptions.find((option) => option.id === id)?.label; + const savedLabel = myVote ? labelOf(myVote.scoreOptionId ?? NO_VOTE) : null; + + const vote = async () => { + setError(null); + try { + const { data } = await voteProposal({ + variables: { + input: { + reviewSessionId: String(reviewSessionId), + proposalId, + scoreOptionId: choice === NO_VOTE ? null : choice, + comment, + }, + }, + }); + if (data?.voteProposal.__typename !== "ReviewProposal") { + setError("This proposal or score option no longer exists."); + return; + } + onVoted(`Saved ${labelOf(choice)} on โ€œ${proposalTitle}โ€`); + } catch { + setError("Couldn't save your vote. Try again."); + } + }; + + return ( + + + + + {scoreOptions.map((option, index) => { + const picked = option.id === choice; + return ( + + ); + })} + + + + + + + + + + +