Skip to content

Instantly share code, notes, and snippets.

@perjo927
Created September 8, 2020 16:07
Show Gist options
  • Save perjo927/0571c88434f4e8c753aec86615fc2e6b to your computer and use it in GitHub Desktop.
Save perjo927/0571c88434f4e8c753aec86615fc2e6b to your computer and use it in GitHub Desktop.
List Manager Template
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