Skip to content

Commit

Permalink
🐛 (embed) Fix custom close icon placement in bubble button
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 31, 2023
1 parent f8af76d commit 81c2e50
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 52 deletions.
3 changes: 2 additions & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.1.11",
"version": "0.1.12",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down Expand Up @@ -29,6 +29,7 @@
"@typebot.io/tsconfig": "workspace:*",
"autoprefixer": "10.4.14",
"babel-preset-solid": "1.7.7",
"clsx": "2.0.0",
"eslint": "8.44.0",
"eslint-config-custom": "workspace:*",
"eslint-plugin-solid": "0.12.1",
Expand Down
95 changes: 46 additions & 49 deletions packages/embeds/js/src/features/bubble/components/BubbleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Show } from 'solid-js'
import { isNotDefined, isSvgSrc } from '@typebot.io/lib'
import { BubbleTheme, ButtonTheme } from '../types'
import { isLight } from '@typebot.io/lib/hexToRgb'
import { clsx } from 'clsx'

type Props = Pick<BubbleTheme, 'placement'> &
ButtonTheme & {
Expand All @@ -20,11 +21,11 @@ export const BubbleButton = (props: Props) => (
<button
part="button"
onClick={() => props.toggleBot()}
class={
'fixed bottom-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') +
(props.placement === 'left' ? ' left-5' : ' right-5')
}
class={clsx(
'fixed bottom-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',
props.placement === 'left' ? ' left-5' : ' right-5'
)}
style={{
'background-color': props.backgroundColor ?? defaultButtonColor,
'z-index': 42424242,
Expand All @@ -40,11 +41,11 @@ export const BubbleButton = (props: Props) => (
? defaultDarkIconColor
: defaultLightIconColor),
}}
class={
`stroke-2 fill-transparent absolute duration-200 transition ` +
(props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100') +
(props.size === 'large' ? ' w-9' : ' w-7')
}
class={clsx(
'stroke-2 fill-transparent absolute duration-200 transition',
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" />
</svg>
Expand All @@ -53,27 +54,25 @@ export const BubbleButton = (props: Props) => (
<img
part="button-icon"
src={props.customIconSrc}
class={
'duration-200 transition' +
(props.isBotOpened
? ' scale-0 opacity-0'
: ' scale-100 opacity-100') +
(isSvgSrc(props.customIconSrc)
class={clsx(
'duration-200 transition',
props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100',
isSvgSrc(props.customIconSrc)
? props.size === 'large'
? ' w-9 h-9'
: ' w-7 h-7'
: ' w-[90%] h-[90%]') +
(isSvgSrc(props.customIconSrc) ? '' : ' object-cover rounded-full')
}
? 'w-9 h-9'
: 'w-7 h-7'
: 'w-[90%] h-[90%]',
isSvgSrc(props.customIconSrc) ? '' : 'object-cover rounded-full'
)}
alt="Bubble button icon"
/>
</Show>
<Show when={props.customIconSrc && !isImageSrc(props.customIconSrc)}>
<span
class={
'text-4xl duration-200 transition' +
(props.isBotOpened ? ' scale-0 opacity-0' : ' scale-100 opacity-100')
}
class={clsx(
'text-4xl duration-200 transition',
props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100'
)}
style={{
'font-family':
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",
Expand All @@ -92,13 +91,13 @@ export const BubbleButton = (props: Props) => (
? defaultDarkIconColor
: defaultLightIconColor),
}}
class={
`absolute duration-200 transition ` +
(props.isBotOpened
class={clsx(
'absolute duration-200 transition',
props.isBotOpened
? 'scale-100 rotate-0 opacity-100'
: 'scale-0 -rotate-180 opacity-0') +
(props.size === 'large' ? ' w-9' : ' w-7')
}
: 'scale-0 -rotate-180 opacity-0',
props.size === 'large' ? ' w-9' : ' w-7'
)}
>
<path
fill-rule="evenodd"
Expand All @@ -113,33 +112,31 @@ export const BubbleButton = (props: Props) => (
<img
part="button-icon"
src={props.customCloseIconSrc}
class={
'duration-200 transition' +
(props.isBotOpened
class={clsx(
'absolute duration-200 transition',
props.isBotOpened
? 'scale-100 rotate-0 opacity-100'
: 'scale-0 -rotate-180 opacity-0') +
(isSvgSrc(props.customCloseIconSrc)
: 'scale-0 -rotate-180 opacity-0',
isSvgSrc(props.customCloseIconSrc)
? props.size === 'large'
? ' w-9 h-9'
: ' w-7 h-7'
: ' w-[90%] h-[90%]') +
(isSvgSrc(props.customCloseIconSrc)
? ''
: ' object-cover rounded-full')
}
alt="Bubble button clost icon"
? 'w-9 h-9'
: 'w-7 h-7'
: 'w-[90%] h-[90%]',
isSvgSrc(props.customCloseIconSrc) ? '' : 'object-cover rounded-full'
)}
alt="Bubble button close icon"
/>
</Show>
<Show
when={props.customCloseIconSrc && !isImageSrc(props.customCloseIconSrc)}
>
<span
class={
'text-4xl duration-200 transition' +
(props.isBotOpened
class={clsx(
'absolute text-4xl duration-200 transition',
props.isBotOpened
? 'scale-100 rotate-0 opacity-100'
: 'scale-0 -rotate-180 opacity-0')
}
: 'scale-0 -rotate-180 opacity-0'
)}
style={{
'font-family':
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.1.11",
"version": "0.1.12",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.1.11",
"version": "0.1.12",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 comments on commit 81c2e50

@vercel
Copy link

@vercel vercel bot commented on 81c2e50 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 81c2e50 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 81c2e50 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

silvercop.com.br
silvercop.online
stan.vselise.com
typebot.aloe.bot
vidalimentar.com
capitaldigital.live
carsalesenquiry.com
casahackeada.online
chat.marius.digital
chat.sr7digital.com
chatbot.matthesv.de
chatbot.repplai.com
chatwebandreia.site
demo.botscientis.us
demo.wemakebots.xyz
feiralimpanomes.com
hrbot.robomotion.io
inearephones.cr8.ai
kbsub.wpwakanda.com
limitenahora.com.br
live.botscientis.us
mentoria.omelhor.vc
messengerbet.online
noticiariododia.com
nutrisamirbayde.com
online.onlinmey.com
order.maitempah.com
profileadscloud.com
query.forgetsql.com
quest.wpwakanda.com
secretespiao.online
start.belenmotz.com
support.wawplus.com
survey1.digienge.io
surveys.essiell.com
test.botscientis.us
test.getreview.help
test.reventepro.com
typebot.stillio.app
typebot.stillio.com
wa.onewebcenter.com
web.draleticiah.com
whatsdigital.online
wordsandimagery.com
88584434.therpm.club
92109660.therpm.club
abbonamento.bwell.it
app.horadelucrar.com
assistent.m-vogel.de
ativandograna.online
bium.gratirabbit.com
bot.ansuraniphone.my
bot.barrettamario.it
bot.cotemeuplano.com
bot.grupodojo.com.br
viewer-v2-typebot-io.vercel.app
download.thailandmicespecialist.com
mdb.assessoria.aloisio.progenbr.com
mdb.assessoria.girotto.progenbr.com
mdb.assessoria.marinho.progenbr.com
mdb.assessoria.rodrigo.progenbr.com
register.thailandmicespecialist.com
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com

@vercel
Copy link

@vercel vercel bot commented on 81c2e50 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.