feat(inputs): ✨ Add URL input
This commit is contained in:
@ -2,6 +2,7 @@ import {
|
||||
ChatIcon,
|
||||
EmailIcon,
|
||||
FlagIcon,
|
||||
GlobeIcon,
|
||||
NumberIcon,
|
||||
TextIcon,
|
||||
} from 'assets/icons'
|
||||
@ -24,6 +25,9 @@ export const StepIcon = ({ type }: StepIconProps) => {
|
||||
case InputStepType.EMAIL: {
|
||||
return <EmailIcon />
|
||||
}
|
||||
case InputStepType.URL: {
|
||||
return <GlobeIcon />
|
||||
}
|
||||
case 'start': {
|
||||
return <FlagIcon />
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ export const StepTypeLabel = ({ type }: Props) => {
|
||||
case InputStepType.EMAIL: {
|
||||
return <Text>Email</Text>
|
||||
}
|
||||
case InputStepType.URL: {
|
||||
return <Text>Website</Text>
|
||||
}
|
||||
default: {
|
||||
return <></>
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { InputStepType, Step, TextInputOptions } from 'models'
|
||||
import { EmailInputSettingsBody } from './EmailInputSettingsBody'
|
||||
import { NumberInputSettingsBody } from './NumberInputSettingsBody'
|
||||
import { TextInputSettingsBody } from './TextInputSettingsBody'
|
||||
import { UrlInputSettingsBody } from './UrlInputSettingsBody'
|
||||
|
||||
type Props = {
|
||||
step: Step
|
||||
@ -51,6 +52,14 @@ const SettingsPopoverBodyContent = ({ step }: Props) => {
|
||||
/>
|
||||
)
|
||||
}
|
||||
case InputStepType.URL: {
|
||||
return (
|
||||
<UrlInputSettingsBody
|
||||
options={step.options}
|
||||
onOptionsChange={handleOptionsChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
default: {
|
||||
return <></>
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
import { FormLabel, Stack } from '@chakra-ui/react'
|
||||
import { DebouncedInput } from 'components/shared/DebouncedInput'
|
||||
import { UrlInputOptions } from 'models'
|
||||
import React from 'react'
|
||||
|
||||
type UrlInputSettingsBodyProps = {
|
||||
options?: UrlInputOptions
|
||||
onOptionsChange: (options: UrlInputOptions) => void
|
||||
}
|
||||
|
||||
export const UrlInputSettingsBody = ({
|
||||
options,
|
||||
onOptionsChange,
|
||||
}: UrlInputSettingsBodyProps) => {
|
||||
const handlePlaceholderChange = (placeholder: string) =>
|
||||
onOptionsChange({ ...options, labels: { ...options?.labels, placeholder } })
|
||||
const handleButtonLabelChange = (button: string) =>
|
||||
onOptionsChange({ ...options, labels: { ...options?.labels, button } })
|
||||
|
||||
return (
|
||||
<Stack spacing={4}>
|
||||
<Stack>
|
||||
<FormLabel mb="0" htmlFor="placeholder">
|
||||
Placeholder:
|
||||
</FormLabel>
|
||||
<DebouncedInput
|
||||
id="placeholder"
|
||||
initialValue={options?.labels?.placeholder ?? 'Type your URL...'}
|
||||
delay={100}
|
||||
onChange={handlePlaceholderChange}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<FormLabel mb="0" htmlFor="button">
|
||||
Button label:
|
||||
</FormLabel>
|
||||
<DebouncedInput
|
||||
id="button"
|
||||
initialValue={options?.labels?.button ?? 'Send'}
|
||||
delay={100}
|
||||
onChange={handleButtonLabelChange}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
)
|
||||
}
|
@ -39,6 +39,13 @@ export const StepNodeLabel = (props: Step | StartStep) => {
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
case InputStepType.URL: {
|
||||
return (
|
||||
<Text color={'gray.500'}>
|
||||
{props.options?.labels?.placeholder ?? 'Type your URL...'}
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
case 'start': {
|
||||
return <Text>{props.label}</Text>
|
||||
}
|
||||
|
Reference in New Issue
Block a user