Skip to content

Commit

Permalink
Add css to buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Rybinski committed Aug 12, 2021
1 parent 5c5ad01 commit 1ff9907
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions mul-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@ import {
html,
component,
useState,
} from "./deps.js";
css,
useCSS,
} from "https://deno.land/x/mulink@0.0.16/deps.js";

function MulButton() {
function MulButton({ disabled }) {
const [name, setName] = useState("Add to Favorites");

useCSS(this, [mulButtonCss]);
return html`
<button type="button" @click=${(ev) => setName("Added, thanks")}>
<button .disabled=${disabled} type="button" @click=${(ev) => setName("Added, thanks")}>
${name}
</button>
<style>
button {
background: yellow;
}
</style>
`;
}

MulButton.observedAttributes = ['disabled']


const mulDisabledButton = css`
button:disabled {
background: grey;
cursor: default;
}
`

const mulDefaultButton = css`
button {
background: orange;
cursor: pointer;
}
`

const mulButtonCss = css`
${mulDefaultButton}
${mulDisabledButton}
`

customElements.define("mul-button", component(MulButton));

0 comments on commit 1ff9907

Please sign in to comment.