@spectrum-web-components/action-button
Advanced tools
Comparing version 1.1.0-beta.33 to 1.1.0-beta.34
{ | ||
"name": "@spectrum-web-components/action-button", | ||
"version": "1.1.0-beta.33", | ||
"version": "1.1.0-beta.34", | ||
"publishConfig": { | ||
@@ -61,7 +61,7 @@ "access": "public" | ||
"dependencies": { | ||
"@spectrum-web-components/base": "^1.1.0-beta.33", | ||
"@spectrum-web-components/button": "^1.1.0-beta.33", | ||
"@spectrum-web-components/icon": "^1.1.0-beta.33", | ||
"@spectrum-web-components/icons-ui": "^1.1.0-beta.33", | ||
"@spectrum-web-components/shared": "^1.1.0-beta.33" | ||
"@spectrum-web-components/base": "^1.1.0-beta.34", | ||
"@spectrum-web-components/button": "^1.1.0-beta.34", | ||
"@spectrum-web-components/icon": "^1.1.0-beta.34", | ||
"@spectrum-web-components/icons-ui": "^1.1.0-beta.34", | ||
"@spectrum-web-components/shared": "^1.1.0-beta.34" | ||
}, | ||
@@ -77,3 +77,3 @@ "devDependencies": { | ||
], | ||
"gitHead": "7d68460f58254e9e1978ff91ca38c41871d0145c" | ||
"gitHead": "4fdaaa0f8d63ddae3e820c2eb6d60ccc8fb44a55" | ||
} |
@@ -543,1 +543,23 @@ ## Description | ||
``` | ||
## Handling events | ||
Events handlers for clicks and other user actions can be registered on a | ||
`<sp-action-button>` as on a standard HTML `<button>` element. | ||
```html | ||
<sp-button onclick="spAlert(this, '<sp-action-button> clicked!')"> | ||
Click me | ||
</sp-button> | ||
``` | ||
In addition to handling events like a native `<button>` HTML element, one can also use a `<sp-action-button>` in place of the `<a>` HTML element by using the `href` and optional `target` attribute. | ||
```html | ||
<sp-action-button | ||
href="https://github.com/adobe/spectrum-web-components" | ||
target="_blank" | ||
> | ||
Click me | ||
</sp-action-button> | ||
``` |
@@ -31,2 +31,9 @@ "use strict"; | ||
}; | ||
export const href = (args) => renderButtonsSelected(args); | ||
href.args = { | ||
href: "https://github.com/adobe/spectrum-web-components", | ||
icon: html` | ||
<sp-icon-edit hidden slot="icon"></sp-icon-edit> | ||
` | ||
}; | ||
//# sourceMappingURL=action-button.stories.js.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
<sp-action-button | ||
href=${ifDefined(properties.href)} | ||
?quiet="${!!properties.quiet}" | ||
@@ -13,0 +14,0 @@ ?emphasized="${!!properties.emphasized}" |
@@ -18,2 +18,3 @@ "use strict"; | ||
import { m as BlackActionButton } from "../stories/action-button-black.stories.js"; | ||
import { sendMouse } from "../../../test/plugins/browser.js"; | ||
describe("ActionButton", () => { | ||
@@ -244,3 +245,31 @@ testForLitDevWarnings( | ||
}); | ||
it("allows link click", async () => { | ||
var _a, _b; | ||
let clicked = false; | ||
const el = await fixture(html` | ||
<sp-action-button href="#top" target="_blank"> | ||
With Target | ||
</sp-action-button> | ||
`); | ||
await elementUpdated(el); | ||
(_b = (_a = el.shadowRoot) == null ? void 0 : _a.querySelector(".anchor")) == null ? void 0 : _b.addEventListener("click", (event) => { | ||
event.preventDefault(); | ||
clicked = true; | ||
}); | ||
const rect = el.getBoundingClientRect(); | ||
await sendMouse({ | ||
steps: [ | ||
{ | ||
position: [ | ||
rect.left + rect.width / 2, | ||
rect.top + rect.height / 2 | ||
], | ||
type: "click" | ||
} | ||
] | ||
}); | ||
await elementUpdated(el); | ||
expect(clicked).to.be.true; | ||
}); | ||
}); | ||
//# sourceMappingURL=action-button.test.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
419856
1821
565