2
0

💄 (js) Fix spacings related to avatars

This commit is contained in:
Baptiste Arnaud
2023-03-07 17:11:24 +01:00
parent 2788d58e50
commit b2fa2024a7
15 changed files with 16 additions and 41 deletions

View File

@ -1,12 +1,8 @@
name: Build Docker images name: Build Docker images
on: on:
create:
tags:
- 'v*'
- '!js-v*'
- '!react-v*'
push: push:
tags: ['v*']
branches: [main] branches: [main]
pull_request: pull_request:
branches: [main] branches: [main]

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/js", "name": "@typebot.io/js",
"version": "0.0.20", "version": "0.0.21",
"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

@ -1,4 +1,5 @@
import { BotContext } from '@/types' import { BotContext } from '@/types'
import { isMobile } from '@/utils/isMobileSignal'
import type { ChatReply, Settings, Theme } from 'models' import type { ChatReply, Settings, Theme } from 'models'
import { createSignal, For, onMount, Show } from 'solid-js' import { createSignal, For, onMount, Show } from 'solid-js'
import { HostBubble } from '../bubbles/HostBubble' import { HostBubble } from '../bubbles/HostBubble'
@ -60,8 +61,10 @@ export const ChatChunk = (props: Props) => {
class="flex-1" class="flex-1"
style={{ style={{
'margin-right': props.theme.chat.guestAvatar?.isEnabled 'margin-right': props.theme.chat.guestAvatar?.isEnabled
? '50px' ? isMobile()
: '8px', ? '32px'
: '48px'
: undefined,
}} }}
> >
<For each={props.messages.slice(0, displayedMessageIndex() + 1)}> <For each={props.messages.slice(0, displayedMessageIndex() + 1)}>
@ -81,6 +84,7 @@ export const ChatChunk = (props: Props) => {
inputIndex={props.inputIndex} inputIndex={props.inputIndex}
onSubmit={props.onSubmit} onSubmit={props.onSubmit}
onSkip={props.onSkip} onSkip={props.onSkip}
hasHostAvatar={props.theme.chat.hostAvatar?.isEnabled ?? false}
guestAvatar={props.theme.chat.guestAvatar} guestAvatar={props.theme.chat.guestAvatar}
context={props.context} context={props.context}
isInputPrefillEnabled={ isInputPrefillEnabled={

View File

@ -16,16 +16,7 @@ export const LoadingChunk = (props: Props) => (
hostAvatarSrc={props.theme.chat.hostAvatar?.url} hostAvatarSrc={props.theme.chat.hostAvatar?.url}
/> />
</Show> </Show>
<div <LoadingBubble />
class="flex-1"
style={{
'margin-right': props.theme.chat.guestAvatar?.isEnabled
? '50px'
: '8px',
}}
>
<LoadingBubble />
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -32,6 +32,7 @@ import { PaymentForm } from '@/features/blocks/inputs/payment'
type Props = { type Props = {
block: NonNullable<ChatReply['input']> block: NonNullable<ChatReply['input']>
hasHostAvatar: boolean
guestAvatar?: Theme['chat']['guestAvatar'] guestAvatar?: Theme['chat']['guestAvatar']
inputIndex: number inputIndex: number
context: BotContext context: BotContext
@ -66,7 +67,7 @@ export const InputChatBlock = (props: Props) => {
</Match> </Match>
<Match when={isNotDefined(answer())}> <Match when={isNotDefined(answer())}>
<div class="flex justify-end animate-fade-in"> <div class="flex justify-end animate-fade-in">
{props.guestAvatar?.isEnabled && ( {props.hasHostAvatar && (
<div <div
class={ class={
'flex mr-2 mb-2 mt-1 flex-shrink-0 items-center ' + 'flex mr-2 mb-2 mt-1 flex-shrink-0 items-center ' +
@ -81,7 +82,6 @@ export const InputChatBlock = (props: Props) => {
isInputPrefillEnabled={props.isInputPrefillEnabled} isInputPrefillEnabled={props.isInputPrefillEnabled}
onSubmit={handleSubmit} onSubmit={handleSubmit}
onSkip={handleSkip} onSkip={handleSkip}
hasGuestAvatar={props.guestAvatar?.isEnabled ?? false}
/> />
</div> </div>
</Match> </Match>
@ -93,7 +93,6 @@ const Input = (props: {
context: BotContext context: BotContext
block: NonNullable<ChatReply['input']> block: NonNullable<ChatReply['input']>
inputIndex: number inputIndex: number
hasGuestAvatar: boolean
isInputPrefillEnabled: boolean isInputPrefillEnabled: boolean
onSubmit: (answer: InputSubmitContent) => void onSubmit: (answer: InputSubmitContent) => void
onSkip: (label: string) => void onSkip: (label: string) => void
@ -117,7 +116,6 @@ const Input = (props: {
block={props.block as TextInputBlock} block={props.block as TextInputBlock}
defaultValue={getPrefilledValue()} defaultValue={getPrefilledValue()}
onSubmit={onSubmit} onSubmit={onSubmit}
hasGuestAvatar={props.hasGuestAvatar}
/> />
</Match> </Match>
<Match when={props.block.type === InputBlockType.NUMBER}> <Match when={props.block.type === InputBlockType.NUMBER}>
@ -125,7 +123,6 @@ const Input = (props: {
block={props.block as NumberInputBlock} block={props.block as NumberInputBlock}
defaultValue={getPrefilledValue()} defaultValue={getPrefilledValue()}
onSubmit={onSubmit} onSubmit={onSubmit}
hasGuestAvatar={props.hasGuestAvatar}
/> />
</Match> </Match>
<Match when={props.block.type === InputBlockType.EMAIL}> <Match when={props.block.type === InputBlockType.EMAIL}>
@ -133,7 +130,6 @@ const Input = (props: {
block={props.block as EmailInputBlock} block={props.block as EmailInputBlock}
defaultValue={getPrefilledValue()} defaultValue={getPrefilledValue()}
onSubmit={onSubmit} onSubmit={onSubmit}
hasGuestAvatar={props.hasGuestAvatar}
/> />
</Match> </Match>
<Match when={props.block.type === InputBlockType.URL}> <Match when={props.block.type === InputBlockType.URL}>
@ -141,7 +137,6 @@ const Input = (props: {
block={props.block as UrlInputBlock} block={props.block as UrlInputBlock}
defaultValue={getPrefilledValue()} defaultValue={getPrefilledValue()}
onSubmit={onSubmit} onSubmit={onSubmit}
hasGuestAvatar={props.hasGuestAvatar}
/> />
</Match> </Match>
<Match when={props.block.type === InputBlockType.PHONE}> <Match when={props.block.type === InputBlockType.PHONE}>
@ -152,7 +147,6 @@ const Input = (props: {
} }
defaultValue={getPrefilledValue()} defaultValue={getPrefilledValue()}
onSubmit={onSubmit} onSubmit={onSubmit}
hasGuestAvatar={props.hasGuestAvatar}
/> />
</Match> </Match>
<Match when={props.block.type === InputBlockType.DATE}> <Match when={props.block.type === InputBlockType.DATE}>

View File

@ -30,7 +30,7 @@ export const AudioBubble = (props: Props) => {
return ( return (
<div class="flex flex-col animate-fade-in"> <div class="flex flex-col animate-fade-in">
<div class="flex mb-2 w-full lg:w-11/12 items-center"> <div class="flex mb-2 w-full items-center">
<div class={'flex relative z-10 items-start typebot-host-bubble'}> <div class={'flex relative z-10 items-start typebot-host-bubble'}>
<div <div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 " class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "

View File

@ -29,7 +29,7 @@ export const EmbedBubble = (props: Props) => {
return ( return (
<div class="flex flex-col w-full animate-fade-in"> <div class="flex flex-col w-full animate-fade-in">
<div class="flex mb-2 w-full lg:w-11/12 items-center"> <div class="flex mb-2 w-full items-center">
<div <div
class={'flex relative z-10 items-start typebot-host-bubble w-full'} class={'flex relative z-10 items-start typebot-host-bubble w-full'}
> >

View File

@ -40,7 +40,7 @@ export const ImageBubble = (props: Props) => {
return ( return (
<div class="flex flex-col animate-fade-in"> <div class="flex flex-col animate-fade-in">
<div class="flex mb-2 w-full lg:w-11/12 items-center"> <div class="flex mb-2 w-full items-center">
<div class={'flex relative z-10 items-start typebot-host-bubble'}> <div class={'flex relative z-10 items-start typebot-host-bubble'}>
<div <div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 " class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "

View File

@ -33,7 +33,7 @@ export const VideoBubble = (props: Props) => {
return ( return (
<div class="flex flex-col animate-fade-in"> <div class="flex flex-col animate-fade-in">
<div class="flex mb-2 w-full lg:w-11/12 items-center"> <div class="flex mb-2 w-full items-center">
<div class={'flex relative z-10 items-start typebot-host-bubble'}> <div class={'flex relative z-10 items-start typebot-host-bubble'}>
<div <div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 " class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "

View File

@ -8,7 +8,6 @@ import { createSignal, onMount } from 'solid-js'
type Props = { type Props = {
block: EmailInputBlock block: EmailInputBlock
defaultValue?: string defaultValue?: string
hasGuestAvatar: boolean
onSubmit: (value: InputSubmitContent) => void onSubmit: (value: InputSubmitContent) => void
} }
@ -40,7 +39,6 @@ export const EmailInput = (props: Props) => {
} }
data-testid="input" data-testid="input"
style={{ style={{
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px', 'max-width': '350px',
}} }}
onKeyDown={submitWhenEnter} onKeyDown={submitWhenEnter}

View File

@ -9,7 +9,6 @@ type NumberInputProps = {
block: NumberInputBlock block: NumberInputBlock
defaultValue?: string defaultValue?: string
onSubmit: (value: InputSubmitContent) => void onSubmit: (value: InputSubmitContent) => void
hasGuestAvatar: boolean
} }
export const NumberInput = (props: NumberInputProps) => { export const NumberInput = (props: NumberInputProps) => {
@ -40,7 +39,6 @@ export const NumberInput = (props: NumberInputProps) => {
} }
data-testid="input" data-testid="input"
style={{ style={{
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px', 'max-width': '350px',
}} }}
onKeyDown={submitWhenEnter} onKeyDown={submitWhenEnter}

View File

@ -13,7 +13,6 @@ type PhoneInputProps = Pick<
> & { > & {
defaultValue?: string defaultValue?: string
onSubmit: (value: InputSubmitContent) => void onSubmit: (value: InputSubmitContent) => void
hasGuestAvatar: boolean
} }
export const PhoneInput = (props: PhoneInputProps) => { export const PhoneInput = (props: PhoneInputProps) => {
@ -88,7 +87,6 @@ export const PhoneInput = (props: PhoneInputProps) => {
class={'flex items-end justify-between rounded-lg pr-2 typebot-input'} class={'flex items-end justify-between rounded-lg pr-2 typebot-input'}
data-testid="input" data-testid="input"
style={{ style={{
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '400px', 'max-width': '400px',
}} }}
onKeyDown={submitWhenEnter} onKeyDown={submitWhenEnter}

View File

@ -8,7 +8,6 @@ import { createSignal, onMount } from 'solid-js'
type Props = { type Props = {
block: TextInputBlock block: TextInputBlock
defaultValue?: string defaultValue?: string
hasGuestAvatar: boolean
onSubmit: (value: InputSubmitContent) => void onSubmit: (value: InputSubmitContent) => void
} }
@ -41,7 +40,6 @@ export const TextInput = (props: Props) => {
} }
data-testid="input" data-testid="input"
style={{ style={{
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': props.block.options.isLong ? undefined : '350px', 'max-width': props.block.options.isLong ? undefined : '350px',
}} }}
onKeyDown={submitWhenEnter} onKeyDown={submitWhenEnter}

View File

@ -9,7 +9,6 @@ type Props = {
block: UrlInputBlock block: UrlInputBlock
defaultValue?: string defaultValue?: string
onSubmit: (value: InputSubmitContent) => void onSubmit: (value: InputSubmitContent) => void
hasGuestAvatar: boolean
} }
export const UrlInput = (props: Props) => { export const UrlInput = (props: Props) => {
@ -46,7 +45,6 @@ export const UrlInput = (props: Props) => {
} }
data-testid="input" data-testid="input"
style={{ style={{
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px', 'max-width': '350px',
}} }}
onKeyDown={submitWhenEnter} onKeyDown={submitWhenEnter}

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/react", "name": "@typebot.io/react",
"version": "0.0.20", "version": "0.0.21",
"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",