Skip to content

Commit

Permalink
Estruturação do Projeto para ser uma SPA (devhatt#256)
Browse files Browse the repository at this point in the history
* finish service routes

remove codes

* chore: changed pt-br to english

* style: add eof package.json

* feat: change home folder to pages

* feat: change page petRegisterPage story  structure imports

* fix: change index directory to pages/

* fix: resolve conflict changes sidemenu

* refactor: change directories name of SPA structure

* refactor: refactor in pages and components for nomenclature correct

* refactor: moving Utils for PetDexApp directory

---------

Co-authored-by: JonasGz <[email protected]>
  • Loading branch information
muritadb and JonasGz committed Jun 11, 2024
1 parent b52b17d commit 82183bf
Show file tree
Hide file tree
Showing 60 changed files with 304 additions and 190 deletions.
146 changes: 0 additions & 146 deletions src/home/components/PetWeightPage/index.js

This file was deleted.

File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
rel="stylesheet"
/>
<title>Pet Hat</title>
<script src="./home/index.js" type="module"></script>
<script src="./layouts/index.js" type="module"></script>
<link
rel="icon"
type="image/x-icon"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from 'pet-dex-utilities';
import './index.scss';

import petUrl from '../../images/pet-dex.svg';
import petUrl from '../../../../images/pet-dex.svg';
import avatarUrl from './images/avatar.svg';
import bellUrl from './images/bell.svg';
import exitUrl from './images/exit.svg';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from 'pet-dex-utilities';
import petUrl from '../../images/pet-dex.svg';
import meusPets from './images/meuspets.svg';
import petdex from './images/petdex.svg';
import doacoes from './images/doacoes.svg';
import conta from './images/conta.svg';
import petUrl from '../../../../images/pet-dex.svg';
import configuracoes from './images/configuracoes.svg';
import conta from './images/conta.svg';
import doacoes from './images/doacoes.svg';
import exit from './images/exit.svg';
import exitMenu from './images/exitmenu.svg';
import meusPets from './images/meuspets.svg';
import notificacoes from './images/notifications.svg';
import perfil from './images/perfil.svg';
import exitMenu from './images/exitmenu.svg';
import petdex from './images/petdex.svg';
import './index.scss';

const html = `
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from 'pet-dex-utilities';
import Button from '../../../components/Button';
import Button from '../../../../components/Button';
import petUrl from './images/no-pet-regirested-page.png';
import './index.scss';

Expand All @@ -15,7 +15,7 @@ const html = `
</div>;
`;

export default function NoPetRegirestedPage() {
export default function NoPetRegirested() {
Component.call(this, { html });

const $container = this.selected.get('container');
Expand All @@ -32,7 +32,7 @@ export default function NoPetRegirestedPage() {
this.button.mount($container);
}

NoPetRegirestedPage.prototype = Object.assign(
NoPetRegirestedPage.prototype,
NoPetRegirested.prototype = Object.assign(
NoPetRegirested.prototype,
Component.prototype,
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from 'pet-dex-utilities';
import Button from '../../../components/Button';
import PetCard from '../../../components/PetCard';
import Button from '../../../../components/Button';
import PetCard from '../../../../components/PetCard';
import './index.scss';

const events = ['select:card', 'submit'];
Expand All @@ -12,7 +12,7 @@ const html = `
</div>
`;

export default function PetRegisterPage({ cards = [] } = {}) {
export default function PetRegister({ cards = [] } = {}) {
Component.call(this, { html, events });

const $container = this.selected.get('container');
Expand Down Expand Up @@ -54,7 +54,7 @@ export default function PetRegisterPage({ cards = [] } = {}) {
$button.mount($footerContainer);
}

PetRegisterPage.prototype = Object.assign(
PetRegisterPage.prototype,
PetRegister.prototype = Object.assign(
PetRegister.prototype,
Component.prototype,
);
140 changes: 140 additions & 0 deletions src/layouts/PetDexApp/pages/PetWeight/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { Component } from 'pet-dex-utilities';
import Button from '../../../../components/Button';
import RadioButton from '../../../../components/RadioButton';
import RangeSlider from '../../../../components/RangeSlider';
import TextInput from '../../../../components/TextInput';
import UploadImage from '../../../../components/UploadImage';
import './index.scss';

const html = `
<div class="pet-weight-page">
<div class="pet-weight-page__content" data-select="container">
<div class="pet-weight-page__image-container" data-select="image-container"></div>
<div class="pet-weight-page__description">
<h1 class="pet-weight-page__title">Qual é o peso do seu animal de estimação?</h1>
<p class="pet-weight-page__hint">Ajuste de acordo com a realidade</p>
</div>
<div class="pet-weight-page__slider-container" data-select="slider-container"></div>
<div class="pet-weight-page__inputs" data-select="input-container">
</div>
</div>
</div>;
`;

export default function PetWeight({ petPhoto }) {
Component.call(this, { html });
this.initializeComponents();
this.setupEventListeners();
this.applyCssClasses();
this.petPhoto = petPhoto;
}

PetWeight.prototype = Object.assign(PetWeight.prototype, Component.prototype, {
initializeComponents() {
const $container = this.selected.get('container');
const $imageContainer = this.selected.get('image-container');
const $sliderContainer = this.selected.get('slider-container');
const $inputsContainer = this.selected.get('input-container');

this.setupComponents(
$container,
$imageContainer,
$sliderContainer,
$inputsContainer,
);
},

setupComponents(
$container,
$imageContainer,
$sliderContainer,
$inputsContainer,
) {
this.image = new UploadImage();
this.slider = new RangeSlider();
this.input = new TextInput({
placeholder: 'Peso',
assetUrl: '',
assetPosition: 'prefix',
variation: 'standard',
});
this.radioKG = new RadioButton({
check: true,
text: 'KG',
value: 'kg',
name: 'weight-unit',
});
this.radioLB = new RadioButton({
text: 'LB',
value: 'lb',
name: 'weight-unit',
});
this.button = new Button({
text: 'Continuar',
isFullWidth: false,
isDisabled: false,
});

this.image.mount($imageContainer);
this.slider.mount($sliderContainer);
this.input.mount($inputsContainer);
this.radioKG.mount($inputsContainer);
this.radioLB.mount($inputsContainer);
this.button.mount($container);
},

applyCssClasses() {
this.image.selected
.get('image-preview')
.classList.add('pet-weight-page__image');
this.slider.selected
.get('range-slider')
.classList.add('pet-weight-page__slider');
this.slider.selected
.get('range-slider-value')
.classList.add('pet-weight-page__value');
this.input.selected
.get('input-text')
.classList.add('pet-weight-page__input');
this.input.selected
.get('input-text-container')
.classList.add('pet-weight-page__input-container');
this.radioKG.selected
.get('radio-container')
.classList.add('pet-weight-page__radio');
this.radioLB.selected
.get('radio-container')
.classList.add('pet-weight-page__radio');
this.button.selected.get('button').classList.add('pet-weight-page__button');
},

setupEventListeners() {
this.slider.listen('value:change', (value) => {
this.weight = Number(value.toFixed(1));
this.input.setValue(this.weight);
});

this.input.listen('value:change', (value) => {
const numericValue = parseFloat(value);
if (!numericValue.isNaN && this.weight !== numericValue) {
this.weight = numericValue;
this.slider.setValue(this.weight);
}
});

this.button.listen('click', () => {
const finalWeightUnit = this.weightUnit();
const finalWeight = this.weight;
this.emit('weight', finalWeight, finalWeightUnit);
});
},

weightUnit() {
return this.radioKG.isChecked()
? this.radioKG.getValue()
: this.radioLB.getValue();
},
});
File renamed without changes.
Loading

0 comments on commit 82183bf

Please sign in to comment.