Skip to content

Commit

Permalink
⚡ (video) Allow changing video height when resolved to an iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Oct 12, 2023
1 parent e071c81 commit ee685f1
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Stack, Text } from '@chakra-ui/react'
import { VideoBubbleContent } from '@typebot.io/schemas'
import { TextInput } from '@/components/inputs'
import {
VariableString,
VideoBubbleContent,
VideoBubbleContentType,
} from '@typebot.io/schemas'
import { NumberInput, TextInput } from '@/components/inputs'
import { useScopedI18n } from '@/locales'
import { parseVideoUrl } from '@typebot.io/lib/parseVideoUrl'

Expand All @@ -11,24 +15,42 @@ type Props = {

export const VideoUploadContent = ({ content, onSubmit }: Props) => {
const scopedT = useScopedI18n('editor.blocks.bubbles.video.settings')
const handleUrlChange = (url: string) => {
const updateUrl = (url: string) => {
const info = parseVideoUrl(url)
return onSubmit({
type: info.type,
url,
id: info.id,
})
}
const updateHeight = (height?: number | VariableString) => {
return onSubmit({
...content,
height,
})
}
return (
<Stack p="2">
<TextInput
placeholder={scopedT('worksWith.placeholder')}
defaultValue={content?.url ?? ''}
onChange={handleUrlChange}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
{scopedT('worksWith.text')}
</Text>
<Stack p="2" spacing={4}>
<Stack>
<TextInput
placeholder={scopedT('worksWith.placeholder')}
defaultValue={content?.url ?? ''}
onChange={updateUrl}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
{scopedT('worksWith.text')}
</Text>
</Stack>

{content?.type !== VideoBubbleContentType.URL && (
<NumberInput
label="Height:"
defaultValue={content?.height ?? 400}
onValueChange={updateHeight}
suffix={scopedT('numberInput.unit')}
width="150px"
/>
)}
</Stack>
)
}
1 change: 1 addition & 0 deletions apps/builder/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export default {
'Funktioniert mit YouTube, Vimeo und anderen',
'editor.blocks.bubbles.video.settings.worksWith.placeholder':
'Füge den Videolink ein...',
'editor.blocks.bubbles.video.settings.numberInput.unit': 'px',
'editor.blocks.bubbles.textEditor.plate.label': 'Texteditor',
'editor.blocks.bubbles.textEditor.searchVariable.placeholder':
'Nach einer Variable suchen',
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export default {
'Works with Youtube, Vimeo and others',
'editor.blocks.bubbles.video.settings.worksWith.placeholder':
'Paste the video link...',
'editor.blocks.bubbles.video.settings.numberInput.unit': 'px',
'editor.blocks.bubbles.textEditor.plate.label': 'Text editor',
'editor.blocks.bubbles.textEditor.searchVariable.placeholder':
'Search for a variable',
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export default {
'Fonctionne avec Youtube, Vimeo et autres',
'editor.blocks.bubbles.video.settings.worksWith.placeholder':
'Collez le lien de la vidéo...',
'editor.blocks.bubbles.video.settings.numberInput.unit': 'px',
'editor.blocks.bubbles.textEditor.plate.label': 'Éditeur de texte',
'editor.blocks.bubbles.textEditor.searchVariable.placeholder':
'Rechercher une variable',
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export default {
'Compatível com Youtube, Vimeo e outros',
'editor.blocks.bubbles.video.settings.worksWith.placeholder':
'Colar o link do vídeo...',
'editor.blocks.bubbles.video.settings.numberInput.unit': 'px',
'editor.blocks.bubbles.textEditor.plate.label': 'Editor de texto',
'editor.blocks.bubbles.textEditor.searchVariable.placeholder':
'Pesquisar uma variável',
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export default {
'Compatível com Youtube, Vimeo e outros',
'editor.blocks.bubbles.video.settings.worksWith.placeholder':
'Colar o link do vídeo...',
'editor.blocks.bubbles.video.settings.numberInput.unit': 'px',
'editor.blocks.bubbles.textEditor.plate.label': 'Editor de texto',
'editor.blocks.bubbles.textEditor.searchVariable.placeholder':
'Pesquisar uma variável',
Expand Down
8 changes: 7 additions & 1 deletion packages/bot-engine/parseBubbleBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ export const parseBubbleBlock = (
const parsedContent = deepParseVariables(variables)(block.content)
return {
...block,
content: parsedContent.url ? parseVideoUrl(parsedContent.url) : {},
content: {
...(parsedContent.url ? parseVideoUrl(parsedContent.url) : {}),
height:
typeof parsedContent.height === 'string'
? parseFloat(parsedContent.height)
: parsedContent.height,
},
}
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const VideoBubble = (props: Props) => {
})

return (
<div class="flex flex-col animate-fade-in" ref={ref}>
<div class="flex flex-col w-full animate-fade-in" ref={ref}>
<div class="flex w-full items-center">
<div class="flex relative z-10 items-start typebot-host-bubble overflow-hidden">
<div class="flex relative z-10 items-start typebot-host-bubble overflow-hidden w-full">
<div
class="flex items-center absolute px-4 py-2 bubble-typing z-10 "
style={{
Expand Down Expand Up @@ -86,7 +86,11 @@ export const VideoBubble = (props: Props) => {
isTyping() ? 'opacity-0' : 'opacity-100 p-4'
)}
style={{
height: isTyping() ? (isMobile() ? '32px' : '36px') : '200px',
height: isTyping()
? isMobile()
? '32px'
: '36px'
: `${props.content.height ?? '400'}px`,
}}
>
<iframe
Expand Down
2 changes: 2 additions & 0 deletions packages/schemas/features/blocks/bubbles/video/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { z } from 'zod'
import { blockBaseSchema } from '../../baseSchemas'
import { BubbleBlockType } from '../enums'
import { VideoBubbleContentType } from './enums'
import { variableStringSchema } from '../../../utils'

export const videoBubbleContentSchema = z.object({
url: z.string().optional(),
id: z.string().optional(),
type: z.nativeEnum(VideoBubbleContentType).optional(),
height: z.number().or(variableStringSchema).optional(),
})

export const videoBubbleBlockSchema = blockBaseSchema.merge(
Expand Down

4 comments on commit ee685f1

@vercel
Copy link

@vercel vercel bot commented on ee685f1 Oct 12, 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

app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.mail2wa.me
bot.rslabs.pro
bot.share5.net
bots.bng.tools
bots.bridge.ai
chad.gocto.com
chat.hayuri.id
chat.uprize.hu
chicken.cr8.ai
demo.bot.gives
seletiva-bbb24.com
speciallife.com.br
sub.yolozeeeer.com
survey.digienge.io
tribe.ezbooking.ai
w.onewebcenter.com
zap.techadviser.in
zero-pendencia.com
ai.convobuilder.com
ai.digitaldaftar.in
al.onewebcenter.com
app.danielnalex.com
ask.realversity.org
blazecontrol.com.br
bot.boston-voip.com
bot.cabinpromos.com
bot.carnaval.studio
bot.digitalbled.com
bot.dsignagency.com
bot.enthrallart.com
bot.eventhub.com.au
bot.febredojogo.com
bot.gravityatoms.in
bot.jepierre.com.br
bot.jogodoandre.com
bot.jogomoderno.com
bot.leadgenpod.site
bot.ltmidias.com.br
bot.viralsangat.com
bot.winglabs.com.br
bt.scadiagro.com.br
capitaldigital.live
carsalesenquiry.com
casahackeada.online
chat.jubahkonvo.com
chat.marius.digital
chat.mosdent.com.tr
chat.rahsiakami.com
chat.sr7digital.com
chatbot.matthesv.de
chatbot.repplai.com
chatwebandreia.site
co.onewebcenter.com
cr.onewebcenter.com
danielmentality.com
demo.botscientis.us
demo.wemakebots.xyz
feiralimpanomes.com
go.onewebcenter.com
viewer-v2-typebot-io.vercel.app
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.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 ee685f1 Oct 12, 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 ee685f1 Oct 12, 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

@vercel
Copy link

@vercel vercel bot commented on ee685f1 Oct 12, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.