Skip to content

Commit

Permalink
🚸 (typebotLink) Add icon in typebots dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 16, 2022
1 parent 2bd7cee commit 0c3dcc5
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 23 deletions.
25 changes: 17 additions & 8 deletions apps/builder/src/components/SearchableDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
HStack,
} from '@chakra-ui/react'
import { Variable } from 'models'
import { useState, useRef, useEffect, ChangeEvent } from 'react'
import { useState, useRef, useEffect, ChangeEvent, ReactNode } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { env, isDefined } from 'utils'
import { VariablesButton } from '@/features/variables'

type Props = {
selectedItem?: string
items: string[]
items: (string | { label: ReactNode; value: string })[]
debounceTimeout?: number
withVariableButton?: boolean
onValueChange?: (value: string) => void
Expand All @@ -43,7 +43,9 @@ export const SearchableDropdown = ({
const [filteredItems, setFilteredItems] = useState([
...items
.filter((item) =>
item.toLowerCase().includes((selectedItem ?? '').toLowerCase())
(typeof item === 'string' ? item : item.value)
.toLowerCase()
.includes((selectedItem ?? '').toLowerCase())
)
.slice(0, 50),
])
Expand All @@ -67,7 +69,9 @@ export const SearchableDropdown = ({
setFilteredItems([
...items
.filter((item) =>
item.toLowerCase().includes((selectedItem ?? '').toLowerCase())
(typeof item === 'string' ? item : item.value)
.toLowerCase()
.includes((selectedItem ?? '').toLowerCase())
)
.slice(0, 50),
])
Expand All @@ -91,7 +95,9 @@ export const SearchableDropdown = ({
setFilteredItems([
...items
.filter((item) =>
item.toLowerCase().includes((inputValue ?? '').toLowerCase())
(typeof item === 'string' ? item : item.value)
.toLowerCase()
.includes((inputValue ?? '').toLowerCase())
)
.slice(0, 50),
])
Expand Down Expand Up @@ -134,7 +140,8 @@ export const SearchableDropdown = ({
if (inputRef.current?.selectionStart)
setCarretPosition(inputRef.current.selectionStart)
if (e.key === 'Enter' && isDefined(keyboardFocusIndex)) {
handleItemClick(filteredItems[keyboardFocusIndex])()
const item = filteredItems[keyboardFocusIndex]
handleItemClick(typeof item === 'string' ? item : item.value)()
return setKeyboardFocusIndex(undefined)
}
if (e.key === 'ArrowDown') {
Expand Down Expand Up @@ -200,7 +207,9 @@ export const SearchableDropdown = ({
ref={(el) => (itemsRef.current[idx] = el)}
minH="40px"
key={idx}
onClick={handleItemClick(item)}
onClick={handleItemClick(
typeof item === 'string' ? item : item.value
)}
fontSize="16px"
fontWeight="normal"
rounded="none"
Expand All @@ -212,7 +221,7 @@ export const SearchableDropdown = ({
}
justifyContent="flex-start"
>
{item}
{typeof item === 'string' ? item : item.label}
</Button>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ type Props = {
onOptionsChange: (options: TypebotLinkOptions) => void
}

export const TypebotLinkSettingsForm = ({
options,
onOptionsChange,
}: Props) => {
export const TypebotLinkForm = ({ options, onOptionsChange }: Props) => {
const { linkedTypebots, typebot } = useTypebot()

const handleTypebotIdChange = (typebotId: string | 'current') =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HStack, IconButton, Input } from '@chakra-ui/react'
import { HStack, IconButton, Input, Text } from '@chakra-ui/react'
import { ExternalLinkIcon } from '@/components/icons'
import { useToast } from '@/hooks/useToast'
import Link from 'next/link'
Expand All @@ -7,6 +7,7 @@ import { useMemo } from 'react'
import { byId } from 'utils'
import { useTypebots } from '@/features/dashboard'
import { SearchableDropdown } from '@/components/SearchableDropdown'
import { EmojiOrImageIcon } from '@/components/EmojiOrImageIcon'

type Props = {
typebotId?: string | 'current'
Expand Down Expand Up @@ -46,7 +47,25 @@ export const TypebotsDropdown = ({
selectedItem={
typebotId === 'current' ? 'Current typebot' : currentTypebot?.name
}
items={['Current typebot', ...(typebots ?? []).map((t) => t.name)]}
items={[
{
label: 'Current typebot',
value: 'Current typebot',
},
...(typebots ?? []).map((typebot) => ({
value: typebot.name,
label: (
<HStack as="span" spacing="2">
<EmojiOrImageIcon
icon={typebot.icon}
boxSize="18px"
emojiFontSize="18px"
/>
<Text>{typebot.name}</Text>
</HStack>
),
})),
]}
onValueChange={handleTypebotSelect}
placeholder={'Select a typebot'}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { TypebotLinkForm } from './TypebotLinkForm'
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Props = {
block: TypebotLinkBlock
}

export const TypebotLinkContent = ({ block }: Props) => {
export const TypebotLinkNode = ({ block }: Props) => {
const { linkedTypebots, typebot } = useTypebot()
const isCurrentTypebot =
typebot &&
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './TypebotLinkNode'
export * from './TypebotLinkIcon'
export * from './TypebotLinkForm'
4 changes: 1 addition & 3 deletions apps/builder/src/features/blocks/logic/typebotLink/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export { TypebotLinkSettingsForm } from './components/TypebotLinkSettingsForm'
export { TypebotLinkContent } from './components/TypebotLinkContent'
export { TypebotLinkIcon } from './components/TypebotLinkIcon'
export * from './components'
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { WithVariableContent } from './WithVariableContent'
import { PaymentInputContent } from '@/features/blocks/inputs/payment'
import { RatingInputContent } from '@/features/blocks/inputs/rating'
import { FileInputContent } from '@/features/blocks/inputs/fileUpload'
import { TypebotLinkContent } from '@/features/blocks/logic/typebotLink'
import { TypebotLinkNode } from '@/features/blocks/logic/typebotLink'
import { GoogleSheetsNodeContent } from '@/features/blocks/integrations/googleSheets'
import { GoogleAnalyticsNodeContent } from '@/features/blocks/integrations/googleAnalytics/components/GoogleAnalyticsNodeContent'
import { ZapierContent } from '@/features/blocks/integrations/zapier'
Expand Down Expand Up @@ -117,7 +117,7 @@ export const BlockNodeContent = ({ block, indices }: Props): JSX.Element => {
)
}
case LogicBlockType.TYPEBOT_LINK:
return <TypebotLinkContent block={block} />
return <TypebotLinkNode block={block} />

case IntegrationBlockType.GOOGLE_SHEETS: {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ZapierSettings } from '@/features/blocks/integrations/zapier'
import { CodeSettings } from '@/features/blocks/logic/code'
import { RedirectSettings } from '@/features/blocks/logic/redirect'
import { SetVariableSettings } from '@/features/blocks/logic/setVariable'
import { TypebotLinkSettingsForm } from '@/features/blocks/logic/typebotLink'
import { TypebotLinkForm } from '@/features/blocks/logic/typebotLink'
import { ButtonsOptionsForm } from '@/features/blocks/inputs/buttons'
import { ChatwootSettingsForm } from '@/features/blocks/integrations/chatwoot'

Expand Down Expand Up @@ -200,7 +200,7 @@ export const BlockSettings = ({
}
case LogicBlockType.TYPEBOT_LINK: {
return (
<TypebotLinkSettingsForm
<TypebotLinkForm
options={block.options}
onOptionsChange={handleOptionsChange}
/>
Expand Down

5 comments on commit 0c3dcc5

@vercel
Copy link

@vercel vercel bot commented on 0c3dcc5 Nov 16, 2022

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 0c3dcc5 Nov 16, 2022

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 0c3dcc5 Nov 16, 2022

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
app.typebot.io
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0c3dcc5 Nov 16, 2022

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-alpha – ./apps/viewer

ns8.vn
yobot.me
247987.com
8jours.top
bot.aws.bj
bot.bbc.bj
finplex.be
sat.cr8.ai
bot.aipr.kr
minipost.uk
bt.id8rs.com
bot.krdfy.com
vhpage.cr8.ai
am.nigerias.io
an.nigerias.io
ar.nigerias.io
bot.enreso.org
bot.lalmon.com
ticketfute.com
apo.nigerias.io
apr.nigerias.io
aso.nigerias.io
bot.ageenda.com
bot.artiweb.app
bot.devitus.com
bot.tc-mail.com
chat.sureb4.com
eventhub.com.au
games.klujo.com
sakuranembro.it
typebot.aloe.do
bot.piccinato.co
bot.upfunnel.art
botc.ceox.com.br
clo.closeer.work
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
kw.wpwakanda.com
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
app.chatforms.net
bot.agfunnel.tech
bot.hostnation.de
offer.botscientis.us
sellmycarglasgow.com
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
abutton.wpwakanda.com
aidigitalmarketing.kr
bbutton.wpwakanda.com
bot.incusservices.com
reward.onlinebotdemo.xyz
type.opaulovieira.com.br
aibot.angrybranding.co.uk
bot.aidigitalmarketing.kr
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
bot.cabinrentalagency.com
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
chat.ertcrebateportal.com
chat.thisiscrushhouse.com
sellmyharleylouisiana.com
verfica.botmachine.com.br
configurator.bouclidom.com
help.atlasoutfittersk9.com
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
piazzatorre.barrettamario.it
requests.swamprecordsgnv.com
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
yourfeedback.comebackreward.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
viewer-v2-alpha-typebot-io.vercel.app
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0c3dcc5 Nov 16, 2022

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.