Skip to content

Commit

Permalink
🚸 Improve support accessibility
Browse files Browse the repository at this point in the history
Add documentation button in board menu and hide the support bubble in the editor. Makes it accessible only by clicking the "Help" button
  • Loading branch information
baptisteArno committed May 15, 2023
1 parent 25dd0cc commit 123926f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 19 deletions.
7 changes: 3 additions & 4 deletions apps/builder/src/components/SupportBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { useUser } from '@/features/account/hooks/useUser'
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
import React from 'react'
import { Bubble } from '@typebot.io/react'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import { planToReadable } from '@/features/billing/helpers/planToReadable'
import { BubbleProps } from '@typebot.io/js'

export const SupportBubble = () => {
export const SupportBubble = (props: Omit<BubbleProps, 'typebot'>) => {
const { typebot } = useTypebot()
const { user } = useUser()
const { workspace } = useWorkspace()

if (!isCloudProdInstance) return null

return (
<Bubble
apiHost="https://viewer.typebot.io"
Expand All @@ -30,6 +28,7 @@ export const SupportBubble = () => {
backgroundColor: '#fff',
},
}}
{...props}
/>
)
}
7 changes: 7 additions & 0 deletions apps/builder/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,10 @@ export const SmileIcon = (props: IconProps) => (
<line x1="15" y1="9" x2="15.01" y2="9"></line>
</Icon>
)

export const BookIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
</Icon>
)
17 changes: 10 additions & 7 deletions apps/builder/src/features/editor/components/BoardMenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@chakra-ui/react'
import assert from 'assert'
import {
BookIcon,
DownloadIcon,
MoreVerticalIcon,
SettingsIcon,
Expand All @@ -31,14 +32,9 @@ export const BoardMenuButton = (props: FlexProps) => {
const { isOpen, onOpen, onClose } = useDisclosure()

useEffect(() => {
if (
user &&
isNotDefined(user.graphNavigation) &&
isNotDefined(query.isFirstBot)
)
if (isNotDefined(user?.graphNavigation) && isNotDefined(query.isFirstBot))
onOpen()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
}, [onOpen, query.isFirstBot, user?.graphNavigation])

const downloadFlow = () => {
assert(typebot)
Expand All @@ -56,6 +52,10 @@ export const BoardMenuButton = (props: FlexProps) => {
linkElement.click()
setIsDownloading(false)
}

const redirectToDocumentation = () =>
window.open('https://docs.typebot.io/get-started/overview', '_blank')

return (
<Flex
bgColor={useColorModeValue('white', 'gray.900')}
Expand All @@ -72,6 +72,9 @@ export const BoardMenuButton = (props: FlexProps) => {
bgColor={useColorModeValue('white', undefined)}
/>
<MenuList>
<MenuItem icon={<BookIcon />} onClick={redirectToDocumentation}>
Documentation
</MenuItem>
<MenuItem icon={<SettingsIcon />} onClick={onOpen}>
Editor settings
</MenuItem>
Expand Down
9 changes: 6 additions & 3 deletions apps/builder/src/features/editor/components/TypebotHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Spinner,
Text,
useColorModeValue,
useDisclosure,
} from '@chakra-ui/react'
import {
BuoyIcon,
Expand All @@ -18,9 +19,7 @@ import { useRouter } from 'next/router'
import React, { useState } from 'react'
import { isDefined, isNotDefined } from '@typebot.io/lib'
import { EditableTypebotName } from './EditableTypebotName'
import { open as openSupportBubble } from '@typebot.io/js'
import Link from 'next/link'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import { EditableEmojiOrImageIcon } from '@/components/EditableEmojiOrImageIcon'
import { useUndoShortcut } from '@/hooks/useUndoShortcut'
import { useDebouncedCallback } from 'use-debounce'
Expand All @@ -29,6 +28,8 @@ import { PublishButton } from '@/features/publish/components/PublishButton'
import { headerHeight } from '../constants'
import { RightPanel, useEditor } from '../providers/EditorProvider'
import { useTypebot } from '../providers/TypebotProvider'
import { SupportBubble } from '@/components/SupportBubble'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'

export const TypebotHeader = () => {
const router = useRouter()
Expand All @@ -49,6 +50,7 @@ export const TypebotHeader = () => {
const hideUndoShortcutTooltipLater = useDebouncedCallback(() => {
setUndoShortcutTooltipOpen(false)
}, 1000)
const { isOpen, onOpen } = useDisclosure()

const handleNameSubmit = (name: string) => updateTypebot({ name })

Expand All @@ -70,7 +72,7 @@ export const TypebotHeader = () => {

const handleHelpClick = () => {
isCloudProdInstance
? openSupportBubble()
? onOpen()
: window.open('https://docs.typebot.io', '_blank')
}

Expand All @@ -86,6 +88,7 @@ export const TypebotHeader = () => {
bgColor={useColorModeValue('white', 'gray.900')}
flexShrink={0}
>
{isOpen && <SupportBubble autoShowDelay={0} />}
<HStack
display={['none', 'flex']}
pos={{ base: 'absolute', xl: 'static' }}
Expand Down
5 changes: 4 additions & 1 deletion apps/builder/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { NewVersionPopup } from '@/components/NewVersionPopup'
import { I18nProvider } from '@/locales'
import { TypebotProvider } from '@/features/editor/providers/TypebotProvider'
import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'

const { ToastContainer, toast } = createStandaloneToast(customTheme)

Expand Down Expand Up @@ -58,7 +59,9 @@ const App = ({ Component, pageProps }: AppProps) => {
<TypebotProvider typebotId={typebotId}>
<WorkspaceProvider typebotId={typebotId}>
<Component {...pageProps} />
<SupportBubble />
{!pathname.endsWith('edit') && !isCloudProdInstance && (
<SupportBubble />
)}
<NewVersionPopup />
</WorkspaceProvider>
</TypebotProvider>
Expand Down
2 changes: 1 addition & 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.0.49",
"version": "0.0.50",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/embeds/js/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ export const defaultBubbleProps: BubbleProps = {
onOpen: undefined,
theme: undefined,
previewMessage: undefined,
onPreviewMessageClick: undefined,
autoShowDelay: undefined,
}
12 changes: 10 additions & 2 deletions packages/embeds/js/src/features/bubble/components/Bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const Bubble = (props: BubbleProps) => {
'previewMessage',
'onPreviewMessageClick',
'theme',
'autoShowDelay',
])
const [prefilledVariables, setPrefilledVariables] = createSignal(
// eslint-disable-next-line solid/reactivity
Expand All @@ -47,12 +48,19 @@ export const Bubble = (props: BubbleProps) => {

onMount(() => {
window.addEventListener('message', processIncomingEvent)
const autoShowDelay = bubbleProps.previewMessage?.autoShowDelay
const autoShowDelay = bubbleProps.autoShowDelay
const previewMessageAutoShowDelay =
bubbleProps.previewMessage?.autoShowDelay
if (isDefined(autoShowDelay)) {
setTimeout(() => {
showMessage()
openBot()
}, autoShowDelay)
}
if (isDefined(previewMessageAutoShowDelay)) {
setTimeout(() => {
showMessage()
}, previewMessageAutoShowDelay)
}
})

onCleanup(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/embeds/js/src/features/bubble/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type BubbleParams = {
theme?: BubbleTheme
previewMessage?: PreviewMessageParams
autoShowDelay?: number
}

export type BubbleTheme = {
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.0.49",
"version": "0.0.50",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

4 comments on commit 123926f

@vercel
Copy link

@vercel vercel bot commented on 123926f May 15, 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 123926f May 15, 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

bii.bj
1stop.au
wasap.nl
yobot.me
klujo.com
me.cr8.ai
wachat.io
wassep.io
247987.com
8jours.top
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
welcome.triplo.ai
1988.bouclidom.com
amancarseat.online
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.lucide.contact
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
chat.hand-made.one
chat.tuanpakya.com
chat.webisharp.com
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
noticiasnet.online
pant.maxbot.com.br
pantherview.cr8.ai
positivobra.com.br
rollingball.cr8.ai
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
ai.digitaldaftar.in
bot.boston-voip.com
bot.cabinpromos.com
bot.carnaval.studio
bot.digitalbled.com
bot.dsignagency.com
bot.enthrallart.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.leadgenpod.site
bot.ltmidias.com.br
bot.viralsangat.com
bot.winglabs.com.br
carsalesenquiry.com
chat.marius.digital
chat.sr7digital.com
chatbot.matthesv.de
register.algorithmpress.com
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
open.campus.aalen.university
piazzatorre.barrettamario.it
poll.mosaicohairboutique.com
type.cookieacademyonline.com
upload.atlasoutfittersk9.com
bot.brigadeirosemdrama.com.br
tuttirecepcao.fratucci.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
recepcao.tutti.fratucci.com.br
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
baleia.testeeventos.progenbr.com
bot.cabin-rentals-of-georgia.net
open.campus.bot.aalen.university
sondaggio.mosaicohairboutique.it
baleia.testegabinete.progenbr.com
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
sondaggio.mosaicohairboutique.com
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
chrome-os-inquiry-system.itschromeos.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com

@vercel
Copy link

@vercel vercel bot commented on 123926f May 15, 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-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 123926f May 15, 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-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io

Please sign in to comment.