-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (buttons) Allow dynamic buttons from variable
Closes #237
- Loading branch information
1 parent
8462810
commit 2ff6991
Showing
28 changed files
with
290 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
apps/builder/src/features/blocks/inputs/buttons/components/ButtonsBlockNode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { BlockIndices, ChoiceInputBlock, Variable } from 'models' | ||
import React from 'react' | ||
import { ItemNodesList } from '@/features/graph/components/Nodes/ItemNode' | ||
import { | ||
HStack, | ||
Stack, | ||
Tag, | ||
Text, | ||
useColorModeValue, | ||
Wrap, | ||
} from '@chakra-ui/react' | ||
import { useTypebot } from '@/features/editor' | ||
|
||
type Props = { | ||
block: ChoiceInputBlock | ||
indices: BlockIndices | ||
} | ||
|
||
export const ButtonsBlockNode = ({ block, indices }: Props) => { | ||
const { typebot } = useTypebot() | ||
const dynamicVariableName = typebot?.variables.find( | ||
(variable) => variable.id === block.options.dynamicVariableId | ||
)?.name | ||
|
||
return ( | ||
<Stack w="full"> | ||
{block.options.variableId ? ( | ||
<CollectVariableLabel | ||
variableId={block.options.variableId} | ||
variables={typebot?.variables} | ||
/> | ||
) : null} | ||
{block.options.dynamicVariableId ? ( | ||
<Wrap spacing={1}> | ||
<Text>Display</Text> | ||
<Tag bg="orange.400" color="white"> | ||
{dynamicVariableName} | ||
</Tag> | ||
<Text>buttons</Text> | ||
</Wrap> | ||
) : ( | ||
<ItemNodesList block={block} indices={indices} /> | ||
)} | ||
</Stack> | ||
) | ||
} | ||
|
||
const CollectVariableLabel = ({ | ||
variableId, | ||
variables, | ||
}: { | ||
variableId: string | ||
variables?: Variable[] | ||
}) => { | ||
const textColor = useColorModeValue('gray.600', 'gray.400') | ||
const variableName = variables?.find( | ||
(variable) => variable.id === variableId | ||
)?.name | ||
|
||
if (!variableName) return null | ||
return ( | ||
<HStack fontStyle="italic" spacing={1}> | ||
<Text fontSize="sm" color={textColor}> | ||
Collects | ||
</Text> | ||
<Tag bg="orange.400" color="white" size="sm"> | ||
{variableName} | ||
</Tag> | ||
</HStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/builder/src/features/blocks/inputs/buttons/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './ButtonsItemNode' | ||
export * from './ButtonsIcon' | ||
export * from './ButtonsOptionsForm' | ||
export * from './ButtonsBlockSettings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
2ff6991
There was a problem hiding this comment.
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
2ff6991
There was a problem hiding this comment.
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:
landing-page-v2 – ./apps/landing-page
get-typebot.com
landing-page-v2-git-main-typebot-io.vercel.app
typebot.io
landing-page-v2-typebot-io.vercel.app
www.typebot.io
www.get-typebot.com
2ff6991
There was a problem hiding this comment.
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
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.ai
gollum.riku.ai
gsbulletin.com
panther.cr7.ai
panther.cr8.ai
penguin.cr8.ai
talk.gocare.io
test.bot.gives
ticketfute.com
unicorn.cr8.ai
apo.nigerias.io
apr.nigerias.io
aso.nigerias.io
bot.ageenda.com
bot.artiweb.app
bot.devitus.com
bot.jesopizz.it
bot.reeplai.com
bot.scayver.com
bot.tc-mail.com
chat.lalmon.com
chat.sureb4.com
eventhub.com.au
fitness.riku.ai
games.klujo.com
help.taxtree.io
sakuranembro.it
typebot.aloe.do
bot.contakit.com
bot.piccinato.co
bot.sv-energy.it
botc.ceox.com.br
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
haymanevents.com
kw.wpwakanda.com
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
1988.bouclidom.com
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.boston-voip.com
bot.cabinpromos.com
bot.digitalbled.com
bot.dsignagency.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.ltmidias.com.br
bbutton.wpwakanda.com
bot.coachayongzul.com
bot.digitalpointer.id
bot.eikju.photography
bot.incusservices.com
bot.meuesocial.com.br
bot.mycompany.reviews
bot.outstandbrand.com
2ff6991
There was a problem hiding this comment.
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
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app