Files
pihkaal-me/app/components/Home/BottomScreen/Buttons/Buttons.vue

72 lines
1.7 KiB
Vue

<script setup lang="ts">
import GameButton from "./GameButton.vue";
import ContactButton from "./ContactButton.vue";
import DownloadPlayButton from "./DownloadPlayButton.vue";
import Selector from "~/components/Common/ButtonSelector.vue";
const store = useHomeStore();
const BUTTONS_CONFIG = {
game: [31, 23, 193, 49],
contact: [31, 71, 97, 49],
downloadPlay: [127, 71, 97, 49],
} as const satisfies Record<string, ButtonConfig>;
type ButtonType = keyof typeof BUTTONS_CONFIG;
const { selectedButton, selectorPosition } = useButtonNavigation({
buttons: BUTTONS_CONFIG,
initialButton: "game",
onButtonClick: (button) => {
store.animateOutro(`/${button}`);
},
navigation: {
game: {
down: "last",
left: "contact",
right: "downloadPlay",
horizontalMode: "preview",
},
contact: {
up: "game",
right: "downloadPlay",
},
downloadPlay: {
up: "game",
left: "contact",
},
},
});
const getButtonOffset = (button: ButtonType) => {
if (selectedButton.value === button) return store.outro.buttonOffsetY;
return 0;
};
const getOpacity = (button?: ButtonType) => {
if (store.isIntro) return store.intro.stage1Opacity;
if (selectedButton.value === button) return 1;
return store.outro.stage1Opacity;
};
</script>
<template>
<GameButton
:x="33"
:y="25 + getButtonOffset('game')"
:opacity="getOpacity('game')"
/>
<DownloadPlayButton
:x="128"
:y="72 + getButtonOffset('downloadPlay')"
:opacity="getOpacity('downloadPlay')"
/>
<ContactButton
:x="32"
:y="72 + getButtonOffset('contact')"
:opacity="getOpacity('contact')"
/>
<Selector :rect="selectorPosition" :opacity="getOpacity()" />
</template>