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

12
components.d.ts vendored
View File

@@ -1,11 +1,8 @@
// generated by unplugin-vue-components // generated by unplugin-vue-components
// We suggest you to commit this file into source control // We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399 // Read more: https://github.com/vuejs/vue-next/pull/3399
import '@vue/runtime-core'
export {} declare module 'vue' {
declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
AboutMe: typeof import('./src/components/presentation/about-me.vue')['default'] AboutMe: typeof import('./src/components/presentation/about-me.vue')['default']
AppHeader: typeof import('./src/components/app-header.vue')['default'] AppHeader: typeof import('./src/components/app-header.vue')['default']
@@ -13,13 +10,12 @@ declare module '@vue/runtime-core' {
CrcCard: typeof import('./src/components/architecture/crc-card.vue')['default'] CrcCard: typeof import('./src/components/architecture/crc-card.vue')['default']
ForgettingCurve: typeof import('./src/components/smart-notes/forgetting-curve.vue')['default'] ForgettingCurve: typeof import('./src/components/smart-notes/forgetting-curve.vue')['default']
JulienCalixte: typeof import('./src/components/core/julien-calixte.vue')['default'] JulienCalixte: typeof import('./src/components/core/julien-calixte.vue')['default']
MyBooks: typeof import('./src/components/presentation/my-books.vue')['default']
MyProjects: typeof import('./src/components/presentation/my-projects.vue')['default'] MyProjects: typeof import('./src/components/presentation/my-projects.vue')['default']
OrderTag: typeof import('./src/components/core/order-tag.vue')['default'] OrderTag: typeof import('./src/components/core/order-tag.vue')['default']
ProductionFlow: typeof import('./src/components/flow/ProductionFlow.vue')['default'] ProductionFlow: typeof import('./src/components/flow/ProductionFlow.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
ToucanIcon: typeof import('./src/components/core/toucan-icon.vue')['default'] ToucanIcon: typeof import('./src/components/core/toucan-icon.vue')['default']
Welcome: typeof import('./src/components/Welcome.vue')['default'] Welcome: typeof import('./src/components/Welcome.vue')['default']
} }
} }
export { }

View File

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

View File

@@ -0,0 +1,8 @@
---
title: CRC Card playground
layout: post
---
# CRC Card playground
<CrcCard editable />

View File

@@ -222,3 +222,9 @@ export const UserBookmarks: FunctionComponent<Props> = ({ userId }) => {
// removing the magic number at the same time // removing the magic number at the same time
<TilesSkeleton numberOfTiles={MAXIMUM_BOOKMARKS} /> <TilesSkeleton numberOfTiles={MAXIMUM_BOOKMARKS} />
``` ```
## Playground
Do you want to create your own CRC cards?
Take a look at [the CRC card playground](/crc-cards-playground)!