Skip to content
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
8 changes: 6 additions & 2 deletions src/community/components/UnderlineTabs.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.tabs {
display: flex;
gap: 22px;
border-bottom: 1px solid var(--border);
box-shadow: inset 0 -1px 0 var(--border);
overflow-x: auto;
scrollbar-width: none;
}
Expand All @@ -15,7 +15,6 @@
display: inline-flex;
align-items: center;
gap: 7px;
margin-bottom: -1px;
padding: 10px 1px;
border: 0;
border-bottom: 2px solid transparent;
Expand All @@ -28,6 +27,11 @@
cursor: pointer;
}

.tab:focus-visible {
border-radius: var(--radius-2xs);
outline-offset: -2px;
}

.tab:hover {
color: var(--mw-text);
}
Expand Down
75 changes: 68 additions & 7 deletions src/community/pages/Challenge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const PHASES = {
'submissions': {label: 'Submissions open', tone: 'open'},
'judging': {label: 'Judging', tone: 'building'},
'awaiting-results': {label: 'Results pending', tone: 'building'},
'results': {label: 'Results published', tone: 'shipped'}
'results': {label: 'Finished', tone: 'shipped'}
};

const AUDIENCE_PHASES = {
Expand Down Expand Up @@ -261,7 +261,7 @@ const Entry = ({challengeId, project, challenge, user, login, load, onError}) =>
};
return (
<article className={styles.entry}>
{challenge.phase === 'results' && project.place ? <span className={project.place <= 3 ? styles.placeWinner : styles.place}>#{project.place}</span> : null}
{challenge.phase === 'results' && project.place ? <span className={styles.place} data-place={project.place}>#{project.place}</span> : null}
<ProjectCard project={project} />
{showRatings || showJudgeScore ? (
<div className={styles.entryFooter}>
Expand Down Expand Up @@ -456,6 +456,7 @@ const JudgingWorkspace = ({challengeId, projects, criteria, load}) => {
const Timeline = ({space, phase, now, audienceJudged}) => {
const {text: communityText} = useCommunityText();
const finished = phase === 'results' || phase === 'awaiting-results';
const published = phase === 'results';
const steps = [
{
key: 'open',
Expand Down Expand Up @@ -484,8 +485,18 @@ const Timeline = ({space, phase, now, audienceJudged}) => {
at: space.judgingEndsAt,
done: finished,
active: phase === 'judging',
countdown: phase === 'judging' ? (audienceJudged ? communityText('{value1} of voting left', {value1: remaining(space.judgingEndsAt, now)}) : communityText('{value1} of judging left', {value1: remaining(space.judgingEndsAt, now)})) : ''
}
countdown: phase === 'judging' ? (audienceJudged ? communityText('{value1} of voting left', {value1: remaining(space.judgingEndsAt, now)}) : communityText('{value1} of judging left', {value1: remaining(space.judgingEndsAt, now)})) : '',
...(published ? {progress: 1} : {})
},
...(published ? [{
key: 'results',
icon: Medal,
label: communityText('Winner announced'),
at: space.resultsPublishedAt,
done: true,
active: false,
countdown: ''
}] : [])
];
return (
<ol className={styles.timeline} aria-label={communityText('Challenge schedule')}>
Expand All @@ -504,6 +515,53 @@ const Timeline = ({space, phase, now, audienceJudged}) => {
);
};

const resultScore = (project, audienceJudged, communityText) => {
if (!audienceJudged) return <strong>{challengeScore(project.judgeScore)}<small>{communityText('/ 10')}</small></strong>;
if (!project.audienceVoteCount) return <small>{communityText('No ratings')}</small>;
return <strong>{challengeScore(project.audienceScore)}<small>{communityText('/ 5 from {value1} ratings', {value1: project.audienceVoteCount})}</small></strong>;
};

const Results = ({projects, audienceJudged}) => {
const {text: communityText} = useCommunityText();
const podium = projects.filter(project => project.place && project.place <= 3);
const rest = projects.filter(project => !project.place || project.place > 3);
return (
<React.Fragment>
{podium.length ? (
<ol className={styles.podium} aria-label={communityText('Top three')}>
{podium.map(project => (
<li key={project.id} className={styles.podiumEntry}>
<Link to={projectUrl(project)} className={styles.podiumThumb} tabIndex={-1} aria-hidden="true">
<ProjectThumbnail project={project} fallbackClassName={styles.judgeFallback} lazy />
</Link>
<span className={styles.medal} data-place={project.place}>{`#${project.place}`}</span>
<div className={styles.podiumText}>
<Link to={projectUrl(project)}>{project.title}</Link>
<span>{communityText('by')}{' '}<UserLink username={project.owner}>{project.owner}</UserLink></span>
</div>
<div className={styles.podiumScore}>{resultScore(project, audienceJudged, communityText)}</div>
</li>
))}
</ol>
) : null}
{rest.length ? (
<ol className={styles.resultList} aria-label={podium.length ? communityText('Other entries') : communityText('All entries')}>
{rest.map(project => (
<li key={project.id}>
<span className={styles.resultPlace}>{project.place ? `#${project.place}` : '-'}</span>
<Link to={projectUrl(project)} className={styles.resultThumb} tabIndex={-1} aria-hidden="true">
<ProjectThumbnail project={project} fallbackClassName={styles.queueFallback} lazy />
</Link>
<div><Link to={projectUrl(project)}>{project.title}</Link><span>{communityText('by')}{' '}<UserLink username={project.owner}>{project.owner}</UserLink></span></div>
{resultScore(project, audienceJudged, communityText)}
</li>
))}
</ol>
) : null}
</React.Fragment>
);
};

const Challenge = ({id, space, user, login, load}) => {
const {text: communityText} = useCommunityText();
const [tab, setTab] = useState(space.phase === 'results' ? 'results' : 'overview');
Expand Down Expand Up @@ -663,7 +721,9 @@ const Challenge = ({id, space, user, login, load}) => {
{audienceJudged ? (
<div className={styles.sidebarBlock}>
<h2><Star size={16} aria-hidden="true" />{communityText('Audience vote')}</h2>
<p className={styles.sidebarText}>{communityText('Once submissions close, anyone signed in can rate each entry from 1 to 5 stars. Ratings stay hidden until voting ends, and the entry with the highest average rating wins.')}</p>
<p className={styles.sidebarText}>{currentPhase === 'results' ? communityText('Voting has closed. Signed-in members rated each entry from 1 to 5 stars, and the entry with the highest average rating won.') :
currentPhase === 'awaiting-results' ? communityText('Voting has closed. The winner will be announced when the host publishes the results.') :
communityText('Once submissions close, anyone signed in can rate each entry from 1 to 5 stars. Ratings stay hidden until voting ends, and the entry with the highest average rating wins.')}</p>
</div>
) : null}
{!audienceJudged && space.communityVoting ? <p className={styles.sidebarText}>{communityText('Audience ratings are open during judging. They are shown next to each entry but do not decide the winner.')}</p> : null}
Expand Down Expand Up @@ -710,7 +770,8 @@ const Challenge = ({id, space, user, login, load}) => {
count={space.projects.length}
lead={currentPhase === 'submissions' ? communityText('Enter a shared or unlisted project before submissions close.') :
currentPhase === 'judging' && (audienceJudged || space.communityVoting) ? communityText('Click the stars to rate an entry. Ratings stay hidden until voting ends, and you can change yours until then.') :
communityText('Submissions are locked for this challenge.')}
currentPhase === 'results' ? communityText('This challenge has finished. Entries are shown in their final ranking.') :
communityText('Submissions are locked for this challenge.')}
actions={currentPhase === 'submissions' && (space.openSubmissions || space.canManage) ? <SpaceProjectPicker space={liveSpace} onAdded={load} /> : null}
/>
{space.projects.length ? <CardGrid>{space.projects.map(project => <Entry key={project.id} challengeId={id} project={project} challenge={liveSpace} user={user} login={login} load={load} onError={setError} />)}</CardGrid> : <EmptyState icon={Trophy} title={communityText('No submissions yet')}>{communityText('The first entry will appear here.')}</EmptyState>}
Expand All @@ -719,7 +780,7 @@ const Challenge = ({id, space, user, login, load}) => {
{tab === 'results' ? (
<section>
<SectionHeading icon={Medal} title={communityText('Final results')} lead={audienceJudged ? communityText('Ranked by average audience rating. Ties go to the entry with more ratings.') : communityText('Ranked by the judges using the criteria shown on the overview.')} />
{space.projects.length ? <ol className={styles.resultList}>{space.projects.map(project => <li key={project.id}><span className={project.place <= 3 ? styles.resultPlaceWinner : styles.resultPlace}>{project.place ? `#${project.place}` : '-'}</span><div><Link to={`/project/${project.id}`}>{project.title}</Link><span>{communityText('by')}{' '}<UserLink username={project.owner}>{project.owner}</UserLink></span></div>{audienceJudged ? (project.audienceVoteCount ? <strong>{challengeScore(project.audienceScore)}<small>{communityText('/ 5 from {value1} ratings', {value1: project.audienceVoteCount})}</small></strong> : <small>{communityText('No ratings')}</small>) : <strong>{challengeScore(project.judgeScore)}<small>{communityText('/ 10')}</small></strong>}</li>)}</ol> : <EmptyState compact icon={Medal} title={communityText('No results')}>{communityText('This challenge did not receive any submissions.')}</EmptyState>}
{space.projects.length ? <Results projects={space.projects} audienceJudged={audienceJudged} /> : <EmptyState compact icon={Medal} title={communityText('No results')}>{communityText('This challenge did not receive any submissions.')}</EmptyState>}
</section>
) : null}
{tab === 'judging' ? (
Expand Down
160 changes: 149 additions & 11 deletions src/community/pages/Challenge.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
padding: 18px 20px 16px;
border-radius: var(--radius-sm);
background: var(--bg-card);
grid-template-columns: repeat(3, 1fr);
grid-auto-columns: minmax(0, 1fr);
grid-auto-flow: column;
gap: 0 20px;
list-style: none;
}
Expand Down Expand Up @@ -373,8 +374,7 @@
box-shadow: none;
}

.place,
.placeWinner {
.place {
position: absolute;
z-index: 2;
top: 9px;
Expand All @@ -388,9 +388,20 @@
font-weight: 700;
}

.placeWinner {
color: #3b2a00;
background: #f3c952;
.place[data-place='1'],
.place[data-place='2'],
.place[data-place='3'],
.medal {
color: #2b2100;
background: var(--medal, #f3c952);
}

[data-place='2'] {
--medal: #cfd6e0;
}

[data-place='3'] {
--medal: #e0a36f;
}

.entryFooter {
Expand Down Expand Up @@ -969,16 +980,100 @@
background: var(--bg-card);
}

.resultPlace,
.resultPlaceWinner {
.resultPlace {
width: 38px;
color: var(--text-faint);
font-size: var(--fs-lg);
font-weight: 700;
}

.resultPlaceWinner {
color: #d5a519;
.resultThumb {
display: grid;
width: 64px;
flex: 0 0 64px;
aspect-ratio: 4 / 3;
place-items: center;
border-radius: var(--radius-2xs);
background: var(--bg-raised);
overflow: hidden;
}

.resultThumb img,
.podiumThumb img {
width: 100%;
height: 100%;
object-fit: cover;
}

.podium {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
margin: 0 0 8px;
padding: 0;
gap: 8px;
list-style: none;
}

.podiumEntry {
position: relative;
display: grid;
align-content: start;
padding: 12px 12px 14px;
gap: 12px;
border-radius: var(--radius-sm);
background: var(--bg-card);
}

.podiumThumb {
display: grid;
aspect-ratio: 4 / 3;
place-items: center;
border-radius: var(--radius-xs);
background: var(--bg-raised);
overflow: hidden;
}

.medal {
position: absolute;
top: 20px;
left: 20px;
padding: 5px 9px;
border-radius: var(--radius-xs);
box-shadow: var(--card-shadow);
font-size: var(--fs-sm);
font-weight: 700;
}

.podiumText {
display: grid;
min-width: 0;
gap: 2px;
}

.podiumText > a {
font-size: var(--fs-lg);
font-weight: 700;
line-height: 1.25;
overflow-wrap: anywhere;
}

.podiumText > a:hover {
color: var(--accent-strong);
}

.podiumText span {
color: var(--text-faint);
font-size: var(--fs-xs);
}

.podiumScore strong {
font-size: var(--fs-xl);
}

.podiumScore small {
margin-inline-start: 4px;
color: var(--text-faint);
font-size: var(--fs-2xs);
}

.resultList li > div {
Expand Down Expand Up @@ -1043,10 +1138,53 @@
@media (max-width: 620px) {
.timeline {
padding: 14px 16px;
grid-template-columns: 1fr;
grid-auto-flow: row;
gap: 14px;
}

.podium {
grid-template-columns: 1fr;
}

.podiumEntry {
align-items: center;
grid-template-columns: 112px minmax(0, 1fr);
padding: 10px;
gap: 4px 12px;
}

.podiumThumb {
grid-row: 1 / span 2;
}

.podiumText,
.podiumScore {
grid-column: 2;
}

.podiumText {
align-self: end;
}

.podiumScore {
align-self: start;
}

.podiumText > a {
font-size: var(--fs-md);
}

.medal {
top: 14px;
left: 14px;
padding: 3px 6px;
font-size: var(--fs-2xs);
}

.resultThumb {
display: none;
}

.step,
.stepDone,
.stepActive {
Expand Down
Loading
Loading