feat: cube transparency toggle
All checks were successful
Deploy to Production / deploy (push) Successful in 6s
All checks were successful
Deploy to Production / deploy (push) Successful in 6s
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Sun, Moon, Layers } from 'lucide-vue-next';
|
import { Sun, Moon, Layers, Grid2x2 } from 'lucide-vue-next';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { useSettings } from '../composables/useSettings';
|
import { useSettings } from '../composables/useSettings';
|
||||||
|
|
||||||
const { showProjections, toggleProjections } = useSettings();
|
const { showProjections, toggleProjections, isCubeTranslucent, toggleCubeTranslucent } = useSettings();
|
||||||
const isDark = ref(true);
|
const isDark = ref(true);
|
||||||
|
|
||||||
const setTheme = (dark) => {
|
const setTheme = (dark) => {
|
||||||
@@ -39,6 +39,16 @@ onMounted(() => {
|
|||||||
<Layers :size="20" />
|
<Layers :size="20" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<!-- Cube Opacity Toggle -->
|
||||||
|
<button
|
||||||
|
class="btn-neon nav-btn icon-only"
|
||||||
|
@click="toggleCubeTranslucent"
|
||||||
|
:title="isCubeTranslucent ? 'Wyłącz przezroczystość kostki' : 'Włącz przezroczystość kostki'"
|
||||||
|
:class="{ active: isCubeTranslucent }"
|
||||||
|
>
|
||||||
|
<Grid2x2 :size="20" />
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Theme Toggle -->
|
<!-- Theme Toggle -->
|
||||||
<button class="btn-neon nav-btn icon-only" @click="toggleTheme" :title="isDark ? 'Przełącz na jasny' : 'Przełącz na ciemny'">
|
<button class="btn-neon nav-btn icon-only" @click="toggleTheme" :title="isDark ? 'Przełącz na jasny' : 'Przełącz na ciemny'">
|
||||||
<Sun v-if="isDark" :size="20" />
|
<Sun v-if="isDark" :size="20" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useSettings } from '../../composables/useSettings'
|
|||||||
import Line3D from '../common/Line3D.vue'
|
import Line3D from '../common/Line3D.vue'
|
||||||
|
|
||||||
const { cubies, initCube, rotateLayer, turn, FACES } = useCube()
|
const { cubies, initCube, rotateLayer, turn, FACES } = useCube()
|
||||||
const { showProjections } = useSettings()
|
const { showProjections, isCubeTranslucent } = useSettings()
|
||||||
|
|
||||||
// --- Visual State ---
|
// --- Visual State ---
|
||||||
const rx = ref(-25) // Initial View Rotation X
|
const rx = ref(-25) // Initial View Rotation X
|
||||||
@@ -472,6 +472,7 @@ onUnmounted(() => {
|
|||||||
<div v-for="(color, face) in c.faces" :key="face"
|
<div v-for="(color, face) in c.faces" :key="face"
|
||||||
class="sticker"
|
class="sticker"
|
||||||
:class="[face, color]"
|
:class="[face, color]"
|
||||||
|
:style="{ opacity: isCubeTranslucent ? 0.5 : 1 }"
|
||||||
:data-id="c.id"
|
:data-id="c.id"
|
||||||
:data-face="face">
|
:data-face="face">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ try {
|
|||||||
|
|
||||||
const showProjections = ref(initialShowProjections);
|
const showProjections = ref(initialShowProjections);
|
||||||
|
|
||||||
|
let initialCubeTranslucent = false;
|
||||||
|
try {
|
||||||
|
const stored = localStorage.getItem('cubeTranslucent');
|
||||||
|
if (stored !== null) {
|
||||||
|
initialCubeTranslucent = stored === 'true';
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
const isCubeTranslucent = ref(initialCubeTranslucent);
|
||||||
|
|
||||||
export function useSettings() {
|
export function useSettings() {
|
||||||
const toggleProjections = () => {
|
const toggleProjections = () => {
|
||||||
showProjections.value = !showProjections.value;
|
showProjections.value = !showProjections.value;
|
||||||
@@ -18,8 +28,17 @@ export function useSettings() {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleCubeTranslucent = () => {
|
||||||
|
isCubeTranslucent.value = !isCubeTranslucent.value;
|
||||||
|
try {
|
||||||
|
localStorage.setItem('cubeTranslucent', String(isCubeTranslucent.value));
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showProjections,
|
showProjections,
|
||||||
toggleProjections
|
toggleProjections,
|
||||||
|
isCubeTranslucent,
|
||||||
|
toggleCubeTranslucent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user