2
0

💄 (js) Improve popup ui consistency

This commit is contained in:
Baptiste Arnaud
2023-05-23 18:01:49 +02:00
parent 423aca6133
commit c950406997
4 changed files with 34 additions and 9 deletions

View File

@@ -7,7 +7,18 @@ Head over to the Share tab of your bot and click on the Webflow button to get th
### Trigger a typebot command on a click of a button ### Trigger a typebot command on a click of a button
1. Head over to the `Settings` tab of your button and add a dedicated `ID` 1. Head over to the `Settings` tab of your button and add a dedicated `ID`
2. In your typebot `Embed` element, insert this code in the existing `<script>` tag. It should look like: 2. In your typebot `Embed` element, insert this code in the existing `<script>` tag:
```js
document.getElementById('BUTTON_ID').addEventListener('click', (event) => {
event.preventDefault()
Typebot.open()
})
```
You can add as many as you'd like if you need to open the bot on several button clicks
It should look like:
```html ```html
<script type="module"> <script type="module">
@@ -17,13 +28,18 @@ Head over to the Share tab of your bot and click on the Webflow button to get th
typebot: 'my-typebot', typebot: 'my-typebot',
}) })
document.getElementById('<MY_ID>').addEventListener('click', (event) => { document.getElementById('BUTTON_ID_1').addEventListener('click', (event) => {
event.preventDefault()
Typebot.open()
})
document.getElementById('BUTTON_ID_2').addEventListener('click', (event) => {
event.preventDefault() event.preventDefault()
Typebot.open() Typebot.open()
}) })
</script> </script>
``` ```
Make sure to replace `<MY_ID>` with the ID you added on your button element. Make sure to replace `BUTTON_ID_1` and `BUTTON_ID_2` with the ID you added on your button elements.
In this example we are opening the popup when the button is clicked but you could also use any of the [available commands](./commands). In this example we are opening the popup when the specified buttons are clicked but you could also use any of the [available commands](./commands).

View File

@@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/js", "name": "@typebot.io/js",
"version": "0.0.53", "version": "0.0.54",
"description": "Javascript library to display typebots on your website", "description": "Javascript library to display typebots on your website",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@@ -107,17 +107,26 @@ export const Popup = (props: PopupProps) => {
<Show when={isBotOpened()}> <Show when={isBotOpened()}>
<style>{styles}</style> <style>{styles}</style>
<div <div
class="relative z-10" class="relative"
aria-labelledby="modal-title" aria-labelledby="modal-title"
role="dialog" role="dialog"
aria-modal="true" aria-modal="true"
style={{
'z-index': 42424242,
}}
> >
<style>{styles}</style> <style>{styles}</style>
<div class="fixed inset-0 bg-black bg-opacity-50 transition-opacity animate-fade-in" /> <div
class="fixed inset-0 bg-black bg-opacity-50 transition-opacity animate-fade-in"
part="overlay"
/>
<div class="fixed inset-0 z-10 overflow-y-auto"> <div class="fixed inset-0 z-10 overflow-y-auto">
<div class="flex min-h-full items-center justify-center p-4 text-center sm:p-0"> <div class="flex min-h-full items-center justify-center p-4 text-center sm:p-0">
<div <div
class="relative h-[80vh] transform overflow-hidden rounded-lg text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg" class={
'relative h-[80vh] transform overflow-hidden rounded-lg text-left transition-all sm:my-8 sm:w-full sm:max-w-lg' +
(props.theme?.backgroundColor ? ' shadow-xl' : '')
}
style={{ style={{
'background-color': 'background-color':
props.theme?.backgroundColor ?? 'transparent', props.theme?.backgroundColor ?? 'transparent',

View File

@@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/react", "name": "@typebot.io/react",
"version": "0.0.53", "version": "0.0.54",
"description": "React library to display typebots on your website", "description": "React library to display typebots on your website",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",