diff --git a/web/app/components/base/action-button/index.css b/web/app/components/base/action-button/index.css new file mode 100644 index 0000000000..b87dbc8d4a --- /dev/null +++ b/web/app/components/base/action-button/index.css @@ -0,0 +1,49 @@ +@tailwind components; + +@layer components { + .action-btn { + @apply inline-flex justify-center items-center cursor-pointer text-text-tertiary + hover:text-text-secondary + hover:bg-state-base-hover + } + + .action-btn-disabled { + @apply cursor-not-allowed + } + + .action-btn-xl { + @apply p-2 w-9 h-9 rounded-lg + } + + .action-btn-l { + @apply p-1.5 w-[34px] h-[34px] rounded-lg + } + + /* m is for the regular button */ + .action-btn-m { + @apply p-0.5 w-6 h-6 rounded-lg + } + + .action-btn-xs { + @apply p-0 w-5 h-5 rounded + } + + .action-btn.action-btn-active { + @apply + text-text-accent + bg-state-accent-active + hover:bg-state-accent-active-alt + } + + .action-btn.action-btn-disabled { + @apply + text-text-disabled + } + + .action-btn.action-btn-destructive { + @apply + text-text-destructive + bg-state-destructive-hover + } + +} \ No newline at end of file diff --git a/web/app/components/base/action-button/index.tsx b/web/app/components/base/action-button/index.tsx new file mode 100644 index 0000000000..9e4552a2b7 --- /dev/null +++ b/web/app/components/base/action-button/index.tsx @@ -0,0 +1,70 @@ +import type { CSSProperties } from 'react' +import React from 'react' +import { type VariantProps, cva } from 'class-variance-authority' +import classNames from '@/utils/classnames' + +enum ActionButtonState { + Destructive = 'destructive', + Active = 'active', + Disabled = 'disabled', + Default = '', +} + +const actionButtonVariants = cva( + 'action-btn', + { + variants: { + size: { + xs: 'action-btn-xs', + m: 'action-btn-m', + l: 'action-btn-l', + xl: 'action-btn-xl', + }, + }, + defaultVariants: { + size: 'm', + }, + }, +) + +export type ActionButtonProps = { + size?: 'xs' | 'm' | 'l' | 'xl' + state?: ActionButtonState + styleCss?: CSSProperties +} & React.ButtonHTMLAttributes & VariantProps + +function getActionButtonState(state: ActionButtonState) { + switch (state) { + case ActionButtonState.Destructive: + return 'action-btn-destructive' + case ActionButtonState.Active: + return 'action-btn-active' + case ActionButtonState.Disabled: + return 'action-btn-disabled' + default: + return '' + } +} + +const ActionButton = React.forwardRef( + ({ className, size, state = ActionButtonState.Default, styleCss, children, ...props }, ref) => { + return ( + + ) + }, +) +ActionButton.displayName = 'ActionButton' + +export default ActionButton +export { ActionButton, ActionButtonState, actionButtonVariants } diff --git a/web/app/components/base/tooltip-plus/index.tsx b/web/app/components/base/tooltip-plus/index.tsx index 1dd2ac3ad6..b833690469 100644 --- a/web/app/components/base/tooltip-plus/index.tsx +++ b/web/app/components/base/tooltip-plus/index.tsx @@ -13,6 +13,7 @@ export type TooltipProps = { hideArrow?: boolean popupClassName?: string offset?: OffsetOptions + asChild?: boolean } const arrow = ( @@ -27,6 +28,7 @@ const Tooltip: FC = ({ hideArrow, popupClassName, offset, + asChild, }) => { const [open, setOpen] = useState(false) const [isHoverPopup, { @@ -79,6 +81,7 @@ const Tooltip: FC = ({ } }} onMouseLeave={() => triggerMethod === 'hover' && handleLeave(true)} + asChild={asChild} > {children} diff --git a/web/app/components/header/account-about/index.tsx b/web/app/components/header/account-about/index.tsx index e79d6c5725..6edd1b834b 100644 --- a/web/app/components/header/account-about/index.tsx +++ b/web/app/components/header/account-about/index.tsx @@ -45,7 +45,7 @@ export default function AccountAbout({ IS_CE_EDITION ? Open Source License : <> - Privacy Policy, + Privacy Policy, Terms of Service } diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index 873dc0f17e..daf4bddbc4 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -30,6 +30,7 @@ import s from '@/app/components/app/configuration/config-prompt/style.module.css import { useEventEmitterContextContext } from '@/context/event-emitter' import { PROMPT_EDITOR_INSERT_QUICKLY } from '@/app/components/base/prompt-editor/plugins/update-block' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' +import ActionButton from '@/app/components/base/action-button' import TooltipPlus from '@/app/components/base/tooltip-plus' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor/editor-support-vars' import Switch from '@/app/components/base/switch' @@ -128,7 +129,7 @@ const Editor: FC = ({
-
+
{title}
{value?.length || 0}
@@ -138,7 +139,7 @@ const Editor: FC = ({
{/* Operations */} -
+
{isSupportJinja && ( = ({ {!readOnly && ( - + + + )} {showRemove && ( - + + + )} {!isCopied ? ( - + + + ) : ( - + + + ) } diff --git a/web/app/components/workflow/nodes/_base/components/selector.tsx b/web/app/components/workflow/nodes/_base/components/selector.tsx index dcdc2a445d..104500f3c5 100644 --- a/web/app/components/workflow/nodes/_base/components/selector.tsx +++ b/web/app/components/workflow/nodes/_base/components/selector.tsx @@ -63,7 +63,7 @@ const TypeSelector: FC = ({
-
{!noValue ? item?.label : placeholder}
+
{!noValue ? item?.label : placeholder}
{!readonly && }
)} diff --git a/web/app/components/workflow/nodes/_base/components/toggle-expand-btn.tsx b/web/app/components/workflow/nodes/_base/components/toggle-expand-btn.tsx index 5d1be7c67d..8f31fd15b9 100644 --- a/web/app/components/workflow/nodes/_base/components/toggle-expand-btn.tsx +++ b/web/app/components/workflow/nodes/_base/components/toggle-expand-btn.tsx @@ -5,6 +5,7 @@ import { RiCollapseDiagonalLine, RiExpandDiagonalLine, } from '@remixicon/react' +import ActionButton from '@/app/components/base/action-button' type Props = { isExpand: boolean @@ -21,7 +22,9 @@ const ExpandBtn: FC = ({ const Icon = isExpand ? RiCollapseDiagonalLine : RiExpandDiagonalLine return ( - + + + ) } export default React.memo(ExpandBtn) diff --git a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx index ed8e7df770..10fb4a1f4b 100644 --- a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx +++ b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx @@ -4,6 +4,7 @@ import React, { useCallback } from 'react' import { useBoolean } from 'ahooks' import cn from 'classnames' import { Generator } from '@/app/components/base/icons/src/vender/other' +import { ActionButton } from '@/app/components/base/action-button' import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res' import { AppType } from '@/types/app' import type { AutomaticRes } from '@/service/debug' @@ -28,9 +29,11 @@ const PromptGeneratorBtn: FC = ({ }, [onGenerated, showAutomaticFalse]) return (
-
- -
+ + + {showAutomatic && (