diff --git a/README.md b/README.md index 15d8ba9..07a62ba 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The following slots are available: | -- | -- | | `activate` | Button to start the flash progress | `unsupported` | Message to show when the browser is not supported +| `not-allowed` | Message to show when not a secure context ## Events @@ -96,6 +97,7 @@ Field | Description state | The current [state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts) message | A description of the current state manifest | The loaded manifest +build | The manifest's build that was selected chipFamily | The chip that was detected; "ESP32" \| "ESP8266" \| "ESP32-S2" \| "Unknown Chip" details | An optional extra field that is different [per state](https://github.com/esphome/esp-web-tools/blob/main/src/const.ts) diff --git a/index.html b/index.html index 67b8d44..fece0d3 100644 --- a/index.html +++ b/index.html @@ -285,9 +285,9 @@

Replace the button and message with a custom one

You can replace both the activation button and the message that is shown - when the user uses an unsupported browser with your own elements. This - can be done using the activate and - unsupported slots: + when the user uses an unsupported browser or non secure context with + your own elements. This can be done using the activate, + unsupported and not-allowed slots:

 <esp-web-install-button
@@ -297,17 +297,19 @@
 >
   <button slot="activate">Custom install button</button>
   <span slot="unsupported">Ah snap, your browser doesn't work!</span>
+  <span slot="not-allowed">Ah snap, you are not allowed to use this on HTTP!</span>
 </esp-web-install-button>
     

Show or hide the progress bar and log

By default there is a progress bar showing the state and progress of the - flashing progress, you can chnage this progress bar to a log view with + flashing progress, you can change this progress bar to a log view with the show-log attribute.

- You can also hide all progress indicators by adding the `hide-progress` + You can also hide all progress indicators by adding the + hide-progress attribute. This will hide both the progress bar and the log view. You can then implement your own progress elements using the state events. diff --git a/src/flash-progress.ts b/src/flash-progress.ts index 3be47af..4a151b5 100644 --- a/src/flash-progress.ts +++ b/src/flash-progress.ts @@ -69,6 +69,9 @@ export class FlashProgress extends LitElement { color: var(--esp-tools-success-color, #28a745); --mdc-theme-primary: var(--esp-tools-success-color, #28a745); } + mwc-linear-progress { + text-align: left; + } h2 { margin: 16px 0 0; } diff --git a/src/install-button.ts b/src/install-button.ts index 4569c08..595e713 100644 --- a/src/install-button.ts +++ b/src/install-button.ts @@ -3,6 +3,8 @@ import { FlashState } from "./const"; export class InstallButton extends HTMLElement { public static isSupported = "serial" in navigator; + public static isAllowed = window.isSecureContext; + private static style = ` button { position: relative; @@ -80,13 +82,11 @@ export class InstallButton extends HTMLElement { this.renderRoot = this.attachShadow({ mode: "open" }); - if (!InstallButton.isSupported) { + if (!InstallButton.isSupported || !InstallButton.isAllowed) { this.toggleAttribute("install-unsupported", true); - const slot = document.createElement("slot"); - slot.name = "unsupported"; - slot.innerText = - "Your browser does not support installing things on ESP devices. Use Google Chrome or Microsoft Edge."; - this.renderRoot.append(slot); + this.renderRoot.innerHTML = !InstallButton.isSupported + ? "Your browser does not support installing things on ESP devices. Use Google Chrome or Microsoft Edge." + : "You can only install ESP devices on HTTPS websites or on the localhost."; return; }