Created
October 16, 2021 12:37
-
-
Save n8udd/6841daa7be007fe86216cb4ade7e095c to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
const LevelsFilter = ({ levels, updateQuery, queryParams }) => { | |
function colorClassName(level) { | |
const levelColor = 'bg-' + level.color + '-500 text-grey-600 flex pointer px-3 py-2 text-sm mr-2 mb-2 text-center justify-center hover:bg-opacity-75 font-bold opacity-50'; | |
return levelColor; | |
} | |
return ( | |
<div className="bg-white shadow-md p-6 mb-4 dark:text-white w-full" id="levels"> | |
<div className="mb-2"> | |
<div className="flex"> | |
<h1 className="flex mb-2 text-gray-600">Difficulty:</h1> | |
</div> | |
<div className="flex flex-wrap"> | |
{levels.map(level => ( | |
<button | |
key={level.id} | |
onClick={() => { updateQuery('level', level.name) }} | |
data-id={level.id} | |
className={colorClassName(level)} | |
> | |
{level.name} | |
</button> | |
))} | |
</div> | |
</div> | |
</div> | |
) | |
} | |
export default LevelsFilter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment