Skip to content

Commit

Permalink
Replace ESP install component (#618)
Browse files Browse the repository at this point in the history
* Remove the ESP install component code

* Add esp-web-tools NPM package

* Remove esp-web-tools NPM package

* Add js script to Docusaurus

* Refactor component code

* Small refactor on global declare

* Rename the file and component
  • Loading branch information
klaasnicolaas authored Oct 20, 2024
1 parent 98c8188 commit d58ccab
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
4 changes: 2 additions & 2 deletions docs/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'Instruction to get started with the Home Assistant Glow'

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import EspInstallButton from '@site/src/components/EspInstallButton';
import ESPHomeButton from '@site/src/components/ESPWebTools';
import { faUsb } from '@fortawesome/free-brands-svg-icons';

# Get started
Expand Down Expand Up @@ -63,7 +63,7 @@ If your device does not appear in the list, make sure you are using a USB data c
- The Home Assistant Glow is now connected to your network.
6. Congratulations 🎉 You have successfully installed the firmware on your Home Assistant Glow.

<EspInstallButton unsupportedMessage="Provisioning via USB only works in browsers which support Web Serial, such as Chrome or Edge." />
<ESPHomeButton />
</TabItem>
</Tabs>

Expand Down
2 changes: 1 addition & 1 deletion docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const config: Config = {
indexPages: true,
},
]
]
],
};

export default config;
38 changes: 38 additions & 0 deletions docs/src/components/ESPWebTools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Head from "@docusaurus/Head";
import React from "react";
import useBaseUrl from "@docusaurus/useBaseUrl";

/**
* Extend JSX.IntrinsicElements to include the custom element
*/
declare global {
namespace JSX {
interface IntrinsicElements {
"esp-web-install-button": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
> & { manifest: string };
}
}
}

/**
* Load the ESP Web Tools script and handle potential errors during loading
*/
const loadEspWebToolsScript = () => (
<script
type="module"
src="https://unpkg.com/esp-web-tools@10/dist/web/install-button.js?module"
onError={(e) => console.error("Failed to load esp-web-tools script", e)}
/>
);

export default function ESPHomeButton() {
const manifestUrl = useBaseUrl("/home-assistant-glow/manifest.json");
return (
<>
<Head>{loadEspWebToolsScript()}</Head>
<esp-web-install-button manifest={manifestUrl}></esp-web-install-button>
</>
);
}
32 changes: 0 additions & 32 deletions docs/src/components/EspInstallButton.tsx

This file was deleted.

0 comments on commit d58ccab

Please sign in to comment.