Skip to content

Commit

Permalink
Merge pull request #9 from denOldTimer/chapter-six-five
Browse files Browse the repository at this point in the history
Chapter six-five
  • Loading branch information
denOldTimer authored Mar 9, 2021
2 parents c3f3b32 + e604a92 commit e66f046
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 132 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Full rights for the content and video belong to Earth Is Square and Mitchell Rom
- My Notes on that you can reade the [NOTES.MD](NOTES.md) file
- my environment:
- Device: Asus Gaming Laptop from yester year.
- OS: Unbuntu Linux 20.04 Desktop
- OS: Ubuntu Linux 20.04 Desktop
- IDE : VS Code

**SO LETS GET ON WITH IT !**
Expand Down Expand Up @@ -163,13 +163,18 @@ Lifecycle hooks : { [beforeCreated], [created], [beforeMount], [mounted],
- v-model creates a sync link between de form input and a data component/variable/placeholder
- in our ex. textarea is v-model with data-> newTwootContent
5. the submit

- normal submits refresh the html page, so to stop this we use `prevent`
- `@submit.prevent="createNewTwoot"`
- if we prevent, we have to replace it with something else `createNewTwoot`

- [Mutation Methods] :

- unshift => puts the item @ the top of the list = LIFO {last in, first out}
- push => pust the item @ the back of the list LILO {last in, last out}

6) **DOWNLOAD** **[release 1.4.2](https://github.com/denOldTimer/releases/1.5.0)**

---

## Basics : Chapter 6 : Dynamic Styling, Scss & Global styling
Expand All @@ -189,11 +194,24 @@ Lifecycle hooks : { [beforeCreated], [created], [beforeMount], [mounted],
- add an conditional class --exceed if newTwootCharacterCount > 180 chars

5. Global styling:

- IMPORTANT make shore your App.vue style lang="scss", otherwise your app will not startup with global stylings
- add a new folder styles and a file base.scss in the root of your src directory `./src/styles/base.scss`
- create a `vue.config.js` file in the root of your project
- restart server the vue.config.js isn't hot reload

6. **DOWNLOAD** **[release 1.4.2](https://github.com/denOldTimer/releases/1.6.0)**

---

## Advanced : Chapter 6.5 : Refactoring

1. **DOWNLOAD** **[release 1.4.2](https://github.com/denOldTimer/releases/1.6.5)**

---

## Advanced : Chapter 7 : The vue 3 Composition API

---

[data]: https://v3.vuejs.org/api/options-data.html#data-2
Expand Down
43 changes: 37 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<template>
<div id="app">
<nav>
<div class="navigation__logo">Twotter</div>
<div class="navigation__user">
{{ user.username }}
</div>
</nav>
<UserProfile />
</div>
</template>

<script>
import UserProfile from "./components/UserProfile"
import UserProfile from "./components/UserProfile";
export default {
name: 'App',
components: { UserProfile }
}
name: "App",
components: { UserProfile },
data() {
return {
user: {
username: "_MitchellRmney",
},
};
},
};
</script>

<style lang="scss">
Expand All @@ -18,7 +31,25 @@ export default {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f3f5fa;
nav {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 5%;
background-color: deeppink;
color: white;
.navigation__logo {
font-weight: bold;
font-size: 24px;
}
.navigation__user {
font-weight: bold;
}
}
}
</style>
46 changes: 46 additions & 0 deletions src/assets/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"users": [
{
"id": 1,
"username": "_mitchellRomney",
"firstName": "Mitchell",
"lastName": "Romney",
"email": "mitchellromnet@theearthissquare.com",
"isAdmin": true,
"twoots": [
{ "id": 1, "content": "Twotter is Amazing!" },
{
"id": 2,
"content": "Don't forget to subscribe to The Earth is Square!"
}
]
},
{
"id": 2,
"username": "JColeNC",
"firstName": "J.",
"lastName": "Cole",
"email": null,
"isAdmin": false,
"twoots": null
},
{
"id": 3,
"username": "kurtisconner",
"firstName": "kurtis",
"lastName": "conner",
"email": null,
"isAdmin": false,
"twoots": null
},
{
"id": 4,
"username": "boburnham",
"firstName": "Bo",
"lastName": "Burham",
"email": null,
"isAdmin": false,
"twoots": null
}
]
}
104 changes: 104 additions & 0 deletions src/components/CreateTwootPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<template>
<form
class="create-twoot-panel"
@submit.prevent="createNewTwoot"
:class="{ '--exceeded': newTwootCharacterCount > 180 }"
>
<label for="newTwoot"
><strong>New Twoot: </strong>({{ newTwootCharacterCount }}/180)</label
>
<textarea id="newTwoot" rows="4" v-model="newTwootContent"></textarea>

<div class="create-twoot-panel__submit">
<div class="create-twoot-type">
<label for="newTwootType"><strong>Type: </strong></label>
<select id="newTwootType" v-model="selectedTwootType">
<option
:value="option.value"
v-for="(option, index) in twootTypes"
:key="index"
>
{{ option.name }}
</option>
</select>
</div>

<button>Twoot It!</button>
</div>
</form>
</template>

<script>
export default {
name: "CreateTwootPanel",
data() {
return {
newTwootContent: "",
selectedTwootType: "instant", //default => instant
twootTypes: [
{ value: "draft", name: "Draft" },
{ value: "instant", name: "Instant Twoot" },
],
};
},
computed: {
newTwootCharacterCount() {
return this.newTwootContent.length;
},
},
methods: {
createNewTwoot() {
if (this.newTwootContent && this.selectedTwootType !== "draft") {
this.$emit("add-twoot", this.newTwootContent);
this.newTwootContent = "";
}
},
},
};
</script>

<style lang="scss">
.create-twoot-panel {
margin-top: 20px;
padding: 20px 0;
display: flex;
flex-direction: column;
textarea {
border: 1px solid #dfe3e8;
border-radius: 5px;
}
.create-twoot-panel__submit {
display: flex;
justify-content: space-between;
.create-twoot-type {
padding: 10px 0;
}
button {
padding: 5px 20px;
margin: auto 0;
border-radius: 5px;
border: none;
background-color: deeppink;
color: white;
font-weight: bold;
}
}
&.--exceeded {
color: red;
border-color: red;
.create-twoot-panel__submit {
button {
background-color: red;
border: none;
color: white;
}
}
}
}
</style>
32 changes: 14 additions & 18 deletions src/components/TwootItem.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="twoot-item" @click="favouriteTwoot(twoot.id)">
<div class="twoot-item">
<div class="user-profile__twoot">
<div class="twoot-item__user">@{{ username }}</div>
<div class="twoot-item__content">
Expand All @@ -11,23 +11,18 @@

<script>
export default {
name: "TwootItem",
props: {
username: {
type: String,
required: true
},
twoot: {
type: Object,
required: true
}
name: "TwootItem",
props: {
username: {
type: String,
required: true,
},
methods: {
favouriteTwoot(id){
this.$emit('favourite', id)
}
}
}
twoot: {
type: Object,
required: true,
},
},
};
</script>

<style lang="scss" scoped>
Expand All @@ -43,8 +38,9 @@ export default {
&:hover {
transform: scale(1.1, 1.1);
}
.twoot-item__user {
font-weight: bold;
}
}
</style>
</style>
Loading

0 comments on commit e66f046

Please sign in to comment.