From 9411527c5d13fc552d215e277ae434f21dc14a56 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Thu, 22 Oct 2026 12:22:35 +0200 Subject: [PATCH] A main menu: free play, campaign, challenges and leaderboard over a circuit that builds itself Logigate opens on a title screen. Continue, Free play (your own projects), Campaign (progress and what is next), Challenges (every challenge and the puzzle of the week in one Challenges project), Leaderboard (the best ten of this and earlier weeks, your place, your records), Settings. Arrow keys, Enter and Esc work through it; links still open straight into the editor. Players can name themselves on the leaderboards. The logo in the editor leads back to the menu. Co-Authored-By: Claude Opus 5.5 (1M context) --- app/assets/css/main.css | 446 +++++++++++++++++++++- app/components/editor/App.vue | 37 +- app/components/editor/Help.vue | 1 + app/components/editor/MainMenu.vue | 118 ++++++ app/components/editor/MenuBackground.vue | 400 +++++++++++++++++++ app/components/editor/MenuCampaign.vue | 70 ++++ app/components/editor/MenuChallenges.vue | 41 ++ app/components/editor/MenuLeaderboard.vue | 123 ++++++ app/components/editor/Palette.vue | 2 +- app/components/editor/ProjectList.vue | 129 +++++++ app/components/editor/ProjectsDialog.vue | 115 +----- app/components/editor/Toolbar.vue | 6 +- app/composables/useEditor.ts | 129 ++++++- app/lib/logic/project.ts | 2 +- app/lib/logic/storage.ts | 2 + app/lib/logic/types.ts | 8 +- server/api/players/name.post.ts | 17 + server/api/puzzles/[id].get.ts | 2 +- server/api/puzzles/[id]/scores.post.ts | 4 +- server/utils/puzzles.ts | 26 +- tests/leaderboard.test.ts | 44 +++ 21 files changed, 1579 insertions(+), 143 deletions(-) create mode 100644 app/components/editor/MainMenu.vue create mode 100644 app/components/editor/MenuBackground.vue create mode 100644 app/components/editor/MenuCampaign.vue create mode 100644 app/components/editor/MenuChallenges.vue create mode 100644 app/components/editor/MenuLeaderboard.vue create mode 100644 app/components/editor/ProjectList.vue create mode 100644 server/api/players/name.post.ts create mode 100644 tests/leaderboard.test.ts diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 9feea6c..0d5020d 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -2220,7 +2220,8 @@ kbd { border-color: rgb(76 194 255 / 0.35); } -.campaign .bar { +.campaign .bar, +.menu-card .bar { height: 6px; margin-top: 8px; border-radius: 3px; @@ -2228,7 +2229,8 @@ kbd { overflow: hidden; } -.campaign .bar span { +.campaign .bar span, +.menu-card .bar span { display: block; height: 100%; background: var(--on); @@ -3377,3 +3379,443 @@ kbd { .quick-add .item { cursor: pointer; } + +/* ── Title screen ───────────────────────────────────────────────── */ +.brand { + padding: 4px 8px 4px 4px; + border-radius: 6px; +} + +.brand:hover { + background: var(--panel-2); +} + +.title-screen { + position: fixed; + inset: 0; + overflow: hidden; + background: #0b0f14; +} + +.menu-bg { + position: absolute; + inset: 0; + display: block; + width: 100%; + height: 100%; +} + +.title-shade { + position: absolute; + inset: 0; + pointer-events: none; + background: + radial-gradient(ellipse at 65% 50%, transparent 35%, rgb(5 8 12 / 0.7) 100%), + linear-gradient(90deg, rgb(8 11 16 / 0.94) 0%, rgb(8 11 16 / 0.72) 32%, rgb(8 11 16 / 0) 62%); +} + +.title-layout { + position: relative; + display: flex; + gap: 40px; + height: 100%; + padding: clamp(24px, 7vh, 80px) clamp(16px, 6vw, 96px); +} + +.title-side { + display: flex; + flex-direction: column; + flex-shrink: 0; + width: min(380px, 100%); + min-height: 0; +} + +.title-logo { + display: flex; + align-items: center; + gap: 14px; + color: var(--on); +} + +.title-logo svg { + width: 52px; + height: 52px; + filter: drop-shadow(0 0 12px rgb(61 220 132 / 0.5)); +} + +.title-logo h1 { + font-size: clamp(38px, 5vw, 56px); + font-weight: 800; + line-height: 1; + letter-spacing: -0.03em; + color: var(--text); +} + +.title-tag { + margin-top: 10px; + font-size: 15px; + color: var(--muted); +} + +.title-nav { + display: flex; + flex-direction: column; + gap: 4px; + margin-top: clamp(24px, 6vh, 56px); +} + +.title-item { + display: flex; + align-items: center; + gap: 14px; + width: 100%; + padding: 11px 16px; + border: 1px solid transparent; + border-radius: 10px; + text-align: left; + color: var(--text); + transition: + background 0.15s, + border-color 0.15s; +} + +.title-item .label { + display: block; + font-size: 17px; + font-weight: 650; +} + +.title-item .sub { + display: block; + margin-top: 1px; + font-size: 12px; + color: var(--muted); +} + +.title-item .chev { + color: var(--muted); + opacity: 0; + transition: + opacity 0.15s, + transform 0.15s; +} + +.title-item:hover, +.title-item:focus-visible, +.title-item.active { + background: rgb(26 33 43 / 0.85); + border-color: var(--border); + outline: none; +} + +.title-item:focus-visible { + border-color: var(--accent); +} + +.title-item:hover .chev, +.title-item:focus-visible .chev, +.title-item.active .chev { + opacity: 1; + transform: translateX(3px); +} + +.title-item.active { + box-shadow: inset 3px 0 0 var(--on); +} + +.title-item.primary > svg { + color: var(--on); +} + +.title-foot { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 2px; + margin-top: auto; + padding-top: 20px; +} + +.title-link { + display: inline-flex; + align-items: center; + gap: 8px; + padding: 4px 0; + font-size: 13px; + color: var(--muted); +} + +.title-link:hover { + color: var(--text); +} + +.title-page { + display: flex; + flex-direction: column; + flex: 1; + min-width: 0; + max-width: 780px; + overflow: hidden; + background: rgb(19 24 31 / 0.9); + backdrop-filter: blur(8px); + border: 1px solid var(--border); + border-radius: 14px; + box-shadow: 0 30px 80px rgb(0 0 0 / 0.5); +} + +.title-page > header { + display: flex; + align-items: center; + gap: 8px; + padding: 12px 16px; + border-bottom: 1px solid var(--border); +} + +.title-page h2 { + font-size: 20px; + font-weight: 700; + letter-spacing: -0.01em; +} + +.title-page h3 { + margin: 18px 0 8px; + font-size: 11px; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--muted); +} + +.title-page-body { + flex: 1; + overflow-y: auto; + padding: 16px 22px 24px; +} + +.title-page-enter-active, +.title-page-leave-active { + transition: + opacity 0.18s, + transform 0.18s; +} + +.title-page-enter-from, +.title-page-leave-to { + opacity: 0; + transform: translateX(16px); +} + +@media (max-width: 860px) { + .title-layout.open .title-side { + display: none; + } + + .title-page { + max-width: none; + } +} + +@media (prefers-reduced-motion: reduce) { + .title-page-enter-active, + .title-page-leave-active { + transition: none; + } +} + +.menu-card { + margin-top: 12px; + padding: 14px 16px; + border: 1px solid var(--border); + border-radius: 10px; + background: var(--panel-2); +} + +.menu-card p { + font-size: 13px; + line-height: 1.45; + color: var(--muted); +} + +.menu-card p strong { + color: var(--text); +} + +.weekly-card { + margin-top: 0; + border-color: rgb(76 194 255 / 0.35); +} + +.menu-steps { + display: grid; + gap: 2px; + margin-top: 14px; +} + +.menu-steps li { + display: flex; + align-items: center; + gap: 10px; + padding: 7px 10px; + border-radius: 8px; + font-size: 13px; +} + +.menu-steps li > svg { + color: var(--muted); +} + +.menu-steps li.solved > svg { + color: var(--on); +} + +.menu-steps li.locked { + opacity: 0.5; +} + +.menu-steps li.next { + background: rgb(61 220 132 / 0.08); + box-shadow: inset 0 0 0 1px rgb(61 220 132 / 0.3); +} + +.menu-steps .unlocks { + font-size: 12px; + color: var(--muted); +} + +.menu-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); + gap: 8px; + margin-top: 10px; +} + +.menu-tile { + display: flex; + flex-direction: column; + gap: 6px; + width: 100%; + height: 100%; + padding: 12px 14px; + border: 1px solid var(--border); + border-radius: 10px; + background: var(--panel-2); + text-align: left; + transition: + border-color 0.15s, + transform 0.15s; +} + +.menu-tile:hover, +.menu-tile:focus-visible { + border-color: var(--accent); + outline: none; + transform: translateY(-1px); +} + +.menu-grid li.solved .menu-tile { + border-color: rgb(61 220 132 / 0.3); +} + +.menu-tile .goal { + font-size: 12px; + line-height: 1.4; + color: var(--muted); +} + +.menu-tile .pins { + margin-top: auto; + font-family: var(--font-mono); + font-size: 11px; + color: var(--muted); +} + +.menu-board .name-row { + display: flex; + align-items: flex-end; + gap: 8px; +} + +.board-tabs { + margin-top: 16px; + overflow-x: auto; +} + +.board-tabs button { + flex: none; + padding: 0 12px; +} + +table.board { + width: 100%; + margin-top: 12px; + border-collapse: collapse; + font-size: 13px; +} + +.board th { + padding: 6px 8px; + border-bottom: 1px solid var(--border); + font-size: 11px; + font-weight: 600; + text-align: left; + color: var(--muted); +} + +.board td { + padding: 7px 8px; + border-bottom: 1px solid rgb(37 46 58 / 0.5); +} + +.board .num { + text-align: right; + font-variant-numeric: tabular-nums; +} + +.board .rank { + width: 32px; + font-variant-numeric: tabular-nums; + color: var(--muted); +} + +.board tbody tr:first-child .rank { + color: var(--lamp); + font-weight: 700; +} + +.board tr.you td { + background: rgb(61 220 132 / 0.08); +} + +.board tr.gap td { + border-top: 2px dashed var(--border); +} + +.you-tag { + margin-left: 8px; + font-size: 10px; + font-weight: 700; + letter-spacing: 0.05em; + text-transform: uppercase; + color: var(--on); +} + +.records { + display: grid; + gap: 2px; +} + +.records li { + display: flex; + justify-content: space-between; + padding: 6px 10px; + border-radius: 6px; + font-size: 13px; +} + +.records li:nth-child(odd) { + background: rgb(26 33 43 / 0.6); +} + +.menu-board .name-row .field { + margin-bottom: 0; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 8fcc9e9..619b44b 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -17,24 +17,35 @@ onMounted(() => { const stop = ed.startLoop() onBeforeUnmount(stop) void ed.startAccount() - try { - if (!localStorage.getItem('logigate:help-seen')) ed.showHelp.value = true - } catch {} }) + +// The first time into the editor, the help explains the basics. +watch( + ed.screen, + s => { + try { + if (s === 'editor' && !localStorage.getItem('logigate:help-seen')) ed.showHelp.value = true + } catch {} + }, + { immediate: true }, +)