Files
nuzlocke-tracker/frontend/src/components/RuleBadges.tsx
Julian Tabel 1cd1389408
Some checks failed
CI / backend-tests (push) Successful in 28s
CI / frontend-tests (push) Failing after 28s
Replace playstyle rules with free-text custom rules markdown field
Remove hardcoreMode, setModeOnly, and bossTeamMatch toggles which had
no mechanical impact on the tracker. Replace them with a customRules
markdown field so users can document their own rules (especially useful
for genlockes). Add react-markdown + remark-gfm for rendering and
@tailwindcss/typography for prose styling. The custom rules display is
collapsible and hidden by default.

Also simplifies the BossDefeatModal by removing the Lost result and
attempts counter, and always shows boss team size in the level cap bar.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 15:09:02 +01:00

55 lines
1.9 KiB
TypeScript

import type { NuzlockeRules } from '../types'
import { RULE_DEFINITIONS } from '../types/rules'
import { TypeBadge } from './TypeBadge'
interface RuleBadgesProps {
rules: NuzlockeRules
}
export function RuleBadges({ rules }: RuleBadgesProps) {
const enabledRules = RULE_DEFINITIONS.filter((def) => rules[def.key])
const allowedTypes = rules.allowedTypes ?? []
const hasCustomRules = (rules.customRules ?? '').trim().length > 0
if (enabledRules.length === 0 && allowedTypes.length === 0 && !hasCustomRules) {
return <span className="text-sm text-text-tertiary">No rules enabled</span>
}
return (
<div className="flex flex-wrap gap-1.5">
{enabledRules.map((def) => (
<span
key={def.key}
title={def.description}
className={`px-2 py-0.5 rounded-full text-xs font-medium ${
def.category === 'core'
? 'bg-blue-900/40 text-blue-300 light:bg-blue-100 light:text-blue-700'
: 'bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-700'
}`}
>
{def.name}
</span>
))}
{allowedTypes.length > 0 && (
<span
title={`Type restriction: ${allowedTypes.map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(', ')}`}
className="px-2 py-0.5 rounded-full text-xs font-medium bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-700 flex items-center gap-1"
>
<span>Type Restriction</span>
{allowedTypes.map((t) => (
<TypeBadge key={t} type={t} size="sm" />
))}
</span>
)}
{hasCustomRules && (
<span
title={rules.customRules}
className="px-2 py-0.5 rounded-full text-xs font-medium bg-purple-900/40 text-purple-300 light:bg-purple-100 light:text-purple-700"
>
Custom Rules
</span>
)}
</div>
)
}