From 6e43839d2992ad21a5eb34e126d5c1138349c34a Mon Sep 17 00:00:00 2001 From: Po Chun Chiu <57251712+EiffelFly@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:58:17 +0800 Subject: [PATCH] fix: fix useInstillForm field's description tooltip break words issue (#937) Because - The fields of useInstillForm are using the same tooltip to show complicated description, there break-words rule is not correct - close https://github.com/instill-ai/community/issues/533 This commit - fix useInstillForm field's description tooltip break words issue --- .../common/FieldDescriptionTooltip.tsx | 34 ++++++++++++++++ .../components/common/index.ts | 1 + .../components/regular/BooleanField.tsx | 34 ++-------------- .../regular/CredentialTextField.tsx | 39 ++---------------- .../regular/OneOfConditionField.tsx | 39 ++---------------- .../components/regular/SingleSelectField.tsx | 39 ++---------------- .../components/regular/TextAreaField.tsx | 39 ++---------------- .../components/regular/TextField.tsx | 39 ++---------------- .../smart-hint/SmartHintInfoCard.tsx | 13 +++--- .../components/smart-hint/TextArea.tsx | 40 ++----------------- .../components/smart-hint/TextField.tsx | 40 ++----------------- 11 files changed, 67 insertions(+), 290 deletions(-) create mode 100644 packages/toolkit/src/lib/use-instill-form/components/common/FieldDescriptionTooltip.tsx create mode 100644 packages/toolkit/src/lib/use-instill-form/components/common/index.ts diff --git a/packages/toolkit/src/lib/use-instill-form/components/common/FieldDescriptionTooltip.tsx b/packages/toolkit/src/lib/use-instill-form/components/common/FieldDescriptionTooltip.tsx new file mode 100644 index 0000000000..e9f4442d23 --- /dev/null +++ b/packages/toolkit/src/lib/use-instill-form/components/common/FieldDescriptionTooltip.tsx @@ -0,0 +1,34 @@ +import { Icons, ParagraphWithHTML, Tooltip } from "@instill-ai/design-system"; +import { Nullable } from "../../../type"; + +export const FieldDescriptionTooltip = ({ + description, +}: { + description: Nullable; +}) => { + return description ? ( + + + + + + + +
+ +
+ +
+
+
+
+ ) : null; +}; diff --git a/packages/toolkit/src/lib/use-instill-form/components/common/index.ts b/packages/toolkit/src/lib/use-instill-form/components/common/index.ts new file mode 100644 index 0000000000..676ecac81b --- /dev/null +++ b/packages/toolkit/src/lib/use-instill-form/components/common/index.ts @@ -0,0 +1 @@ +export * from "./FieldDescriptionTooltip"; diff --git a/packages/toolkit/src/lib/use-instill-form/components/regular/BooleanField.tsx b/packages/toolkit/src/lib/use-instill-form/components/regular/BooleanField.tsx index 8162a0b7c7..cceec49e42 100644 --- a/packages/toolkit/src/lib/use-instill-form/components/regular/BooleanField.tsx +++ b/packages/toolkit/src/lib/use-instill-form/components/regular/BooleanField.tsx @@ -1,6 +1,6 @@ -import { Form, Icons, Switch, Tooltip } from "@instill-ai/design-system"; -import { ParagraphWithHTML } from "@instill-ai/design-system"; +import { Form, Switch } from "@instill-ai/design-system"; import type { AutoFormFieldBaseProps } from "../../type"; +import { FieldDescriptionTooltip } from "../common"; export const BooleanField = ({ form, @@ -29,35 +29,7 @@ export const BooleanField = ({ > {title} - {description ? ( - - - - - - - -
- -
- -
-
-
-
- ) : null} + {title} - {description ? ( - - - - - - - -
- -
- -
-
-
-
- ) : null} + diff --git a/packages/toolkit/src/lib/use-instill-form/components/regular/OneOfConditionField.tsx b/packages/toolkit/src/lib/use-instill-form/components/regular/OneOfConditionField.tsx index 933c831aa3..0507ad2586 100644 --- a/packages/toolkit/src/lib/use-instill-form/components/regular/OneOfConditionField.tsx +++ b/packages/toolkit/src/lib/use-instill-form/components/regular/OneOfConditionField.tsx @@ -1,11 +1,5 @@ import cn from "clsx"; -import { - Form, - Icons, - ParagraphWithHTML, - Select, - Tooltip, -} from "@instill-ai/design-system"; +import { Form, Select } from "@instill-ai/design-system"; import * as React from "react"; import { recursivelyResetFormData } from "../../transform"; import { Nullable } from "../../../type"; @@ -14,6 +8,7 @@ import { InstillFormTree, SelectedConditionMap, } from "../../type"; +import { FieldDescriptionTooltip } from "../common"; export const OneOfConditionField = ({ form, @@ -84,35 +79,7 @@ export const OneOfConditionField = ({ > {title} - {description ? ( - - - - - - - -
- -
- -
-
-
-
- ) : null} + { diff --git a/packages/toolkit/src/lib/use-instill-form/components/regular/SingleSelectField.tsx b/packages/toolkit/src/lib/use-instill-form/components/regular/SingleSelectField.tsx index 455aa7ef2d..42a5ee76eb 100644 --- a/packages/toolkit/src/lib/use-instill-form/components/regular/SingleSelectField.tsx +++ b/packages/toolkit/src/lib/use-instill-form/components/regular/SingleSelectField.tsx @@ -1,12 +1,7 @@ import cn from "clsx"; -import { - Form, - Icons, - ParagraphWithHTML, - Select, - Tooltip, -} from "@instill-ai/design-system"; +import { Form, Select } from "@instill-ai/design-system"; import { AutoFormFieldBaseProps } from "../../type"; +import { FieldDescriptionTooltip } from "../common"; export const SingleSelectField = ({ form, @@ -37,35 +32,7 @@ export const SingleSelectField = ({ > {title} - {description ? ( - - - - - - - -
- -
- -
-
-
-
- ) : null} + { diff --git a/packages/toolkit/src/lib/use-instill-form/components/regular/TextAreaField.tsx b/packages/toolkit/src/lib/use-instill-form/components/regular/TextAreaField.tsx index a882493f2e..e618718798 100644 --- a/packages/toolkit/src/lib/use-instill-form/components/regular/TextAreaField.tsx +++ b/packages/toolkit/src/lib/use-instill-form/components/regular/TextAreaField.tsx @@ -1,12 +1,7 @@ import cn from "clsx"; -import { - Form, - Icons, - ParagraphWithHTML, - Textarea, - Tooltip, -} from "@instill-ai/design-system"; +import { Form, Textarea } from "@instill-ai/design-system"; import { AutoFormFieldBaseProps } from "../../type"; +import { FieldDescriptionTooltip } from "../common"; export const TextAreaField = ({ form, @@ -34,35 +29,7 @@ export const TextAreaField = ({ > {title} - {description ? ( - - - - - - - -
- -
- -
-
-
-
- ) : null} +