From f51258a79616bb565b945735e6866ab398a30399 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 8 Oct 2024 11:38:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20button=20shrink=20in=20som?= =?UTF-8?q?e=20embed=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/deprecated/bot-engine/package.json | 2 +- packages/deprecated/typebot-js/package.json | 2 +- packages/embeds/js/package.json | 4 +-- packages/embeds/js/src/components/Button.tsx | 34 +++++++++++-------- .../embeds/js/src/components/SendButton.tsx | 22 +++++++----- packages/embeds/nextjs/package.json | 4 +-- packages/embeds/react/package.json | 4 +-- packages/embeds/wordpress/package.json | 2 +- 8 files changed, 41 insertions(+), 33 deletions(-) diff --git a/packages/deprecated/bot-engine/package.json b/packages/deprecated/bot-engine/package.json index 730cc13afd..e79d040fcf 100644 --- a/packages/deprecated/bot-engine/package.json +++ b/packages/deprecated/bot-engine/package.json @@ -1,7 +1,7 @@ { "name": "bot-engine", "private": true, - "license": "AGPL-3.0-or-later", + "license": "FSL-1.1-ALv2", "version": "0.1.0", "type": "module", "scripts": { diff --git a/packages/deprecated/typebot-js/package.json b/packages/deprecated/typebot-js/package.json index b1db788016..04de43d084 100644 --- a/packages/deprecated/typebot-js/package.json +++ b/packages/deprecated/typebot-js/package.json @@ -3,7 +3,7 @@ "version": "2.2.17", "main": "dist/index.js", "unpkg": "dist/index.global.js", - "license": "AGPL-3.0-or-later", + "license": "FSL-1.1-ALv2", "scripts": { "dev": "tsup --watch", "build": "tsup", diff --git a/packages/embeds/js/package.json b/packages/embeds/js/package.json index f206a0214e..1b5ff8e22f 100644 --- a/packages/embeds/js/package.json +++ b/packages/embeds/js/package.json @@ -1,8 +1,8 @@ { "name": "@typebot.io/js", - "version": "0.3.18", + "version": "0.3.19", "description": "Javascript library to display typebots on your website", - "license": "AGPL-3.0-or-later", + "license": "FSL-1.1-ALv2", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/embeds/js/src/components/Button.tsx b/packages/embeds/js/src/components/Button.tsx index 6adf5d4277..21747ddfa6 100644 --- a/packages/embeds/js/src/components/Button.tsx +++ b/packages/embeds/js/src/components/Button.tsx @@ -1,31 +1,35 @@ +import clsx from "clsx"; import { type JSX, Show, children, splitProps } from "solid-js"; import { Spinner } from "./Spinner"; -type Props = { +export type ButtonProps = { variant?: "primary" | "secondary"; - children: JSX.Element; isDisabled?: boolean; isLoading?: boolean; -} & JSX.ButtonHTMLAttributes; +} & Pick< + JSX.ButtonHTMLAttributes, + "class" | "children" | "type" | "on:click" +>; -export const Button = (props: Props) => { +export const Button = (props: ButtonProps) => { const childrenReturn = children(() => props.children); - const [local, buttonProps] = splitProps(props, ["disabled", "class"]); + const [local, buttonProps] = splitProps(props, [ + "variant", + "isDisabled", + "isLoading", + ]); return ( diff --git a/packages/embeds/js/src/components/SendButton.tsx b/packages/embeds/js/src/components/SendButton.tsx index 4d71025a35..9d0f66597c 100644 --- a/packages/embeds/js/src/components/SendButton.tsx +++ b/packages/embeds/js/src/components/SendButton.tsx @@ -1,28 +1,32 @@ import { isMobile } from "@/utils/isMobileSignal"; import { isEmpty } from "@typebot.io/lib/utils"; import clsx from "clsx"; -import { type JSX, Match, Switch, splitProps } from "solid-js"; -import { Button } from "./Button"; +import { Match, Switch, splitProps } from "solid-js"; +import { Button, type ButtonProps } from "./Button"; import { SendIcon } from "./icons/SendIcon"; type SendButtonProps = { isDisabled?: boolean; isLoading?: boolean; disableIcon?: boolean; - class?: string; -} & JSX.ButtonHTMLAttributes; +} & ButtonProps; export const SendButton = (props: SendButtonProps) => { - const [local, others] = splitProps(props, ["disableIcon"]); + const [local, buttonProps] = splitProps(props, [ + "isDisabled", + "isLoading", + "disableIcon", + ]); + const showIcon = (isMobile() && !local.disableIcon) || - !props.children || - (typeof props.children === "string" && isEmpty(props.children)); + !buttonProps.children || + (typeof buttonProps.children === "string" && isEmpty(buttonProps.children)); return (