@ariabones/button
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -21,9 +21,10 @@ // src/index.ts | ||
this.setAttribute("aria-pressed", pressed ?? "false"); | ||
this.setAttribute("_", ` | ||
on click | ||
if @aria-pressed equals 'true' | ||
set @aria-pressed to 'false' | ||
else | ||
set @aria-pressed to 'true' | ||
`); | ||
this.addEventListener("click", () => { | ||
const ariaPressed = this.getAttribute("aria-pressed") ?? "false"; | ||
if (ariaPressed === "true") { | ||
this.setAttribute("aria-pressed", "false"); | ||
} else { | ||
this.setAttribute("aria-pressed", "true"); | ||
} | ||
}); | ||
} | ||
@@ -30,0 +31,0 @@ if (newValue === "menu") { |
{ | ||
"name": "@ariabones/button", | ||
"type": "module", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "Nicolas Accetta", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -1,1 +0,31 @@ | ||
# @ariabones/button | ||
## toggle | ||
### installation | ||
``` | ||
npm install @ariabones/button | ||
yarn add @ariabones/button | ||
pnpm install @ariabones/button | ||
``` | ||
### usage | ||
```html | ||
<button is="ariabones-button" data-type="toggle" data-pressed="true"> | ||
Toggle button | ||
</button> | ||
``` | ||
### api | ||
| property | type | default | description | | ||
| ------------ | ----------------- | ------- | --------------------------------------------------- | | ||
| data-pressed | "true" or "false" | "false" | used to set up the initial value of aria-pressed | | ||
| aria-pressed | "true" or "false" | "false" | indicates if the button is currently pressed or not | | ||
### keyboard interaction | ||
| key | description | | ||
| ----- | ------------------ | | ||
| Space | toggles the button | | ||
| Enter | toggles the button | |
Sorry, the diff of this file is not supported yet
40211
108
32