move to feature module and init board
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import FeatureSteps from '@/FeatureSteps.vue'
|
import FeatureSteps from '@/modules/feature/FeatureSteps.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { FeatureStep } from '@/feature-steps'
|
import { FeatureStep } from '@/modules/feature/feature-steps'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -22,18 +22,22 @@ const hasFeaturesDone = computed(() => props.step.featuresInProgress.length > 0)
|
|||||||
<ul v-if="hasFeaturesInProgress">
|
<ul v-if="hasFeaturesInProgress">
|
||||||
<li
|
<li
|
||||||
v-for="feature in step.featuresInProgress"
|
v-for="feature in step.featuresInProgress"
|
||||||
:key="feature"
|
:key="feature.name"
|
||||||
class="bin"
|
class="bin"
|
||||||
>
|
>
|
||||||
{{ feature }}
|
{{ feature.name }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
<section class="done">
|
<section class="done">
|
||||||
<h5>📝✅</h5>
|
<h5>📝✅</h5>
|
||||||
<ul v-if="hasFeaturesDone">
|
<ul v-if="hasFeaturesDone">
|
||||||
<li v-for="feature in step.featuresDone" :key="feature" class="bin">
|
<li
|
||||||
{{ feature }}
|
v-for="feature in step.featuresDone"
|
||||||
|
:key="feature.name"
|
||||||
|
class="bin"
|
||||||
|
>
|
||||||
|
{{ feature.name }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div
|
<div
|
||||||
@@ -60,10 +64,6 @@ const hasFeaturesDone = computed(() => props.step.featuresInProgress.length > 0)
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
section ul {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h5 {
|
h5 {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
@@ -78,11 +78,15 @@ const hasFeaturesDone = computed(() => props.step.featuresInProgress.length > 0)
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-size: 12pt;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blue-bin {
|
.blue-bin {
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 18pt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import FeatureStep from '@/FeatureStep.vue'
|
import FeatureStep from '@/modules/feature/FeatureStep.vue'
|
||||||
import { featureSteps } from '@/feature-steps'
|
import { createFeatureBoard } from '@/modules/feature/feature-board'
|
||||||
|
import { featureSteps as initialFeatureSteps } from '@/modules/feature/feature-steps'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const featureBoard = createFeatureBoard()
|
||||||
|
|
||||||
|
const featureSteps = ref(featureBoard.initBoard(initialFeatureSteps))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
29
src/modules/feature/feature-board.ts
Normal file
29
src/modules/feature/feature-board.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { FeatureStatus, FeatureStep } from '@/modules/feature/feature-steps'
|
||||||
|
import { features } from '@/modules/feature/feature.fixture'
|
||||||
|
import { pickRandomElement, popNElement, shuffleArray } from '@/utils'
|
||||||
|
|
||||||
|
export const createFeatureBoard = () => {
|
||||||
|
const boardFeatures = shuffleArray(features)
|
||||||
|
|
||||||
|
const initBoard = (featureSteps: FeatureStep[]): FeatureStep[] => {
|
||||||
|
const initialFeatures = popNElement(boardFeatures, 10)
|
||||||
|
|
||||||
|
initialFeatures.forEach((feature) => {
|
||||||
|
const step = pickRandomElement(featureSteps)
|
||||||
|
const doingOrDone: FeatureStatus = pickRandomElement(['doing', 'done'])
|
||||||
|
|
||||||
|
switch (doingOrDone) {
|
||||||
|
case 'doing':
|
||||||
|
step.featuresInProgress.push(feature)
|
||||||
|
break
|
||||||
|
case 'done':
|
||||||
|
step.featuresDone.push(feature)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return featureSteps
|
||||||
|
}
|
||||||
|
|
||||||
|
return { initBoard }
|
||||||
|
}
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
|
export type FeatureStatus = 'doing' | 'done'
|
||||||
|
|
||||||
export type FeatureStep = {
|
export type FeatureStep = {
|
||||||
title: string
|
title: string
|
||||||
featuresInProgress: string[]
|
featuresInProgress: Feature[]
|
||||||
featuresDone: string[]
|
featuresDone: Feature[]
|
||||||
blueBuckets: number
|
blueBuckets: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const featureSteps: FeatureStep[] = [
|
export const featureSteps: FeatureStep[] = [
|
||||||
{
|
{
|
||||||
title: 'Pitch',
|
title: 'Pitch',
|
||||||
featuresInProgress: ['Feature 3', 'Feature 4'],
|
featuresInProgress: [],
|
||||||
featuresDone: ['Feature 1', 'Feature 2'],
|
featuresDone: [],
|
||||||
blueBuckets: 2
|
blueBuckets: 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
20
src/utils.ts
20
src/utils.ts
@@ -10,3 +10,23 @@ export const shuffleArray = <T>(array: T[]) => {
|
|||||||
|
|
||||||
return arrayCopy
|
return arrayCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const popNElement = <T>(array: T[], numberOfElements: number) => {
|
||||||
|
const poppedElements: T[] = []
|
||||||
|
|
||||||
|
for (let i = 0; i < numberOfElements; i++) {
|
||||||
|
const element = array.pop()
|
||||||
|
|
||||||
|
if (element) {
|
||||||
|
poppedElements.push(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return poppedElements
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pickRandomIndex = <T>(array: T[]) =>
|
||||||
|
Math.floor(Math.random() * array.length)
|
||||||
|
|
||||||
|
export const pickRandomElement = <T>(array: T[]) =>
|
||||||
|
array[pickRandomIndex(array)]
|
||||||
|
|||||||
Reference in New Issue
Block a user