Skip to content

Commit

Permalink
Add attributes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Jun 14, 2021
1 parent c699ad6 commit 4a13f7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ Add the following to your website to show a button to start the provisioning pro

A warning message will be rendered if the browser does not support WebBluetooth.

### Attributes

The following attributes are automatically added to `<improv-wifi-launch-button>` and can be used for styling:

| Attribute | Description |
| -- | -- |
| `supported` | Added if this browser is supported
| `unsupported` | Added if this browser is not supported

### Slots

It is possible to customize the button and the message. You do this by putting your elements inside the `<improv-wifi-launch-button>` element and adding the appropriate `slot` attribute. Use `activate` to replace the activation button and `unsupported` to replace the unsupported message:

```html
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/launch-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ export class LaunchButton extends HTMLElement {
this.renderRoot = this.attachShadow({ mode: "open" });

if (!LaunchButton.isSupported || !LaunchButton.isAllowed) {
this.toggleAttribute("not-supported", true);
this.renderRoot.innerHTML = !LaunchButton.isSupported
? "<slot name='unsupported'>Your browser does not support bluetooth provisioning. Use Google Chrome or Microsoft Edge.</slot>"
: "<slot name='not-allowed'>You can only use Improv on HTTPS sites or localhost.</slot>";
return;
}

this.toggleAttribute("supported", true);

this.addEventListener("mouseover", () => {
// Preload
import("./provision");
Expand Down

0 comments on commit 4a13f7f

Please sign in to comment.