before ai

This commit is contained in:
LionTion committed 2026-09-10 14:23:49 +02:00
1 parent 85d0d0be57
commit be50463157
11 files changed
+202 -73

No files matched your search

+6 -51
View File
@@ -10,6 +10,12 @@
}
}
@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}
html {
height: 100%;
}
@@ -46,54 +52,3 @@ a {
width: 100%;
height: 100%;
}
.charged-button {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.5rem 1.25rem;
min-width: 8rem;
height: 2.75rem;
border: 2px solid white;
border-radius: 0.625rem;
outline: none;
isolation: isolate;
cursor: pointer;
background: #000;
color: #FFF;
box-shadow: 0 0 0 1px hsl(0 0% 0% / 0.15);
transition: box-shadow 120ms ease, transform 120ms ease;
}
.charged-button:hover {
box-shadow: 0 0 0 1px hsl(0 0% 0% / 0.45);
}
.charged-button:active {
transform: scale(0.97);
}
.charged-button__label {
position: relative;
z-index: 1;
pointer-events: none;
}
.charged-button-fill {
pointer-events: none;
position: absolute;
inset: 0;
border-radius: inherit;
opacity: 0.7;
background: linear-gradient(120deg, #1ea, #2af, #e1f, #2af);
background-size: 200% 200%;
transition: opacity 120ms ease;
}
@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}
+16 -8
View File
@@ -1,19 +1,18 @@
"use client";
import { useState } from "react";
import { useEffect, useState } from "react";
import Image from "next/image";
import styles from "./page.module.css";
import ChargedButton from "@/components/ChargedButton";
import MapView from "@/components/MapView";
import WelcomeScreen from "@/components/screens/WelcomeScreen";
import { useLocalStorage } from "@/hooks/useLocalStorage";
import { PREF } from "@/utils/const";
export default function Main() {
const [doTest, setDoTest] = useState(false);
return (
<div className={styles.page}>
<main className={styles.main}>
<ChargedButton
const [ step, setStep ] = useLocalStorage(PREF.step, "0");
/*const [doTest, setDoTest] = useState(false);
<ChargedButton
onAction={() => {
console.log("Click!");
}}
@@ -22,7 +21,16 @@ export default function Main() {
<button onClick={() => {
setDoTest(true);
}}>test</button>
{doTest && <MapView></MapView>}
{doTest && <MapView></MapView>}*/
console.log("STEP", step);
/*useEffect(() => {
setValue("1");
}, []);*/
return (
<div className={styles.page}>
<main className={styles.main}>
<WelcomeScreen />
</main>
</div>
+1 -1
View File
@@ -2,7 +2,7 @@
/// <reference lib="webworker" />
import { defaultCache } from "@serwist/turbopack/worker";
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist";
import { Serwist } from "serwist";
import { Serwist, CacheFirst } from "serwist";
// This declares the value of `injectionPoint` to TypeScript.
// `injectionPoint` is the string that will be replaced by the
+14 -8
View File
@@ -1,28 +1,32 @@
"use client";
import { CSSProperties, ReactNode, useRef, useState } from "react";
import styles from "@/css/ChargedButton.module.css";
interface ChargedButtonProps {
children?: ReactNode;
style?: CSSProperties;
className?: string;
/** Time in milliseconds needed to fully charge by continuous hold. */
holdDuration?: number;
/** Runs exactly once, when the button is fully charged at 100%. */
onAction?: () => void;
disabled?: boolean;
}
export default function ChargedButton({
children,
style,
className,
holdDuration = 1000,
onAction,
disabled = false,
}: ChargedButtonProps) {
const [progress, setProgress] = useState(0);
const [isCharging, setIsCharging] = useState(false);
const [isDischarging, setIsDischarging] = useState(false);
const rafRef = useRef(0);
const startTimeRef = useRef(0);
const stateRef = useRef({ charging: false, discharging: false });
const dischargingRef = useRef(false);
const cancelRaf = () => {
@@ -33,7 +37,7 @@ export default function ChargedButton({
};
const onPointerDown = () => {
if (dischargingRef.current) return;
if (disabled || dischargingRef.current) return;
cancelRaf();
startTimeRef.current = performance.now();
setIsCharging(true);
@@ -43,7 +47,7 @@ export default function ChargedButton({
};
const onPointerUp = () => {
if (dischargingRef.current) return;
if (disabled || dischargingRef.current) return;
cancelRaf();
setIsCharging(false);
setProgress(0);
@@ -65,7 +69,7 @@ export default function ChargedButton({
onAction?.();
}
} else {
const fraction = Math.min(1, elapsed / (holdDuration * 0.1));
const fraction = Math.min(1, elapsed / Math.max(holdDuration * 0.05, 150));
setProgress(1.0 - fraction);
if (fraction >= 1) {
setProgress(0);
@@ -82,7 +86,7 @@ export default function ChargedButton({
return (
<button
type="button"
className="charged-button"
className={styles["charged-button"] + ((disabled) ? " " + styles["button-disabled"] : "") + (className ? " " + className : "")}
style={style}
onPointerDown={onPointerDown}
onTouchStart={onPointerDown}
@@ -91,11 +95,13 @@ export default function ChargedButton({
onPointerCancel={onPointerUp}
onTouchCancel={onPointerUp}
>
<span className="charged-button__label">{children}</span>
<span className={styles["charged-button-label"]}>{children}</span>
<span
className=" charged-button-fill"
className={styles["charged-button-fill"]}
aria-hidden="true"
style={{ width: `${progress * 100}%` }}
style={{
clipPath: `inset(0 ${100 - progress * 100}% 0 0)`,
}}
/>
</button>
);
+9
View File
@@ -0,0 +1,9 @@
export default function PermissionModal() {
return (
<div className="">
</div>
);
}
+83 -5
View File
@@ -1,10 +1,88 @@
"use client";
import { ChangeEvent, SyntheticEvent, useEffect, useRef, useState } from "react";
import styles from "../../css/WelcomeScreen.module.css";
import ChargedButton from "../ChargedButton";
const CODE_LENGTH = 9;
const COOLDOWN_MS = 3000;
export default function WelcomeScreen() {
console.log(styles);
return(
<div className="screen-container">
const [tourCode, setTourCode] = useState("");
const [lastSubmitTs, setLastSubmitTs] = useState(0);
const [isCooldown, setIsCooldown] = useState(false);
const tourCodeRef = useRef("");
const cooldownRef = useRef(-1);
</div>
)
const checkCooldown = () => {
if (cooldownRef.current === -1) return false;
return Date.now() - cooldownRef.current <= COOLDOWN_MS
};
const isTourCodeValid = () => {
return tourCode.length === CODE_LENGTH;
};
useEffect(() => {
if (checkCooldown()) {
setIsCooldown(true);
const inputTimeout = setTimeout(() => {
console.log("Cooldown over");
setIsCooldown(false);
}, 3000);
return () => clearTimeout(inputTimeout);
} else {
setIsCooldown(false);
}
}, [lastSubmitTs]);
const submit = () => {
const value = tourCodeRef.current;
if (!isTourCodeValid() && checkCooldown()) {
return;
}
cooldownRef.current = Date.now();
setLastSubmitTs(cooldownRef.current);
console.log("submitted", value);
};
const handleChange = (event: ChangeEvent<HTMLInputElement>): boolean => {
const value = event.target.value;
if (value.length > CODE_LENGTH) {
event.preventDefault();
return false;
}
tourCodeRef.current = value;
setTourCode(value.toUpperCase().replaceAll(/\W/g, ""));
return true;
};
const buttonDisabled = isCooldown || !isTourCodeValid();
return (
<div className="screen-container">
<label className="screen__label">
<input
type="text"
className="screen-input"
value={tourCode}
onChange={handleChange}
aria-label="Tour Code"
placeholder={`Enter a tour code (${CODE_LENGTH} characters max)`}
/>
</label>
<ChargedButton
holdDuration={1000}
onAction={submit}
className="screen-submit"
disabled={buttonDisabled}
>
{(!buttonDisabled) ? "Halten zum Spielen!" : "Halten zum Spielen."}
</ChargedButton>
</div>
);
}
+50
View File
@@ -0,0 +1,50 @@
.charged-button {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.5rem 1.25rem;
min-width: 8rem;
height: 2.75rem;
border: 2px solid white;
border-radius: 0.625rem;
overflow: hidden;
outline: none;
isolation: isolate;
cursor: pointer;
background: #000;
color: #FFF;
box-shadow: 0 0 0 1px hsl(0 0% 0% / 0.15);
transition: box-shadow 120ms ease, transform 120ms ease;
-webkit-tap-highlight-color: transparent;
user-select: none;
-webkit-user-select: none;
&.button-disabled {
color: lightslategray;
border-color: lightslategray;
}
}
.charged-button:hover {
box-shadow: 0 0 0 1px hsl(0 0% 0% / 0.45);
}
.charged-button:active {
transform: scale(0.97);
}
.charged-button-label {
position: relative;
z-index: 1;
pointer-events: none;
}
.charged-button-fill {
pointer-events: none;
position: absolute;
inset: 0;
border-radius: inherit;
opacity: 0.7;
background: linear-gradient(120deg, #1ea, #2af, #e1f);
transition: opacity 120ms ease;
}
View File
Whitespace-only changes.
+7
View File
@@ -0,0 +1,7 @@
export type Gender = 'male' | 'female' | 'other';
export interface Player {
id: number;
name: string;
gender: Gender;
}
+7
View File
@@ -0,0 +1,7 @@
export enum PREF {
code = "PREF_TOUR_CODE",
points = "PREF_POINTS",
players = "PREF_PLAYERS",
completed_riddles = "PREF_COMPLETED_RIDDLES",
step = "PREF_APP_SCREEN_STEP",
};
+9
View File
@@ -0,0 +1,9 @@
import { Player } from "@/types/player";
export function parsePlayerData(raw: string): Array<Player> {
return [];
}
export function formatPlayerData(arr: Array<Player>): string {
return "";
}