mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-20 14:12:01 -05:00
* Renders groups * Bracket data refactoring * Starting bracket working (first bracket only) * TODOs + crash fix * Source bracket logic initial * Bracket progression (DE underground bracket) * Preview working for second bracket * Bracket nav initial * Check-in to bracket feature * Start Underground bracket * Team/teams pages tweaks to support underground bracket * Underground bracket finalization progress * Tournament class * id -> userId + more useOutletContext removed * Bracket loader refactored out * Migrate admin to useTournament * Bracket.settings * Slim tournament loader * Fix useEffect infinite loop * Adjust waiting for teams text * Refactor old tournament DB call from to admin * Admin action: check in/out from specific bracket * Standings work * Back button from match page -> correct bracket * Standings logic for DE grand finals * Standings + finalize bracket * Dev log * Unit tests utils etc. * Adjust TODOs * Fix round robin issues * Add RR tests * Round robin standings initial * Wins against tied + points tiebreaker progress * Fix losing state when switching between tabs * Add check-in indications to seeding page * Link to user page on seed tool * Submit points * Total points from bracket manager * findById gonezino * Ahead of time check-in * Couple todos * Reopen logic refactor * Tournament format settings * RR->SE placements, skipping underground bracket * Fix tournament team page round names * More teams to UG bracket if first round of DE only byes * Fix graphics bug * Fixes * Fix some E2E tests * Fix E2E tests
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import clsx from "clsx";
|
|
|
|
type LabelProps = Pick<
|
|
React.DetailedHTMLProps<
|
|
React.LabelHTMLAttributes<HTMLLabelElement>,
|
|
HTMLLabelElement
|
|
>,
|
|
"children" | "htmlFor"
|
|
> & {
|
|
valueLimits?: {
|
|
current: number;
|
|
max: number;
|
|
};
|
|
required?: boolean;
|
|
className?: string;
|
|
labelClassName?: string;
|
|
spaced?: boolean;
|
|
};
|
|
|
|
export function Label({
|
|
valueLimits,
|
|
required,
|
|
children,
|
|
htmlFor,
|
|
className,
|
|
labelClassName,
|
|
spaced = true,
|
|
}: LabelProps) {
|
|
return (
|
|
<div className={clsx("label__container", className, { "mb-0": !spaced })}>
|
|
<label htmlFor={htmlFor} className={labelClassName}>
|
|
{children} {required && <span className="text-error">*</span>}
|
|
</label>
|
|
{valueLimits ? (
|
|
<div className={clsx("label__value", lengthWarning(valueLimits))}>
|
|
{valueLimits.current}/{valueLimits.max}
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function lengthWarning(valueLimits: NonNullable<LabelProps["valueLimits"]>) {
|
|
if (valueLimits.current >= valueLimits.max) return "error";
|
|
if (valueLimits.current / valueLimits.max >= 0.9) return "warning";
|
|
|
|
return;
|
|
}
|