Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b8dcacd18 | |||
| 4ef4f2b251 | |||
| 17d8cbfedd | |||
| a41e337c43 | |||
| 1f1de61044 | |||
| 7f22aa9198 | |||
| 133a676682 | |||
| 30318fafaf | |||
| 5549e24c17 | |||
| ca3193d07e | |||
| 41a36768cd | |||
| 315fb29eac | |||
| 395e9caff4 | |||
| e1c73181d4 | |||
| 874e35bba3 | |||
| 69b04d3336 | |||
| c5b212234a | |||
| 8e0ddf3a72 | |||
| bfb24cfb03 | |||
| 8d3bde8d38 | |||
| d25fa67100 | |||
| c7834bd8bf | |||
| 7d405ef0f6 | |||
| 431b534477 | |||
| ebf9030185 | |||
| 8f52f5daa5 | |||
| 2dc68ab8d0 | |||
| 993ced424e | |||
| 1b0b6a671a | |||
| e39ac9a794 | |||
| 81ed97b263 | |||
| 61359e6665 | |||
| 8f8f6a6e8e | |||
| a02c17e462 | |||
| 490ca6b4a5 | |||
| 10ed00b7b6 | |||
| a335adeca8 | |||
| 72adab61c7 | |||
| 2c892f3adc | |||
| b6b289cd57 | |||
| ea2e3c573b | |||
| cf2e9de56d | |||
| 4313831e84 | |||
| 60ef352cda | |||
| 91c873ef97 | |||
| c4764e9505 | |||
| 423258ef17 | |||
| 0bd2b905a9 | |||
| 572acc3979 | |||
| 7256809f0b | |||
| 9f89fe4340 | |||
| 7610a4a523 | |||
| 285c486c6e | |||
| 8a97cc5d0d | |||
| c287523fa5 | |||
| eb6b69134f | |||
| 4d50eb97eb | |||
| a1df95d3d4 | |||
| 4a7c088776 | |||
| 6f3ed143e5 | |||
| c5f9da81a9 | |||
| 0decf2324c | |||
| 96999f740c | |||
| 4982e6ed49 |
@@ -1 +0,0 @@
|
|||||||
if('serviceWorker' in navigator) navigator.serviceWorker.register('/dev-sw.js?dev-sw', { scope: '/', type: 'classic' })
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// If the loader is already loaded, just stop.
|
|
||||||
if (!self.define) {
|
|
||||||
let registry = {};
|
|
||||||
|
|
||||||
// Used for `eval` and `importScripts` where we can't get script URL by other means.
|
|
||||||
// In both cases, it's safe to use a global var because those functions are synchronous.
|
|
||||||
let nextDefineUri;
|
|
||||||
|
|
||||||
const singleRequire = (uri, parentUri) => {
|
|
||||||
uri = new URL(uri + ".js", parentUri).href;
|
|
||||||
return registry[uri] || (
|
|
||||||
|
|
||||||
new Promise(resolve => {
|
|
||||||
if ("document" in self) {
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.src = uri;
|
|
||||||
script.onload = resolve;
|
|
||||||
document.head.appendChild(script);
|
|
||||||
} else {
|
|
||||||
nextDefineUri = uri;
|
|
||||||
importScripts(uri);
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
.then(() => {
|
|
||||||
let promise = registry[uri];
|
|
||||||
if (!promise) {
|
|
||||||
throw new Error(`Module ${uri} didn’t register its module`);
|
|
||||||
}
|
|
||||||
return promise;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.define = (depsNames, factory) => {
|
|
||||||
const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
|
|
||||||
if (registry[uri]) {
|
|
||||||
// Module is already loading or loaded.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let exports = {};
|
|
||||||
const require = depUri => singleRequire(depUri, uri);
|
|
||||||
const specialDeps = {
|
|
||||||
module: { uri },
|
|
||||||
exports,
|
|
||||||
require
|
|
||||||
};
|
|
||||||
registry[uri] = Promise.all(depsNames.map(
|
|
||||||
depName => specialDeps[depName] || require(depName)
|
|
||||||
)).then(deps => {
|
|
||||||
factory(...deps);
|
|
||||||
return exports;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
define(['./workbox-5a5d9309'], (function (workbox) { 'use strict';
|
|
||||||
|
|
||||||
self.skipWaiting();
|
|
||||||
workbox.clientsClaim();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The precacheAndRoute() method efficiently caches and responds to
|
|
||||||
* requests for URLs in the manifest.
|
|
||||||
* See https://goo.gl/S9QRab
|
|
||||||
*/
|
|
||||||
workbox.precacheAndRoute([{
|
|
||||||
"url": "registerSW.js",
|
|
||||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
|
||||||
}, {
|
|
||||||
"url": "index.html",
|
|
||||||
"revision": "0.eh0stsihuc8"
|
|
||||||
}], {});
|
|
||||||
workbox.cleanupOutdatedCaches();
|
|
||||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
|
||||||
allowlist: [/^\/$/]
|
|
||||||
}));
|
|
||||||
|
|
||||||
}));
|
|
||||||
File diff suppressed because it is too large
Load Diff
2050
package-lock.json
generated
2050
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-nonograms-solid",
|
"name": "vue-nonograms-solid",
|
||||||
"version": "1.0.0",
|
"version": "1.6.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview",
|
||||||
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fireworks-js": "^2.10.8",
|
"fireworks-js": "^2.10.8",
|
||||||
@@ -16,7 +17,10 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.0.4",
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
|
"@vue/test-utils": "^2.4.6",
|
||||||
|
"jsdom": "^28.0.0",
|
||||||
"vite": "^5.1.4",
|
"vite": "^5.1.4",
|
||||||
"vite-plugin-pwa": "^0.20.5"
|
"vite-plugin-pwa": "^0.20.5",
|
||||||
|
"vitest": "^4.0.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/App.vue
32
src/App.vue
@@ -9,6 +9,7 @@ import GuidePanel from './components/GuidePanel.vue';
|
|||||||
import WinModal from './components/WinModal.vue';
|
import WinModal from './components/WinModal.vue';
|
||||||
import CustomGameModal from './components/CustomGameModal.vue';
|
import CustomGameModal from './components/CustomGameModal.vue';
|
||||||
import FixedBar from './components/FixedBar.vue';
|
import FixedBar from './components/FixedBar.vue';
|
||||||
|
import ReloadPrompt from './components/ReloadPrompt.vue';
|
||||||
|
|
||||||
// Main App Entry
|
// Main App Entry
|
||||||
const store = usePuzzleStore();
|
const store = usePuzzleStore();
|
||||||
@@ -21,6 +22,7 @@ const installDismissed = ref(false);
|
|||||||
const isCoarsePointer = ref(false);
|
const isCoarsePointer = ref(false);
|
||||||
const isStandalone = ref(false);
|
const isStandalone = ref(false);
|
||||||
const themePreference = ref('system');
|
const themePreference = ref('system');
|
||||||
|
const appVersion = __APP_VERSION__;
|
||||||
let displayModeMedia = null;
|
let displayModeMedia = null;
|
||||||
let prefersColorSchemeMedia = null;
|
let prefersColorSchemeMedia = null;
|
||||||
|
|
||||||
@@ -164,10 +166,15 @@ onUnmounted(() => {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<footer class="app-version">
|
||||||
|
v{{ appVersion }}
|
||||||
|
</footer>
|
||||||
|
|
||||||
<!-- Modals Teleport -->
|
<!-- Modals Teleport -->
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<WinModal v-if="store.isGameWon" />
|
<WinModal v-if="store.isGameWon" />
|
||||||
<CustomGameModal v-if="showCustomModal" @close="showCustomModal = false" />
|
<CustomGameModal v-if="showCustomModal" @close="showCustomModal = false" />
|
||||||
|
<ReloadPrompt />
|
||||||
</Teleport>
|
</Teleport>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
@@ -183,8 +190,8 @@ onUnmounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.install-banner {
|
.install-banner {
|
||||||
background: rgba(0, 242, 254, 0.1);
|
background: var(--banner-bg);
|
||||||
border: 1px solid var(--primary-neon);
|
border: 1px solid var(--banner-border);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -193,10 +200,11 @@ onUnmounted(() => {
|
|||||||
width: 90%;
|
width: 90%;
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
box-shadow: var(--banner-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.install-text {
|
.install-text {
|
||||||
color: #fff;
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.install-actions {
|
.install-actions {
|
||||||
@@ -208,7 +216,7 @@ onUnmounted(() => {
|
|||||||
.install-close {
|
.install-close {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
color: #aaa;
|
color: var(--text-muted);
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@@ -238,4 +246,20 @@ onUnmounted(() => {
|
|||||||
.fade-leave-to {
|
.fade-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-version {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
opacity: 0.8;
|
||||||
|
background: var(--panel-bg);
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
border-top: 1px solid var(--panel-border);
|
||||||
|
z-index: 90;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -34,35 +34,30 @@ const clearLongPress = () => {
|
|||||||
|
|
||||||
const handlePointerDown = (e) => {
|
const handlePointerDown = (e) => {
|
||||||
if (e.pointerType === 'mouse') {
|
if (e.pointerType === 'mouse') {
|
||||||
if (e.button === 0) emit('start-drag', props.r, props.c, false);
|
if (e.button === 0) emit('start-drag', props.r, props.c, false, false);
|
||||||
if (e.button === 2) emit('start-drag', props.r, props.c, true);
|
if (e.button === 2) emit('start-drag', props.r, props.c, true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
longPressTriggered = false;
|
|
||||||
clearLongPress();
|
// Touch logic
|
||||||
longPressTimer = setTimeout(() => {
|
const now = Date.now();
|
||||||
longPressTriggered = true;
|
if (now - lastTap < 300) {
|
||||||
emit('start-drag', props.r, props.c, true);
|
// Double tap -> X (Force)
|
||||||
}, 450);
|
emit('start-drag', props.r, props.c, true, true);
|
||||||
|
lastTap = 0;
|
||||||
|
} else {
|
||||||
|
// Single tap / Start drag -> Fill
|
||||||
|
emit('start-drag', props.r, props.c, false, false);
|
||||||
|
lastTap = now;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePointerUp = (e) => {
|
const handlePointerUp = (e) => {
|
||||||
if (e.pointerType === 'mouse') return;
|
// Handled in pointerdown
|
||||||
clearLongPress();
|
|
||||||
if (longPressTriggered) return;
|
|
||||||
const now = Date.now();
|
|
||||||
const isDoubleTap = now - lastTap < 300;
|
|
||||||
lastTap = now;
|
|
||||||
if (isDoubleTap) {
|
|
||||||
emit('start-drag', props.r, props.c, true);
|
|
||||||
} else {
|
|
||||||
emit('start-drag', props.r, props.c, false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePointerCancel = (e) => {
|
const handlePointerCancel = (e) => {
|
||||||
if (e.pointerType === 'mouse') return;
|
// Handled in pointerdown
|
||||||
clearLongPress();
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,37 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import { usePuzzleStore } from '@/stores/puzzle';
|
import { usePuzzleStore } from '@/stores/puzzle';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
|
import { calculateDifficulty } from '@/utils/puzzleUtils';
|
||||||
|
|
||||||
const emit = defineEmits(['close']);
|
const emit = defineEmits(['close']);
|
||||||
const store = usePuzzleStore();
|
const store = usePuzzleStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const customSize = ref(10);
|
const customSize = ref(10);
|
||||||
|
const fillRate = ref(50);
|
||||||
const errorMsg = ref('');
|
const errorMsg = ref('');
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const savedSize = localStorage.getItem('nonograms_custom_size');
|
||||||
|
if (savedSize && !isNaN(savedSize)) {
|
||||||
|
customSize.value = Math.max(5, Math.min(80, Number(savedSize)));
|
||||||
|
}
|
||||||
|
|
||||||
|
const savedFillRate = localStorage.getItem('nonograms_custom_fill_rate');
|
||||||
|
if (savedFillRate && !isNaN(savedFillRate)) {
|
||||||
|
fillRate.value = Math.max(10, Math.min(90, Number(savedFillRate)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(customSize, (newVal) => {
|
||||||
|
localStorage.setItem('nonograms_custom_size', newVal);
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(fillRate, (newVal) => {
|
||||||
|
localStorage.setItem('nonograms_custom_fill_rate', newVal);
|
||||||
|
});
|
||||||
|
|
||||||
const snapToStep = (value, step) => {
|
const snapToStep = (value, step) => {
|
||||||
const rounded = Math.round(value / step) * step;
|
const rounded = Math.round(value / step) * step;
|
||||||
return Math.max(5, Math.min(80, rounded));
|
return Math.max(5, Math.min(80, rounded));
|
||||||
@@ -19,6 +41,20 @@ const handleSnap = () => {
|
|||||||
customSize.value = snapToStep(Number(customSize.value), 5);
|
customSize.value = snapToStep(Number(customSize.value), 5);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const difficultyLevel = computed(() => {
|
||||||
|
return calculateDifficulty(fillRate.value / 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
const difficultyColor = computed(() => {
|
||||||
|
switch(difficultyLevel.value) {
|
||||||
|
case 'extreme': return '#ff3333';
|
||||||
|
case 'hardest': return '#ff9933';
|
||||||
|
case 'harder': return '#ffff33';
|
||||||
|
case 'easy': return '#33ff33';
|
||||||
|
default: return '#33ff33';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const confirm = () => {
|
const confirm = () => {
|
||||||
const size = parseInt(customSize.value);
|
const size = parseInt(customSize.value);
|
||||||
if (isNaN(size) || size < 5 || size > 80) {
|
if (isNaN(size) || size < 5 || size > 80) {
|
||||||
@@ -26,7 +62,7 @@ const confirm = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.initCustomGame(size);
|
store.initCustomGame(size, fillRate.value / 100);
|
||||||
emit('close');
|
emit('close');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -53,6 +89,29 @@ const confirm = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>{{ t('custom.fillRate') }}</p>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="range-value">{{ fillRate }}%</div>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
v-model="fillRate"
|
||||||
|
min="10"
|
||||||
|
max="90"
|
||||||
|
step="5"
|
||||||
|
/>
|
||||||
|
<div class="range-scale">
|
||||||
|
<span>10%</span>
|
||||||
|
<span>90%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="difficulty-indicator">
|
||||||
|
<span class="label">{{ t('custom.difficulty') }}:</span>
|
||||||
|
<span class="value" :style="{ color: difficultyColor }">
|
||||||
|
{{ t(`difficulty.${difficultyLevel}`) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p v-if="errorMsg" class="error">{{ errorMsg }}</p>
|
<p v-if="errorMsg" class="error">{{ errorMsg }}</p>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@@ -87,6 +146,7 @@ const confirm = () => {
|
|||||||
border: 1px solid var(--accent-cyan);
|
border: 1px solid var(--accent-cyan);
|
||||||
box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
|
box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
|
||||||
animation: slideUp 0.3s ease;
|
animation: slideUp 0.3s ease;
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
@@ -161,6 +221,31 @@ input[type="range"]::-moz-range-thumb {
|
|||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.difficulty-indicator {
|
||||||
|
margin: 20px 0;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
height: 1.5em; /* Reserve space for one line of text */
|
||||||
|
}
|
||||||
|
|
||||||
|
.difficulty-indicator .label {
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.difficulty-indicator .value {
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
text-shadow: 0 0 10px currentColor;
|
||||||
|
transition: color 0.3s ease;
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 120px; /* Reserve space for longest text */
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
color: #ff4d4d;
|
color: #ff4d4d;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
|
|||||||
@@ -15,6 +15,94 @@ const rowHintsRef = ref(null);
|
|||||||
const activeRow = ref(null);
|
const activeRow = ref(null);
|
||||||
const activeCol = ref(null);
|
const activeCol = ref(null);
|
||||||
const isFinePointer = ref(false);
|
const isFinePointer = ref(false);
|
||||||
|
const scrollWrapper = ref(null);
|
||||||
|
const scrollTrack = ref(null);
|
||||||
|
const showScrollbar = ref(false);
|
||||||
|
const thumbWidth = ref(20);
|
||||||
|
const thumbLeft = ref(0);
|
||||||
|
let isDraggingScroll = false;
|
||||||
|
let dragStartX = 0;
|
||||||
|
let dragStartLeft = 0;
|
||||||
|
|
||||||
|
const checkScroll = () => {
|
||||||
|
const el = scrollWrapper.value;
|
||||||
|
if (!el) return;
|
||||||
|
const sw = el.scrollWidth;
|
||||||
|
const cw = el.clientWidth;
|
||||||
|
|
||||||
|
// Only show custom scrollbar on mobile/tablet (width < 768px) and if content overflows
|
||||||
|
const isMobile = window.innerWidth <= 768;
|
||||||
|
showScrollbar.value = isMobile && (sw > cw + 1);
|
||||||
|
|
||||||
|
if (showScrollbar.value) {
|
||||||
|
// Thumb width percentage = (viewport / total) * 100
|
||||||
|
const ratio = cw / sw;
|
||||||
|
thumbWidth.value = Math.max(10, ratio * 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleScroll = () => {
|
||||||
|
if (isDraggingScroll) return;
|
||||||
|
const el = scrollWrapper.value;
|
||||||
|
if (!el) return;
|
||||||
|
const sw = el.scrollWidth;
|
||||||
|
const cw = el.clientWidth;
|
||||||
|
const sl = el.scrollLeft;
|
||||||
|
const maxScroll = sw - cw;
|
||||||
|
if (maxScroll <= 0) return;
|
||||||
|
|
||||||
|
// Map scroll position to thumb position (0 to 100 - thumbWidth)
|
||||||
|
const maxThumb = 100 - thumbWidth.value;
|
||||||
|
thumbLeft.value = (sl / maxScroll) * maxThumb;
|
||||||
|
};
|
||||||
|
|
||||||
|
const startScrollDrag = (e) => {
|
||||||
|
isDraggingScroll = true;
|
||||||
|
dragStartX = e.clientX || e.touches[0].clientX;
|
||||||
|
dragStartLeft = thumbLeft.value;
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', onScrollDrag);
|
||||||
|
document.addEventListener('mouseup', stopScrollDrag);
|
||||||
|
document.addEventListener('touchmove', onScrollDrag, { passive: false });
|
||||||
|
document.addEventListener('touchend', stopScrollDrag);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onScrollDrag = (e) => {
|
||||||
|
if (!isDraggingScroll || !scrollTrack.value) return;
|
||||||
|
|
||||||
|
const clientX = e.clientX || (e.touches ? e.touches[0].clientX : 0);
|
||||||
|
const deltaX = clientX - dragStartX;
|
||||||
|
const trackWidth = scrollTrack.value.offsetWidth;
|
||||||
|
|
||||||
|
if (trackWidth === 0) return;
|
||||||
|
|
||||||
|
// Calculate delta as percentage of track
|
||||||
|
const deltaPercent = (deltaX / trackWidth) * 100;
|
||||||
|
|
||||||
|
// New thumb position
|
||||||
|
let newLeft = dragStartLeft + deltaPercent;
|
||||||
|
const maxThumb = 100 - thumbWidth.value;
|
||||||
|
newLeft = Math.max(0, Math.min(maxThumb, newLeft));
|
||||||
|
|
||||||
|
thumbLeft.value = newLeft;
|
||||||
|
|
||||||
|
// Sync scroll
|
||||||
|
const el = scrollWrapper.value;
|
||||||
|
if (el) {
|
||||||
|
const sw = el.scrollWidth;
|
||||||
|
const cw = el.clientWidth;
|
||||||
|
const maxScroll = sw - cw;
|
||||||
|
el.scrollLeft = (newLeft / maxThumb) * maxScroll;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopScrollDrag = () => {
|
||||||
|
isDraggingScroll = false;
|
||||||
|
document.removeEventListener('mousemove', onScrollDrag);
|
||||||
|
document.removeEventListener('mouseup', stopScrollDrag);
|
||||||
|
document.removeEventListener('touchmove', onScrollDrag);
|
||||||
|
document.removeEventListener('touchend', stopScrollDrag);
|
||||||
|
};
|
||||||
|
|
||||||
const getRowHintsWidth = () => {
|
const getRowHintsWidth = () => {
|
||||||
const el = rowHintsRef.value?.$el;
|
const el = rowHintsRef.value?.$el;
|
||||||
@@ -23,17 +111,27 @@ const getRowHintsWidth = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const computeCellSize = () => {
|
const computeCellSize = () => {
|
||||||
const vw = Math.min(window.innerWidth, 900);
|
|
||||||
const rootStyles = getComputedStyle(document.documentElement);
|
const rootStyles = getComputedStyle(document.documentElement);
|
||||||
const hintWidth = getRowHintsWidth();
|
const hintWidth = getRowHintsWidth();
|
||||||
const gapRaw = rootStyles.getPropertyValue('--gap-size') || '2px';
|
const gapRaw = rootStyles.getPropertyValue('--gap-size') || '2px';
|
||||||
const gridPadRaw = rootStyles.getPropertyValue('--grid-padding') || '5px';
|
const gridPadRaw = rootStyles.getPropertyValue('--grid-padding') || '5px';
|
||||||
const gap = parseFloat(gapRaw);
|
const gap = parseFloat(gapRaw);
|
||||||
const gridPad = parseFloat(gridPadRaw);
|
const gridPad = parseFloat(gridPadRaw);
|
||||||
const bodyStyles = getComputedStyle(document.body);
|
|
||||||
const bodyPadding = parseFloat(bodyStyles.paddingLeft) + parseFloat(bodyStyles.paddingRight);
|
let containerWidth;
|
||||||
const availableForGrid = vw - bodyPadding - hintWidth;
|
if (scrollWrapper.value) {
|
||||||
|
containerWidth = scrollWrapper.value.clientWidth;
|
||||||
|
} else {
|
||||||
|
// Fallback if wrapper not ready: window width minus estimated padding
|
||||||
|
// Body padding (40) + Layout padding (40) = 80
|
||||||
|
containerWidth = window.innerWidth - 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we don't have negative space
|
||||||
|
const availableForGrid = Math.max(0, containerWidth - hintWidth);
|
||||||
|
|
||||||
const size = Math.floor((availableForGrid - gridPad * 2 - (store.size - 1) * gap) / store.size);
|
const size = Math.floor((availableForGrid - gridPad * 2 - (store.size - 1) * gap) / store.size);
|
||||||
|
// Keep min 18, max 36
|
||||||
cellSize.value = Math.max(18, Math.min(36, size));
|
cellSize.value = Math.max(18, Math.min(36, size));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,6 +172,7 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
isFinePointer.value = window.matchMedia('(pointer: fine)').matches;
|
isFinePointer.value = window.matchMedia('(pointer: fine)').matches;
|
||||||
window.addEventListener('resize', computeCellSize);
|
window.addEventListener('resize', computeCellSize);
|
||||||
|
window.addEventListener('resize', checkScroll);
|
||||||
window.addEventListener('mouseup', handleGlobalMouseUp);
|
window.addEventListener('mouseup', handleGlobalMouseUp);
|
||||||
window.addEventListener('pointerup', handleGlobalPointerUp);
|
window.addEventListener('pointerup', handleGlobalPointerUp);
|
||||||
window.addEventListener('touchend', handleGlobalPointerUp, { passive: true });
|
window.addEventListener('touchend', handleGlobalPointerUp, { passive: true });
|
||||||
@@ -81,6 +180,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('resize', computeCellSize);
|
window.removeEventListener('resize', computeCellSize);
|
||||||
|
window.removeEventListener('resize', checkScroll);
|
||||||
window.removeEventListener('mouseup', handleGlobalMouseUp);
|
window.removeEventListener('mouseup', handleGlobalMouseUp);
|
||||||
window.removeEventListener('pointerup', handleGlobalPointerUp);
|
window.removeEventListener('pointerup', handleGlobalPointerUp);
|
||||||
window.removeEventListener('touchend', handleGlobalPointerUp);
|
window.removeEventListener('touchend', handleGlobalPointerUp);
|
||||||
@@ -89,11 +189,12 @@ onUnmounted(() => {
|
|||||||
watch(() => store.size, async () => {
|
watch(() => store.size, async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
computeCellSize();
|
computeCellSize();
|
||||||
|
checkScroll();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="game-board-wrapper">
|
<div class="game-board-wrapper" ref="scrollWrapper" @scroll="handleScroll">
|
||||||
<div class="game-container" :style="{ '--cell-size': `${cellSize}px` }">
|
<div class="game-container" :style="{ '--cell-size': `${cellSize}px` }">
|
||||||
<div class="corner-spacer"></div>
|
<div class="corner-spacer"></div>
|
||||||
|
|
||||||
@@ -131,13 +232,39 @@ watch(() => store.size, async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<div v-if="showScrollbar" class="fixed-scroll-bar">
|
||||||
|
<div class="fixed-scroll-track" ref="scrollTrack" @pointerdown="startScrollDrag">
|
||||||
|
<div
|
||||||
|
class="fixed-scroll-thumb"
|
||||||
|
:style="{ width: `${thumbWidth}%`, left: `${thumbLeft}%` }"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.game-board-wrapper {
|
.game-board-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
|
overflow-x: auto;
|
||||||
|
width: 100%;
|
||||||
|
scrollbar-width: none; /* Hide default scrollbar */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop: Remove scroll behavior to ensure full grid visibility */
|
||||||
|
@media (min-width: 769px) {
|
||||||
|
.game-board-wrapper {
|
||||||
|
overflow-x: auto; /* Allow scrolling if grid is too large (e.g. 80x80) */
|
||||||
|
align-items: center; /* Center the grid on desktop */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.game-board-wrapper::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-container {
|
.game-container {
|
||||||
@@ -145,17 +272,24 @@ watch(() => store.size, async () => {
|
|||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
grid-template-rows: auto auto;
|
grid-template-rows: auto auto;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
padding: 20px;
|
padding: 0;
|
||||||
background: rgba(0, 0, 0, 0.2);
|
background: transparent;
|
||||||
border-radius: 16px;
|
box-shadow: none;
|
||||||
box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
|
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.corner-spacer {
|
.corner-spacer {
|
||||||
height: auto; /* Adapts to Col Hints height */
|
height: auto; /* Adapts to Col Hints height */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Row Hints */
|
||||||
|
.game-container > :nth-child(3) {
|
||||||
|
/* No special styles */
|
||||||
|
}
|
||||||
|
|
||||||
.grid {
|
.grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: var(--gap-size);
|
gap: var(--gap-size);
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.guide-panel {
|
.guide-panel {
|
||||||
background: rgba(0, 0, 0, 0.25);
|
background: var(--panel-bg);
|
||||||
border: 1px solid rgba(0, 242, 254, 0.3);
|
border: 1px solid var(--panel-border);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
@@ -46,6 +46,7 @@ const { t } = useI18n();
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur(5px);
|
||||||
|
box-shadow: var(--panel-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-text {
|
.status-text {
|
||||||
@@ -53,7 +54,7 @@ const { t } = useI18n();
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
color: #ccc;
|
color: var(--text-muted);
|
||||||
min-height: 20px;
|
min-height: 20px;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
|
import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
|
||||||
import { usePuzzleStore } from '@/stores/puzzle';
|
import { usePuzzleStore } from '@/stores/puzzle';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
import { Gamepad2, Palette, CircleHelp, Sun, Moon, Menu, X, ChevronDown, ChevronUp } from 'lucide-vue-next';
|
import { Gamepad2, Palette, CircleHelp, Sun, Moon, Menu, X, ChevronDown, ChevronUp, Monitor } from 'lucide-vue-next';
|
||||||
|
|
||||||
const store = usePuzzleStore();
|
const store = usePuzzleStore();
|
||||||
const { t, locale, setLocale, locales } = useI18n();
|
const { t, locale, setLocale, locales } = useI18n();
|
||||||
@@ -20,6 +20,7 @@ const searchTerm = ref('');
|
|||||||
const langToCountry = {
|
const langToCountry = {
|
||||||
en: 'gb',
|
en: 'gb',
|
||||||
zh: 'cn',
|
zh: 'cn',
|
||||||
|
'zh-hant': 'tw',
|
||||||
hi: 'in',
|
hi: 'in',
|
||||||
es: 'es',
|
es: 'es',
|
||||||
fr: 'fr',
|
fr: 'fr',
|
||||||
@@ -61,7 +62,59 @@ const langToCountry = {
|
|||||||
gl: 'es-ga',
|
gl: 'es-ga',
|
||||||
cy: 'gb-wls',
|
cy: 'gb-wls',
|
||||||
gd: 'gb-sct',
|
gd: 'gb-sct',
|
||||||
eu: 'es-pv'
|
eu: 'es-pv',
|
||||||
|
af: 'za',
|
||||||
|
am: 'et',
|
||||||
|
hy: 'am',
|
||||||
|
az: 'az',
|
||||||
|
my: 'mm',
|
||||||
|
km: 'kh',
|
||||||
|
ceb: 'ph',
|
||||||
|
fa: 'ir',
|
||||||
|
gu: 'in',
|
||||||
|
ht: 'ht',
|
||||||
|
he: 'il',
|
||||||
|
ig: 'ng',
|
||||||
|
ilo: 'ph',
|
||||||
|
id: 'id',
|
||||||
|
ja: 'jp',
|
||||||
|
jv: 'id',
|
||||||
|
kn: 'in',
|
||||||
|
kk: 'kz',
|
||||||
|
rw: 'rw',
|
||||||
|
rn: 'bi',
|
||||||
|
ko: 'kr',
|
||||||
|
ku: 'tr',
|
||||||
|
ckb: 'iq',
|
||||||
|
ky: 'kg',
|
||||||
|
lo: 'la',
|
||||||
|
ms: 'my',
|
||||||
|
mr: 'in',
|
||||||
|
mn: 'mn',
|
||||||
|
ne: 'np',
|
||||||
|
om: 'et',
|
||||||
|
ps: 'af',
|
||||||
|
pa: 'in',
|
||||||
|
so: 'so',
|
||||||
|
sw: 'tz',
|
||||||
|
tl: 'ph',
|
||||||
|
ta: 'in',
|
||||||
|
te: 'in',
|
||||||
|
th: 'th',
|
||||||
|
bo: 'cn',
|
||||||
|
ti: 'er',
|
||||||
|
uz: 'uz',
|
||||||
|
vi: 'vn',
|
||||||
|
wo: 'sn',
|
||||||
|
yo: 'ng',
|
||||||
|
'pt-br': 'br',
|
||||||
|
'pt-pt': 'pt',
|
||||||
|
'fr-ca': 'ca',
|
||||||
|
'nl-be': 'be',
|
||||||
|
'es-es': 'es',
|
||||||
|
'es-419': 'mx',
|
||||||
|
'zh-hant': 'tw',
|
||||||
|
'zh-hans': 'cn'
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFlagClass = (code) => {
|
const getFlagClass = (code) => {
|
||||||
@@ -188,7 +241,7 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<!-- Game Menu -->
|
<!-- Game Menu -->
|
||||||
<div class="nav-dropdown">
|
<div class="nav-dropdown">
|
||||||
<button class="btn-neon nav-btn" @click.stop="toggleGameMenu">
|
<button class="btn-neon nav-btn" @click.stop="toggleGameMenu">
|
||||||
<Gamepad2 :size="18" /> NEW GAME
|
<Gamepad2 :size="18" /> {{ t('nav.newGame') }}
|
||||||
</button>
|
</button>
|
||||||
<transition name="slide-fade">
|
<transition name="slide-fade">
|
||||||
<div v-if="isGameOpen" class="dropdown-menu">
|
<div v-if="isGameOpen" class="dropdown-menu">
|
||||||
@@ -210,15 +263,18 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<!-- Theme Menu -->
|
<!-- Theme Menu -->
|
||||||
<div class="nav-dropdown">
|
<div class="nav-dropdown">
|
||||||
<button class="btn-neon nav-btn" @click.stop="toggleThemeMenu">
|
<button class="btn-neon nav-btn" @click.stop="toggleThemeMenu">
|
||||||
<Palette :size="18" /> Theme
|
<Palette :size="18" /> {{ t('theme.label') }}
|
||||||
</button>
|
</button>
|
||||||
<transition name="slide-fade">
|
<transition name="slide-fade">
|
||||||
<div v-if="isThemeOpen" class="dropdown-menu theme-menu">
|
<div v-if="isThemeOpen" class="dropdown-menu theme-menu">
|
||||||
|
<button class="dropdown-item" @click="setTheme('system')">
|
||||||
|
<Monitor :size="16" /> {{ t('theme.system') }}
|
||||||
|
</button>
|
||||||
<button class="dropdown-item" @click="setTheme('light')">
|
<button class="dropdown-item" @click="setTheme('light')">
|
||||||
<Sun :size="16" /> Light
|
<Sun :size="16" /> {{ t('theme.light') }}
|
||||||
</button>
|
</button>
|
||||||
<button class="dropdown-item" @click="setTheme('dark')">
|
<button class="dropdown-item" @click="setTheme('dark')">
|
||||||
<Moon :size="16" /> Dark
|
<Moon :size="16" /> {{ t('theme.dark') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -226,7 +282,7 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
|
|
||||||
<!-- Guide Button -->
|
<!-- Guide Button -->
|
||||||
<button class="btn-neon nav-btn" @click="toggleGuide">
|
<button class="btn-neon nav-btn" @click="toggleGuide">
|
||||||
<CircleHelp :size="18" /> GUIDE
|
<CircleHelp :size="18" /> {{ t('nav.guide') }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Language Menu -->
|
<!-- Language Menu -->
|
||||||
@@ -280,7 +336,7 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<!-- Mobile Game Menu -->
|
<!-- Mobile Game Menu -->
|
||||||
<div class="mobile-group">
|
<div class="mobile-group">
|
||||||
<button class="mobile-item-trigger" @click="toggleGameMenu">
|
<button class="mobile-item-trigger" @click="toggleGameMenu">
|
||||||
<span class="flex-center gap-10"><Gamepad2 :size="20" /> NEW GAME</span>
|
<span class="flex-center gap-10"><Gamepad2 :size="20" /> {{ t('nav.newGame') }}</span>
|
||||||
<component :is="isGameOpen ? ChevronUp : ChevronDown" :size="16" />
|
<component :is="isGameOpen ? ChevronUp : ChevronDown" :size="16" />
|
||||||
</button>
|
</button>
|
||||||
<div v-if="isGameOpen" class="mobile-sub-menu">
|
<div v-if="isGameOpen" class="mobile-sub-menu">
|
||||||
@@ -301,15 +357,18 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<!-- Mobile Theme Menu -->
|
<!-- Mobile Theme Menu -->
|
||||||
<div class="mobile-group">
|
<div class="mobile-group">
|
||||||
<button class="mobile-item-trigger" @click="toggleThemeMenu">
|
<button class="mobile-item-trigger" @click="toggleThemeMenu">
|
||||||
<span class="flex-center gap-10"><Palette :size="20" /> Theme</span>
|
<span class="flex-center gap-10"><Palette :size="20" /> {{ t('theme.label') }}</span>
|
||||||
<component :is="isThemeOpen ? ChevronUp : ChevronDown" :size="16" />
|
<component :is="isThemeOpen ? ChevronUp : ChevronDown" :size="16" />
|
||||||
</button>
|
</button>
|
||||||
<div v-if="isThemeOpen" class="mobile-sub-menu">
|
<div v-if="isThemeOpen" class="mobile-sub-menu">
|
||||||
|
<button class="mobile-sub-item" @click="setTheme('system')">
|
||||||
|
<Monitor :size="16" /> {{ t('theme.system') }}
|
||||||
|
</button>
|
||||||
<button class="mobile-sub-item" @click="setTheme('light')">
|
<button class="mobile-sub-item" @click="setTheme('light')">
|
||||||
<Sun :size="16" /> Light
|
<Sun :size="16" /> {{ t('theme.light') }}
|
||||||
</button>
|
</button>
|
||||||
<button class="mobile-sub-item" @click="setTheme('dark')">
|
<button class="mobile-sub-item" @click="setTheme('dark')">
|
||||||
<Moon :size="16" /> Dark
|
<Moon :size="16" /> {{ t('theme.dark') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -317,7 +376,7 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<!-- Mobile Guide -->
|
<!-- Mobile Guide -->
|
||||||
<div class="mobile-group">
|
<div class="mobile-group">
|
||||||
<button class="mobile-item-trigger" @click="toggleGuide">
|
<button class="mobile-item-trigger" @click="toggleGuide">
|
||||||
<span class="flex-center gap-10"><CircleHelp :size="20" /> GUIDE</span>
|
<span class="flex-center gap-10"><CircleHelp :size="20" /> {{ t('nav.guide') }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -328,7 +387,7 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
<span class="lang-flag-current mobile-flag">
|
<span class="lang-flag-current mobile-flag">
|
||||||
<span :class="getFlagClass(locale)"></span>
|
<span :class="getFlagClass(locale)"></span>
|
||||||
</span>
|
</span>
|
||||||
Language
|
{{ t('language.label') }}
|
||||||
</span>
|
</span>
|
||||||
<component :is="isLangOpen ? ChevronUp : ChevronDown" :size="16" />
|
<component :is="isLangOpen ? ChevronUp : ChevronDown" :size="16" />
|
||||||
</button>
|
</button>
|
||||||
@@ -549,14 +608,14 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100vw;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background: rgba(10, 10, 25, 0.98);
|
background: rgba(10, 10, 25, 0.98);
|
||||||
backdrop-filter: blur(20px);
|
backdrop-filter: blur(20px);
|
||||||
z-index: 10000;
|
z-index: 10000;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 20px;
|
padding: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,22 +623,24 @@ watch(isMobileMenuOpen, (val) => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 40px;
|
padding: 10px 20px;
|
||||||
padding-bottom: 20px;
|
|
||||||
border-bottom: 1px solid rgba(0, 242, 254, 0.2);
|
border-bottom: 1px solid rgba(0, 242, 254, 0.2);
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-title {
|
.mobile-title {
|
||||||
font-size: 1.5rem;
|
font-size: 1.8rem;
|
||||||
color: var(--primary-neon);
|
color: var(--primary-neon);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
letter-spacing: 2px;
|
letter-spacing: 3px;
|
||||||
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-menu-items {
|
.mobile-menu-items {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-group {
|
.mobile-group {
|
||||||
|
|||||||
110
src/components/ReloadPrompt.vue
Normal file
110
src/components/ReloadPrompt.vue
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<script setup>
|
||||||
|
import { useRegisterSW } from 'virtual:pwa-register/vue'
|
||||||
|
import { useI18n } from '@/composables/useI18n'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const {
|
||||||
|
offlineReady,
|
||||||
|
needRefresh,
|
||||||
|
updateServiceWorker,
|
||||||
|
} = useRegisterSW()
|
||||||
|
|
||||||
|
const close = async () => {
|
||||||
|
offlineReady.value = false
|
||||||
|
needRefresh.value = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="offlineReady || needRefresh"
|
||||||
|
class="pwa-toast"
|
||||||
|
role="alert"
|
||||||
|
>
|
||||||
|
<div class="message">
|
||||||
|
<span v-if="offlineReady">
|
||||||
|
{{ t('pwa.offlineReady') }}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
{{ t('pwa.newContent') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<button v-if="needRefresh" class="btn-neon small" @click="updateServiceWorker()">
|
||||||
|
{{ t('pwa.reload') }}
|
||||||
|
</button>
|
||||||
|
<button class="close-btn" @click="close">
|
||||||
|
{{ t('pwa.close') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pwa-toast {
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
bottom: 60px; /* Above the footer */
|
||||||
|
margin: 16px;
|
||||||
|
padding: 15px;
|
||||||
|
border: 1px solid var(--banner-border);
|
||||||
|
background: var(--banner-bg);
|
||||||
|
border-radius: 12px;
|
||||||
|
z-index: 2000;
|
||||||
|
text-align: left;
|
||||||
|
box-shadow: var(--banner-shadow);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
color: var(--text-color);
|
||||||
|
max-width: 320px;
|
||||||
|
animation: slideIn 0.3s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideIn {
|
||||||
|
from {
|
||||||
|
transform: translateY(20px);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--text-muted);
|
||||||
|
color: var(--text-muted);
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn:hover {
|
||||||
|
border-color: var(--text-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-neon.small {
|
||||||
|
padding: 6px 16px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,7 +3,7 @@ import { computed } from 'vue';
|
|||||||
import { usePuzzleStore } from '@/stores/puzzle';
|
import { usePuzzleStore } from '@/stores/puzzle';
|
||||||
import { useTimer } from '@/composables/useTimer';
|
import { useTimer } from '@/composables/useTimer';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
import { RotateCcw, RefreshCw, Eye } from 'lucide-vue-next';
|
import { RotateCcw, RefreshCw, Eye, Undo } from 'lucide-vue-next';
|
||||||
|
|
||||||
const store = usePuzzleStore();
|
const store = usePuzzleStore();
|
||||||
const { formatTime } = useTimer();
|
const { formatTime } = useTimer();
|
||||||
@@ -45,7 +45,7 @@ const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`);
|
|||||||
</button>
|
</button>
|
||||||
<div class="action-separator"></div>
|
<div class="action-separator"></div>
|
||||||
<button class="action-btn" @click="store.undo" :title="t('actions.undo')">
|
<button class="action-btn" @click="store.undo" :title="t('actions.undo')">
|
||||||
<RotateCcw :size="20" />
|
<Undo :size="20" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import { Fireworks } from 'fireworks-js';
|
|||||||
import { usePuzzleStore } from '@/stores/puzzle';
|
import { usePuzzleStore } from '@/stores/puzzle';
|
||||||
import { useI18n } from '@/composables/useI18n';
|
import { useI18n } from '@/composables/useI18n';
|
||||||
import { useTimer } from '@/composables/useTimer';
|
import { useTimer } from '@/composables/useTimer';
|
||||||
import xIcon from '@/assets/brands/x.svg';
|
import { Download, FileCode } from 'lucide-vue-next';
|
||||||
import facebookIcon from '@/assets/brands/facebook.svg';
|
import { calculateDifficulty } from '@/utils/puzzleUtils';
|
||||||
import whatsappIcon from '@/assets/brands/whatsapp.svg';
|
|
||||||
|
|
||||||
const store = usePuzzleStore();
|
const store = usePuzzleStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@@ -42,30 +41,43 @@ const playFanfare = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
masterGain = audioContext.createGain();
|
masterGain = audioContext.createGain();
|
||||||
masterGain.gain.value = 0.18;
|
masterGain.gain.value = 0.25; // Slightly louder but softer tone
|
||||||
masterGain.connect(audioContext.destination);
|
masterGain.connect(audioContext.destination);
|
||||||
const notes = [
|
|
||||||
{ time: 0.0, dur: 0.18, freqs: [523.25, 659.25, 783.99] },
|
|
||||||
{ time: 0.2, dur: 0.18, freqs: [587.33, 740.0, 880.0] },
|
|
||||||
{ time: 0.4, dur: 0.22, freqs: [659.25, 830.61, 987.77] },
|
|
||||||
{ time: 0.7, dur: 0.35, freqs: [698.46, 880.0, 1046.5] }
|
|
||||||
];
|
|
||||||
const now = audioContext.currentTime;
|
const now = audioContext.currentTime;
|
||||||
notes.forEach(({ time, dur, freqs }) => {
|
|
||||||
freqs.forEach((freq) => {
|
const playNote = (freq, startTime, duration) => {
|
||||||
const osc = audioContext.createOscillator();
|
const osc = audioContext.createOscillator();
|
||||||
const gain = audioContext.createGain();
|
const gain = audioContext.createGain();
|
||||||
osc.type = 'triangle';
|
|
||||||
|
// Mix of sine and triangle for a bell-like quality
|
||||||
|
osc.type = 'sine';
|
||||||
osc.frequency.value = freq;
|
osc.frequency.value = freq;
|
||||||
gain.gain.setValueAtTime(0.0001, now + time);
|
|
||||||
gain.gain.linearRampToValueAtTime(0.8, now + time + 0.02);
|
// Envelope for elegant bell/chime sound
|
||||||
gain.gain.exponentialRampToValueAtTime(0.0001, now + time + dur);
|
gain.gain.setValueAtTime(0, startTime);
|
||||||
|
gain.gain.linearRampToValueAtTime(0.4, startTime + 0.05); // Soft attack
|
||||||
|
gain.gain.exponentialRampToValueAtTime(0.01, startTime + duration); // Long release
|
||||||
|
|
||||||
osc.connect(gain);
|
osc.connect(gain);
|
||||||
gain.connect(masterGain);
|
gain.connect(masterGain);
|
||||||
osc.start(now + time);
|
|
||||||
osc.stop(now + time + dur + 0.05);
|
osc.start(startTime);
|
||||||
});
|
osc.stop(startTime + duration + 0.1);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// C Major 7 Arpeggio sequence (C5, E5, G5, B5, C6) - Elegant & Uplifting
|
||||||
|
const sequence = [
|
||||||
|
{ freq: 523.25, time: 0.0, dur: 0.8 }, // C5
|
||||||
|
{ freq: 659.25, time: 0.1, dur: 0.8 }, // E5
|
||||||
|
{ freq: 783.99, time: 0.2, dur: 0.8 }, // G5
|
||||||
|
{ freq: 987.77, time: 0.3, dur: 0.8 }, // B5 (Maj7)
|
||||||
|
{ freq: 1046.50, time: 0.4, dur: 2.0 }, // C6 (High C resolve)
|
||||||
|
// Add a bass root note at the end for fullness
|
||||||
|
{ freq: 523.25, time: 0.4, dur: 2.0 } // C5
|
||||||
|
];
|
||||||
|
|
||||||
|
sequence.forEach(note => playNote(note.freq, now + note.time, note.dur));
|
||||||
};
|
};
|
||||||
|
|
||||||
const triggerVibration = () => {
|
const triggerVibration = () => {
|
||||||
@@ -88,8 +100,9 @@ const buildShareCanvas = () => {
|
|||||||
const padding = 28;
|
const padding = 28;
|
||||||
const headerHeight = 64;
|
const headerHeight = 64;
|
||||||
const footerHeight = 28;
|
const footerHeight = 28;
|
||||||
|
const infoHeight = 40; // New space for difficulty/guide info
|
||||||
const width = boardSize + padding * 2;
|
const width = boardSize + padding * 2;
|
||||||
const height = boardSize + padding * 2 + headerHeight + footerHeight;
|
const height = boardSize + padding * 2 + headerHeight + footerHeight + infoHeight;
|
||||||
const scale = window.devicePixelRatio || 1;
|
const scale = window.devicePixelRatio || 1;
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = width * scale;
|
canvas.width = width * scale;
|
||||||
@@ -109,6 +122,24 @@ const buildShareCanvas = () => {
|
|||||||
ctx.fillText(t('app.title'), padding, padding + 10);
|
ctx.fillText(t('app.title'), padding, padding + 10);
|
||||||
ctx.font = '600 16px "Segoe UI", sans-serif';
|
ctx.font = '600 16px "Segoe UI", sans-serif';
|
||||||
ctx.fillText(`${t('win.time')} ${formattedTime.value}`, padding, padding + 34);
|
ctx.fillText(`${t('win.time')} ${formattedTime.value}`, padding, padding + 34);
|
||||||
|
|
||||||
|
// Difficulty & Density Info
|
||||||
|
const densityPercent = Math.round(store.currentDensity * 100);
|
||||||
|
const difficultyKey = calculateDifficulty(store.currentDensity);
|
||||||
|
let diffColor = '#33ff33';
|
||||||
|
if (difficultyKey === 'extreme') diffColor = '#ff3333';
|
||||||
|
else if (difficultyKey === 'hardest') diffColor = '#ff9933';
|
||||||
|
else if (difficultyKey === 'harder') diffColor = '#ffff33';
|
||||||
|
|
||||||
|
const difficultyText = t(`difficulty.${difficultyKey}`);
|
||||||
|
ctx.font = '600 14px "Segoe UI", sans-serif';
|
||||||
|
|
||||||
|
// Right aligned difficulty info
|
||||||
|
const diffLabel = `${t('win.difficulty')} ${difficultyText} (${densityPercent}%)`;
|
||||||
|
const diffWidth = ctx.measureText(diffLabel).width;
|
||||||
|
ctx.fillStyle = diffColor;
|
||||||
|
ctx.fillText(diffLabel, width - padding - diffWidth, padding + 34);
|
||||||
|
|
||||||
const gridX = padding;
|
const gridX = padding;
|
||||||
const gridY = padding + headerHeight;
|
const gridY = padding + headerHeight;
|
||||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.06)';
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.06)';
|
||||||
@@ -152,12 +183,143 @@ const buildShareCanvas = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Guide Usage Info (Dirty Flag)
|
||||||
|
if (store.guideUsageCount > 0) {
|
||||||
|
ctx.fillStyle = '#ff4d4d';
|
||||||
|
ctx.font = '600 14px "Segoe UI", sans-serif';
|
||||||
|
|
||||||
|
const totalCells = store.size * store.size;
|
||||||
|
const percent = Math.min(100, Math.round((store.guideUsageCount / totalCells) * 100));
|
||||||
|
const guideText = t('win.usedGuide', { count: store.guideUsageCount, percent });
|
||||||
|
|
||||||
|
ctx.fillText(`⚠️ ${guideText}`, padding, height - padding - footerHeight + 10);
|
||||||
|
}
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.75)';
|
ctx.fillStyle = 'rgba(255, 255, 255, 0.75)';
|
||||||
ctx.font = '500 14px "Segoe UI", sans-serif';
|
ctx.font = '500 14px "Segoe UI", sans-serif';
|
||||||
ctx.fillText(appUrl, padding, height - padding + 6);
|
ctx.fillText(appUrl, padding, height - padding + 6);
|
||||||
return canvas;
|
return canvas;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildShareSVG = () => {
|
||||||
|
const grid = store.playerGrid;
|
||||||
|
if (!grid || !grid.length) return null;
|
||||||
|
|
||||||
|
const appUrl = 'https://nonograms.7u.pl/';
|
||||||
|
const size = store.size;
|
||||||
|
const maxBoard = 640;
|
||||||
|
const cellSize = Math.max(8, Math.floor(maxBoard / size));
|
||||||
|
const boardSize = cellSize * size;
|
||||||
|
const padding = 28;
|
||||||
|
const headerHeight = 64;
|
||||||
|
const footerHeight = 28;
|
||||||
|
const infoHeight = 40;
|
||||||
|
const width = boardSize + padding * 2;
|
||||||
|
const height = boardSize + padding * 2 + headerHeight + footerHeight + infoHeight;
|
||||||
|
|
||||||
|
// Colors
|
||||||
|
const bgGradientStart = '#1b2a4a';
|
||||||
|
const bgGradientEnd = '#0a1324';
|
||||||
|
const overlayColor = 'rgba(0, 0, 0, 0.35)';
|
||||||
|
const textColor = '#e8fbff';
|
||||||
|
const gridColor = 'rgba(255, 255, 255, 0.06)';
|
||||||
|
const gridLineColor = 'rgba(255, 255, 255, 0.12)';
|
||||||
|
const filledColor = '#00f2fe';
|
||||||
|
const crossColor = 'rgba(255, 255, 255, 0.5)';
|
||||||
|
const urlColor = 'rgba(255, 255, 255, 0.75)';
|
||||||
|
|
||||||
|
// Difficulty Logic
|
||||||
|
const densityPercent = Math.round(store.currentDensity * 100);
|
||||||
|
const difficultyKey = calculateDifficulty(store.currentDensity);
|
||||||
|
let diffColor = '#33ff33';
|
||||||
|
if (difficultyKey === 'extreme') diffColor = '#ff3333';
|
||||||
|
else if (difficultyKey === 'hardest') diffColor = '#ff9933';
|
||||||
|
else if (difficultyKey === 'harder') diffColor = '#ffff33';
|
||||||
|
const difficultyText = t(`difficulty.${difficultyKey}`);
|
||||||
|
const diffLabel = `${t('win.difficulty')} ${difficultyText} (${densityPercent}%)`;
|
||||||
|
|
||||||
|
let svgContent = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}">`;
|
||||||
|
|
||||||
|
// Background
|
||||||
|
svgContent += `
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||||
|
<stop offset="0%" stop-color="${bgGradientStart}"/>
|
||||||
|
<stop offset="100%" stop-color="${bgGradientEnd}"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="100%" height="100%" fill="url(#bg)"/>
|
||||||
|
<rect x="12" y="12" width="${width - 24}" height="${height - 24}" fill="${overlayColor}"/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Text: Title & Time
|
||||||
|
svgContent += `
|
||||||
|
<text x="${padding}" y="${padding + 28}" font-family="Segoe UI, sans-serif" font-weight="700" font-size="26" fill="${textColor}">${t('app.title')}</text>
|
||||||
|
<text x="${padding}" y="${padding + 56}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="16" fill="${textColor}">${t('win.time')} ${formattedTime.value}</text>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Text: Difficulty (Right Aligned - manual approx or end anchor)
|
||||||
|
svgContent += `
|
||||||
|
<text x="${width - padding}" y="${padding + 56}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="14" fill="${diffColor}" text-anchor="end">${diffLabel}</text>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const gridX = padding;
|
||||||
|
const gridY = padding + headerHeight;
|
||||||
|
|
||||||
|
// Grid Background
|
||||||
|
svgContent += `<rect x="${gridX}" y="${gridY}" width="${boardSize}" height="${boardSize}" fill="${gridColor}"/>`;
|
||||||
|
|
||||||
|
// Grid Lines
|
||||||
|
let gridLines = '';
|
||||||
|
for (let i = 0; i <= size; i++) {
|
||||||
|
const pos = i * cellSize;
|
||||||
|
// Vertical
|
||||||
|
gridLines += `<line x1="${gridX + pos}" y1="${gridY}" x2="${gridX + pos}" y2="${gridY + boardSize}" stroke="${gridLineColor}" stroke-width="1"/>`;
|
||||||
|
// Horizontal
|
||||||
|
gridLines += `<line x1="${gridX}" y1="${gridY + pos}" x2="${gridX + boardSize}" y2="${gridY + pos}" stroke="${gridLineColor}" stroke-width="1"/>`;
|
||||||
|
}
|
||||||
|
svgContent += gridLines;
|
||||||
|
|
||||||
|
// Cells
|
||||||
|
let cells = '';
|
||||||
|
const lineWidth = Math.max(1.5, Math.floor(cellSize * 0.12));
|
||||||
|
|
||||||
|
for (let r = 0; r < size; r++) {
|
||||||
|
for (let c = 0; c < size; c++) {
|
||||||
|
const state = grid[r]?.[c];
|
||||||
|
const cx = gridX + c * cellSize;
|
||||||
|
const cy = gridY + r * cellSize;
|
||||||
|
|
||||||
|
if (state === 1) { // Filled
|
||||||
|
cells += `<rect x="${cx + 1}" y="${cy + 1}" width="${cellSize - 2}" height="${cellSize - 2}" fill="${filledColor}"/>`;
|
||||||
|
} else if (state === 2) { // Cross
|
||||||
|
const d = cellSize * 0.6;
|
||||||
|
const off = cellSize * 0.2;
|
||||||
|
cells += `
|
||||||
|
<path d="M${cx + off} ${cy + off} L${cx + off + d} ${cy + off + d} M${cx + off + d} ${cy + off} L${cx + off} ${cy + off + d}"
|
||||||
|
stroke="${crossColor}" stroke-width="${lineWidth}" stroke-linecap="round"/>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
svgContent += cells;
|
||||||
|
|
||||||
|
// Guide Usage
|
||||||
|
if (store.guideUsageCount > 0) {
|
||||||
|
const totalCells = store.size * store.size;
|
||||||
|
const percent = Math.min(100, Math.round((store.guideUsageCount / totalCells) * 100));
|
||||||
|
const guideText = t('win.usedGuide', { count: store.guideUsageCount, percent });
|
||||||
|
svgContent += `<text x="${padding}" y="${height - padding - footerHeight + 10}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="14" fill="#ff4d4d">⚠️ ${guideText}</text>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL
|
||||||
|
svgContent += `<text x="${padding}" y="${height - padding + 6}" font-family="Segoe UI, sans-serif" font-weight="500" font-size="14" fill="${urlColor}">${appUrl}</text>`;
|
||||||
|
|
||||||
|
svgContent += '</svg>';
|
||||||
|
return svgContent;
|
||||||
|
};
|
||||||
|
|
||||||
const canvasToBlob = (canvas) => new Promise((resolve) => canvas.toBlob((blob) => resolve(blob), 'image/png'));
|
const canvasToBlob = (canvas) => new Promise((resolve) => canvas.toBlob((blob) => resolve(blob), 'image/png'));
|
||||||
|
|
||||||
const createShareBlob = async () => {
|
const createShareBlob = async () => {
|
||||||
@@ -166,6 +328,20 @@ const createShareBlob = async () => {
|
|||||||
return canvasToBlob(canvas);
|
return canvasToBlob(canvas);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const downloadShareSVG = () => {
|
||||||
|
const svgString = buildShareSVG();
|
||||||
|
if (!svgString) return;
|
||||||
|
const blob = new Blob([svgString], { type: 'image/svg+xml' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.download = `nonogram-${store.size}x${store.size}.svg`;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
};
|
||||||
|
|
||||||
const downloadShareImage = async () => {
|
const downloadShareImage = async () => {
|
||||||
const blob = await createShareBlob();
|
const blob = await createShareBlob();
|
||||||
if (!blob) return;
|
if (!blob) return;
|
||||||
@@ -183,7 +359,7 @@ const buildShareUrl = (target, text, url) => {
|
|||||||
const encodedText = encodeURIComponent(text);
|
const encodedText = encodeURIComponent(text);
|
||||||
const encodedUrl = encodeURIComponent(url);
|
const encodedUrl = encodeURIComponent(url);
|
||||||
if (target === 'x') {
|
if (target === 'x') {
|
||||||
return `https://twitter.com/intent/tweet?text=${encodedText}&url=${encodedUrl}`;
|
return `https://x.com/intent/tweet?text=${encodedText}&url=${encodedUrl}`;
|
||||||
}
|
}
|
||||||
if (target === 'facebook') {
|
if (target === 'facebook') {
|
||||||
return `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}"e=${encodedText}`;
|
return `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}"e=${encodedText}`;
|
||||||
@@ -197,13 +373,18 @@ const buildShareUrl = (target, text, url) => {
|
|||||||
const shareTo = async (target) => {
|
const shareTo = async (target) => {
|
||||||
if (shareInProgress.value) return;
|
if (shareInProgress.value) return;
|
||||||
shareInProgress.value = true;
|
shareInProgress.value = true;
|
||||||
try {
|
|
||||||
const blob = await createShareBlob();
|
|
||||||
if (!blob) return;
|
|
||||||
const file = new File([blob], `nonogram-${store.size}x${store.size}.png`, { type: 'image/png' });
|
|
||||||
const text = shareText.value;
|
const text = shareText.value;
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
if (navigator.share && navigator.canShare && navigator.canShare({ files: [file] })) {
|
const shareUrl = buildShareUrl(target, text, url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Try native share first if available (supports images)
|
||||||
|
if (navigator.share && navigator.canShare) {
|
||||||
|
const blob = await createShareBlob();
|
||||||
|
if (blob) {
|
||||||
|
const file = new File([blob], `nonogram-${store.size}x${store.size}.png`, { type: 'image/png' });
|
||||||
|
if (navigator.canShare({ files: [file] })) {
|
||||||
await navigator.share({
|
await navigator.share({
|
||||||
files: [file],
|
files: [file],
|
||||||
text,
|
text,
|
||||||
@@ -212,14 +393,28 @@ const shareTo = async (target) => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await downloadShareImage();
|
|
||||||
const shareUrl = buildShareUrl(target, text, url);
|
|
||||||
if (shareUrl) {
|
|
||||||
window.open(shareUrl, '_blank', 'noopener');
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.name === 'AbortError') {
|
||||||
|
return; // User cancelled native share, do nothing
|
||||||
|
}
|
||||||
|
// Other errors -> fall through to fallback
|
||||||
} finally {
|
} finally {
|
||||||
shareInProgress.value = false;
|
shareInProgress.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: Direct Link + Download
|
||||||
|
// Open window immediately if possible (though we awaited above, so it might be blocked,
|
||||||
|
// but we can't do much about it if we want to try native share first).
|
||||||
|
// Ideally, for Desktop, navigator.share is undefined so we skip the await above.
|
||||||
|
|
||||||
|
if (shareUrl) {
|
||||||
|
window.open(shareUrl, '_blank', 'noopener');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger download as "screenshot support"
|
||||||
|
downloadShareImage();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -279,19 +474,27 @@ onUnmounted(() => {
|
|||||||
<div class="share">
|
<div class="share">
|
||||||
<div class="share-title">{{ t('win.shareTitle') }}</div>
|
<div class="share-title">{{ t('win.shareTitle') }}</div>
|
||||||
<div class="share-buttons">
|
<div class="share-buttons">
|
||||||
|
<!-- X (Twitter) -->
|
||||||
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareX')" @click="shareTo('x')">
|
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareX')" @click="shareTo('x')">
|
||||||
<img :src="xIcon" alt="" class="share-icon" />
|
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M18.901 3H22l-7.21 8.26L23 21h-6.66L11.13 14.76 5.66 21H2.56l7.73-8.83L1 3h6.8l4.63 5.56L18.9 3h.001zm-1.2 15.9h1.77L6.44 5.1H4.44l13.26 13.8z"/></svg>
|
||||||
</button>
|
</button>
|
||||||
|
<!-- Facebook -->
|
||||||
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareFacebook')" @click="shareTo('facebook')">
|
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareFacebook')" @click="shareTo('facebook')">
|
||||||
<img :src="facebookIcon" alt="" class="share-icon" />
|
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.791-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
|
||||||
</button>
|
</button>
|
||||||
|
<!-- WhatsApp -->
|
||||||
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareWhatsapp')" @click="shareTo('whatsapp')">
|
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareWhatsapp')" @click="shareTo('whatsapp')">
|
||||||
<img :src="whatsappIcon" alt="" class="share-icon" />
|
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.008-.57-.008-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/></svg>
|
||||||
|
</button>
|
||||||
|
<!-- Download Screenshot (Compact) -->
|
||||||
|
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareDownload')" @click="downloadShareImage">
|
||||||
|
<Download :size="20" />
|
||||||
|
</button>
|
||||||
|
<!-- Download SVG (Compact) -->
|
||||||
|
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" aria-label="Download SVG" @click="downloadShareSVG">
|
||||||
|
<FileCode :size="20" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-neon secondary share-download" :disabled="shareInProgress" @click="downloadShareImage">
|
|
||||||
{{ t('win.shareDownload') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@@ -409,6 +612,7 @@ p {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.share-download {
|
.share-download {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
padding: 8px 18px;
|
padding: 8px 18px;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ export function useNonogram() {
|
|||||||
const dragMode = ref(null); // 'fill', 'empty', 'cross'
|
const dragMode = ref(null); // 'fill', 'empty', 'cross'
|
||||||
const startCellState = ref(null);
|
const startCellState = ref(null);
|
||||||
|
|
||||||
const startDrag = (r, c, isRightClick = false) => {
|
const startDrag = (r, c, isRightClick = false, force = false) => {
|
||||||
if (store.isGameWon) return;
|
if (store.isGameWon) return;
|
||||||
|
|
||||||
isDragging.value = true;
|
isDragging.value = true;
|
||||||
@@ -16,9 +16,7 @@ export function useNonogram() {
|
|||||||
|
|
||||||
if (isRightClick) {
|
if (isRightClick) {
|
||||||
// Right click logic
|
// Right click logic
|
||||||
// If current is 1 (filled), do nothing usually? Or ignore?
|
if (!force && current === 1) {
|
||||||
// Standard: Toggle 0 <-> 2
|
|
||||||
if (current === 1) {
|
|
||||||
dragMode.value = null; // invalid drag start
|
dragMode.value = null; // invalid drag start
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export function useSolver() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isProcessing.value) return;
|
if (isProcessing.value) return;
|
||||||
|
store.markGuideUsed();
|
||||||
ensureWorker();
|
ensureWorker();
|
||||||
isProcessing.value = true;
|
isProcessing.value = true;
|
||||||
|
|
||||||
@@ -77,6 +78,9 @@ export function useSolver() {
|
|||||||
} else if (type === 'done') {
|
} else if (type === 'done') {
|
||||||
isProcessing.value = false;
|
isProcessing.value = false;
|
||||||
pause();
|
pause();
|
||||||
|
} else if (type === 'stuck') {
|
||||||
|
isProcessing.value = false;
|
||||||
|
pause();
|
||||||
} else {
|
} else {
|
||||||
isProcessing.value = false;
|
isProcessing.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/main.js
16
src/main.js
@@ -31,19 +31,3 @@ app.directive('cell-hover', vCellHover)
|
|||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
let refreshing = false
|
|
||||||
const triggerReload = () => {
|
|
||||||
if (refreshing) return
|
|
||||||
refreshing = true
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
navigator.serviceWorker.addEventListener('controllerchange', triggerReload)
|
|
||||||
const checkForUpdate = () => {
|
|
||||||
navigator.serviceWorker.getRegistration().then((registration) => registration?.update())
|
|
||||||
}
|
|
||||||
window.addEventListener('visibilitychange', () => {
|
|
||||||
if (document.visibilityState === 'visible') checkForUpdate()
|
|
||||||
})
|
|
||||||
window.addEventListener('focus', checkForUpdate)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
const solution = ref([]);
|
const solution = ref([]);
|
||||||
const playerGrid = ref([]); // 0: empty, 1: filled, 2: cross
|
const playerGrid = ref([]); // 0: empty, 1: filled, 2: cross
|
||||||
const isGameWon = ref(false);
|
const isGameWon = ref(false);
|
||||||
|
const hasUsedGuide = ref(false);
|
||||||
|
const guideUsageCount = ref(0);
|
||||||
|
const currentDifficulty = ref(null); // 'easy', 'medium', 'hard', 'custom' or object { density: 0.5 }
|
||||||
|
const currentDensity = ref(0);
|
||||||
const size = ref(5);
|
const size = ref(5);
|
||||||
const startTime = ref(null);
|
const startTime = ref(null);
|
||||||
const elapsedTime = ref(0);
|
const elapsedTime = ref(0);
|
||||||
@@ -116,22 +120,30 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
|
|
||||||
resetGrid();
|
resetGrid();
|
||||||
isGameWon.value = false;
|
isGameWon.value = false;
|
||||||
|
hasUsedGuide.value = false;
|
||||||
|
guideUsageCount.value = 0;
|
||||||
|
currentDensity.value = totalCellsToFill.value / (size.value * size.value);
|
||||||
elapsedTime.value = 0;
|
elapsedTime.value = 0;
|
||||||
startTimer();
|
startTimer();
|
||||||
|
saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initCustomGame(customSize) {
|
function initCustomGame(customSize, density = 0.5) {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
currentLevelId.value = 'custom';
|
currentLevelId.value = 'custom';
|
||||||
size.value = customSize;
|
size.value = customSize;
|
||||||
|
|
||||||
// Generate random grid
|
// Generate random grid
|
||||||
solution.value = generateRandomGrid(customSize);
|
solution.value = generateRandomGrid(customSize, density);
|
||||||
|
|
||||||
resetGrid();
|
resetGrid();
|
||||||
isGameWon.value = false;
|
isGameWon.value = false;
|
||||||
|
hasUsedGuide.value = false;
|
||||||
|
guideUsageCount.value = 0;
|
||||||
|
currentDensity.value = density;
|
||||||
elapsedTime.value = 0;
|
elapsedTime.value = 0;
|
||||||
startTimer();
|
startTimer();
|
||||||
|
saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetGrid() {
|
function resetGrid() {
|
||||||
@@ -238,6 +250,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
solution: solution.value,
|
solution: solution.value,
|
||||||
playerGrid: playerGrid.value,
|
playerGrid: playerGrid.value,
|
||||||
isGameWon: isGameWon.value,
|
isGameWon: isGameWon.value,
|
||||||
|
hasUsedGuide: hasUsedGuide.value,
|
||||||
|
guideUsageCount: guideUsageCount.value,
|
||||||
|
currentDensity: currentDensity.value,
|
||||||
elapsedTime: elapsedTime.value,
|
elapsedTime: elapsedTime.value,
|
||||||
moves: moves.value,
|
moves: moves.value,
|
||||||
history: history.value
|
history: history.value
|
||||||
@@ -255,6 +270,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
solution.value = parsed.solution;
|
solution.value = parsed.solution;
|
||||||
playerGrid.value = parsed.playerGrid;
|
playerGrid.value = parsed.playerGrid;
|
||||||
isGameWon.value = parsed.isGameWon;
|
isGameWon.value = parsed.isGameWon;
|
||||||
|
hasUsedGuide.value = parsed.hasUsedGuide || false;
|
||||||
|
guideUsageCount.value = parsed.guideUsageCount || 0;
|
||||||
|
currentDensity.value = parsed.currentDensity || 0;
|
||||||
elapsedTime.value = parsed.elapsedTime || 0;
|
elapsedTime.value = parsed.elapsedTime || 0;
|
||||||
moves.value = parsed.moves || 0;
|
moves.value = parsed.moves || 0;
|
||||||
history.value = parsed.history || [];
|
history.value = parsed.history || [];
|
||||||
@@ -271,44 +289,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initGame(levelId = 'easy') {
|
// Duplicate initGame removed
|
||||||
// If init called without args and we have save, load it?
|
|
||||||
// User might want to start fresh if clicking buttons.
|
|
||||||
// Let's add explicit 'continue' logic or just auto-load on first run.
|
|
||||||
// For now, let's just stick to explicit init, but maybe load on mount if exists?
|
|
||||||
// The user didn't explicitly ask for "Continue", but "features from HTML".
|
|
||||||
// HTML usually auto-saves and loads.
|
|
||||||
|
|
||||||
stopTimer();
|
// Duplicate initCustomGame removed
|
||||||
currentLevelId.value = levelId;
|
|
||||||
|
|
||||||
let puzzle = PUZZLES[levelId];
|
|
||||||
if (!puzzle) {
|
|
||||||
puzzle = PUZZLES['easy'];
|
|
||||||
}
|
|
||||||
|
|
||||||
size.value = puzzle.size;
|
|
||||||
solution.value = puzzle.grid;
|
|
||||||
|
|
||||||
resetGrid();
|
|
||||||
isGameWon.value = false;
|
|
||||||
elapsedTime.value = 0;
|
|
||||||
startTimer();
|
|
||||||
saveState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify initCustomGame similarly
|
|
||||||
function initCustomGame(customSize) {
|
|
||||||
stopTimer();
|
|
||||||
currentLevelId.value = 'custom';
|
|
||||||
size.value = customSize;
|
|
||||||
solution.value = generateRandomGrid(customSize);
|
|
||||||
resetGrid();
|
|
||||||
isGameWon.value = false;
|
|
||||||
elapsedTime.value = 0;
|
|
||||||
startTimer();
|
|
||||||
saveState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Duplicate toggleCell/setCell removed
|
// Duplicate toggleCell/setCell removed
|
||||||
|
|
||||||
@@ -316,6 +299,8 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
if (currentLevelId.value === 'custom') {
|
if (currentLevelId.value === 'custom') {
|
||||||
resetGrid();
|
resetGrid();
|
||||||
isGameWon.value = false;
|
isGameWon.value = false;
|
||||||
|
hasUsedGuide.value = false;
|
||||||
|
guideUsageCount.value = 0;
|
||||||
elapsedTime.value = 0;
|
elapsedTime.value = 0;
|
||||||
startTimer();
|
startTimer();
|
||||||
saveState();
|
saveState();
|
||||||
@@ -324,6 +309,13 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function markGuideUsed() {
|
||||||
|
if (isGameWon.value) return;
|
||||||
|
hasUsedGuide.value = true;
|
||||||
|
guideUsageCount.value++;
|
||||||
|
saveState();
|
||||||
|
}
|
||||||
|
|
||||||
function closeWinModal() {
|
function closeWinModal() {
|
||||||
if (!isGameWon.value) return;
|
if (!isGameWon.value) return;
|
||||||
isGameWon.value = false;
|
isGameWon.value = false;
|
||||||
@@ -347,7 +339,11 @@ export const usePuzzleStore = defineStore('puzzle', () => {
|
|||||||
loadState, // expose loadState
|
loadState, // expose loadState
|
||||||
moves,
|
moves,
|
||||||
undo,
|
undo,
|
||||||
closeWinModal
|
closeWinModal,
|
||||||
|
hasUsedGuide,
|
||||||
|
guideUsageCount,
|
||||||
|
currentDensity,
|
||||||
|
markGuideUsed
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@import './scrollbar.css';
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
/* --- Glassmorphism Design System --- */
|
/* --- Glassmorphism Design System --- */
|
||||||
--bg-gradient: linear-gradient(135deg, #43C6AC 0%, #191654 100%);
|
--bg-gradient: linear-gradient(135deg, #43C6AC 0%, #191654 100%);
|
||||||
@@ -52,6 +54,9 @@
|
|||||||
--scroll-track: rgba(0, 0, 0, 0.1);
|
--scroll-track: rgba(0, 0, 0, 0.1);
|
||||||
--scroll-thumb: rgba(255, 255, 255, 0.2);
|
--scroll-thumb: rgba(255, 255, 255, 0.2);
|
||||||
--scroll-thumb-hover: var(--accent-cyan);
|
--scroll-thumb-hover: var(--accent-cyan);
|
||||||
|
--fixed-bar-bg: rgba(0, 0, 0, 0.85);
|
||||||
|
--fixed-bar-thumb: rgba(0, 242, 255, 0.5);
|
||||||
|
--fixed-bar-thumb-hover: rgba(0, 242, 255, 0.8);
|
||||||
|
|
||||||
/* Rozmiary */
|
/* Rozmiary */
|
||||||
--cell-size: 30px;
|
--cell-size: 30px;
|
||||||
@@ -113,6 +118,9 @@
|
|||||||
--scroll-track: rgba(15, 23, 42, 0.08);
|
--scroll-track: rgba(15, 23, 42, 0.08);
|
||||||
--scroll-thumb: rgba(15, 23, 42, 0.2);
|
--scroll-thumb: rgba(15, 23, 42, 0.2);
|
||||||
--scroll-thumb-hover: #0ea5e9;
|
--scroll-thumb-hover: #0ea5e9;
|
||||||
|
--fixed-bar-bg: rgba(248, 250, 255, 0.95);
|
||||||
|
--fixed-bar-thumb: rgba(14, 165, 233, 0.5);
|
||||||
|
--fixed-bar-thumb-hover: rgba(14, 165, 233, 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -121,6 +129,11 @@
|
|||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
overflow-x: hidden;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|||||||
54
src/styles/scrollbar.css
Normal file
54
src/styles/scrollbar.css
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
/* Fixed Scroll Bar */
|
||||||
|
.fixed-scroll-bar {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 15px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 85%;
|
||||||
|
max-width: 400px;
|
||||||
|
height: 44px; /* Increased hit area */
|
||||||
|
background: transparent;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
opacity: 0;
|
||||||
|
animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateX(-50%) translateY(10px); }
|
||||||
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-scroll-track {
|
||||||
|
width: 100%;
|
||||||
|
height: 14px; /* Increased visual thickness */
|
||||||
|
background: rgba(15, 23, 42, 0.4);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
-webkit-backdrop-filter: blur(4px);
|
||||||
|
border-radius: 7px;
|
||||||
|
position: relative;
|
||||||
|
pointer-events: auto;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-scroll-thumb {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--primary-accent);
|
||||||
|
border-radius: 7px;
|
||||||
|
cursor: grab;
|
||||||
|
box-shadow: 0 0 12px rgba(0, 242, 255, 0.5);
|
||||||
|
transition: background 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-scroll-thumb:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
|
||||||
|
}
|
||||||
@@ -40,15 +40,36 @@ export function calculateHints(grid) {
|
|||||||
return { rowHints, colHints };
|
return { rowHints, colHints };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateRandomGrid(size) {
|
export function generateRandomGrid(size, density = 0.5) {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
for (let i = 0; i < size; i++) {
|
for (let i = 0; i < size; i++) {
|
||||||
const row = [];
|
const row = [];
|
||||||
for (let j = 0; j < size; j++) {
|
for (let j = 0; j < size; j++) {
|
||||||
// ~50% chance of being filled
|
row.push(Math.random() < density ? 1 : 0);
|
||||||
row.push(Math.random() > 0.5 ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
grid.push(row);
|
grid.push(row);
|
||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function calculateDifficulty(density) {
|
||||||
|
// Shannon Entropy: H(x) = -x*log2(x) - (1-x)*log2(1-x)
|
||||||
|
// Normalized to 0-1 range (since max entropy at 0.5 is 1)
|
||||||
|
|
||||||
|
// Avoid log(0)
|
||||||
|
if (density <= 0 || density >= 1) return 'easy';
|
||||||
|
|
||||||
|
const entropy = -density * Math.log2(density) - (1 - density) * Math.log2(1 - density);
|
||||||
|
|
||||||
|
// Thresholds based on entropy
|
||||||
|
// 0.5 density -> entropy 1.0 (Extreme)
|
||||||
|
// 0.4/0.6 density -> entropy ~0.97 (Extreme)
|
||||||
|
// 0.3/0.7 density -> entropy ~0.88 (Hardest)
|
||||||
|
// 0.2/0.8 density -> entropy ~0.72 (Harder)
|
||||||
|
// <0.2/>0.8 density -> entropy <0.72 (Easy)
|
||||||
|
|
||||||
|
if (entropy >= 0.96) return 'extreme'; // approx 38% - 62%
|
||||||
|
if (entropy >= 0.85) return 'hardest'; // approx 28% - 38% & 62% - 72%
|
||||||
|
if (entropy >= 0.65) return 'harder'; // approx 17% - 28% & 72% - 83%
|
||||||
|
return 'easy';
|
||||||
|
}
|
||||||
|
|||||||
51
src/utils/puzzleUtils.spec.js
Normal file
51
src/utils/puzzleUtils.spec.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
import { calculateHints } from './puzzleUtils'
|
||||||
|
|
||||||
|
describe('puzzleUtils', () => {
|
||||||
|
it('calculateHints correctly calculates hints for a simple grid', () => {
|
||||||
|
const grid = [
|
||||||
|
[1, 0, 1],
|
||||||
|
[1, 1, 1],
|
||||||
|
[0, 1, 0]
|
||||||
|
]
|
||||||
|
// Row 0: 1, then space, then 1 -> [1, 1]
|
||||||
|
// Row 1: 1, 1, 1 -> [3]
|
||||||
|
// Row 2: space, 1, space -> [1]
|
||||||
|
|
||||||
|
// Col 0: 1, 1, 0 -> [2]
|
||||||
|
// Col 1: 0, 1, 1 -> [2] ? Wait. Col 1 is 0, 1, 1. So space, 1, 1 -> [2].
|
||||||
|
// Let's trace col 1 manually:
|
||||||
|
// r0,c1 = 0
|
||||||
|
// r1,c1 = 1 -> count=1
|
||||||
|
// r2,c1 = 1 -> count=2
|
||||||
|
// end -> push 2.
|
||||||
|
// So Col 1 is [2].
|
||||||
|
|
||||||
|
// Wait, my manual trace above for col 1:
|
||||||
|
// grid[0][1] is 0.
|
||||||
|
// grid[1][1] is 1.
|
||||||
|
// grid[2][1] is 1.
|
||||||
|
// Yes, [2].
|
||||||
|
|
||||||
|
// Col 2: 1, 1, 0 -> [2].
|
||||||
|
|
||||||
|
const expected = {
|
||||||
|
rowHints: [[1, 1], [3], [1]],
|
||||||
|
colHints: [[2], [2], [2]]
|
||||||
|
}
|
||||||
|
expect(calculateHints(grid)).toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calculateHints handles empty rows/cols', () => {
|
||||||
|
const grid = [
|
||||||
|
[0, 0, 0],
|
||||||
|
[0, 0, 0],
|
||||||
|
[0, 0, 0]
|
||||||
|
]
|
||||||
|
const expected = {
|
||||||
|
rowHints: [[0], [0], [0]],
|
||||||
|
colHints: [[0], [0], [0]]
|
||||||
|
}
|
||||||
|
expect(calculateHints(grid)).toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -5,7 +5,7 @@ const messages = {
|
|||||||
'worker.solved': 'Rozwiązane!',
|
'worker.solved': 'Rozwiązane!',
|
||||||
'worker.logicRow': 'Logika: Wiersz {row}, Kolumna {col} -> {state}',
|
'worker.logicRow': 'Logika: Wiersz {row}, Kolumna {col} -> {state}',
|
||||||
'worker.logicCol': 'Logika: Kolumna {col}, Wiersz {row} -> {state}',
|
'worker.logicCol': 'Logika: Kolumna {col}, Wiersz {row} -> {state}',
|
||||||
'worker.guess': 'Zgadywanie: Wiersz {row}, Kolumna {col}',
|
'worker.stuck': 'Brak logicznego ruchu. Spróbuj zgadnąć lub cofnąć.',
|
||||||
'worker.done': 'Koniec!',
|
'worker.done': 'Koniec!',
|
||||||
'worker.state.filled': 'Pełne',
|
'worker.state.filled': 'Pełne',
|
||||||
'worker.state.empty': 'Puste'
|
'worker.state.empty': 'Puste'
|
||||||
@@ -14,7 +14,7 @@ const messages = {
|
|||||||
'worker.solved': 'Solved!',
|
'worker.solved': 'Solved!',
|
||||||
'worker.logicRow': 'Logic: Row {row}, Column {col} -> {state}',
|
'worker.logicRow': 'Logic: Row {row}, Column {col} -> {state}',
|
||||||
'worker.logicCol': 'Logic: Column {col}, Row {row} -> {state}',
|
'worker.logicCol': 'Logic: Column {col}, Row {row} -> {state}',
|
||||||
'worker.guess': 'Guessing: Row {row}, Column {col}',
|
'worker.stuck': 'No logical move found. Try guessing or undoing.',
|
||||||
'worker.done': 'Done!',
|
'worker.done': 'Done!',
|
||||||
'worker.state.filled': 'Filled',
|
'worker.state.filled': 'Filled',
|
||||||
'worker.state.empty': 'Empty'
|
'worker.state.empty': 'Empty'
|
||||||
@@ -91,16 +91,34 @@ const solveLineLogic = (lineState, hints) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
const len = hints[hintIndex];
|
const len = hints[hintIndex];
|
||||||
|
// maxStart logic: we need enough space for this block (len) + subsequent blocks/gaps (suffixMin[hintIndex+1])
|
||||||
|
// suffixMin[hintIndex] = len + (m - hintIndex - 1) + suffixMin[hintIndex+1]
|
||||||
|
// Actually suffixMin[hintIndex] already includes everything needed from here to end.
|
||||||
|
// So if we place block at start, end is start + len.
|
||||||
|
// Total space needed is suffixMin[hintIndex].
|
||||||
|
// So start can go up to n - suffixMin[hintIndex].
|
||||||
const maxStart = n - suffixMin[hintIndex];
|
const maxStart = n - suffixMin[hintIndex];
|
||||||
|
|
||||||
for (let start = pos; start <= maxStart; start++) {
|
for (let start = pos; start <= maxStart; start++) {
|
||||||
if (hasFilled(pos, start)) continue;
|
if (hasFilled(pos, start)) continue; // Must be empty before this block
|
||||||
if (hasCross(start, start + len)) continue;
|
if (hasCross(start, start + len)) continue; // Block space must be free of crosses
|
||||||
if (start + len < n && lineState[start + len] === 1) continue;
|
|
||||||
const nextPos = start + len < n ? start + len + 1 : start + len;
|
// If not the last block, we need a gap after
|
||||||
|
if (hintIndex < m - 1) {
|
||||||
|
if (start + len < n && lineState[start + len] === 1) continue; // Gap must not be filled
|
||||||
|
// We can assume gap is at start + len. Next block starts at least at start + len + 1
|
||||||
|
const nextPos = start + len + 1;
|
||||||
if (canPlaceSuffix(nextPos, hintIndex + 1)) {
|
if (canPlaceSuffix(nextPos, hintIndex + 1)) {
|
||||||
memoSuffix[pos][hintIndex] = true;
|
memoSuffix[pos][hintIndex] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Last block
|
||||||
|
// Check if we can fill the rest with empty
|
||||||
|
if (hasFilled(start + len, n)) continue;
|
||||||
|
memoSuffix[pos][hintIndex] = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memoSuffix[pos][hintIndex] = false;
|
memoSuffix[pos][hintIndex] = false;
|
||||||
return false;
|
return false;
|
||||||
@@ -115,17 +133,43 @@ const solveLineLogic = (lineState, hints) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
const len = hints[hintCount - 1];
|
const len = hints[hintCount - 1];
|
||||||
const maxStart = pos - len;
|
|
||||||
|
// Logic for prefix:
|
||||||
|
// We are placing the (hintCount-1)-th block ending at 'start + len' <= pos.
|
||||||
|
// So 'start' <= pos - len.
|
||||||
|
// But we also need to ensure there is space for previous blocks.
|
||||||
|
// However, the simple constraint is just iterating backwards.
|
||||||
|
|
||||||
|
// maxStart: if this is the only block, maxStart = pos - len.
|
||||||
|
// If there are previous blocks, we need a gap before this block.
|
||||||
|
// So previous block ended at start - 1.
|
||||||
|
// Actually the recursive call will handle space check.
|
||||||
|
// But for the gap check:
|
||||||
|
// If we place block at 'start', we need lineState[start-1] != 1 (if start > 0).
|
||||||
|
// And we recursively check canPlacePrefix(start-1, count-1).
|
||||||
|
// But if start=0 and count > 1, impossible.
|
||||||
|
|
||||||
|
const maxStart = pos - len; // Simplified, loop condition handles rest
|
||||||
|
|
||||||
for (let start = maxStart; start >= 0; start--) {
|
for (let start = maxStart; start >= 0; start--) {
|
||||||
if (hasCross(start, start + len)) continue;
|
if (hasCross(start, start + len)) continue;
|
||||||
if (start + len < pos && lineState[start + len] === 1) continue;
|
if (hasFilled(start + len, pos)) continue; // Must be empty after this block up to pos
|
||||||
if (hasFilled(start + len, pos)) continue;
|
|
||||||
if (start > 0 && lineState[start - 1] === 1) continue;
|
// Check gap before
|
||||||
const prevPos = start > 0 ? start - 1 : 0;
|
if (hintCount > 1) {
|
||||||
|
if (start === 0) continue; // No space for previous blocks
|
||||||
|
if (lineState[start - 1] === 1) continue; // Gap must not be filled
|
||||||
|
const prevPos = start - 1;
|
||||||
if (canPlacePrefix(prevPos, hintCount - 1)) {
|
if (canPlacePrefix(prevPos, hintCount - 1)) {
|
||||||
memoPrefix[pos][hintCount] = true;
|
memoPrefix[pos][hintCount] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// First block
|
||||||
|
if (hasFilled(0, start)) continue; // Before first block must be empty
|
||||||
|
memoPrefix[pos][hintCount] = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memoPrefix[pos][hintCount] = false;
|
memoPrefix[pos][hintCount] = false;
|
||||||
return false;
|
return false;
|
||||||
@@ -136,7 +180,14 @@ const solveLineLogic = (lineState, hints) => {
|
|||||||
const len = hints[i];
|
const len = hints[i];
|
||||||
const starts = [];
|
const starts = [];
|
||||||
for (let start = 0; start <= n - len; start++) {
|
for (let start = 0; start <= n - len; start++) {
|
||||||
if (!canPlacePrefix(start, i)) continue;
|
if (i === 0) {
|
||||||
|
if (!canPlacePrefix(start, 0)) continue;
|
||||||
|
} else {
|
||||||
|
if (start === 0) continue;
|
||||||
|
if (lineState[start - 1] === 1) continue;
|
||||||
|
if (!canPlacePrefix(start - 1, i)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasCross(start, start + len)) continue;
|
if (hasCross(start, start + len)) continue;
|
||||||
if (start + len < n && lineState[start + len] === 1) continue;
|
if (start + len < n && lineState[start + len] === 1) continue;
|
||||||
const nextPos = start + len < n ? start + len + 1 : start + len;
|
const nextPos = start + len < n ? start + len + 1 : start + len;
|
||||||
@@ -236,29 +287,9 @@ const handleStep = (playerGrid, solution, locale) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let r = 0; r < size; r++) {
|
// Check for guess logic - we want to avoid this unless strictly necessary
|
||||||
for (let c = 0; c < size; c++) {
|
// If no logic move found, return 'stuck' instead of cheating
|
||||||
const current = playerGrid[r][c];
|
return { type: 'stuck', statusText: t(locale, 'worker.stuck') };
|
||||||
const target = solution[r][c];
|
|
||||||
let isCorrect = false;
|
|
||||||
if (target === 1 && current === 1) isCorrect = true;
|
|
||||||
if (target === 0 && current === 2) isCorrect = true;
|
|
||||||
if (target === 0 && current === 0) isCorrect = false;
|
|
||||||
if (target === 1 && current === 0) isCorrect = false;
|
|
||||||
if (!isCorrect) {
|
|
||||||
const newState = target === 1 ? 1 : 2;
|
|
||||||
return {
|
|
||||||
type: 'move',
|
|
||||||
r,
|
|
||||||
c,
|
|
||||||
state: newState,
|
|
||||||
statusText: t(locale, 'worker.guess', { row: r + 1, col: c + 1 })
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { type: 'done', statusText: t(locale, 'worker.done') };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.onmessage = (event) => {
|
self.onmessage = (event) => {
|
||||||
|
|||||||
60
update_i18n_guide.cjs
Normal file
60
update_i18n_guide.cjs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const filePath = 'src/composables/useI18n.js';
|
||||||
|
let content = fs.readFileSync(filePath, 'utf8');
|
||||||
|
|
||||||
|
// 1. Add key to all language objects
|
||||||
|
const lines = content.split('\n');
|
||||||
|
const newLines = [];
|
||||||
|
let insideLang = false;
|
||||||
|
let currentLang = null;
|
||||||
|
|
||||||
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
const line = lines[i];
|
||||||
|
|
||||||
|
const langStartMatch = line.match(/^\s{2}(['"]?[\w-]+['"]?): \{/);
|
||||||
|
if (langStartMatch) {
|
||||||
|
insideLang = true;
|
||||||
|
currentLang = langStartMatch[1].replace(/['"]/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insideLang && (line.trim() === '},' || line.trim() === '}')) {
|
||||||
|
let translation = 'GUIDE';
|
||||||
|
if (currentLang === 'pl') translation = 'PRZEWODNIK';
|
||||||
|
if (currentLang === 'es') translation = 'GUÍA';
|
||||||
|
if (currentLang === 'fr') translation = 'GUIDE';
|
||||||
|
if (currentLang === 'de') translation = 'ANLEITUNG';
|
||||||
|
if (currentLang === 'it') translation = 'GUIDA';
|
||||||
|
if (currentLang === 'pt' || currentLang === 'pt-br') translation = 'GUIA';
|
||||||
|
if (currentLang === 'ru') translation = 'РУКОВОДСТВО';
|
||||||
|
if (currentLang === 'zh') translation = '指南';
|
||||||
|
|
||||||
|
// Ensure previous line has comma
|
||||||
|
if (newLines.length > 0) {
|
||||||
|
const lastLine = newLines[newLines.length - 1];
|
||||||
|
if (!lastLine.trim().endsWith(',') && !lastLine.trim().endsWith('{')) {
|
||||||
|
newLines[newLines.length - 1] = lastLine + ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newLines.push(` 'nav.guide': '${translation}'`);
|
||||||
|
insideLang = false;
|
||||||
|
currentLang = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
newLines.push(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
content = newLines.join('\n');
|
||||||
|
|
||||||
|
// 2. Add to requiredKeys
|
||||||
|
// Find "const requiredKeys = ["
|
||||||
|
// We know it ends with 'nav.newGame' now.
|
||||||
|
content = content.replace(
|
||||||
|
"'nav.newGame'",
|
||||||
|
"'nav.newGame','nav.guide'"
|
||||||
|
);
|
||||||
|
|
||||||
|
fs.writeFileSync(filePath, content);
|
||||||
|
console.log('Updated useI18n.js with nav.guide');
|
||||||
@@ -4,11 +4,18 @@ import { VitePWA } from 'vite-plugin-pwa'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
define: {
|
||||||
|
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version)
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'prompt',
|
||||||
injectRegister: 'auto',
|
injectRegister: 'auto',
|
||||||
|
workbox: {
|
||||||
|
cleanupOutdatedCaches: true,
|
||||||
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,json,vue,txt,woff2}']
|
||||||
|
},
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: true
|
enabled: true
|
||||||
},
|
},
|
||||||
|
|||||||
16
vitest.config.js
Normal file
16
vitest.config.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'jsdom',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './src')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user