hexabot/widget/public/index.html
2024-10-12 10:27:05 +01:00

45 lines
1.3 KiB
HTML

<!DOCTYPE html>
<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>
// Create the shadow root and attach it to the widget container
const createElement = (tag, props = {}) => Object.assign(document.createElement(tag), props);
const shadowContainer = createElement("div");
document
.getElementById('hb-chat-widget')
.attachShadow({ mode: 'open' })
.append(
shadowContainer,
createElement("link", {
rel: "stylesheet",
href: "./style.css"
})
);
ReactDOM.render(
React.createElement(HexabotWidget, {
apiUrl: 'http://localhost:4000',
channel: 'offline',
token: 'token123',
}),
shadowContainer,
);
</script>
</body>
</html>