Skip to content
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

Issue 27 - Calendar component #219

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

DominMFD
Copy link
Contributor

@DominMFD DominMFD commented May 8, 2024

Closes #27

Feature

Criação do componente de calendário

Visual evidences 🖼️

image

calendar_component.mp4
Checklist
  • Issue linked
  • Build working correctly
  • Tests created
Additional info Componente já estava criado mas tem alguns comentários do outro PR para resolver, eu resolvi alguns e abri esse PR para ser mais fácil de gerenciar os comentários. As cores não estão 100% certas, estou esperando a resposta do Desiger.

Copy link
Contributor

@Alecell Alecell left a comment

Choose a reason for hiding this comment

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

precisamos de um story para cada componente criado nessa tarefa

Copy link
Contributor

Choose a reason for hiding this comment

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

Pq esse CSS foi alterado?

Copy link
Contributor

Choose a reason for hiding this comment

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

As alteraçòes de cores tao certas aqui?

O Gray é Gray mesmo, nào é Grey

@@ -0,0 +1,219 @@
import { Component } from 'pet-dex-utilities';
import './index.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

Importar o css depois dos componentes

@@ -0,0 +1,219 @@
import { Component } from 'pet-dex-utilities';
import './index.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

Importar o css depois dos componentes

Copy link
Contributor

@Alecell Alecell left a comment

Choose a reason for hiding this comment

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

Lembre-se, inicialmente esse componente foi pensado para usar o componente de sliding internamente, então pode ser interessante fginalizar o slider antes de iniciar esse

import { listenBreakpoint } from '../../../../utils/breakpoints/breakpoints';
import DateButton from '../DateButton';

const events = ['changeMonth', 'changeYear'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Mudar o name pattern dos eventos

Comment on lines +27 to +28
let handleTouchStart;
let handleTouchMove;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remover as variaveis

Comment on lines +32 to +63
handleTouchStart = (event) => {
startTouch = selector.isDesktop
? event.touches[0].clientY
: event.touches[0].clientX;
};

handleTouchMove = (event) => {
event.preventDefault();
const currentTouch = selector.isDesktop
? event.touches[0].clientY
: event.touches[0].clientX;
let move = 0;
const moveRange = 20;
move = currentTouch - startTouch;

if (Math.abs(move) > moveRange) {
const isSlideNext = move < 0;
const nextYear = +selector.dates[3].children[0].innerText;
const prevYear = +selector.dates[1].children[0].innerText;
const nextMonth = monthsBR.indexOf(
selector.dates[3].children[0].innerText,
);
const prevMonth = monthsBR.indexOf(
selector.dates[1].children[0].innerText,
);
if (isSlideNext && selector.isYear) selector.setYear(nextYear);
if (!isSlideNext && selector.isYear) selector.setYear(prevYear);
if (isSlideNext && !selector.isYear) selector.setMonth(nextMonth);
if (!isSlideNext && !selector.isYear) selector.setMonth(prevMonth);
startTouch = currentTouch;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Toda essa parte do touchstart e touchmove deveria ser feita com o módulo atual de swipe, haviamos permitido deixar assim por enquanto pq a funcionalidade que precisavamos nao havia no modulo. Agora que será remanejado vamos revisitar isso e tentar usar o modulo de swipping.

selector.dateSelector.addEventListener('touchmove', handleTouchMove);
}

let handleScroll;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remover a variavel

Comment on lines +69 to +95
function scrollModal(selector) {
const $dateSelector = selector.dateSelector;

handleScroll = (event) => {
event.preventDefault();
const isScrollNext = event.deltaY > 0;

if (selector.isYear) {
const nextYear = +selector.dates[3].children[0].innerText;
const prevYear = +selector.dates[1].children[0].innerText;
const newYear = isScrollNext ? nextYear : prevYear;
selector.setYear(newYear);
} else {
const nextMonth = monthsBR.indexOf(
selector.dates[3].children[0].innerText,
);
const prevMonth = monthsBR.indexOf(
selector.dates[1].children[0].innerText,
);
const newMonth = isScrollNext ? nextMonth : prevMonth;
selector.setMonth(newMonth);
}
};

$dateSelector.addEventListener('wheel', handleScroll);
addTouchEvents(selector);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Isso aqui seria removido usando o slider

Comment on lines +139 to +145
this.dateClickHandle = (index) => () => {
if (this.isYear) {
this.setYear(this.dateArray[index]);
} else {
this.setMonth(monthsBR.indexOf(this.dateArray[index]));
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Renomear o método

Comment on lines +158 to +164
setTimeout(() => {
this.date.scrollIntoView({
behavior: 'instant',
block: 'center',
inline: 'center',
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Estranho isso existir x.x

Copy link
Contributor

Choose a reason for hiding this comment

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

Acredito que tudo que ta feito aqui poderia ser dividido em mais funcionalidades, arquivos e funções

Comment on lines +182 to +200
setMonth(newMonth) {
for (let i = 0; i < this.dateArray.length; i += 1) {
const index = (newMonth - (2 - i) + 12) % 12;
this.dateArray[i] = monthsBR[index];
}

this.dateArray.forEach((item, index) => {
this.dates[index].children[0].innerText = item;
});

this.date.scrollIntoView({
behavior: 'instant',
block: 'center',
inline: 'center',
});

this.emit('changeMonth', newMonth);
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Acredito que essa função ta complexa demais pra só trocar o mes

Comment on lines +201 to +218
setYear(newYear) {
for (let i = 0; i < this.dateArray.length; i += 1) {
this.dateArray[i] = newYear - (2 - i);
}

this.dateArray.forEach((item, index) => {
this.dates[index].children[0].innerText = item;
});

this.date.scrollIntoView({
behavior: 'instant',
block: 'center',
inline: 'center',
});

this.emit('changeYear', newYear);
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Acredito que essa funcao ta complexa demais pra so trocar o ano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crianção do componente de calendário
3 participants