💄 Improve progress bar UI and make avoid starting at 0
This commit is contained in:
@@ -115,6 +115,10 @@ export const GeneralSettings = ({
|
|||||||
onChange={updateBranding}
|
onChange={updateBranding}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<ProgressBarForm
|
||||||
|
progressBar={generalTheme?.progressBar}
|
||||||
|
onProgressBarChange={updateProgressBar}
|
||||||
|
/>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Text>{t('theme.sideMenu.global.font')}</Text>
|
<Text>{t('theme.sideMenu.global.font')}</Text>
|
||||||
<RadioButtons
|
<RadioButtons
|
||||||
@@ -128,10 +132,6 @@ export const GeneralSettings = ({
|
|||||||
background={generalTheme?.background}
|
background={generalTheme?.background}
|
||||||
onBackgroundChange={handleBackgroundChange}
|
onBackgroundChange={handleBackgroundChange}
|
||||||
/>
|
/>
|
||||||
<ProgressBarForm
|
|
||||||
progressBar={generalTheme?.progressBar}
|
|
||||||
onProgressBarChange={updateProgressBar}
|
|
||||||
/>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ColorPicker } from '@/components/ColorPicker'
|
|||||||
import { DropdownList } from '@/components/DropdownList'
|
import { DropdownList } from '@/components/DropdownList'
|
||||||
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
||||||
import { NumberInput } from '@/components/inputs'
|
import { NumberInput } from '@/components/inputs'
|
||||||
import { HStack, Text } from '@chakra-ui/react'
|
import { FormLabel, HStack } from '@chakra-ui/react'
|
||||||
import { ProgressBar } from '@typebot.io/schemas'
|
import { ProgressBar } from '@typebot.io/schemas'
|
||||||
import {
|
import {
|
||||||
defaultTheme,
|
defaultTheme,
|
||||||
@@ -25,9 +25,6 @@ export const ProgressBarForm = ({
|
|||||||
const updateColor = (color: string) =>
|
const updateColor = (color: string) =>
|
||||||
onProgressBarChange({ ...progressBar, color })
|
onProgressBarChange({ ...progressBar, color })
|
||||||
|
|
||||||
const updateBackgroundColor = (backgroundColor: string) =>
|
|
||||||
onProgressBarChange({ ...progressBar, backgroundColor })
|
|
||||||
|
|
||||||
const updatePlacement = (placement: (typeof progressBarPlacements)[number]) =>
|
const updatePlacement = (placement: (typeof progressBarPlacements)[number]) =>
|
||||||
onProgressBarChange({ ...progressBar, placement })
|
onProgressBarChange({ ...progressBar, placement })
|
||||||
|
|
||||||
@@ -55,6 +52,29 @@ export const ProgressBarForm = ({
|
|||||||
onItemSelect={updatePlacement}
|
onItemSelect={updatePlacement}
|
||||||
items={progressBarPlacements}
|
items={progressBarPlacements}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<HStack justifyContent="space-between">
|
||||||
|
<FormLabel mb="0" mr="0">
|
||||||
|
Color:
|
||||||
|
</FormLabel>
|
||||||
|
<ColorPicker
|
||||||
|
defaultValue={
|
||||||
|
progressBar?.color ?? defaultTheme.general.progressBar.color
|
||||||
|
}
|
||||||
|
onColorChange={updateColor}
|
||||||
|
/>
|
||||||
|
</HStack>
|
||||||
|
<NumberInput
|
||||||
|
label="Thickness:"
|
||||||
|
direction="row"
|
||||||
|
withVariableButton={false}
|
||||||
|
maxW="100px"
|
||||||
|
defaultValue={
|
||||||
|
progressBar?.thickness ?? defaultTheme.general.progressBar.thickness
|
||||||
|
}
|
||||||
|
onValueChange={updateThickness}
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
<DropdownList
|
<DropdownList
|
||||||
size="sm"
|
size="sm"
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -66,36 +86,6 @@ export const ProgressBarForm = ({
|
|||||||
onItemSelect={updatePosition}
|
onItemSelect={updatePosition}
|
||||||
items={progressBarPositions}
|
items={progressBarPositions}
|
||||||
/>
|
/>
|
||||||
<HStack justifyContent="space-between">
|
|
||||||
<Text>Color:</Text>
|
|
||||||
<ColorPicker
|
|
||||||
defaultValue={
|
|
||||||
progressBar?.color ?? defaultTheme.general.progressBar.color
|
|
||||||
}
|
|
||||||
onColorChange={updateColor}
|
|
||||||
/>
|
|
||||||
</HStack>
|
|
||||||
<HStack justifyContent="space-between">
|
|
||||||
<Text>Background color:</Text>
|
|
||||||
<ColorPicker
|
|
||||||
defaultValue={
|
|
||||||
progressBar?.backgroundColor ??
|
|
||||||
defaultTheme.general.progressBar.backgroundColor
|
|
||||||
}
|
|
||||||
onColorChange={updateBackgroundColor}
|
|
||||||
/>
|
|
||||||
</HStack>
|
|
||||||
<HStack justifyContent="space-between">
|
|
||||||
<Text>Thickness:</Text>
|
|
||||||
<NumberInput
|
|
||||||
withVariableButton={false}
|
|
||||||
defaultValue={
|
|
||||||
progressBar?.thickness ?? defaultTheme.general.progressBar.thickness
|
|
||||||
}
|
|
||||||
onValueChange={updateThickness}
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
</HStack>
|
|
||||||
</SwitchWithRelatedSettings>
|
</SwitchWithRelatedSettings>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19433,8 +19433,12 @@
|
|||||||
"family": {
|
"family": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"url": {
|
"css": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Deprecated, use `css` instead"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -6744,8 +6744,12 @@
|
|||||||
"family": {
|
"family": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"url": {
|
"css": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Deprecated, use `css` instead"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { startSession } from '@typebot.io/bot-engine/startSession'
|
|||||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||||
import { filterPotentiallySensitiveLogs } from '@typebot.io/bot-engine/logs/filterPotentiallySensitiveLogs'
|
import { filterPotentiallySensitiveLogs } from '@typebot.io/bot-engine/logs/filterPotentiallySensitiveLogs'
|
||||||
|
import { computeCurrentProgress } from '@typebot.io/bot-engine/computeCurrentProgress'
|
||||||
|
|
||||||
export const startChat = publicProcedure
|
export const startChat = publicProcedure
|
||||||
.meta({
|
.meta({
|
||||||
@@ -83,6 +84,12 @@ export const startChat = publicProcedure
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isEnded =
|
||||||
|
newSessionState.progressMetadata &&
|
||||||
|
!input?.id &&
|
||||||
|
(clientSideActions?.filter((c) => c.expectsDedicatedReply).length ??
|
||||||
|
0) === 0
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sessionId: session.id,
|
sessionId: session.id,
|
||||||
typebot: {
|
typebot: {
|
||||||
@@ -96,7 +103,15 @@ export const startChat = publicProcedure
|
|||||||
dynamicTheme,
|
dynamicTheme,
|
||||||
logs: logs?.filter(filterPotentiallySensitiveLogs),
|
logs: logs?.filter(filterPotentiallySensitiveLogs),
|
||||||
clientSideActions,
|
clientSideActions,
|
||||||
progress: newSessionState.progressMetadata ? 0 : undefined,
|
progress: newSessionState.progressMetadata
|
||||||
|
? isEnded
|
||||||
|
? 100
|
||||||
|
: computeCurrentProgress({
|
||||||
|
typebotsQueue: newSessionState.typebotsQueue,
|
||||||
|
progressMetadata: newSessionState.progressMetadata,
|
||||||
|
currentInputBlockId: input?.id as string,
|
||||||
|
})
|
||||||
|
: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { startSession } from '@typebot.io/bot-engine/startSession'
|
|||||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||||
import { publicProcedure } from '@/helpers/server/trpc'
|
import { publicProcedure } from '@/helpers/server/trpc'
|
||||||
|
import { computeCurrentProgress } from '@typebot.io/bot-engine/computeCurrentProgress'
|
||||||
|
|
||||||
export const startChatPreview = publicProcedure
|
export const startChatPreview = publicProcedure
|
||||||
.meta({
|
.meta({
|
||||||
@@ -71,6 +72,12 @@ export const startChatPreview = publicProcedure
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isEnded =
|
||||||
|
newSessionState.progressMetadata &&
|
||||||
|
!input?.id &&
|
||||||
|
(clientSideActions?.filter((c) => c.expectsDedicatedReply).length ??
|
||||||
|
0) === 0
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sessionId: session.id,
|
sessionId: session.id,
|
||||||
typebot: {
|
typebot: {
|
||||||
@@ -83,7 +90,15 @@ export const startChatPreview = publicProcedure
|
|||||||
dynamicTheme,
|
dynamicTheme,
|
||||||
logs,
|
logs,
|
||||||
clientSideActions,
|
clientSideActions,
|
||||||
progress: newSessionState.progressMetadata ? 0 : undefined,
|
progress: newSessionState.progressMetadata
|
||||||
|
? isEnded
|
||||||
|
? 100
|
||||||
|
: computeCurrentProgress({
|
||||||
|
typebotsQueue: newSessionState.typebotsQueue,
|
||||||
|
progressMetadata: newSessionState.progressMetadata,
|
||||||
|
currentInputBlockId: input?.id as string,
|
||||||
|
})
|
||||||
|
: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export const computeCurrentProgress = ({
|
|||||||
progressMetadata,
|
progressMetadata,
|
||||||
currentInputBlockId,
|
currentInputBlockId,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
if (progressMetadata.totalAnswers === 0) return 0
|
|
||||||
const paths = computePossibleNextInputBlocks({
|
const paths = computePossibleNextInputBlocks({
|
||||||
typebotsQueue: typebotsQueue,
|
typebotsQueue: typebotsQueue,
|
||||||
blockId: currentInputBlockId,
|
blockId: currentInputBlockId,
|
||||||
@@ -22,11 +21,10 @@ export const computeCurrentProgress = ({
|
|||||||
},
|
},
|
||||||
currentPath: [],
|
currentPath: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(progressMetadata.totalAnswers /
|
((progressMetadata.totalAnswers + 1) /
|
||||||
(Math.max(...paths.map((b) => b.length)) +
|
(Math.max(...paths.map((b) => b.length)) +
|
||||||
progressMetadata.totalAnswers)) *
|
(progressMetadata.totalAnswers + 1))) *
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.44",
|
"version": "0.2.45",
|
||||||
"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",
|
||||||
|
|||||||
@@ -242,12 +242,6 @@ pre {
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.typebot-host-bubble img,
|
|
||||||
.typebot-host-bubble iframe,
|
|
||||||
.typebot-host-bubble video {
|
|
||||||
border-radius: var(--typebot-border-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
.typebot-guest-bubble {
|
.typebot-guest-bubble {
|
||||||
color: var(--typebot-guest-bubble-color);
|
color: var(--typebot-guest-bubble-color);
|
||||||
background-color: var(--typebot-guest-bubble-bg-color);
|
background-color: var(--typebot-guest-bubble-bg-color);
|
||||||
@@ -409,7 +403,11 @@ select option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.typebot-progress-bar-container {
|
.typebot-progress-bar-container {
|
||||||
background-color: var(--typebot-progress-bar-bg-color);
|
background-color: rgba(
|
||||||
|
var(--typebot-button-bg-color-rgb),
|
||||||
|
calc(var(--selectable-base-alpha) + 0.12)
|
||||||
|
);
|
||||||
|
|
||||||
height: var(--typebot-progress-bar-height);
|
height: var(--typebot-progress-bar-height);
|
||||||
position: var(--typebot-progress-bar-position);
|
position: var(--typebot-progress-bar-position);
|
||||||
top: var(--typebot-progress-bar-top);
|
top: var(--typebot-progress-bar-top);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const cssVariableNames = {
|
|||||||
progressBar: {
|
progressBar: {
|
||||||
position: '--typebot-progress-bar-position',
|
position: '--typebot-progress-bar-position',
|
||||||
color: '--typebot-progress-bar-color',
|
color: '--typebot-progress-bar-color',
|
||||||
backgroundColor: '--typebot-progress-bar-bg-color',
|
colorRgb: '--typebot-progress-bar-color-rgb',
|
||||||
height: '--typebot-progress-bar-height',
|
height: '--typebot-progress-bar-height',
|
||||||
top: '--typebot-progress-bar-top',
|
top: '--typebot-progress-bar-top',
|
||||||
bottom: '--typebot-progress-bar-bottom',
|
bottom: '--typebot-progress-bar-bottom',
|
||||||
@@ -110,9 +110,11 @@ const setProgressBar = (
|
|||||||
progressBar.color ?? defaultTheme.general.progressBar.color
|
progressBar.color ?? defaultTheme.general.progressBar.color
|
||||||
)
|
)
|
||||||
documentStyle.setProperty(
|
documentStyle.setProperty(
|
||||||
cssVariableNames.general.progressBar.backgroundColor,
|
cssVariableNames.general.progressBar.colorRgb,
|
||||||
progressBar.backgroundColor ??
|
hexToRgb(
|
||||||
defaultTheme.general.progressBar.backgroundColor
|
progressBar.backgroundColor ??
|
||||||
|
defaultTheme.general.progressBar.backgroundColor
|
||||||
|
).join(', ')
|
||||||
)
|
)
|
||||||
documentStyle.setProperty(
|
documentStyle.setProperty(
|
||||||
cssVariableNames.general.progressBar.height,
|
cssVariableNames.general.progressBar.height,
|
||||||
@@ -254,7 +256,6 @@ const setTypebotBackground = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parseBackgroundValue = ({ type, content }: Background = {}) => {
|
const parseBackgroundValue = ({ type, content }: Background = {}) => {
|
||||||
console.log('parseBackgroundValue', type, content)
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BackgroundType.NONE:
|
case BackgroundType.NONE:
|
||||||
return 'transparent'
|
return 'transparent'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.44",
|
"version": "0.2.45",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.44",
|
"version": "0.2.45",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"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