Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 48 additions & 0 deletions src/components/DeslikeCollab.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script>
import IconCollab from '../components/IconCollab.svelte'
let deslikes = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tradução correta de "não gostei" é "dislike"


function handleClick() {
deslikes += 1;
}
</script>

<style>
button {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evite usar tags diretamente, sempre tenha preferencia pelo uso de classes para manter a mantenabilidade e a facilidade da leitura.

E não sei ao certo sobre o scoped do Svelte, se ele adiciona escopo em tags diretamente, o que pode gerar conflitos com outros componentes. Apesar que acho que o Svelte também coloca escopo.

Recomendo sempre utilizar o nome do componente na tag raiz, assim como os demais componentes presentes no repositório.
Neste caso a classe .dislike-button no CSS
E no HTML:

<button on:click={handleClick} class="dislike-button"> 

height: 40px;
width: 100px;
border-radius: 20px;
border: none;
cursor: pointer;
padding: 5px 15px;
background: rgb(255, 252, 238, 0.1);
margin: 20px 0 20px 16px;
}

button:last-child {
margin: 20px 0 0 5px;
}

button > div {
display: flex;
justify-content: space-evenly;
align-items: center;
}

button > div > p {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este é um exemplo, div e p podem ser qualquer coisa, o que uma alteração futura no HTML do componente pode gerar problemas e ter que reler todo lugar onde div está contido

color: #FFF;
font-size: 16px;
line-height: 24px;
letter-spacing: 0.5px;
font-family: Comfortaa;
}
</style>

<button on:click={handleClick}>
<div>
<IconCollab
name="deslike_button"
alt="Deslike Button" />
<p>{deslikes}</p>
</div>
</button>
44 changes: 44 additions & 0 deletions src/components/LikeCollab.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script>
import IconCollab from '../components/IconCollab.svelte'
let likes = 0

function handleClick() {
likes += 1;
}
</script>

<style>
button {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O mesmo caso dos comentários sobre os usos de classes vale para este componente também

height: 40px;
width: 100px;
border-radius: 20px;
border: none;
cursor: pointer;
padding: 5px 15px;
background: rgb(255, 252, 238, 0.1);
margin: 20px 0 20px 16px;
}

button > div {
display: flex;
justify-content: space-evenly;
align-items: center;
}

button > div > p {
color: #FFF;
font-size: 16px;
line-height: 24px;
letter-spacing: 0.5px;
font-family: Comfortaa;
}
</style>

<button on:click={handleClick}>
<div>
<IconCollab
name="like_button"
alt="Like Button" />
<p>{likes}</p>
</div>
</button>
4 changes: 4 additions & 0 deletions src/routes/_layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script>
import HeaderCollab from '../containers/HeaderCollab.svelte'
import LikeCollab from '../components/LikeCollab.svelte'
import DeslikeCollab from '../components/DeslikeCollab.svelte'

export let segment
</script>
Expand All @@ -12,4 +14,6 @@

<main>
<slot />
<LikeCollab />
<DeslikeCollab />
</main>
3 changes: 3 additions & 0 deletions static/img/dark/icon/deslike_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions static/img/dark/icon/like_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.