-
Notifications
You must be signed in to change notification settings - Fork 44
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
avatar button Issue 18 #55
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component } from 'pet-dex-utilities'; | ||
import './index.scss'; | ||
import icon from './Icon.svg'; | ||
import iconHover from './iconHover.svg'; | ||
|
||
const html = ` | ||
<a href="#" class="avatarButton" data-select="container"> | ||
<img class="plus" data-select="image" src="${icon}" alt="" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não nomeie a classe com seu conteudo, no caso |
||
</a> | ||
`; | ||
|
||
export default function AvatarButton() { | ||
Component.call(this, { html }); | ||
|
||
const $image = this.selected.get('image'); | ||
const imageOriginal = icon; | ||
const imageHover = iconHover; | ||
|
||
$image.addEventListener('mouseover', () => ($image.src = imageHover)); | ||
$image.addEventListener('mouseout', () => ($image.src = imageOriginal)); | ||
} | ||
Comment on lines
+19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pq precisou usar JS e não apenas um CSS? |
||
|
||
AvatarButton.prototype = Object.assign( | ||
AvatarButton.prototype, | ||
Component.prototype | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.plus { | ||
padding: 18px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não usar pixel para |
||
border-radius: 9999px; | ||
border: 1.5px solid #fff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pixel com ponto flutuante é bad |
||
background: rgba(32, 35, 38, 1); | ||
|
||
&:hover { | ||
transition: 0.3s; | ||
border: 1.5px solid #62dcf6; | ||
cursor: pointer; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,11 @@ | ||
import { extractElements } from 'pet-dex-utilities'; | ||
import Card from '../components/Card'; | ||
import './index.scss'; | ||
|
||
function renderCards(qty, $container) { | ||
for (let i = 0; i < qty; i += 1) { | ||
const card = new Card(); | ||
card.mount($container); | ||
card.setTitle(`Card ${i}`); | ||
card.listen('purchase', () => { | ||
console.log(`purchase de quem usa o componente, esse é o card ${i}`); | ||
}); | ||
|
||
const $card = card.selected.get('card-button'); | ||
|
||
if (i === 2) { | ||
card.disable(); | ||
$card.classList.add('card-container__button--disabled'); | ||
} else { | ||
$card.classList.add('card-container__button--active'); | ||
} | ||
} | ||
} | ||
import AvatarButton from '../components/Avatar'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const selected = extractElements([document.body]); | ||
const $container = selected.get('container'); | ||
|
||
renderCards(5, $container); | ||
const avatar = new AvatarButton(); | ||
avatar.mount($container); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O nome dessa classe não condiz com o BEM https://getbem.com/introduction/