forked from extern/froscon-2023-demo
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
03f43618ff | ||
|
ad97f8c66b | ||
|
6abb9bcf8d | ||
|
0ad1ecbc14 | ||
|
d8a4bd6af4 | ||
|
42db27c5d0 | ||
|
c2ddb12140 | ||
|
0b840d140a | ||
|
b4241566b6 | ||
|
4792c56eab | ||
|
6008ec8c29 |
@ -5,8 +5,73 @@
|
|||||||
<title>FrOSCon - 2023 - Demo</title>
|
<title>FrOSCon - 2023 - Demo</title>
|
||||||
|
|
||||||
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
<link href="./css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="./js/vue.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="container">
|
<body class="container">
|
||||||
<h1>Hello World</h1>
|
<h1>Hello World</h1>
|
||||||
|
|
||||||
|
<div class="card" id="app">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">{{ message }}</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
<input type="text" v-model="message" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Cards: {{ cards.length }}
|
||||||
|
Charcounter: {{ amountOfChars }}
|
||||||
|
Average Chars: {{ averageCharsAmount }}
|
||||||
|
</p>
|
||||||
|
<a href="#" class="btn btn-primary" v-on:click="addCard">Add Card</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6" v-for="(card, i) of cards" :key="card.id">
|
||||||
|
<card :css-class="i % 2 === 0 ? 'bg-primary' : 'bg-secondary'"></card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const MyVueApp = Vue.createApp({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
message: 'Hello Vue!',
|
||||||
|
cards: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
amountOfChars() {
|
||||||
|
if(this.cards.length === 0) return 0
|
||||||
|
|
||||||
|
return this.cards.map(c => c.content.length).reduce((pv, cv) => pv + cv)
|
||||||
|
},
|
||||||
|
averageCharsAmount() {
|
||||||
|
if(this.amountOfChars === 0) return 0
|
||||||
|
|
||||||
|
return this.amountOfChars / this.cards.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addCard() {
|
||||||
|
this.cards.push({
|
||||||
|
id: new Date().getTime(),
|
||||||
|
content: this.message,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
removeCard(i) {
|
||||||
|
this.cards.splice(i, 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
message(newValue) {
|
||||||
|
console.log("Message changed: ", newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<script src="./js/card.js"></script>
|
||||||
|
<script>
|
||||||
|
MyVueApp.mount('#app')
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
12
src/js/card.js
Normal file
12
src/js/card.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
MyVueApp.component('card', {
|
||||||
|
props: ['cssClass'],
|
||||||
|
template: `
|
||||||
|
<div class="card">
|
||||||
|
<div :class="cssClass">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title"></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
})
|
15361
src/js/vue.js
Normal file
15361
src/js/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user