-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add board config input form components
- Loading branch information
Showing
10 changed files
with
290 additions
and
32 deletions.
There are no files selected for viewing
33 changes: 16 additions & 17 deletions
33
packages/vue-client/src/components/GameCreation/BadukConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/vue-client/src/components/GameCreation/BoardConfigForms/BoardConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup lang="ts"> | ||
import { BoardConfig, BoardPattern } from "@ogfcommunity/variants-shared"; | ||
import { type Ref, ref } from "vue"; | ||
import GridBoardConfigForm from "./GridBoardConfigForm.vue"; | ||
import RhombitrihexagonalBoardConfigForm from "./RhombitrihexagonalBoardConfigForm.vue"; | ||
import CircularBoardConfigForm from "./CircularBoardConfigForm.vue"; | ||
import TrihexagonalConfigForm from "./TrihexagonalConfigForm.vue"; | ||
import SierpinskyBoardConfigForm from "./SierpinskyBoardConfigForm.vue"; | ||
const props = defineProps<{ gridOnly?: boolean }>(); | ||
const board_type: Ref<string> = ref(BoardPattern.Grid); | ||
// TODO: respect initial board config as defined by variant | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: BoardConfig): void; | ||
}>(); | ||
function emitConfigChange(config: BoardConfig) { | ||
emit("configChanged", config); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="config-form-column"> | ||
<template v-if="$props.gridOnly !== true"> | ||
<label>Pattern</label> | ||
<select v-model="board_type" style="width: fit-content"> | ||
<option :value="BoardPattern.Grid">Rectangular</option> | ||
<option :value="BoardPattern.Polygonal">Polygonal</option> | ||
<option :value="BoardPattern.Circular">Circular</option> | ||
<option :value="BoardPattern.Trihexagonal">Trihexagonal</option> | ||
<option :value="BoardPattern.Sierpinsky">Sierpinsky Triangle</option> | ||
</select> | ||
</template> | ||
<GridBoardConfigForm | ||
v-if="board_type === BoardPattern.Grid" | ||
@config-changed="emitConfigChange" | ||
/> | ||
<RhombitrihexagonalBoardConfigForm | ||
v-if="board_type === BoardPattern.Polygonal" | ||
@config-changed="emitConfigChange" | ||
/> | ||
<CircularBoardConfigForm | ||
v-if="board_type === BoardPattern.Circular" | ||
@config-changed="emitConfigChange" | ||
/> | ||
<TrihexagonalConfigForm | ||
v-if="board_type === BoardPattern.Trihexagonal" | ||
@config-changed="emitConfigChange" | ||
/> | ||
<SierpinskyBoardConfigForm | ||
v-if="board_type === BoardPattern.Sierpinsky" | ||
@config-changed="emitConfigChange" | ||
/> | ||
</div> | ||
</template> |
35 changes: 35 additions & 0 deletions
35
packages/vue-client/src/components/GameCreation/BoardConfigForms/CircularBoardConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script setup lang="ts"> | ||
import { CircularBoardConfig } from "@ogfcommunity/variants-shared"; | ||
import { ref } from "vue"; | ||
const defaultConfig: CircularBoardConfig = { | ||
type: "circular", | ||
rings: 9, | ||
nodesPerRing: 9, | ||
}; | ||
const props = defineProps<{ initialConfig?: CircularBoardConfig }>(); | ||
const config = ref(props.initialConfig ?? defaultConfig); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: CircularBoardConfig): void; | ||
}>(); | ||
function emitConfigChange() { | ||
emit("configChanged", config.value); | ||
} | ||
if (!props.initialConfig) { | ||
emitConfigChange(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @change="emitConfigChange" class="config-form-column"> | ||
<label>Nodes per Ring</label> | ||
<input type="number" min="3" v-model="config.nodesPerRing" /> | ||
<label>Number of Rings</label> | ||
<input type="number" min="3" v-model="config.rings" /> | ||
</form> | ||
</template> |
36 changes: 36 additions & 0 deletions
36
packages/vue-client/src/components/GameCreation/BoardConfigForms/GridBoardConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup lang="ts"> | ||
import { GridBoardConfig } from "@ogfcommunity/variants-shared"; | ||
import { ref } from "vue"; | ||
const defaultConfig: GridBoardConfig = { | ||
type: "grid", | ||
width: 19, | ||
height: 19, | ||
}; | ||
const props = defineProps<{ initialConfig?: GridBoardConfig }>(); | ||
const config = ref(props.initialConfig ?? defaultConfig); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: GridBoardConfig): void; | ||
}>(); | ||
function emitConfigChange() { | ||
emit("configChanged", config.value); | ||
} | ||
if (!props.initialConfig) { | ||
emitConfigChange(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @change="emitConfigChange" class="config-form-column"> | ||
<div class=""></div> | ||
<label>Width</label> | ||
<input type="number" min="1" v-model="config.width" /> | ||
<label>Height</label> | ||
<input type="number" min="1" v-model="config.height" /> | ||
</form> | ||
</template> |
32 changes: 32 additions & 0 deletions
32
...client/src/components/GameCreation/BoardConfigForms/RhombitrihexagonalBoardConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
import { RhombitrihexagonalBoardConfig } from "@ogfcommunity/variants-shared"; | ||
import { ref } from "vue"; | ||
const defaultConfig: RhombitrihexagonalBoardConfig = { | ||
type: "polygonal", | ||
size: 4, | ||
}; | ||
const props = defineProps<{ initialConfig?: RhombitrihexagonalBoardConfig }>(); | ||
const config = ref(props.initialConfig ?? defaultConfig); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: RhombitrihexagonalBoardConfig): void; | ||
}>(); | ||
function emitConfigChange() { | ||
emit("configChanged", config.value); | ||
} | ||
if (!props.initialConfig) { | ||
emitConfigChange(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @change="emitConfigChange" class="config-form-column"> | ||
<label>Size</label> | ||
<input type="number" min="1" max="6" v-model="config.size" /> | ||
</form> | ||
</template> |
32 changes: 32 additions & 0 deletions
32
...ges/vue-client/src/components/GameCreation/BoardConfigForms/SierpinskyBoardConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
import { SierpinskyBoardConfig } from "@ogfcommunity/variants-shared"; | ||
import { ref } from "vue"; | ||
const defaultConfig: SierpinskyBoardConfig = { | ||
type: "sierpinsky", | ||
size: 3, | ||
}; | ||
const props = defineProps<{ initialConfig?: SierpinskyBoardConfig }>(); | ||
const config = ref(props.initialConfig ?? defaultConfig); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: SierpinskyBoardConfig): void; | ||
}>(); | ||
function emitConfigChange() { | ||
emit("configChanged", config.value); | ||
} | ||
if (!props.initialConfig) { | ||
emitConfigChange(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @change="emitConfigChange" class="config-form-column"> | ||
<label>Size</label> | ||
<input type="number" min="1" max="6" v-model="config.size" /> | ||
</form> | ||
</template> |
32 changes: 32 additions & 0 deletions
32
packages/vue-client/src/components/GameCreation/BoardConfigForms/TrihexagonalConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
import { TrihexagonalBoardConfig } from "@ogfcommunity/variants-shared"; | ||
import { ref } from "vue"; | ||
const defaultConfig: TrihexagonalBoardConfig = { | ||
type: "trihexagonal", | ||
size: 8, | ||
}; | ||
const props = defineProps<{ initialConfig?: TrihexagonalBoardConfig }>(); | ||
const config = ref(props.initialConfig ?? defaultConfig); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: TrihexagonalBoardConfig): void; | ||
}>(); | ||
function emitConfigChange() { | ||
emit("configChanged", config.value); | ||
} | ||
if (!props.initialConfig) { | ||
emitConfigChange(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @change="emitConfigChange" class="config-form-column"> | ||
<label>Size</label> | ||
<input type="number" min="1" v-model="config.size" /> | ||
</form> | ||
</template> |
27 changes: 27 additions & 0 deletions
27
packages/vue-client/src/components/GameCreation/GridBadukConfigForm.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
import { | ||
NewBadukConfig, | ||
NewGridBadukConfig, | ||
} from "@ogfcommunity/variants-shared"; | ||
import BadukConfigForm from "./BadukConfigForm.vue"; | ||
const props = defineProps<{ | ||
initialConfig: NewGridBadukConfig; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: "configChanged", config: NewBadukConfig): void; | ||
}>(); | ||
function emitConfigChange(config: NewBadukConfig) { | ||
emit("configChanged", config); | ||
} | ||
</script> | ||
|
||
<template> | ||
<BadukConfigForm | ||
v-bind:initial-config="$props.initialConfig" | ||
v-bind:grid-only="true" | ||
@config-changed="emitConfigChange" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters