Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added current examples #224

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/components/examples/Dynamic Button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div>
<button class="btn btn-primary" @click="$emit('clicked')">{{ text }}</button>
</div>
</template>

<script>
export default {
name: "DynamicButton",
props: {
text: {
type: String,
default: "Beispiel Button"
},
color: {
type: String,
default: "green"
}
},
}
</script>

<style scoped>
button {
background-color: v-bind(color);
border: none;
border-radius: 10px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin-bottom: 10px;
}
</style>
63 changes: 63 additions & 0 deletions src/components/examples/HTML_Template.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<div id="content">
<p>
Die Nachricht lautet: <b>{{ message }}</b>
</p>
<DynamicButton color="orange" text="Text ändern" @clicked="changeText()" />
<hr>
<p>Ein Element kann auch durch html Templates wiederholt werden.</p>
<span v-for="n in 5" :key="n">Wiederholung: {{ n }}<br></span>
<hr>
<p>Nun noch ein kleines Beispiel mit "v-model" und if statements<br>
Durch diese kann man nicht nur den Text ersetzen, wonach es hier eventuell aussieht, sondern ganze bereiche ersetzen.</p>
<input type="checkbox" v-model="ifTest" name="IF"/>
<label for="IF">Zum ändern der zu überprüfenden Variable</label><br>
<p style="color: #008200" v-if="ifTest">Dieser Text wird angezeigt, wenn die Checkbox <b><u>an</u></b> ist.</p>
<p style="color: #ff0000" v-else>Dieser Text wird angezeigt, wenn die Checkbox <b><u>aus</u></b> ist.</p>
</div>
</template>

<script>
import DynamicButton from "@/components/examples/Dynamic Button.vue";

export default {
name: "HTML_Template",
components: {
DynamicButton,
},
data() {
return {
message: "Das ist der Inhalt einer Variable",

currentIndex: 0,
ifTest: true,
};
},
methods: {
changeText() {
let options = [
"Das ist der Inhalt einer Variable",
"Das ist ein Beispiel Text",
"Platzhalter",
"Lorem Ipsum",
];
let randomIndex = Math.floor(Math.random() * options.length);
if (randomIndex === this.currentIndex) {
randomIndex = (randomIndex + 1) % options.length;
}
this.currentIndex = randomIndex;
this.message = options[randomIndex];
},
},
};
</script>

<style scoped>
#content {
margin-top: 10px;
padding: 5px 20px 20px;
background-color: #bee2ee; /* light blue */
border-radius: 10px;
width: fit-content;
}
</style>
26 changes: 26 additions & 0 deletions src/components/examples/StaticButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div>
<button class="btn btn-primary" @click="$emit('clicked')">Beispiel Button</button>
</div>
</template>

<script>
export default {
name: "StaticButton",
}
</script>

<style scoped>
button {
background-color: #4CAF50; /* Green */
border: none;
border-radius: 10px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin-bottom: 10px;
}
</style>
11 changes: 6 additions & 5 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ const routes = [
component: HomeView
},
{
// create a sub route folder so
// /easter/clock
// /easter/snake

path: "/easter",
name: "easter",
redirect: {name: "home"},
Expand Down Expand Up @@ -58,7 +54,12 @@ const routes = [
path: "stars",
name: "stars",
component: () => import("../views/extra/StarsView.vue")
}
},
{
path: "example",
name: "example",
component: () => import("../views/extra/ExampleView.vue"),
},
]
}
]
Expand Down
72 changes: 72 additions & 0 deletions src/views/extra/ExampleView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div class="content">
<p>Hier kommt der HTML Template Code rein</p><hr class="maxWidth bold">
<p>Das sind statische Buttons, diese bleiben immer gleich</p>
<div class="inline">
<StaticButton @clicked="test('Static Button clicked')"/>
<StaticButton @clicked="test('Static Button clicked')"/>
</div>
<p>Das sind dynamische Buttons, diese kann man durch einfache Parameter verändern.<br>
So kann ich Beispielsweise die Farbe, oder den Text ändern.</p>
<div class="inline">
<DynamicButton color="darkblue" text="Dieser Text ist variabel" @clicked="test('Dynamic Button clicked')"/>
<DynamicButton color="tomato" :text="'Counter: ' + counter" @clicked="counter++"/>
</div>
<hr>
Der folgende Inhalt ist aus dem HTML Template Beispiel
<HTML_Template/>
</div>
</template>

<script>
// Hier findet die Logik statt
import StaticButton from "@/components/examples/StaticButton.vue";
import DynamicButton from "@/components/examples/Dynamic Button.vue";
import HTML_Template from "@/components/examples/HTML_Template.vue";

export default {
name: 'ExampleView',
components: {
StaticButton,
DynamicButton,
HTML_Template
},
data() {
return {
counter: 0
}
},
methods: {
test(message) {
alert(message)
}
},
computed: {},
mounted() {
},
watch: {},
}
</script>

<style scoped>
/* Hier kommt der CSS Code rein, also die Styles */
.content {
padding: 5px 20px 20px;
background-color: #fff;

height: 100vh;
width: 100vw;
}
hr.maxWidth {
width: 100vw;
margin-left: -20px;
margin-bottom: 15px;
}
hr.bold {
border-top: 2px solid #000;
}
div.inline {
display: inline-flex;
gap: 10px;
}
</style>