-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
144 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,62 @@ | ||
import { Component } from 'pet-dex-utilities'; | ||
import MyPetsCard from '../MyPetsCard'; | ||
import Sliding from '../Sliding'; | ||
import './index.scss'; | ||
|
||
const events = ['']; | ||
import arrowLeft from './images/arrowLeft.svg'; | ||
import arrowRight from './images/arrowRight.svg'; | ||
|
||
import './index.scss'; | ||
|
||
const html = ` | ||
<div class="my-pets" data-select="my-pets"> | ||
<div class="my-pets"> | ||
<button class="my-pets__button" data-select="button-previous"> | ||
<img src=${arrowLeft}></img> | ||
</button> | ||
<div class="my-pets__cards-container" data-select="my-pets-cards-container"></div> | ||
<button class="my-pets__button" data-select="button-next"> | ||
<img src=${arrowRight}></img> | ||
</button> | ||
</div> | ||
`; | ||
|
||
export default function MyPets() { | ||
Component.call(this, { html, events }); | ||
|
||
const $myPetsContainer = this.selected.get('my-pets'); | ||
|
||
const myPetsCard = new MyPetsCard({ | ||
name: 'Kelvo', | ||
gender: 'male', | ||
race: 'Cachorro', | ||
type: 'Humano', | ||
desc: 'Mistura marrom-escura-branca, com sobrancelhas claras e uma mancha em forma de coração na pata esquerda.', | ||
export default function MyPets({ | ||
pets = [ | ||
{ | ||
name: '', | ||
gender: '', | ||
race: '', | ||
type: '', | ||
desc: '', | ||
}, | ||
], | ||
}) { | ||
Component.call(this, { html }); | ||
|
||
const $myPetsContainer = this.selected.get('my-pets-cards-container'); | ||
const $previousButton = this.selected.get('button-previous'); | ||
const $nextButton = this.selected.get('button-next'); | ||
|
||
const cards = []; | ||
pets.forEach((pet) => { | ||
const petCard = new MyPetsCard(pet); | ||
const div = document.createElement('div'); | ||
petCard.mount(div); | ||
cards.push(div); | ||
}); | ||
const sliding = new Sliding({ | ||
slides: cards, | ||
shuffleMode: true, | ||
slideSideSpacing: 80, | ||
}); | ||
|
||
const div = document.createElement('div'); | ||
myPetsCard.mount(div); | ||
|
||
const sliding = new Sliding({ slides: [div] }); | ||
|
||
sliding.mount($myPetsContainer); | ||
|
||
$previousButton.onclick = () => { | ||
sliding.previous(); | ||
}; | ||
$nextButton.onclick = () => { | ||
sliding.next(); | ||
}; | ||
} | ||
|
||
MyPets.prototype = Object.assign(MyPets.prototype, Component.prototype, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.my-pets { | ||
display: flex; | ||
|
||
gap: 4rem; | ||
|
||
align-items: center; | ||
|
||
&__button { | ||
font: inherit; | ||
color: inherit; | ||
|
||
padding: 0; | ||
|
||
padding: 1.7rem; | ||
border: 0; | ||
|
||
background: none; | ||
|
||
box-shadow: 0 1px 4px 0 rgba(139, 158, 184, 0.2); | ||
outline: inherit; | ||
border-radius: 14px; | ||
|
||
cursor: pointer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
import MyPets from '../components/MyPets'; | ||
import MyPets from '~src/components/MyPets'; | ||
|
||
export default { | ||
title: 'Components/MyPets', | ||
render: (args) => { | ||
const dropdown = new MyPets(args); | ||
const myPets = new MyPets(args); | ||
const $container = document.createElement('div'); | ||
dropdown.mount($container); | ||
myPets.mount($container); | ||
|
||
return $container; | ||
}, | ||
}; | ||
|
||
export const Default = {}; | ||
export const Default = { | ||
args: { | ||
pets: [ | ||
{ | ||
name: 'Um super cachorro', | ||
gender: 'male', | ||
race: 'Border Collie', | ||
type: 'Cachorro', | ||
desc: 'Mistura marrom-escura-branca, com sobrancelhas claras e uma mancha em forma de coração na pata esquerda.', | ||
}, | ||
{ | ||
name: 'Tobias', | ||
gender: 'male', | ||
race: 'Border Collie', | ||
type: 'Cachorro', | ||
desc: 'Mistura marrom-escura-branca, com sobrancelhas claras e uma mancha em forma de coração na pata esquerda.', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import MyPetsCard from '../components/MyPetsCard'; | ||
|
||
export default { | ||
title: 'Components/MyPetsCard', | ||
render: (args) => { | ||
const myPetsCard = new MyPetsCard(args); | ||
const $container = document.createElement('div'); | ||
myPetsCard.mount($container); | ||
|
||
return $container; | ||
}, | ||
}; | ||
|
||
export const Default = { | ||
args: { | ||
name: 'Jake', | ||
gender: 'male', | ||
race: 'Border Collie', | ||
type: 'Cachorro', | ||
desc: 'Mistura marrom-escura-branca, com sobrancelhas claras e uma mancha em forma de coração na pata esquerda.', | ||
}, | ||
}; |