-
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
12 changed files
with
453 additions
and
22 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const activeSlide = (slides, slide) => { | ||
Array.from(slides).forEach((item) => { | ||
item.classList.toggle('sliding__slide--active', item === slide); | ||
}); | ||
}; |
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,26 @@ | ||
export const activeSlideShuffle = (slides, activeIndex) => { | ||
const totalSlides = slides.length; | ||
const hasMoreThanTwoSlides = totalSlides > 2; | ||
const prevIndex = activeIndex === 0 ? totalSlides - 1 : activeIndex - 1; | ||
const nextIndex = activeIndex === totalSlides - 1 ? 0 : activeIndex + 1; | ||
|
||
Array.from(slides).forEach((slide, index) => { | ||
slide.classList.remove( | ||
'sliding__slide--active', | ||
'sliding__slide--unfocused', | ||
'sliding__slide--prev', | ||
'sliding__slide--next', | ||
); | ||
|
||
if (index === activeIndex) slide.classList.add('sliding__slide--active'); | ||
|
||
if (index !== activeIndex && !hasMoreThanTwoSlides) | ||
slide.classList.add('sliding__slide--unfocused'); | ||
|
||
if (index === prevIndex && hasMoreThanTwoSlides) | ||
slide.classList.add('sliding__slide--prev'); | ||
|
||
if (index === nextIndex && hasMoreThanTwoSlides) | ||
slide.classList.add('sliding__slide--next'); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Component } from 'pet-dex-utilities'; | ||
import TextInput from '../../../components/TextInput'; | ||
import UploadImage from '../../../components/UploadImage'; | ||
import Button from '../../../components/Button'; | ||
import './index.scss'; | ||
|
||
const events = ['submit']; | ||
|
||
const html = ` | ||
<div class='pet-name'> | ||
<div class='pet-name__container'> | ||
<div class='pet-name__image' data-select='upload-image-container'></div> | ||
<h1 class='pet-name__title'>Qual o nome do seu bichinho?</h1> | ||
<div class='pet-name__input' data-select='input-container'></div> | ||
</div> | ||
<div class="pet-name__footer"> | ||
<div class='pet-name__button' data-select='button-container'></div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
export default function PetName() { | ||
Component.call(this, { html, events }); | ||
|
||
const $inputContainer = this.selected.get('input-container'); | ||
const $uploadImage = this.selected.get('upload-image-container'); | ||
const $buttonContainer = this.selected.get('button-container'); | ||
|
||
this.input = new TextInput({ | ||
placeholder: 'Nome do Pet', | ||
}); | ||
|
||
this.upload = new UploadImage(); | ||
this.button = new Button({ | ||
text: 'Continuar', | ||
isFullWidth: true, | ||
isDisabled: false, | ||
}); | ||
|
||
const updateButtonVisibility = () => { | ||
const input = this.input.getValue(); | ||
const image = this.upload.getImage(); | ||
|
||
this.button.setIsDisabled(!(input && image)); | ||
}; | ||
updateButtonVisibility(); | ||
|
||
this.upload.listen('value:change', updateButtonVisibility); | ||
this.input.listen('value:change', updateButtonVisibility); | ||
|
||
this.button.listen('click', () => { | ||
const image = this.upload.getImage(); | ||
const name = this.input.getValue(); | ||
this.emit('submit', { image, name }); | ||
}); | ||
|
||
this.upload.mount($uploadImage); | ||
this.input.mount($inputContainer); | ||
this.button.mount($buttonContainer); | ||
} | ||
|
||
PetName.prototype = Object.assign(PetName.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,70 @@ | ||
@use '~styles/breakpoints.scss' as breakpoints; | ||
@use '~styles/colors.scss' as colors; | ||
@use '~styles/fonts.scss' as fonts; | ||
|
||
.pet-name { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
&__container { | ||
width: 100%; | ||
|
||
margin-bottom: 2.4rem; | ||
} | ||
|
||
&__image { | ||
max-width: 18.6rem; | ||
|
||
margin: 5rem auto; | ||
} | ||
|
||
&__title { | ||
font-family: fonts.$primaryFont; | ||
color: colors.$gray800; | ||
text-align: center; | ||
font-size: fonts.$xs; | ||
font-weight: fonts.$medium; | ||
|
||
margin: 7rem auto 3rem; | ||
} | ||
|
||
&__input { | ||
width: min(100%, 42rem); | ||
|
||
margin: 0 auto; | ||
} | ||
|
||
&__footer { | ||
width: 100%; | ||
|
||
display: flex; | ||
|
||
justify-content: center; | ||
|
||
margin-top: auto; | ||
} | ||
|
||
&__button { | ||
width: min(100%, 42rem); | ||
} | ||
} | ||
|
||
@include breakpoints.from1024 { | ||
.pet-name { | ||
align-items: center; | ||
|
||
&__container { | ||
margin-bottom: 0; | ||
} | ||
|
||
&__title { | ||
font-size: fonts.$sm; | ||
|
||
margin-top: 15rem; | ||
} | ||
|
||
&__button { | ||
margin-top: 4rem; | ||
} | ||
} | ||
} |
Oops, something went wrong.