chore(history): squash 16 commit(s) from 2026-09-26
- chore(backend): sync Cargo.lock with gateway dev-dependency - feat(frontend): ClickGui replica matching the in-game GUI — category panels, Modules/Settings switch, theme cards - feat(frontend): floating glass top bar in the mod's UI language - fix(frontend): soft night backdrop for the ClickGui, editor that fits one screen - chore(frontend): replace em dashes in UI copy with lighter separators - refactor(frontend): split landing sections and theme editor into subfolders (4-files-per-folder rule) - feat(frontend): login and registration in the mod's glass panel style - feat(frontend): link the game with a device code - feat(frontend): account page with avatar upload and linked games - feat(frontend): my configs with share codes and publishing - feat(frontend): public showcase listing and detail pages - chore(frontend): drop em dashes from visible copy - feat(frontend): atmospheric backdrop, glass download block and ClickGui-style FAQ on the landing - feat(frontend): Konami code, DevTools console greeting and ASCII 404 block - feat: public player profiles at /u/:id and author link in the showcase - fix(frontend): stop the theme editor overflowing horizontally at 375px
This commit is contained in:
parent
7f4b532f99
commit
ff2edc8eb6
116 changed files with 3534 additions and 1020 deletions
20
frontend/src/shared/easter/KonamiEffect.tsx
Normal file
20
frontend/src/shared/easter/KonamiEffect.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useKonami } from './useKonami'
|
||||
|
||||
export function KonamiEffect() {
|
||||
const { t } = useTranslation('common')
|
||||
const active = useKonami()
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.classList.toggle('lv-konami', active)
|
||||
return () => document.documentElement.classList.remove('lv-konami')
|
||||
}, [active])
|
||||
|
||||
if (!active) return null
|
||||
return (
|
||||
<div role="status" className="fixed bottom-6 left-1/2 z-50 -translate-x-1/2 rounded-panel border border-ice/40 bg-slate/90 px-4 py-2 font-code text-sm text-ice">
|
||||
{t('konami')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
3
frontend/src/shared/easter/art.generated.ts
Normal file
3
frontend/src/shared/easter/art.generated.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// Generated with pyfiglet (fonts: slant, big). Do not edit by hand.
|
||||
export const LOGO_ART = " __ _ ___ __\n / / ____| | / (_)______ ______ _/ /\n / / / __ \\ | / / / ___/ / / / __ `/ / \n / /___/ /_/ / |/ / (__ ) /_/ / /_/ / / \n/_____/\\____/|___/_/____/\\__,_/\\__,_/_/"
|
||||
export const NOT_FOUND_ART = " _ _ ___ _ _ \n| || | / _ \\| || | \n| || |_| | | | || |_ \n|__ _| | | |__ _|\n | | | |_| | | | \n |_| \\___/ |_|"
|
||||
14
frontend/src/shared/easter/consoleGreeting.ts
Normal file
14
frontend/src/shared/easter/consoleGreeting.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { LOGO_ART } from './art.generated'
|
||||
|
||||
export function printConsoleGreeting(lang: string): void {
|
||||
const ru = lang.startsWith('ru')
|
||||
console.log(`%c${LOGO_ART}`, 'color:#5cc8e7;font-family:monospace;font-weight:bold')
|
||||
console.log(
|
||||
`%c${ru ? 'Открыл DevTools? Значит, тебе тут рады.' : 'Opened DevTools? You are welcome here.'}`,
|
||||
'color:#eef5f3;font-size:13px',
|
||||
)
|
||||
console.log(
|
||||
`%c${ru ? 'Совет: попробуй ↑ ↑ ↓ ↓ ← → ← → B A.' : 'Hint: try ↑ ↑ ↓ ↓ ← → ← → B A.'}`,
|
||||
'color:#9fb3b0;font-size:11px',
|
||||
)
|
||||
}
|
||||
20
frontend/src/shared/easter/tests/konami.test.tsx
Normal file
20
frontend/src/shared/easter/tests/konami.test.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { act, renderHook } from '@testing-library/react'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { useKonami } from '../useKonami'
|
||||
|
||||
const press = (key: string) => act(() => void window.dispatchEvent(new KeyboardEvent('keydown', { key })))
|
||||
|
||||
describe('useKonami', () => {
|
||||
it('activates after the full code', () => {
|
||||
const { result } = renderHook(() => useKonami())
|
||||
;['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b'].forEach(press)
|
||||
expect(result.current).toBe(false)
|
||||
press('a')
|
||||
expect(result.current).toBe(true)
|
||||
})
|
||||
it('ignores a wrong sequence', () => {
|
||||
const { result } = renderHook(() => useKonami())
|
||||
;['ArrowUp', 'ArrowDown', 'b', 'a'].forEach(press)
|
||||
expect(result.current).toBe(false)
|
||||
})
|
||||
})
|
||||
29
frontend/src/shared/easter/useKonami.ts
Normal file
29
frontend/src/shared/easter/useKonami.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
|
||||
const CODE = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a']
|
||||
|
||||
/** Returns true for a few seconds after the Konami code is typed anywhere on the page. */
|
||||
export function useKonami(durationMs = 7000): boolean {
|
||||
const [active, setActive] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let index = 0
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
const key = e.key.length === 1 ? e.key.toLowerCase() : e.key
|
||||
index = key === CODE[index] ? index + 1 : key === CODE[0] ? 1 : 0
|
||||
if (index < CODE.length) return
|
||||
index = 0
|
||||
setActive(true)
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => setActive(false), durationMs)
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => {
|
||||
window.removeEventListener('keydown', onKey)
|
||||
clearTimeout(timer)
|
||||
}
|
||||
}, [durationMs])
|
||||
|
||||
return active
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue