-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implementation of filters on the Activities page #212
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/pages/Activities/index.js
Outdated
<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> |
There was a problem hiding this comment.
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?
src/pages/Activities/activities.scss
Outdated
|
||
.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; | ||
} |
There was a problem hiding this comment.
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
src/pages/Activities/index.js
Outdated
@@ -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))); |
There was a problem hiding this comment.
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?
src/pages/Activities/index.js
Outdated
<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> | ||
))} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Dismissing this, as we all gathered and reviewed the code together :)
There was a problem hiding this 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!
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: