diff --git a/src/lib/features/new-game/ProgressIndicator.tsx b/src/lib/features/new-game/ProgressIndicator.tsx new file mode 100644 index 0000000..8698bff --- /dev/null +++ b/src/lib/features/new-game/ProgressIndicator.tsx @@ -0,0 +1,31 @@ +import { h } from 'preact'; +import type { JSX } from 'preact'; +import styles from './NewGame.module.css'; + +interface ProgressIndicatorProps { + currentStep: number; + totalSteps?: number; + style?: JSX.CSSProperties; +} + +export function ProgressIndicator({ + currentStep, + totalSteps = 7, + style, +}: ProgressIndicatorProps) { + const activeIndex = Math.min(Math.max(currentStep, 1), totalSteps) - 1; + + return ( +
+ {Array.from({ length: totalSteps }, (_, index) => { + const isActive = index === activeIndex; + const className = isActive + ? `${styles['progress-dot']} ${styles['active']}` + : styles['progress-dot']; + + return ; + })} +
+ ); +} + diff --git a/src/lib/features/new-game/index.ts b/src/lib/features/new-game/index.ts index c17f3ea..dc84ee7 100644 --- a/src/lib/features/new-game/index.ts +++ b/src/lib/features/new-game/index.ts @@ -6,4 +6,5 @@ export { GameTypeStep } from './steps/GameTypeStep'; export { RaceToStep } from './steps/RaceToStep'; export { BreakRuleStep } from './steps/BreakRuleStep'; export { BreakOrderStep } from './steps/BreakOrderStep'; +export { ProgressIndicator } from './ProgressIndicator'; diff --git a/src/lib/features/new-game/steps/BreakOrderStep.tsx b/src/lib/features/new-game/steps/BreakOrderStep.tsx index 6e00c0b..811bc88 100644 --- a/src/lib/features/new-game/steps/BreakOrderStep.tsx +++ b/src/lib/features/new-game/steps/BreakOrderStep.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useEffect, useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; import type { BreakRule } from '@lib/domain/types'; interface BreakOrderStepProps { @@ -37,74 +38,75 @@ export const BreakOrderStep = ({ players, rule, onNext, onCancel, initialFirst = return (
-
Wer hat den ersten Anstoss?
-
- - - - - - - +
+
Wer hat den ersten Anstoss?
+
-
Wer hat den ersten Anstoss?
-
- {players.filter(Boolean).map((name, idx) => ( - + ))} +
+ + {rule === 'wechselbreak' && playerCount === 3 && ( + <> +
Wer hat den zweiten Anstoss?
+
+ {players.filter(Boolean).map((name, idx) => ( + + ))} +
+ + )} +
+ +
+
+ - ))} -
- {rule === 'wechselbreak' && playerCount === 3 && ( - <> -
Wer hat den zweiten Anstoss?
-
- {players.filter(Boolean).map((name, idx) => ( - - ))} -
- - )} -
- - + style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer', opacity: ((rule === 'wechselbreak' && playerCount === 3) ? !(first > 0 && (second ?? 0) > 0) : !(first > 0)) ? 0.5 : 1 }} + > + → + +
); diff --git a/src/lib/features/new-game/steps/BreakRuleStep.tsx b/src/lib/features/new-game/steps/BreakRuleStep.tsx index 1f0656d..ced8a5b 100644 --- a/src/lib/features/new-game/steps/BreakRuleStep.tsx +++ b/src/lib/features/new-game/steps/BreakRuleStep.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; import type { BreakRule } from '@lib/domain/types'; interface BreakRuleStepProps { @@ -14,39 +15,43 @@ export const BreakRuleStep = ({ onNext, onCancel, initialValue = 'winnerbreak' } return (
-
Break-Regel wählen
-
- - - - - - - +
+
Break-Regel wählen
+
-
- {[ - { key: 'winnerbreak', label: 'Winnerbreak' }, - { key: 'wechselbreak', label: 'Wechselbreak' }, - ].map(opt => ( - + ))} +
+
+ +
+
+ - ))} -
-
- - + +
); diff --git a/src/lib/features/new-game/steps/GameTypeStep.tsx b/src/lib/features/new-game/steps/GameTypeStep.tsx index da98940..efc007e 100644 --- a/src/lib/features/new-game/steps/GameTypeStep.tsx +++ b/src/lib/features/new-game/steps/GameTypeStep.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; import { GAME_TYPES } from '@lib/domain/constants'; interface GameTypeStepProps { @@ -28,15 +29,7 @@ export const GameTypeStep = ({ onNext, onCancel, initialValue = '' }: GameTypeSt
Spielart auswählen
-
- - - - - - - -
+
diff --git a/src/lib/features/new-game/steps/Player1Step.tsx b/src/lib/features/new-game/steps/Player1Step.tsx index da30ece..c03ad0d 100644 --- a/src/lib/features/new-game/steps/Player1Step.tsx +++ b/src/lib/features/new-game/steps/Player1Step.tsx @@ -9,6 +9,7 @@ import { ERROR_STYLES, } from '@lib/domain/constants'; import { PlayerSelectModal } from './PlayerSelectModal'; +import { ProgressIndicator } from '../ProgressIndicator'; interface PlayerStepProps { playerNameHistory: string[]; @@ -82,15 +83,10 @@ export const Player1Step = ({ playerNameHistory, onNext, onCancel, initialValue
Name Spieler 1
-
- - - - - - - -
+
diff --git a/src/lib/features/new-game/steps/Player2Step.tsx b/src/lib/features/new-game/steps/Player2Step.tsx index 6450380..b770c0a 100644 --- a/src/lib/features/new-game/steps/Player2Step.tsx +++ b/src/lib/features/new-game/steps/Player2Step.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useEffect, useRef, useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; interface PlayerStepProps { playerNameHistory: string[]; @@ -52,15 +53,7 @@ export const Player2Step = ({ playerNameHistory, onNext, onCancel, initialValue
Name Spieler 2
-
- - - - - - - -
+
diff --git a/src/lib/features/new-game/steps/Player3Step.tsx b/src/lib/features/new-game/steps/Player3Step.tsx index d1453ab..dfeedf5 100644 --- a/src/lib/features/new-game/steps/Player3Step.tsx +++ b/src/lib/features/new-game/steps/Player3Step.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useEffect, useRef, useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; interface PlayerStepProps { playerNameHistory: string[]; @@ -49,15 +50,7 @@ export const Player3Step = ({ playerNameHistory, onNext, onCancel, initialValue
Name Spieler 3 (optional)
-
- - - - - - - -
+
diff --git a/src/lib/features/new-game/steps/RaceToStep.tsx b/src/lib/features/new-game/steps/RaceToStep.tsx index 5f2d356..2e34640 100644 --- a/src/lib/features/new-game/steps/RaceToStep.tsx +++ b/src/lib/features/new-game/steps/RaceToStep.tsx @@ -1,6 +1,7 @@ import { h } from 'preact'; import { useEffect, useState } from 'preact/hooks'; import styles from '../NewGame.module.css'; +import { ProgressIndicator } from '../ProgressIndicator'; import { RACE_TO_QUICK_PICKS, RACE_TO_DEFAULT, @@ -51,15 +52,7 @@ export const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }: Ra return (
Race To auswählen
-
- - - - - - - -
+