CRC Card playground!

This commit is contained in:
Julien Calixte
2022-12-15 11:27:46 +01:00
parent 6b1103287b
commit 72a83c7a03
4 changed files with 71 additions and 15 deletions

View File

@@ -1,35 +1,75 @@
<script setup lang="ts">
<script setup lang="ts">import { ref } from 'vue';
interface Props {
name: string,
responsabilities?: string[]
collaborators?: string[]
editable?: boolean
}
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
responsabilities: () => [],
collaborators: () => []
collaborators: () => [],
editable: false
})
const allReponsabilities = ref(props.responsabilities)
const newResponsability = ref('')
const addResponsability = () => {
if (!newResponsability || allReponsabilities.value.find(resp => newResponsability.value === resp)) {
return
}
allReponsabilities.value = [...allReponsabilities.value, newResponsability.value]
newResponsability.value = ''
}
const allCollaborators = ref(props.collaborators)
const newCollaborator = ref('')
const addCollaborator = () => {
if (!newCollaborator || allCollaborators.value.find(coll => newCollaborator.value === coll)) {
return
}
allCollaborators.value = [...allCollaborators.value, newCollaborator.value]
newCollaborator.value = ''
}
</script>
<template>
<div class="crc-card">
<h3>{{ name }}</h3>
<h3 :contenteditable="editable">{{ name }}</h3>
<section>
<div class="responsabilities">
<hr>
<ol>
<li v-for="responsability in responsabilities" :key="responsability">
<li v-for="responsability in allReponsabilities" :key="responsability">
{{ responsability }}
</li>
</ol>
<form @submit.prevent="addResponsability" v-if="editable">
<input type="text" v-model="newResponsability">
<button type="submit">+</button>
</form>
</div>
<div class="collaborators" v-if="collaborators.length">
<div class="collaborators" v-if="collaborators.length || editable">
<hr>
<ol>
<li v-for="collaborator in collaborators" :key="collaborator">
<li v-for="collaborator in allCollaborators" :key="collaborator">
{{ collaborator }}
</li>
</ol>
<form @submit.prevent="addCollaborator" v-if="editable">
<input type="text" v-model.trim="newCollaborator">
<button type="submit">+</button>
</form>
</div>
</section>
</div>
@@ -72,5 +112,11 @@ withDefaults(defineProps<Props>(), {
visibility: hidden;
}
}
& [contenteditable] {
background-color: rgb(76, 71, 71);
padding: 0 0.5rem;
border-radius: 0.5rem;
}
}
</style>