mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-22 21:06:40 +08:00
🐛 Fix invalid chat window background URL in default Bubble theme
Closes #2264
This commit is contained in:
parent
f97c9780d2
commit
5a4787be44
@ -5,13 +5,13 @@ import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../../Javascript/JavascriptBubbleSnippet";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const FramerBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -4,12 +4,12 @@ import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../../Javascript/JavascriptBubbleSnippet";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const GtmBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -17,12 +17,7 @@ export const JavascriptBubbleSnippet = ({ theme, previewMessage }: Props) => {
|
||||
${parseInitBubbleCode({
|
||||
typebot: typebot?.publicId ?? "",
|
||||
customDomain: typebot?.customDomain,
|
||||
theme: {
|
||||
...theme,
|
||||
chatWindow: {
|
||||
backgroundColor: typebot?.theme.general?.background?.content ?? "#fff",
|
||||
},
|
||||
},
|
||||
theme,
|
||||
previewMessage,
|
||||
})}</script>`,
|
||||
{
|
||||
|
||||
@ -1,23 +1,42 @@
|
||||
import { useTypebot } from "@/features/editor/providers/TypebotProvider";
|
||||
import { Code, Stack, Text } from "@chakra-ui/react";
|
||||
import type { BubbleProps } from "@typebot.io/js";
|
||||
import {
|
||||
BackgroundType,
|
||||
defaultBackgroundColor,
|
||||
defaultBackgroundType,
|
||||
} from "@typebot.io/theme/constants";
|
||||
import type { Typebot } from "@typebot.io/typebot/schemas/typebot";
|
||||
import { colors } from "@typebot.io/ui/colors";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../JavascriptBubbleSnippet";
|
||||
|
||||
export const parseDefaultBubbleTheme = (typebot?: Typebot) => ({
|
||||
button: {
|
||||
backgroundColor:
|
||||
typebot?.theme.chat?.buttons?.backgroundColor ?? colors.gray.dark["2"],
|
||||
},
|
||||
});
|
||||
export const getInitialBubbleTheme = (
|
||||
typebot?: Typebot,
|
||||
): BubbleProps["theme"] => {
|
||||
return {
|
||||
chatWindow: {
|
||||
backgroundColor:
|
||||
(typebot?.theme.general?.background?.type ?? defaultBackgroundType) ===
|
||||
BackgroundType.COLOR
|
||||
? (typebot?.theme.general?.background?.content ??
|
||||
defaultBackgroundColor[
|
||||
(typebot?.version ?? "6.1") as keyof typeof defaultBackgroundColor
|
||||
])
|
||||
: undefined,
|
||||
},
|
||||
button: {
|
||||
backgroundColor:
|
||||
typebot?.theme.chat?.buttons?.backgroundColor ?? colors.gray.dark["2"],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const JavascriptBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -3,14 +3,14 @@ import { ListItem, OrderedList, Stack, Text } from "@chakra-ui/react";
|
||||
import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { InstallNextjsPackageSnippet } from "../InstallNextjsPackageSnippet";
|
||||
import { NextjsBubbleSnippet } from "../NextjsBubbleSnippet";
|
||||
|
||||
export const NextjsBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -3,14 +3,14 @@ import { ListItem, OrderedList, Stack, Text } from "@chakra-ui/react";
|
||||
import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { InstallReactPackageSnippet } from "../InstallReactPackageSnippet";
|
||||
import { ReactBubbleSnippet } from "../ReactBubbleSnippet";
|
||||
|
||||
export const ReactBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -9,12 +9,12 @@ import {
|
||||
parseInlineScript,
|
||||
typebotImportCode,
|
||||
} from "../../../snippetParsers/shared";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const ScriptBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -4,13 +4,13 @@ import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../../Javascript/JavascriptBubbleSnippet";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const ShopifyBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -4,13 +4,13 @@ import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../../Javascript/JavascriptBubbleSnippet";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const WebflowBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -4,13 +4,13 @@ import type { BubbleProps } from "@typebot.io/js";
|
||||
import { useState } from "react";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { JavascriptBubbleSnippet } from "../../Javascript/JavascriptBubbleSnippet";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
|
||||
export const WixBubbleInstructions = () => {
|
||||
const { typebot } = useTypebot();
|
||||
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
|
||||
@ -16,7 +16,7 @@ import { useState } from "react";
|
||||
import packageJson from "../../../../../../../../../../packages/embeds/js/package.json";
|
||||
import { BubbleSettings } from "../../../settings/BubbleSettings/BubbleSettings";
|
||||
import { parseInitBubbleCode } from "../../../snippetParsers/bubble";
|
||||
import { parseDefaultBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { getInitialBubbleTheme } from "../../Javascript/instructions/JavascriptBubbleInstructions";
|
||||
import { typebotCloudLibraryVersion } from "./constants";
|
||||
|
||||
type Props = {
|
||||
@ -26,7 +26,7 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
|
||||
const { typebot } = useTypebot();
|
||||
|
||||
const [theme, setTheme] = useState<BubbleProps["theme"]>(
|
||||
parseDefaultBubbleTheme(typebot),
|
||||
getInitialBubbleTheme(typebot),
|
||||
);
|
||||
const [previewMessage, setPreviewMessage] =
|
||||
useState<BubbleProps["previewMessage"]>();
|
||||
@ -34,12 +34,7 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
|
||||
const initCode = parseInitBubbleCode({
|
||||
typebot: publicId,
|
||||
customDomain: typebot?.customDomain,
|
||||
theme: {
|
||||
...theme,
|
||||
chatWindow: {
|
||||
backgroundColor: typebot?.theme.general?.background?.content ?? "#fff",
|
||||
},
|
||||
},
|
||||
theme,
|
||||
previewMessage,
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user