hexabot/widget/public/index.html

46 lines
1.3 KiB
HTML
Raw Normal View History

2024-12-03 14:24:31 +00:00
<!doctype html>
2024-09-10 09:50:11 +00:00
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Widget Embed</title>
<script
crossorigin
src="https://unpkg.com/react@18/umd/react.production.min.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
></script>
<link rel="stylesheet" href="./style.css" />
<script src="./hexabot-widget.umd.js"></script>
</head>
<body>
<div id="hb-chat-widget"></div>
<script>
2024-10-12 09:26:14 +00:00
// Create the shadow root and attach it to the widget container
2024-12-03 14:24:31 +00:00
const createElement = (tag, props = {}) =>
Object.assign(document.createElement(tag), props);
2024-10-12 09:26:14 +00:00
const shadowContainer = createElement("div");
document
2024-12-03 14:24:31 +00:00
.getElementById("hb-chat-widget")
.attachShadow({ mode: "open" })
.append(
shadowContainer,
createElement("link", {
rel: "stylesheet",
href: "./style.css",
}),
);
2024-09-10 09:50:11 +00:00
ReactDOM.render(
2024-10-12 09:26:14 +00:00
React.createElement(HexabotWidget, {
2024-12-03 14:24:31 +00:00
apiUrl: "http://localhost:4000",
channel: "web-channel",
token: "token123",
2024-09-10 09:50:11 +00:00
}),
2024-10-12 09:26:14 +00:00
shadowContainer,
2024-09-10 09:50:11 +00:00
);
</script>
</body>
</html>