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

Implementation of filters on the Activities page #212

Conversation

msantosdevlab
Copy link
Member

Descrição

Foram inseridos os filtros das tags na página Atividades
Fixes #210

Como testar esta modificação?

As.Raparigas.do.Codigo.mp4

Checklist:

  • O meu PR segue as regras de estilo de código deste projeto
  • Eu fiz uma autoavaliação (review) do meu próprio código ou materiais
  • Eu fiz as alterações correspondentes na documentação

Copy link

vercel bot commented Jul 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ardc-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 13, 2024 9:46am

Comment on lines 100 to 106
<button onClick={() => handleCategoryClick('')} className={`${selectedCategory === '' ? 'activeTab' : 'inactiveTab'} rounded-pill`}> Todos <span>{total}</span> </button>
<button onClick={() => handleCategoryClick('evento')} className={`${selectedCategory === 'evento' ? 'activeTab' : 'inactiveTab'} rounded-pill`}> Evento <span>{qtEvento}</span>
</button>
<button onClick={() => handleCategoryClick('media')} className={`${selectedCategory === 'media' ? 'activeTab' : 'inactiveTab'} rounded-pill`}> Media <span>{qtMedia}</span>
</button>
<button onClick={() => handleCategoryClick('workshop')} className={`${selectedCategory === 'workshop' ? 'activeTab' : 'inactiveTab'} rounded-pill`}> Workshop <span>{qtWorkshop}</span>
</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

isto pode ser feito por um array, evitando a duplicacao de código

const calculateCategoryTotal = (category) =>{
   return activitiesRefined && activitiesRefined.filter((item) => item.category.label === category).length;
}

(...)

<button onClick={() => handleCategoryClick('')} className={`${selectedCategory === '' ? 'activeTab' : 'inactiveTab'} rounded-pill`}> Todos <span>{activitiesRefined && activitiesRefined.length;}</span> </button>
Constants.Categories.map((item) =>{
        <button onClick={() => handleCategoryClick('evento')} className={`${selectedCategory === item.label ? 'activeTab' : 'inactiveTab'} rounded-pill`}> { capitalize(item.label)} <span> { calculateCategoryTotal(item.label)  }</span>
        </button>
})


//utils.js
function capitalize(word) {
   return word.charAt(0).toUpperCase() + word.slice(1);
}

que achas?

Comment on lines 10 to 37

.inactiveTab, .activeTab{
padding: 6px 18px;
text-decoration: none;
margin-right: 15px;
}

.inactiveTab{
border: 1px solid #DEDEDE;
background-color: transparent;
color: #000958;
}

.activeTab{
background-color: #01C2A9;
color: #fff;
border: 1px solid #01C2A9;
}

.activeTab > span, .inactiveTab > span {
padding: 5px;
background-color: #000958;
border-radius: 50px;
font-size: 10px;
color: #fff;
line-height: 1.5;
vertical-align: middle;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

podes substituir as cores pelas variáveis que estao no ./styles/variables.scss ?
para que possa ficar consistente com as cores do sistema, caso queiramos mudar

@@ -76,15 +76,42 @@ function Activities({ translation }) {
})
.sort((a, b) => sortByDesc(a, b, 'date'));

const categories = Array.from(new Set(activities.map(item => item.category.label)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Acho que não precisas disto, podes simplesmente fazer require das constantes, já existe uma lista declarada com as categorias todas. Que achas?

Comment on lines 101 to 112
<button onClick={() => handleCategoryClick('')} className={`${selectedCategory === '' ? 'activeTab' : 'inactiveTab'} rounded-pill`}>
Todos <span>{total}</span>
</button>
{categories.map((category, index) => (
<button
key={index}
onClick={() => handleCategoryClick(category)}
className={`${selectedCategory === category ? 'activeTab' : 'inactiveTab'} rounded-pill`}
>
{capitalize(category)} <span>{calculateCategoryTotal(category)}</span>
</button>
))}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, poderíamos ter antes uma dropdown com seleção múltipla, mas isto pode ser uma iteração para depois

Copy link
Member

Choose a reason for hiding this comment

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

Acho que pode ser para depois também, Não sei se temos design para esta interação 🤔 podia também ser uma outra issue.

@isabelcosta isabelcosta mentioned this pull request Jul 9, 2024
3 tasks
@isabelcosta isabelcosta dismissed toothlesspanda’s stale review July 13, 2024 09:47

Dismissing this, as we all gathered and reviewed the code together :)

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

Obrigada pela tua contribuição @msantosdevlab !
Muito bom trabalho! 👏🏾 💯 E obrigada @toothlesspanda pela ajuda!

@isabelcosta isabelcosta merged commit b0dfe05 into As-Raparigas-do-Codigo:dev Jul 13, 2024
6 checks passed
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.

Criar filtro na pagina de Atividades
3 participants