Skip to content

Commit b787829

Browse files
committed
Updated styles for psych sheet
1 parent 9502c4a commit b787829

File tree

2 files changed

+47
-42
lines changed

2 files changed

+47
-42
lines changed

src/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717
@apply bg-green-50;
1818
}
1919
}
20+
21+
.stickyGridHeader > * {
22+
@apply sticky top-0;
23+
}

src/pages/Competition/PsychSheet/PsychSheetEvent.tsx

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import getUnicodeFlagIcon from 'country-flag-icons/unicode';
44
import { useCallback, useMemo } from 'react';
55
import { useTranslation } from 'react-i18next';
66
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
7-
import StickyBox from 'react-sticky-box';
87
import { Container } from '@/components/Container';
98
import { activityCodeToName } from '@/lib/activityCodes';
109
import { acceptedRegistration, isRegisteredForEvent } from '@/lib/person';
@@ -67,7 +66,7 @@ export const PsychSheetEvent = () => {
6766
[sortedPersons],
6867
);
6968

70-
const gridCss = 'grid grid-cols-[3em_2em_1fr_min-content_7em] grid-rows-10';
69+
const gridCss = 'grid grid-cols-[3em_2em_1fr_min-content_7em]';
7170

7271
const handleEventChange = useCallback(
7372
(newEventId: EventId) => {
@@ -106,14 +105,17 @@ export const PsychSheetEvent = () => {
106105
<option value="single">{t('common.wca.resultType.single')}</option>
107106
</select>
108107
</div>
109-
<StickyBox offsetTop={0} offsetBottom={0}>
110-
<div className={classNames('bg-green-300 w-full', gridCss)} role="rowheader">
108+
109+
<div className={gridCss}>
110+
<div
111+
className={'[&>span]:bg-green-300 stickyGridHeader contents absolute'}
112+
role="rowheader">
111113
<span className="px-3 py-2.5 text-right font-bold">#</span>
112-
<span className="px-3 py-2.5 text-left"></span>
114+
<span className="px-3 py-2.5 text-left" />
113115
<span className="px-3 py-2.5 text-left font-bold">
114116
{t('competition.rankings.name')}
115117
</span>
116-
<span className="px-3 py-2.5 text-right font-bold">
118+
<span className="px-3 py-2.5 text-right font-bold whitespace-nowrap">
117119
{resultType === 'single'
118120
? t('common.wca.resultType.single')
119121
: t('common.wca.resultType.average')}{' '}
@@ -122,42 +124,41 @@ export const PsychSheetEvent = () => {
122124
{t('common.wca.recordType.WR')}
123125
</span>
124126
</div>
125-
</StickyBox>
126-
127-
<div className={classNames(gridCss, 'striped')}>
128-
{sortedPersons?.map((person) => {
129-
const rank =
130-
(rankings?.findIndex((i) => i === person.pr?.worldRanking) >= 0
131-
? rankings?.findIndex((i) => i === person.pr?.worldRanking)
132-
: rankings.length) + 1;
133-
134-
const prAverage = person.personalBests?.find(
135-
(pr) => pr.eventId === eventId && pr.type === 'average',
136-
);
137-
138-
return (
139-
<Link
140-
key={person.registrantId}
141-
className="contents"
142-
to={`/competitions/${wcif?.id}/personal-bests/${person.wcaId}`}>
143-
<span className="px-3 py-2.5 text-right flex items-center [font-variant-numeric:tabular-nums]">
144-
{rank}
145-
</span>
146-
<span className="px-3 py-2.5 text-left flex items-center w-full">
147-
{getUnicodeFlagIcon(person.countryIso2)}
148-
</span>
149-
<span className="px-3 py-2.5 text-left truncate">{person.name}</span>
150-
<span className="px-3 py-2.5 text-right [font-variant-numeric:tabular-nums]">
151-
{prAverage ? renderResultByEventId(eventId, 'average', prAverage.best) : ''}
152-
</span>
153-
<span className="px-3 py-2.5 text-right [font-variant-numeric:tabular-nums]">
154-
{prAverage
155-
? `${prAverage.worldRanking.toLocaleString([...navigator.languages])}`
156-
: ''}
157-
</span>
158-
</Link>
159-
);
160-
})}
127+
<div className="contents striped">
128+
{sortedPersons?.map((person) => {
129+
const rank =
130+
(rankings?.findIndex((i) => i === person.pr?.worldRanking) >= 0
131+
? rankings?.findIndex((i) => i === person.pr?.worldRanking)
132+
: rankings.length) + 1;
133+
134+
const prAverage = person.personalBests?.find(
135+
(pr) => pr.eventId === eventId && pr.type === 'average',
136+
);
137+
138+
return (
139+
<Link
140+
key={person.registrantId}
141+
className="contents"
142+
to={`/competitions/${wcif?.id}/personal-bests/${person.wcaId}`}>
143+
<span className="px-3 py-2.5 text-right [font-variant-numeric:tabular-nums]">
144+
{rank}
145+
</span>
146+
<span className="px-3 py-2.5 text-left flex items-center w-full">
147+
{getUnicodeFlagIcon(person.countryIso2)}
148+
</span>
149+
<span className="px-3 py-2.5 text-left truncate">{person.name}</span>
150+
<span className="px-3 py-2.5 text-right [font-variant-numeric:tabular-nums]">
151+
{prAverage ? renderResultByEventId(eventId, 'average', prAverage.best) : ''}
152+
</span>
153+
<span className="px-3 py-2.5 text-right [font-variant-numeric:tabular-nums]">
154+
{prAverage
155+
? `${prAverage.worldRanking.toLocaleString([...navigator.languages])}`
156+
: ''}
157+
</span>
158+
</Link>
159+
);
160+
})}
161+
</div>
161162
</div>
162163
</div>
163164
</Container>

0 commit comments

Comments
 (0)