Created
September 8, 2020 16:07
-
-
Save perjo927/0571c88434f4e8c753aec86615fc2e6b to your computer and use it in GitHub Desktop.
List Manager Template
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 { html } from "lit-html"; | |
import { CONSTS } from "../redux/actions/index"; | |
const { ALL, DONE, IN_PROGRESS } = CONSTS.visibilityFilters; | |
const filterAll = { filter: ALL, text: "All" }; | |
const filterDone = { filter: DONE, text: "Done" }; | |
const filterInProgress = { | |
filter: IN_PROGRESS, | |
text: "In Progress", | |
}; | |
const Filter = ({ filter, text, selected, onClick }) => { | |
const isFilterSelected = filter === selected; | |
const className = isFilterSelected ? "selected" : ""; | |
return html` | |
<a | |
@click=${() => !isFilterSelected && onClick(filter)} | |
disabled=${isFilterSelected} | |
class=${className} | |
> | |
${text} | |
</a> | |
`; | |
}; | |
export const ListManager = (args) => html` | |
<div class="list-manager"> | |
${Filter({ ...filterAll, ...args })} | |
${Filter({ ...filterInProgress, ...args })} | |
${Filter({ ...filterDone, ...args })} | |
</div> | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment