Two Keys: co-op mystery games for couples. Eight games on four engines (story, defuse, sync, labyrinth), two-device and couch play, mobile-first UI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 22:36:12 +02:00
co-authored by Claude Opus 5.5
commit 0de6617c82
85 changed files with 15692 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import { useEffect } from 'react';
import type { CSSProperties } from 'react';
import type { Category, Role, Theme } from '@two-keys/shared';
/** "#7b1e3a" → "123 30 58", the form Tailwind's rgb(var(--x) / alpha) wants. */
export function hexToRgb(hex: string): string {
const n = parseInt(hex.slice(1), 16);
return `${(n >> 16) & 255} ${(n >> 8) & 255} ${n & 255}`;
}
export function themeVars(theme: Theme): CSSProperties {
return {
'--primary': hexToRgb(theme.primary),
'--accent': hexToRgb(theme.accent),
'--bg': hexToRgb(theme.background),
'--heading-font': `'${theme.headingFont}'`,
} as CSSProperties;
}
/** Applies a game's theme to the whole page while a room is open. */
export function useTheme(theme: Theme | undefined) {
const key = theme ? JSON.stringify(theme) : '';
useEffect(() => {
if (!key) return;
const root = document.documentElement;
const vars = themeVars(JSON.parse(key)) as Record<string, string>;
for (const [name, value] of Object.entries(vars)) root.style.setProperty(name, value);
return () => {
for (const name of Object.keys(vars)) root.style.removeProperty(name);
};
}, [key]);
}
export const CATEGORY_LABEL: Record<Category, string> = {
'murder-mystery': 'Murder Mystery',
'escape-room': 'Escape Room',
'co-op': 'Co-op',
};
/** A is warm (amber), B is cool (teal). */
export const ROLE_TEXT: Record<Role, string> = { A: 'text-roleA', B: 'text-roleB' };
export const ROLE_BORDER: Record<Role, string> = { A: 'border-roleA/60', B: 'border-roleB/60' };
export const ROLE_BG: Record<Role, string> = { A: 'bg-roleA/15', B: 'bg-roleB/15' };
export const difficultyKeys = (n: number) => '🔑'.repeat(n);