@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.31",
|
"version": "0.0.32",
|
||||||
"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",
|
||||||
|
@ -122,6 +122,7 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
<PreviewMessage
|
<PreviewMessage
|
||||||
{...previewMessage()}
|
{...previewMessage()}
|
||||||
previewMessageTheme={bubbleProps.theme?.previewMessage}
|
previewMessageTheme={bubbleProps.theme?.previewMessage}
|
||||||
|
buttonSize={bubbleProps.theme?.button?.size}
|
||||||
onClick={handlePreviewMessageClick}
|
onClick={handlePreviewMessageClick}
|
||||||
onCloseClick={hideMessage}
|
onCloseClick={hideMessage}
|
||||||
/>
|
/>
|
||||||
@ -132,6 +133,7 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
isBotOpened={isBotOpened()}
|
isBotOpened={isBotOpened()}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
part="bot"
|
||||||
style={{
|
style={{
|
||||||
height: 'calc(100% - 80px)',
|
height: 'calc(100% - 80px)',
|
||||||
transition:
|
transition:
|
||||||
@ -143,8 +145,9 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
'z-index': 42424242,
|
'z-index': 42424242,
|
||||||
}}
|
}}
|
||||||
class={
|
class={
|
||||||
'fixed bottom-20 sm:right-4 rounded-lg w-full sm:w-[400px] max-h-[704px] ' +
|
'fixed sm:right-5 rounded-lg w-full sm:w-[400px] max-h-[704px]' +
|
||||||
(isBotOpened() ? 'opacity-1' : 'opacity-0 pointer-events-none')
|
(isBotOpened() ? ' opacity-1' : ' opacity-0 pointer-events-none') +
|
||||||
|
(props.theme?.button?.size === 'large' ? ' bottom-24' : ' bottom-20')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Show when={isBotStarted()}>
|
<Show when={isBotStarted()}>
|
||||||
|
@ -13,9 +13,11 @@ const defaultIconColor = 'white'
|
|||||||
export const BubbleButton = (props: Props) => {
|
export const BubbleButton = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
part="button"
|
||||||
onClick={() => props.toggleBot()}
|
onClick={() => props.toggleBot()}
|
||||||
class={
|
class={
|
||||||
'fixed bottom-4 right-4 shadow-md w-12 h-12 rounded-full hover:scale-110 active:scale-95 transition-transform duration-200 flex justify-center items-center animate-fade-in'
|
'fixed bottom-5 right-5 shadow-md rounded-full hover:scale-110 active:scale-95 transition-transform duration-200 flex justify-center items-center animate-fade-in' +
|
||||||
|
(props.size === 'large' ? ' w-16 h-16' : ' w-12 h-12')
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
'background-color': props.backgroundColor ?? defaultButtonColor,
|
'background-color': props.backgroundColor ?? defaultButtonColor,
|
||||||
@ -29,8 +31,11 @@ export const BubbleButton = (props: Props) => {
|
|||||||
stroke: props.iconColor ?? defaultIconColor,
|
stroke: props.iconColor ?? defaultIconColor,
|
||||||
}}
|
}}
|
||||||
class={
|
class={
|
||||||
`w-7 stroke-2 fill-transparent absolute duration-200 transition ` +
|
`stroke-2 fill-transparent absolute duration-200 transition ` +
|
||||||
(props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100')
|
(props.isBotOpened
|
||||||
|
? 'scale-0 opacity-0'
|
||||||
|
: 'scale-100 opacity-100') +
|
||||||
|
(props.size === 'large' ? ' w-9' : ' w-7')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />
|
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />
|
||||||
@ -39,7 +44,10 @@ export const BubbleButton = (props: Props) => {
|
|||||||
<Show when={props.customIconSrc}>
|
<Show when={props.customIconSrc}>
|
||||||
<img
|
<img
|
||||||
src={props.customIconSrc}
|
src={props.customIconSrc}
|
||||||
class="w-7 h-7 rounded-full object-cover"
|
class={
|
||||||
|
'rounded-full object-cover' +
|
||||||
|
(props.size === 'large' ? ' w-9 h-9' : ' w-7 h-7')
|
||||||
|
}
|
||||||
alt="Bubble button icon"
|
alt="Bubble button icon"
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
@ -48,10 +56,11 @@ export const BubbleButton = (props: Props) => {
|
|||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
style={{ fill: props.iconColor ?? 'white' }}
|
style={{ fill: props.iconColor ?? 'white' }}
|
||||||
class={
|
class={
|
||||||
`w-7 absolute duration-200 transition ` +
|
`absolute duration-200 transition ` +
|
||||||
(props.isBotOpened
|
(props.isBotOpened
|
||||||
? 'scale-100 rotate-0 opacity-100'
|
? 'scale-100 rotate-0 opacity-100'
|
||||||
: 'scale-0 -rotate-180 opacity-0')
|
: 'scale-0 -rotate-180 opacity-0') +
|
||||||
|
(props.size === 'large' ? ' w-9' : ' w-7')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
import { createSignal, Show } from 'solid-js'
|
import { createSignal, Show } from 'solid-js'
|
||||||
import { PreviewMessageParams, PreviewMessageTheme } from '../types'
|
import {
|
||||||
|
ButtonTheme,
|
||||||
|
PreviewMessageParams,
|
||||||
|
PreviewMessageTheme,
|
||||||
|
} from '../types'
|
||||||
|
|
||||||
export type PreviewMessageProps = Pick<
|
export type PreviewMessageProps = Pick<
|
||||||
PreviewMessageParams,
|
PreviewMessageParams,
|
||||||
'avatarUrl' | 'message'
|
'avatarUrl' | 'message'
|
||||||
> & {
|
> & {
|
||||||
|
buttonSize: ButtonTheme['size']
|
||||||
previewMessageTheme?: PreviewMessageTheme
|
previewMessageTheme?: PreviewMessageTheme
|
||||||
onClick: () => void
|
onClick: () => void
|
||||||
onCloseClick: () => void
|
onCloseClick: () => void
|
||||||
@ -19,8 +24,12 @@ export const PreviewMessage = (props: PreviewMessageProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
part="preview-message"
|
||||||
onClick={() => props.onClick()}
|
onClick={() => props.onClick()}
|
||||||
class="fixed bottom-20 right-4 max-w-[256px] rounded-md duration-200 flex items-center gap-4 shadow-md animate-fade-in cursor-pointer hover:shadow-lg p-4"
|
class={
|
||||||
|
'fixed right-5 max-w-[256px] rounded-md duration-200 flex items-center gap-4 shadow-md animate-fade-in cursor-pointer hover:shadow-lg p-4' +
|
||||||
|
(props.buttonSize === 'large' ? ' bottom-24' : ' bottom-20')
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
'background-color':
|
'background-color':
|
||||||
props.previewMessageTheme?.backgroundColor ?? defaultBackgroundColor,
|
props.previewMessageTheme?.backgroundColor ?? defaultBackgroundColor,
|
||||||
|
@ -14,6 +14,7 @@ export type ChatWindowTheme = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonTheme = {
|
export type ButtonTheme = {
|
||||||
|
size?: 'medium' | 'large'
|
||||||
backgroundColor?: string
|
backgroundColor?: string
|
||||||
iconColor?: string
|
iconColor?: string
|
||||||
customIconSrc?: string
|
customIconSrc?: string
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.31",
|
"version": "0.0.32",
|
||||||
"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",
|
||||||
|
@ -9,7 +9,7 @@ declare global {
|
|||||||
'typebot-bubble': React.DetailedHTMLProps<
|
'typebot-bubble': React.DetailedHTMLProps<
|
||||||
React.HTMLAttributes<HTMLElement>,
|
React.HTMLAttributes<HTMLElement>,
|
||||||
HTMLElement
|
HTMLElement
|
||||||
> & { class?: string }
|
>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
packages/embeds/react/src/stories/assets/index.css
Normal file
1
packages/embeds/react/src/stories/assets/index.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -9,6 +9,7 @@ import {
|
|||||||
} from '@typebot.io/js'
|
} from '@typebot.io/js'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { leadGenerationTypebot } from './assets/leadGenerationTypebot'
|
import { leadGenerationTypebot } from './assets/leadGenerationTypebot'
|
||||||
|
import './assets/index.css'
|
||||||
|
|
||||||
export const Default = () => {
|
export const Default = () => {
|
||||||
const [name, setName] = useState('John')
|
const [name, setName] = useState('John')
|
||||||
@ -47,6 +48,7 @@ export const Default = () => {
|
|||||||
button: {
|
button: {
|
||||||
backgroundColor: '#FF7537',
|
backgroundColor: '#FF7537',
|
||||||
iconColor: 'white',
|
iconColor: 'white',
|
||||||
|
size: 'large',
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
isPreview
|
isPreview
|
||||||
|
Reference in New Issue
Block a user