Skip to content

Commit

Permalink
refactor: export PlayButton component to dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
Alystrasz committed Sep 27, 2022
1 parent 3fbff79 commit 5c389c6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 26 deletions.
49 changes: 49 additions & 0 deletions src-vue/src/components/PlayButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script lang="ts">
import { NorthstarState } from '../utils/NorthstarState';
export default {
name: 'PlayButton',
data() {},
computed: {
playButtonLabel(): string {
if (this.$store.state.northstar_is_running) {
return "Game is running";
}
switch(this.$store.state.northstar_state) {
case NorthstarState.INSTALL:
return "Install";
case NorthstarState.INSTALLING:
return "Installing..."
case NorthstarState.MUST_UPDATE:
return "Update";
case NorthstarState.UPDATING:
return "Updating...";
case NorthstarState.READY_TO_PLAY:
return "Launch game";
default:
return "";
}
}
},
methods: {
launchGame() {
this.$store.commit('launchGame');
}
}
};
</script>

<template>
<el-button :disabled="northstarIsRunning" type="primary" size="large" @click="launchGame" class="fc_launch__button">
{{ playButtonLabel }}
</el-button>
</template>

<style scoped>
.fc_launch__button:focus {
background-color: var(--el-color-primary);
border-color: var(--el-color-primary);
}
</style>
31 changes: 5 additions & 26 deletions src-vue/src/views/PlayView.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
<script lang="ts">
import { ElNotification } from 'element-plus';
import { NorthstarState } from '../utils/NorthstarState';
import {Tabs} from "../utils/Tabs";
import PlayButton from '../components/PlayButton.vue';
export default {
data() {
return {
developerModeClicks: 0
}
},
components: {
PlayButton
},
computed: {
northstarIsRunning(): boolean {
return this.$store.state.northstar_is_running;
},
northstarVersion(): string {
return this.$store.state.installed_northstar_version;
},
playButtonLabel(): string {
if (this.$store.state.northstar_is_running) {
return "Game is running";
}
switch(this.$store.state.northstar_state) {
case NorthstarState.INSTALL:
return "Install";
case NorthstarState.INSTALLING:
return "Installing..."
case NorthstarState.MUST_UPDATE:
return "Update";
case NorthstarState.UPDATING:
return "Updating...";
case NorthstarState.READY_TO_PLAY:
return "Launch game";
}
}
},
methods: {
activateDeveloperMode() {
Expand All @@ -52,10 +37,6 @@ export default {
showChangelogPage() {
this.$store.commit('updateCurrentTab', Tabs.CHANGELOG);
},
launchGame() {
this.$store.commit('launchGame');
}
}
};
Expand All @@ -73,9 +54,7 @@ export default {
</div>
</div>
<div>
<el-button :disabled="northstarIsRunning" type="primary" size="large" @click="launchGame" class="fc_launch__button">
{{ playButtonLabel }}
</el-button>
<PlayButton/>
<div v-if="$store.state.developer_mode" id="fc_services__status">
<div>
<div class="fc_version__line">Northstar is running: </div>
Expand Down

0 comments on commit 5c389c6

Please sign in to comment.