Skip to content

Commit

Permalink
Merge pull request #5 from denOldTimer/chapter-four
Browse files Browse the repository at this point in the history
chapter four - refactoring behind the scenes
  • Loading branch information
denOldTimer authored Mar 8, 2021
2 parents d688651 + 14d2de9 commit be04da0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,5 @@ Lifecycle hooks : { [beforeCreated], [created], [beforeMount], [mounted],
[conditionals]: https://v3.vuejs.org/guide/conditional.html
[v-if]: https://v3.vuejs.org/guide/conditional.html#v-if
[v-for]: https://v3.vuejs.org/guide/list.html#mapping-an-array-to-elements-with-v-for

4. Refactoring behaind the sences: new component TwootItem
46 changes: 46 additions & 0 deletions src/components/TwootItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div class="twoot-item">
<div class="user-profile__twoot">
<div class="twoot-item__user">@{{ username }}</div>
<div class="twoot-item__content">
{{ twoot.content }}
</div>
</div>
</div>
</template>

<script>
export default {
name: "TwootItem",
props: {
username: {
type: String,
required: true
},
twoot: {
type: Object,
required: true
}
}
}
</script>

<style>
.twoot-item {
padding: 20px;
background-color: white;
border-radius: 5px;
border: 1px solid #dfe3e8;
box-sizing: border-box;
cursor: pointer;
transition: all 0.25s ease;
}
.twoot-item:hover {
transform: scale(1.1, 1.1);
}
.twoot-item__user {
font-weight: bold;
}
</style>
16 changes: 11 additions & 5 deletions src/components/UserProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
</div>
</div>
<div class="user-profile__twoots-wrapper">
<div
class="user-profile__twoot"
<TwootItem
v-for="twoot in user.twoots"
:key="twoot.id"
>
{{ twoot.content }}
</div>
:username="user.username"
:twoot="twoot"
/>
</div>
</div>
</template>

<script>
import TwootItem from './TwootItem';
export default {
name:"UserProfile",
components: { TwootItem },
data(){
return {
followers: 0,
Expand Down Expand Up @@ -92,6 +93,11 @@ export default {
font-weight: bold;
}
.user-profile__twoots-wrapper {
display: grid;
grid-gap: 10px;
}
h1 {
margin: 0;
}
Expand Down

0 comments on commit be04da0

Please sign in to comment.