♻️ (lp) Remove old bot-engine from landing page
This commit is contained in:
@ -11,26 +11,27 @@ const hostElementCss = `
|
||||
}
|
||||
`
|
||||
|
||||
export const Standard = (props: BotProps) => {
|
||||
export const Standard = (
|
||||
props: BotProps,
|
||||
{ element }: { element: HTMLElement }
|
||||
) => {
|
||||
const [isBotDisplayed, setIsBotDisplayed] = createSignal(false)
|
||||
|
||||
const launchBot = () => {
|
||||
setIsBotDisplayed(true)
|
||||
}
|
||||
|
||||
const observer = new IntersectionObserver((intersections) => {
|
||||
const botLauncherObserver = new IntersectionObserver((intersections) => {
|
||||
if (intersections.some((intersection) => intersection.isIntersecting))
|
||||
launchBot()
|
||||
})
|
||||
|
||||
onMount(() => {
|
||||
const standardElement = document.querySelector('typebot-standard')
|
||||
if (!standardElement) return
|
||||
observer.observe(standardElement)
|
||||
botLauncherObserver.observe(element)
|
||||
})
|
||||
|
||||
onCleanup(() => {
|
||||
observer.disconnect()
|
||||
botLauncherObserver.disconnect()
|
||||
})
|
||||
|
||||
return (
|
||||
|
@ -10,6 +10,7 @@ import { Standard } from './features/standard'
|
||||
|
||||
export const registerWebComponents = () => {
|
||||
if (typeof window === 'undefined') return
|
||||
// @ts-expect-error element incorect type
|
||||
customElement('typebot-standard', defaultBotProps, Standard)
|
||||
customElement('typebot-bubble', defaultBubbleProps, Bubble)
|
||||
customElement('typebot-popup', defaultPopupProps, Popup)
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable solid/reactivity */
|
||||
import { BubbleProps } from './features/bubble'
|
||||
import { PopupProps } from './features/popup'
|
||||
import { BotProps } from './components/Bot'
|
||||
@ -10,10 +11,10 @@ import {
|
||||
toggle,
|
||||
} from './features/commands'
|
||||
|
||||
export const initStandard = (
|
||||
props: BotProps & { style?: string; class?: string }
|
||||
) => {
|
||||
const standardElement = document.querySelector('typebot-standard')
|
||||
export const initStandard = (props: BotProps & { id?: string }) => {
|
||||
const standardElement = props.id
|
||||
? document.getElementById(props.id)
|
||||
: document.querySelector('typebot-standard')
|
||||
if (!standardElement) throw new Error('<typebot-standard> element not found.')
|
||||
Object.assign(standardElement, props)
|
||||
}
|
||||
|
Reference in New Issue
Block a user