🚸 Improve support accessibility
Add documentation button in board menu and hide the support bubble in the editor. Makes it accessible only by clicking the "Help" button
This commit is contained in:
@@ -3,16 +3,14 @@ import { useUser } from '@/features/account/hooks/useUser'
|
|||||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Bubble } from '@typebot.io/react'
|
import { Bubble } from '@typebot.io/react'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
import { planToReadable } from '@/features/billing/helpers/planToReadable'
|
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 { typebot } = useTypebot()
|
||||||
const { user } = useUser()
|
const { user } = useUser()
|
||||||
const { workspace } = useWorkspace()
|
const { workspace } = useWorkspace()
|
||||||
|
|
||||||
if (!isCloudProdInstance) return null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Bubble
|
<Bubble
|
||||||
apiHost="https://viewer.typebot.io"
|
apiHost="https://viewer.typebot.io"
|
||||||
@@ -30,6 +28,7 @@ export const SupportBubble = () => {
|
|||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -621,3 +621,10 @@ export const SmileIcon = (props: IconProps) => (
|
|||||||
<line x1="15" y1="9" x2="15.01" y2="9"></line>
|
<line x1="15" y1="9" x2="15.01" y2="9"></line>
|
||||||
</Icon>
|
</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>
|
||||||
|
)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import {
|
import {
|
||||||
|
BookIcon,
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
SettingsIcon,
|
SettingsIcon,
|
||||||
@@ -31,14 +32,9 @@ export const BoardMenuButton = (props: FlexProps) => {
|
|||||||
const { isOpen, onOpen, onClose } = useDisclosure()
|
const { isOpen, onOpen, onClose } = useDisclosure()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (isNotDefined(user?.graphNavigation) && isNotDefined(query.isFirstBot))
|
||||||
user &&
|
|
||||||
isNotDefined(user.graphNavigation) &&
|
|
||||||
isNotDefined(query.isFirstBot)
|
|
||||||
)
|
|
||||||
onOpen()
|
onOpen()
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [onOpen, query.isFirstBot, user?.graphNavigation])
|
||||||
}, [])
|
|
||||||
|
|
||||||
const downloadFlow = () => {
|
const downloadFlow = () => {
|
||||||
assert(typebot)
|
assert(typebot)
|
||||||
@@ -56,6 +52,10 @@ export const BoardMenuButton = (props: FlexProps) => {
|
|||||||
linkElement.click()
|
linkElement.click()
|
||||||
setIsDownloading(false)
|
setIsDownloading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const redirectToDocumentation = () =>
|
||||||
|
window.open('https://docs.typebot.io/get-started/overview', '_blank')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
bgColor={useColorModeValue('white', 'gray.900')}
|
bgColor={useColorModeValue('white', 'gray.900')}
|
||||||
@@ -72,6 +72,9 @@ export const BoardMenuButton = (props: FlexProps) => {
|
|||||||
bgColor={useColorModeValue('white', undefined)}
|
bgColor={useColorModeValue('white', undefined)}
|
||||||
/>
|
/>
|
||||||
<MenuList>
|
<MenuList>
|
||||||
|
<MenuItem icon={<BookIcon />} onClick={redirectToDocumentation}>
|
||||||
|
Documentation
|
||||||
|
</MenuItem>
|
||||||
<MenuItem icon={<SettingsIcon />} onClick={onOpen}>
|
<MenuItem icon={<SettingsIcon />} onClick={onOpen}>
|
||||||
Editor settings
|
Editor settings
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
Text,
|
Text,
|
||||||
useColorModeValue,
|
useColorModeValue,
|
||||||
|
useDisclosure,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import {
|
import {
|
||||||
BuoyIcon,
|
BuoyIcon,
|
||||||
@@ -18,9 +19,7 @@ import { useRouter } from 'next/router'
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { isDefined, isNotDefined } from '@typebot.io/lib'
|
import { isDefined, isNotDefined } from '@typebot.io/lib'
|
||||||
import { EditableTypebotName } from './EditableTypebotName'
|
import { EditableTypebotName } from './EditableTypebotName'
|
||||||
import { open as openSupportBubble } from '@typebot.io/js'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
|
||||||
import { EditableEmojiOrImageIcon } from '@/components/EditableEmojiOrImageIcon'
|
import { EditableEmojiOrImageIcon } from '@/components/EditableEmojiOrImageIcon'
|
||||||
import { useUndoShortcut } from '@/hooks/useUndoShortcut'
|
import { useUndoShortcut } from '@/hooks/useUndoShortcut'
|
||||||
import { useDebouncedCallback } from 'use-debounce'
|
import { useDebouncedCallback } from 'use-debounce'
|
||||||
@@ -29,6 +28,8 @@ import { PublishButton } from '@/features/publish/components/PublishButton'
|
|||||||
import { headerHeight } from '../constants'
|
import { headerHeight } from '../constants'
|
||||||
import { RightPanel, useEditor } from '../providers/EditorProvider'
|
import { RightPanel, useEditor } from '../providers/EditorProvider'
|
||||||
import { useTypebot } from '../providers/TypebotProvider'
|
import { useTypebot } from '../providers/TypebotProvider'
|
||||||
|
import { SupportBubble } from '@/components/SupportBubble'
|
||||||
|
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
||||||
|
|
||||||
export const TypebotHeader = () => {
|
export const TypebotHeader = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -49,6 +50,7 @@ export const TypebotHeader = () => {
|
|||||||
const hideUndoShortcutTooltipLater = useDebouncedCallback(() => {
|
const hideUndoShortcutTooltipLater = useDebouncedCallback(() => {
|
||||||
setUndoShortcutTooltipOpen(false)
|
setUndoShortcutTooltipOpen(false)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
const { isOpen, onOpen } = useDisclosure()
|
||||||
|
|
||||||
const handleNameSubmit = (name: string) => updateTypebot({ name })
|
const handleNameSubmit = (name: string) => updateTypebot({ name })
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ export const TypebotHeader = () => {
|
|||||||
|
|
||||||
const handleHelpClick = () => {
|
const handleHelpClick = () => {
|
||||||
isCloudProdInstance
|
isCloudProdInstance
|
||||||
? openSupportBubble()
|
? onOpen()
|
||||||
: window.open('https://docs.typebot.io', '_blank')
|
: window.open('https://docs.typebot.io', '_blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +88,7 @@ export const TypebotHeader = () => {
|
|||||||
bgColor={useColorModeValue('white', 'gray.900')}
|
bgColor={useColorModeValue('white', 'gray.900')}
|
||||||
flexShrink={0}
|
flexShrink={0}
|
||||||
>
|
>
|
||||||
|
{isOpen && <SupportBubble autoShowDelay={0} />}
|
||||||
<HStack
|
<HStack
|
||||||
display={['none', 'flex']}
|
display={['none', 'flex']}
|
||||||
pos={{ base: 'absolute', xl: 'static' }}
|
pos={{ base: 'absolute', xl: 'static' }}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { NewVersionPopup } from '@/components/NewVersionPopup'
|
|||||||
import { I18nProvider } from '@/locales'
|
import { I18nProvider } from '@/locales'
|
||||||
import { TypebotProvider } from '@/features/editor/providers/TypebotProvider'
|
import { TypebotProvider } from '@/features/editor/providers/TypebotProvider'
|
||||||
import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider'
|
import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider'
|
||||||
|
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
|
||||||
|
|
||||||
const { ToastContainer, toast } = createStandaloneToast(customTheme)
|
const { ToastContainer, toast } = createStandaloneToast(customTheme)
|
||||||
|
|
||||||
@@ -58,7 +59,9 @@ const App = ({ Component, pageProps }: AppProps) => {
|
|||||||
<TypebotProvider typebotId={typebotId}>
|
<TypebotProvider typebotId={typebotId}>
|
||||||
<WorkspaceProvider typebotId={typebotId}>
|
<WorkspaceProvider typebotId={typebotId}>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
|
{!pathname.endsWith('edit') && !isCloudProdInstance && (
|
||||||
<SupportBubble />
|
<SupportBubble />
|
||||||
|
)}
|
||||||
<NewVersionPopup />
|
<NewVersionPopup />
|
||||||
</WorkspaceProvider>
|
</WorkspaceProvider>
|
||||||
</TypebotProvider>
|
</TypebotProvider>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.49",
|
"version": "0.0.50",
|
||||||
"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",
|
||||||
|
|||||||
@@ -32,4 +32,6 @@ export const defaultBubbleProps: BubbleProps = {
|
|||||||
onOpen: undefined,
|
onOpen: undefined,
|
||||||
theme: undefined,
|
theme: undefined,
|
||||||
previewMessage: undefined,
|
previewMessage: undefined,
|
||||||
|
onPreviewMessageClick: undefined,
|
||||||
|
autoShowDelay: undefined,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
'previewMessage',
|
'previewMessage',
|
||||||
'onPreviewMessageClick',
|
'onPreviewMessageClick',
|
||||||
'theme',
|
'theme',
|
||||||
|
'autoShowDelay',
|
||||||
])
|
])
|
||||||
const [prefilledVariables, setPrefilledVariables] = createSignal(
|
const [prefilledVariables, setPrefilledVariables] = createSignal(
|
||||||
// eslint-disable-next-line solid/reactivity
|
// eslint-disable-next-line solid/reactivity
|
||||||
@@ -47,12 +48,19 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
window.addEventListener('message', processIncomingEvent)
|
window.addEventListener('message', processIncomingEvent)
|
||||||
const autoShowDelay = bubbleProps.previewMessage?.autoShowDelay
|
const autoShowDelay = bubbleProps.autoShowDelay
|
||||||
|
const previewMessageAutoShowDelay =
|
||||||
|
bubbleProps.previewMessage?.autoShowDelay
|
||||||
if (isDefined(autoShowDelay)) {
|
if (isDefined(autoShowDelay)) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showMessage()
|
openBot()
|
||||||
}, autoShowDelay)
|
}, autoShowDelay)
|
||||||
}
|
}
|
||||||
|
if (isDefined(previewMessageAutoShowDelay)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
showMessage()
|
||||||
|
}, previewMessageAutoShowDelay)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export type BubbleParams = {
|
export type BubbleParams = {
|
||||||
theme?: BubbleTheme
|
theme?: BubbleTheme
|
||||||
previewMessage?: PreviewMessageParams
|
previewMessage?: PreviewMessageParams
|
||||||
|
autoShowDelay?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BubbleTheme = {
|
export type BubbleTheme = {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.49",
|
"version": "0.0.50",
|
||||||
"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",
|
||||||
|
|||||||
Reference in New Issue
Block a user