@ -0,0 +1,50 @@
|
|||||||
|
import { BuoyIcon, ExpandIcon } from '@/components/icons'
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
HStack,
|
||||||
|
IconButton,
|
||||||
|
Link,
|
||||||
|
useColorModeValue,
|
||||||
|
} from '@chakra-ui/react'
|
||||||
|
import { BlockWithOptions } from '@typebot.io/schemas'
|
||||||
|
import { getHelpDocUrl } from '@/features/graph/helpers/getHelpDocUrl'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
blockType: BlockWithOptions['type']
|
||||||
|
onExpandClick: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SettingsHoverBar = ({ blockType, onExpandClick }: Props) => {
|
||||||
|
const helpDocUrl = getHelpDocUrl(blockType)
|
||||||
|
return (
|
||||||
|
<HStack
|
||||||
|
rounded="md"
|
||||||
|
spacing={0}
|
||||||
|
borderWidth="1px"
|
||||||
|
bgColor={useColorModeValue('white', 'gray.800')}
|
||||||
|
shadow="md"
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
icon={<ExpandIcon />}
|
||||||
|
borderRightWidth="1px"
|
||||||
|
borderRightRadius="none"
|
||||||
|
borderLeftRadius="none"
|
||||||
|
aria-label={'Duplicate group'}
|
||||||
|
variant="ghost"
|
||||||
|
onClick={onExpandClick}
|
||||||
|
size="xs"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
leftIcon={<BuoyIcon />}
|
||||||
|
borderLeftRadius="none"
|
||||||
|
size="xs"
|
||||||
|
variant="ghost"
|
||||||
|
href={helpDocUrl}
|
||||||
|
isExternal
|
||||||
|
>
|
||||||
|
Help
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
)
|
||||||
|
}
|
@ -4,12 +4,11 @@ import {
|
|||||||
PopoverBody,
|
PopoverBody,
|
||||||
useEventListener,
|
useEventListener,
|
||||||
Portal,
|
Portal,
|
||||||
IconButton,
|
|
||||||
HStack,
|
|
||||||
Stack,
|
Stack,
|
||||||
useColorModeValue,
|
useColorModeValue,
|
||||||
|
SlideFade,
|
||||||
|
Flex,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { ExpandIcon } from '@/components/icons'
|
|
||||||
import {
|
import {
|
||||||
InputBlockType,
|
InputBlockType,
|
||||||
IntegrationBlockType,
|
IntegrationBlockType,
|
||||||
@ -18,8 +17,7 @@ import {
|
|||||||
BlockOptions,
|
BlockOptions,
|
||||||
BlockWithOptions,
|
BlockWithOptions,
|
||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import { useRef } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import { HelpDocButton } from './HelpDocButton'
|
|
||||||
import { WaitSettings } from '@/features/blocks/logic/wait/components/WaitSettings'
|
import { WaitSettings } from '@/features/blocks/logic/wait/components/WaitSettings'
|
||||||
import { ScriptSettings } from '@/features/blocks/logic/script/components/ScriptSettings'
|
import { ScriptSettings } from '@/features/blocks/logic/script/components/ScriptSettings'
|
||||||
import { JumpSettings } from '@/features/blocks/logic/jump/components/JumpSettings'
|
import { JumpSettings } from '@/features/blocks/logic/jump/components/JumpSettings'
|
||||||
@ -47,6 +45,7 @@ import { GoogleSheetsSettings } from '@/features/blocks/integrations/googleSheet
|
|||||||
import { ChatwootSettings } from '@/features/blocks/integrations/chatwoot/components/ChatwootSettings'
|
import { ChatwootSettings } from '@/features/blocks/integrations/chatwoot/components/ChatwootSettings'
|
||||||
import { AbTestSettings } from '@/features/blocks/logic/abTest/components/AbTestSettings'
|
import { AbTestSettings } from '@/features/blocks/logic/abTest/components/AbTestSettings'
|
||||||
import { PictureChoiceSettings } from '@/features/blocks/inputs/pictureChoice/components/PictureChoiceSettings'
|
import { PictureChoiceSettings } from '@/features/blocks/inputs/pictureChoice/components/PictureChoiceSettings'
|
||||||
|
import { SettingsHoverBar } from './SettingsHoverBar'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
block: BlockWithOptions
|
block: BlockWithOptions
|
||||||
@ -55,6 +54,7 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SettingsPopoverContent = ({ onExpandClick, ...props }: Props) => {
|
export const SettingsPopoverContent = ({ onExpandClick, ...props }: Props) => {
|
||||||
|
const [isHovering, setIsHovering] = useState(false)
|
||||||
const arrowColor = useColorModeValue('white', 'gray.800')
|
const arrowColor = useColorModeValue('white', 'gray.800')
|
||||||
const ref = useRef<HTMLDivElement | null>(null)
|
const ref = useRef<HTMLDivElement | null>(null)
|
||||||
const handleMouseDown = (e: React.MouseEvent) => e.stopPropagation()
|
const handleMouseDown = (e: React.MouseEvent) => e.stopPropagation()
|
||||||
@ -74,17 +74,26 @@ export const SettingsPopoverContent = ({ onExpandClick, ...props }: Props) => {
|
|||||||
maxH="400px"
|
maxH="400px"
|
||||||
ref={ref}
|
ref={ref}
|
||||||
shadow="lg"
|
shadow="lg"
|
||||||
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
>
|
>
|
||||||
<Stack spacing={3}>
|
<Stack spacing={3}>
|
||||||
<HStack justifyContent="flex-end">
|
<Flex
|
||||||
<HelpDocButton blockType={props.block.type} />
|
w="full"
|
||||||
<IconButton
|
pos="absolute"
|
||||||
aria-label="expand"
|
top="-56px"
|
||||||
icon={<ExpandIcon />}
|
height="64px"
|
||||||
size="xs"
|
right={0}
|
||||||
onClick={onExpandClick}
|
justifyContent="flex-end"
|
||||||
/>
|
align="center"
|
||||||
</HStack>
|
>
|
||||||
|
<SlideFade in={isHovering} unmountOnExit>
|
||||||
|
<SettingsHoverBar
|
||||||
|
onExpandClick={onExpandClick}
|
||||||
|
blockType={props.block.type}
|
||||||
|
/>
|
||||||
|
</SlideFade>
|
||||||
|
</Flex>
|
||||||
<BlockSettings {...props} />
|
<BlockSettings {...props} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</PopoverBody>
|
</PopoverBody>
|
||||||
|
@ -1,36 +1,11 @@
|
|||||||
import { BuoyIcon } from '@/components/icons'
|
|
||||||
import { Button, Link } from '@chakra-ui/react'
|
|
||||||
import {
|
import {
|
||||||
BlockWithOptions,
|
BlockWithOptions,
|
||||||
InputBlockType,
|
InputBlockType,
|
||||||
IntegrationBlockType,
|
IntegrationBlockType,
|
||||||
LogicBlockType,
|
LogicBlockType,
|
||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import React from 'react'
|
|
||||||
|
|
||||||
type HelpDocButtonProps = {
|
export const getHelpDocUrl = (blockType: BlockWithOptions['type']): string => {
|
||||||
blockType: BlockWithOptions['type']
|
|
||||||
}
|
|
||||||
|
|
||||||
export const HelpDocButton = ({ blockType }: HelpDocButtonProps) => {
|
|
||||||
const helpDocUrl = getHelpDocUrl(blockType)
|
|
||||||
|
|
||||||
if (helpDocUrl === null) return null
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
as={Link}
|
|
||||||
leftIcon={<BuoyIcon />}
|
|
||||||
size="xs"
|
|
||||||
href={helpDocUrl}
|
|
||||||
isExternal
|
|
||||||
>
|
|
||||||
Help
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getHelpDocUrl = (blockType: BlockWithOptions['type']): string => {
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case LogicBlockType.TYPEBOT_LINK:
|
case LogicBlockType.TYPEBOT_LINK:
|
||||||
return 'https://docs.typebot.io/editor/blocks/logic/typebot-link'
|
return 'https://docs.typebot.io/editor/blocks/logic/typebot-link'
|
Reference in New Issue
Block a user