Skip to content

Commit 522c761

Browse files
committed
UI Breadcrumb changes
1 parent a1aebbb commit 522c761

File tree

18 files changed

+296
-314
lines changed

18 files changed

+296
-314
lines changed

src/components/ActivityRow/ActivityRow.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Stage } from '@/extensions/org.cubingusa.natshelper.v1/types';
66
import { useNow } from '@/hooks/useNow';
77
import { activityCodeToName } from '@/lib/activityCodes';
88
import { formatTimeRange } from '@/lib/time';
9+
import { Pill } from '../Pill';
910

1011
interface ActivityRowProps {
1112
activity: Activity;
@@ -38,14 +39,14 @@ export function ActivityRow({ activity, stage, timeZone, showRoom = true }: Acti
3839
to={`/competitions/${competitionId}/activities/${activity.id}`}>
3940
<span>{activityName}</span>
4041
<span className="text-xs md:text-sm font-light flex justify-between">
41-
{showRoom && (
42-
<span
42+
{showRoom && stage && (
43+
<Pill
4344
className="mr-2 px-1 rounded"
4445
style={{
45-
backgroundColor: `${stage?.color}70`,
46+
backgroundColor: `${stage.color}70`,
4647
}}>
47-
{stage?.name}
48-
</span>
48+
{stage.name}
49+
</Pill>
4950
)}
5051
<span>{formatTimeRange(activity.startTime, activity.endTime, 5, timeZone)}</span>
5152
</span>

src/components/AssignmentLabel/AssignmentLabel.test.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { AssignmentCode } from '@wca/helpers';
22
import { useTranslation } from 'react-i18next';
3-
4-
const Container = ({ children, className }: React.PropsWithChildren<{ className?: string }>) => (
5-
<span className={`${className} px-[6px] py-[4px] rounded-md bg-blue-100`}>{children}</span>
6-
);
3+
import { Pill } from '../Pill';
74

85
interface AssignmentLabelProps {
96
assignmentCode: AssignmentCode;
@@ -14,11 +11,11 @@ export function AssignmentLabel({ assignmentCode }: AssignmentLabelProps) {
1411

1512
if (assignmentCode.match(/judge/i)) {
1613
return (
17-
<Container className="bg-blue-200">
14+
<Pill className="bg-blue-200">
1815
{t('common.assignments.staff-judge.noun', {
1916
defaultValue: assignmentCode.replace('staff-', ''),
2017
})}
21-
</Container>
18+
</Pill>
2219
);
2320
}
2421

@@ -28,20 +25,20 @@ export function AssignmentLabel({ assignmentCode }: AssignmentLabelProps) {
2825

2926
switch (assignmentCode) {
3027
case 'competitor':
31-
return <Container className="bg-green-200">{name}</Container>;
28+
return <Pill className="bg-green-200">{name}</Pill>;
3229
case 'staff-scrambler':
33-
return <Container className="bg-yellow-200">{name}</Container>;
30+
return <Pill className="bg-yellow-200">{name}</Pill>;
3431
case 'staff-runner':
35-
return <Container className="bg-orange-200">{name}</Container>;
32+
return <Pill className="bg-orange-200">{name}</Pill>;
3633
case 'staff-dataentry':
37-
return <Container className="bg-cyan-200">{name}</Container>;
34+
return <Pill className="bg-cyan-200">{name}</Pill>;
3835
case 'staff-announcer':
39-
return <Container className="bg-violet-200">{name}</Container>;
36+
return <Pill className="bg-violet-200">{name}</Pill>;
4037
case 'staff-delegate':
41-
return <Container className="bg-purple-200">{name}</Container>;
38+
return <Pill className="bg-purple-200">{name}</Pill>;
4239
case 'staff-stagelead':
43-
return <Container className="bg-purple-800">{name}</Container>;
40+
return <Pill className="bg-purple-800">{name}</Pill>;
4441
default:
45-
return <Container>{name}</Container>;
42+
return <Pill className="bg-blue-100">{name}</Pill>;
4643
}
4744
}

src/components/AssignmentLabel/__snapshots__/AssignmentLabel.test.tsx.snap

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import classNames from 'classnames';
2+
import { Fragment } from 'react';
3+
import { Link } from 'react-router-dom';
4+
import { Pill, PillProps } from '../Pill';
5+
6+
export type Breadcrumb =
7+
| {
8+
label: string;
9+
href: string;
10+
pillProps?: PillProps;
11+
}
12+
| {
13+
label: string;
14+
};
15+
16+
export interface BreadcrumbsProps {
17+
breadcrumbs: Breadcrumb[];
18+
}
19+
20+
export const Breadcrumbs = ({ breadcrumbs }: BreadcrumbsProps) => {
21+
return (
22+
<div className="flex items-center space-x-1">
23+
{breadcrumbs.map(({ label, ...breadcrumb }, index) => (
24+
<Fragment key={label}>
25+
{index > 0 && <span className="text-gray-500 dark:text-gray-400">·</span>}
26+
{'href' in breadcrumb ? (
27+
<Link to={breadcrumb.href}>
28+
<Pill
29+
{...breadcrumb.pillProps}
30+
className={classNames(
31+
'min-h-[40px] hover:ring-2',
32+
breadcrumb.pillProps?.className,
33+
)}>
34+
{label}
35+
</Pill>
36+
</Link>
37+
) : (
38+
<span key={label}>{label}</span>
39+
)}
40+
</Fragment>
41+
))}
42+
</div>
43+
);
44+
};

src/components/Container/Container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const Container = ({ children, className, fullWidth = false }: ContainerP
1212
className={classNames(
1313
'flex flex-col w-full h-max',
1414
{
15-
'lg:w-1/2 md:w-2/3': !fullWidth,
15+
'max-w-screen-md': !fullWidth,
1616
},
1717
className,
1818
)}>

src/components/CutoffTimeLimitPanel/CutoffTimeLimitPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export function CutoffTimeLimitPanel({
2727

2828
return (
2929
<div className={classNames('flex w-full', className)}>
30-
<div className="flex flex-col space-y-1 flex-1">
31-
<div className="divide-x-2 divide-gray-100">
30+
<div className="flex flex-col space-y-1 flex-1 -mx-2">
31+
<div className="divide-x-2 divide-gray-100 flex">
3232
{cutoff && (
3333
<span className="px-2">
3434
{t('common.wca.cutoff')}:{' '}

src/components/Pill/Pill.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import classNames from 'classnames';
2+
3+
export type PillProps = React.PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>;
4+
5+
export const Pill = ({ className, ...props }: PillProps) => {
6+
return (
7+
<span
8+
className={classNames(
9+
`inline-flex justify-center items-center px-1.5 py-1 ring-1 ring-inset ring-gray-100 font-medium rounded-md bg-gray-100 text-gray-800 shadow-sm`,
10+
className,
11+
)}
12+
{...props}
13+
/>
14+
);
15+
};

src/components/Pill/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Pill';

src/containers/LiveActivities/LiveActivities.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { AssignmentCodeCell } from '@/components/AssignmentCodeCell';
55
import { useNow } from '@/hooks/useNow/useNow';
66
import { useOngoingActivities } from '@/hooks/useOngoingActivities';
77
import { getAllChildActivities, getAllRoundActivities, getRooms } from '@/lib/activities';
8+
import { GroupAssignmentCodeRank } from '@/lib/constants';
89
import { formatTime } from '@/lib/time';
9-
import { GroupAssignmentCodeRank } from '@/pages/Competition/ByGroup/Group';
1010
import { useWCIF } from '@/providers/WCIFProvider';
1111

1212
const useCommon = (competitionId: string) => {

0 commit comments

Comments
 (0)