Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate semantic icon controls (#40624)

yyhd0e2723e4579
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 63f631fe99f..40c8240e344 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -582,11 +582,6 @@
"count": 1
}
},
- "web/app/components/base/action-button/index.tsx": {
- "erasable-syntax-only/enums": {
- "count": 1
- }
- },
"web/app/components/base/agent-log-modal/detail.tsx": {
"typescript/no-explicit-any": {
"count": 1
@@ -725,11 +720,6 @@
"count": 2
}
},
- "web/app/components/base/chat/chat-with-history/sidebar/operation.tsx": {
- "eslint-react/set-state-in-effect": {
- "count": 1
- }
- },
"web/app/components/base/chat/chat-with-history/sidebar/rename-modal.tsx": {
"no-restricted-imports": {
"count": 1
@@ -1194,7 +1184,7 @@
},
"web/app/components/base/icons/src/vender/line/arrows/index.ts": {
"no-barrel-files/no-barrel-files": {
- "count": 5
+ "count": 4
}
},
"web/app/components/base/icons/src/vender/line/communication/index.ts": {
@@ -1244,7 +1234,7 @@
},
"web/app/components/base/icons/src/vender/line/others/index.ts": {
"no-barrel-files/no-barrel-files": {
- "count": 7
+ "count": 5
}
},
"web/app/components/base/icons/src/vender/line/time/index.ts": {
diff --git a/web/app/components/app/configuration/debug/__tests__/index.spec.tsx b/web/app/components/app/configuration/debug/__tests__/index.spec.tsx
index 82c5543d4a2..a1c68fcb783 100644
--- a/web/app/components/app/configuration/debug/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/debug/__tests__/index.spec.tsx
@@ -156,23 +156,6 @@ vi.mock('@/app/components/app/text-generate/item', () => ({
),
}))
-vi.mock('@/app/components/base/action-button', () => ({
- default: ({
- children,
- state,
- ...props
- }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
- state?: string
- }) => (
- <button type="button" data-testid="action-button" data-state={state} {...props}>
- {children}
- </button>
- ),
- ActionButtonState: {
- Active: 'active',
- },
-}))
-
vi.mock('@/app/components/base/agent-log-modal', () => ({
default: ({ onCancel }: { onCancel: () => void }) => (
<div data-testid="agent-log-modal">
diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsx
index 7b7e9898edb..58be6575175 100644
--- a/web/app/components/app/configuration/debug/index.tsx
+++ b/web/app/components/app/configuration/debug/index.tsx
@@ -6,9 +6,9 @@ import type { ModelParameterModalProps } from '@/app/components/header/account-s
import type { Inputs } from '@/models/debug'
import type { ModelConfig as BackendModelConfig, VisionFile, VisionSettings } from '@/types/app'
import { Button } from '@langgenius/dify-ui/button'
+import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
-import { RiAddLine, RiEqualizer2Line, RiSparklingFill } from '@remixicon/react'
import { useBoolean } from 'ahooks'
import { noop } from 'es-toolkit/function'
import { cloneDeep } from 'es-toolkit/object'
@@ -23,10 +23,8 @@ import PromptValuePanel from '@/app/components/app/configuration/prompt-value-pa
import { toast } from '@/app/components/app/configuration/toast'
import { useStore as useAppStore } from '@/app/components/app/store'
import TextGeneration from '@/app/components/app/text-generate/item'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
import AgentLogModal from '@/app/components/base/agent-log-modal'
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
-import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
import PromptLogModal from '@/app/components/base/prompt-log-modal'
import {
ModelFeatureEnum,
@@ -411,7 +409,7 @@ const Debug: FC<IDebug> = ({
return (
<>
- <div className="shrink-0">
+ <Collapsible open={expanded} onOpenChange={setExpanded} render={<div className="shrink-0" />}>
<div className="flex items-center justify-between px-4 pt-3 pb-2">
<div className="system-xl-semibold text-text-primary">
{t(($) => $['inputs.title'], { ns: 'appDebug' })}
@@ -429,7 +427,7 @@ const Debug: FC<IDebug> = ({
}
disabled={multipleModelConfigs.length >= 4 || !canTestAndRun}
>
- <RiAddLine className="size-3.5" />
+ <span aria-hidden="true" className="i-ri-add-line size-3.5" />
{t(($) => $['modelProvider.addModel'], { ns: 'common' })}(
{multipleModelConfigs.length}
/4)
@@ -447,7 +445,10 @@ const Debug: FC<IDebug> = ({
aria-label={t(($) => $['operation.refresh'], { ns: 'common' })}
onClick={clearConversation}
>
- <RefreshCcw01 aria-hidden="true" className="size-4" />
+ <span
+ aria-hidden="true"
+ className="i-custom-vender-line-arrows-refresh-ccw-01 size-4"
+ />
</IconButton>
}
/>
@@ -462,15 +463,17 @@ const Debug: FC<IDebug> = ({
<Tooltip>
<TooltipTrigger
render={
- <ActionButton
- aria-expanded={expanded}
- aria-label={t(($) => $['panel.userInputField'], { ns: 'workflow' })}
- state={expanded ? ActionButtonState.Active : undefined}
- disabled={!canTestAndRun}
- onClick={() => setExpanded(!expanded)}
- >
- <RiEqualizer2Line aria-hidden="true" className="size-4" />
- </ActionButton>
+ <CollapsibleTrigger
+ className="size-6 min-h-0 justify-center gap-0 p-0.5 hover:not-data-disabled:text-text-secondary data-panel-open:bg-state-accent-active data-panel-open:text-text-accent data-panel-open:hover:bg-state-accent-active-alt"
+ render={
+ <IconButton
+ aria-label={t(($) => $['panel.userInputField'], { ns: 'workflow' })}
+ disabled={!canTestAndRun}
+ >
+ <span aria-hidden="true" className="i-ri-equalizer-2-line size-4" />
+ </IconButton>
+ }
+ />
}
/>
<TooltipContent>
@@ -486,10 +489,10 @@ const Debug: FC<IDebug> = ({
)}
</div>
</div>
- {mode !== AppModeEnum.COMPLETION && expanded && (
- <div className="mx-3">
+ {mode !== AppModeEnum.COMPLETION && (
+ <CollapsiblePanel render={<div className="mx-3" />}>
<ChatUserInput inputs={inputs} />
- </div>
+ </CollapsiblePanel>
)}
{mode === AppModeEnum.COMPLETION && (
<PromptValuePanel
@@ -504,7 +507,7 @@ const Debug: FC<IDebug> = ({
onVisionFilesChange={setCompletionFiles}
/>
)}
- </div>
+ </Collapsible>
{debugWithMultipleModel && (
<div className="mt-3 grow overflow-hidden" ref={ref}>
<DebugWithMultipleModel
@@ -591,7 +594,10 @@ const Debug: FC<IDebug> = ({
)}
{!completionRes && !isResponding && (
<div className="flex grow flex-col items-center justify-center gap-2">
- <RiSparklingFill className="size-12 text-text-empty-state-icon" />
+ <span
+ aria-hidden="true"
+ className="i-ri-sparkling-fill size-12 text-text-empty-state-icon"
+ />
<div className="system-sm-regular text-text-quaternary">
{t(($) => $.noResult, { ns: 'appDebug' })}
</div>
diff --git a/web/app/components/app/text-generate/item/__tests__/action-groups.spec.tsx b/web/app/components/app/text-generate/item/__tests__/action-groups.spec.tsx
index 71f96629775..775f0e3cc57 100644
--- a/web/app/components/app/text-generate/item/__tests__/action-groups.spec.tsx
+++ b/web/app/components/app/text-generate/item/__tests__/action-groups.spec.tsx
@@ -1,4 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
import { AppSourceType } from '@/service/share'
import GenerationActionGroups from '../action-groups'
@@ -173,7 +174,9 @@ describe('GenerationActionGroups', () => {
expect(mockOnRetry).toHaveBeenCalledTimes(1)
})
- it('should support disagree and cancel feedback actions', () => {
+ it('should support disagree and cancel feedback actions', async () => {
+ const user = userEvent.setup()
+
const { rerender } = render(
<GenerationActionGroups
appSourceType={AppSourceType.webApp}
@@ -191,7 +194,11 @@ describe('GenerationActionGroups', () => {
/>,
)
- fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)operation\.disagree(?=$|:)/ }))
+ const disagreeButton = screen.getByRole('button', {
+ name: /(?:^|\.)operation\.disagree(?=$|:)/,
+ })
+ expect(disagreeButton).toHaveAttribute('aria-pressed', 'false')
+ await user.click(disagreeButton)
expect(mockOnFeedback).toHaveBeenCalledWith({ rating: 'dislike' })
rerender(
@@ -211,7 +218,11 @@ describe('GenerationActionGroups', () => {
/>,
)
- fireEvent.click(screen.getByRole('button', { name: /(?:^|\.)operation\.cancelAgree(?=$|:)/ }))
+ const agreeButton = screen.getByRole('button', {
+ name: /(?:^|\.)operation\.agree(?=$|:)/,
+ })
+ expect(agreeButton).toHaveAttribute('aria-pressed', 'true')
+ await user.click(agreeButton)
expect(mockOnFeedback).toHaveBeenCalledWith({ rating: null })
rerender(
@@ -231,9 +242,11 @@ describe('GenerationActionGroups', () => {
/>,
)
- fireEvent.click(
- screen.getByRole('button', { name: /(?:^|\.)operation\.cancelDisagree(?=$|:)/ }),
- )
+ const selectedDisagreeButton = screen.getByRole('button', {
+ name: /(?:^|\.)operation\.disagree(?=$|:)/,
+ })
+ expect(selectedDisagreeButton).toHaveAttribute('aria-pressed', 'true')
+ await user.click(selectedDisagreeButton)
expect(mockOnFeedback).toHaveBeenCalledWith({ rating: null })
})
})
diff --git a/web/app/components/app/text-generate/item/action-groups.tsx b/web/app/components/app/text-generate/item/action-groups.tsx
index d54c2f4c5ab..b07a224ba59 100644
--- a/web/app/components/app/text-generate/item/action-groups.tsx
+++ b/web/app/components/app/text-generate/item/action-groups.tsx
@@ -5,22 +5,18 @@ import type { WorkflowProcess } from '@/app/components/base/chat/types'
import type { AppSourceType } from '@/service/share'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { toast } from '@langgenius/dify-ui/toast'
-import {
- RiBookmark3Line,
- RiClipboardLine,
- RiFileList3Line,
- RiResetLeftLine,
- RiSparklingLine,
- RiThumbDownLine,
- RiThumbUpLine,
-} from '@remixicon/react'
+import { Toggle } from '@langgenius/dify-ui/toggle'
import copy from 'copy-to-clipboard'
import { useTranslation } from 'react-i18next'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
import NewAudioButton from '@/app/components/base/new-audio-button'
import { AppSourceType as AppSourceTypeEnum } from '@/service/share'
import { getCopyContent, MAX_GENERATION_DEPTH } from './utils'
+const accentPressedClassName =
+ 'data-pressed:bg-state-accent-active data-pressed:text-text-accent data-pressed:hover:bg-state-accent-active-alt'
+const destructivePressedClassName =
+ 'data-pressed:bg-state-destructive-hover data-pressed:text-text-destructive data-pressed:hover:bg-state-destructive-hover data-pressed:hover:text-text-destructive'
+
type GenerationActionGroupsProps = {
appSourceType: AppSourceType
content: unknown
@@ -85,7 +81,7 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
title={t(($) => $['operation.log'], { ns: 'common' })}
onClick={onOpenLogModal}
>
- <RiFileList3Line aria-hidden="true" className="size-4" />
+ <span aria-hidden="true" className="i-ri-file-list-3-line size-4" />
</IconButton>
</div>
)}
@@ -97,7 +93,7 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
title={t(($) => $['feature.moreLikeThis.title'], { ns: 'appDebug' })}
onClick={onMoreLikeThis}
>
- <RiSparklingLine aria-hidden="true" className="size-4" />
+ <span aria-hidden="true" className="i-ri-sparkling-line size-4" />
</IconButton>
)}
{isShowTextToSpeech && !isTryApp && <NewAudioButton id={messageId!} voice={voice} />}
@@ -113,7 +109,7 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' }))
}}
>
- <RiClipboardLine aria-hidden="true" className="size-4" />
+ <span aria-hidden="true" className="i-ri-clipboard-line size-4" />
</IconButton>
)}
{isInWebApp && isError && (
@@ -122,7 +118,7 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
title={t(($) => $['generation.batchFailed.retry'], { ns: 'share' })}
onClick={onRetry}
>
- <RiResetLeftLine aria-hidden="true" className="size-4" />
+ <span aria-hidden="true" className="i-ri-reset-left-line size-4" />
</IconButton>
)}
{isInWebApp && !isWorkflow && !isTryApp && (
@@ -134,7 +130,7 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
onSave?.(messageId as string)
}}
>
- <RiBookmark3Line aria-hidden="true" className="size-4" />
+ <span aria-hidden="true" className="i-ri-bookmark-3-line size-4" />
</IconButton>
)}
</div>
@@ -142,41 +138,63 @@ const GenerationActionGroups: FC<GenerationActionGroupsProps> = ({
<div className="ml-1 flex items-center gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-xs">
{!feedback?.rating && (
<>
- <ActionButton
- aria-label={t(($) => $['operation.agree'], { ns: 'appDebug' })}
- title={t(($) => $['operation.agree'], { ns: 'appDebug' })}
- onClick={() => onFeedback?.({ rating: 'like' })}
- >
- <RiThumbUpLine className="size-4" />
- </ActionButton>
- <ActionButton
- aria-label={t(($) => $['operation.disagree'], { ns: 'appDebug' })}
- title={t(($) => $['operation.disagree'], { ns: 'appDebug' })}
- onClick={() => onFeedback?.({ rating: 'dislike' })}
- >
- <RiThumbDownLine className="size-4" />
- </ActionButton>
+ <Toggle
+ className={accentPressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && onFeedback?.({ rating: 'like' })}
+ render={
+ <IconButton
+ aria-label={t(($) => $['operation.agree'], { ns: 'appDebug' })}
+ title={t(($) => $['operation.agree'], { ns: 'appDebug' })}
+ >
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ </IconButton>
+ }
+ />
+ <Toggle
+ className={destructivePressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && onFeedback?.({ rating: 'dislike' })}
+ render={
+ <IconButton
+ aria-label={t(($) => $['operation.disagree'], { ns: 'appDebug' })}
+ title={t(($) => $['operation.disagree'], { ns: 'appDebug' })}
+ >
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ </IconButton>
+ }
+ />
</>
)}
{feedback?.rating === 'like' && (
- <ActionButton
- aria-label={t(($) => $['operation.cancelAgree'], { ns: 'appDebug' })}
- state={ActionButtonState.Active}
- title={t(($) => $['operation.cancelAgree'], { ns: 'appDebug' })}
- onClick={() => onFeedback?.({ rating: null })}
- >
- <RiThumbUpLine className="size-4" />
- </ActionButton>
+ <Toggle
+ className={accentPressedClassName}
+ pressed
+ onPressedChange={(pressed) => !pressed && onFeedback?.({ rating: null })}
+ render={
+ <IconButton
+ aria-label={t(($) => $['operation.agree'], { ns: 'appDebug' })}
+ title={t(($) => $['operation.cancelAgree'], { ns: 'appDebug' })}
+ >
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ </IconButton>
+ }
+ />
)}
{feedback?.rating === 'dislike' && (
- <ActionButton
- aria-label={t(($) => $['operation.cancelDisagree'], { ns: 'appDebug' })}
- state={ActionButtonState.Destructive}
- title={t(($) => $['operation.cancelDisagree'], { ns: 'appDebug' })}
- onClick={() => onFeedback?.({ rating: null })}
- >
- <RiThumbDownLine className="size-4" />
- </ActionButton>
+ <Toggle
+ className={destructivePressedClassName}
+ pressed
+ onPressedChange={(pressed) => !pressed && onFeedback?.({ rating: null })}
+ render={
+ <IconButton
+ aria-label={t(($) => $['operation.disagree'], { ns: 'appDebug' })}
+ title={t(($) => $['operation.cancelDisagree'], { ns: 'appDebug' })}
+ >
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ </IconButton>
+ }
+ />
)}
</div>
)}
diff --git a/web/app/components/base/action-button/index.stories.tsx b/web/app/components/base/action-button/index.stories.tsx
deleted file mode 100644
index 06b489b8b0d..00000000000
--- a/web/app/components/base/action-button/index.stories.tsx
+++ /dev/null
@@ -1,270 +0,0 @@
-import type { Meta, StoryObj } from '@storybook/nextjs-vite'
-import {
- RiAddLine,
- RiDeleteBinLine,
- RiEditLine,
- RiMore2Fill,
- RiSaveLine,
- RiShareLine,
-} from '@remixicon/react'
-import ActionButton, { ActionButtonState } from '.'
-
-const meta = {
- title: 'Base/General/ActionButton',
- component: ActionButton,
- parameters: {
- layout: 'centered',
- docs: {
- description: {
- component:
- 'Action button component with multiple sizes and states. Commonly used for toolbar actions and inline operations.',
- },
- },
- },
- tags: ['autodocs'],
- argTypes: {
- size: {
- control: 'select',
- options: ['xs', 'm', 'l', 'xl'],
- description: 'Button size',
- },
- state: {
- control: 'select',
- options: [
- ActionButtonState.Default,
- ActionButtonState.Active,
- ActionButtonState.Disabled,
- ActionButtonState.Destructive,
- ActionButtonState.Hover,
- ],
- description: 'Button state',
- },
- children: {
- control: 'text',
- description: 'Button content',
- },
- disabled: {
- control: 'boolean',
- description: 'Native disabled state',
- },
- },
-} satisfies Meta<typeof ActionButton>
-
-export default meta
-type Story = StoryObj<typeof meta>
-
-// Default state
-export const Default: Story = {
- args: {
- size: 'm',
- children: <RiEditLine className="size-4" />,
- },
-}
-
-// With text
-export const WithText: Story = {
- args: {
- size: 'm',
- children: 'Edit',
- },
-}
-
-// Icon with text
-export const IconWithText: Story = {
- args: {
- size: 'm',
- children: (
- <>
- <RiAddLine className="mr-1 size-4" />
- Add Item
- </>
- ),
- },
-}
-
-// Size variations
-export const ExtraSmall: Story = {
- args: {
- size: 'xs',
- children: <RiEditLine className="size-3" />,
- },
-}
-
-export const Small: Story = {
- args: {
- size: 'xs',
- children: <RiEditLine className="size-3.5" />,
- },
-}
-
-export const Medium: Story = {
- args: {
- size: 'm',
- children: <RiEditLine className="size-4" />,
- },
-}
-
-export const Large: Story = {
- args: {
- size: 'l',
- children: <RiEditLine className="size-5" />,
- },
-}
-
-export const ExtraLarge: Story = {
- args: {
- size: 'xl',
- children: <RiEditLine className="size-6" />,
- },
-}
-
-// State variations
-export const ActiveState: Story = {
- args: {
- size: 'm',
- state: ActionButtonState.Active,
- children: <RiEditLine className="size-4" />,
- },
-}
-
-export const DisabledState: Story = {
- args: {
- size: 'm',
- state: ActionButtonState.Disabled,
- children: <RiEditLine className="size-4" />,
- },
-}
-
-export const DestructiveState: Story = {
- args: {
- size: 'm',
- state: ActionButtonState.Destructive,
- children: <RiDeleteBinLine className="size-4" />,
- },
-}
-
-export const HoverState: Story = {
- args: {
- size: 'm',
- state: ActionButtonState.Hover,
- children: <RiEditLine className="size-4" />,
- },
-}
-
-// Real-world examples
-export const ToolbarActions: Story = {
- render: () => (
- <div className="flex items-center gap-1 rounded-lg bg-background-section-burn p-2">
- <ActionButton size="m">
- <RiEditLine className="size-4" />
- </ActionButton>
- <ActionButton size="m">
- <RiShareLine className="size-4" />
- </ActionButton>
- <ActionButton size="m">
- <RiSaveLine className="size-4" />
- </ActionButton>
- <div className="mx-1 h-4 w-px bg-divider-regular" />
- <ActionButton size="m" state={ActionButtonState.Destructive}>
- <RiDeleteBinLine className="size-4" />
- </ActionButton>
- </div>
- ),
-}
-
-export const InlineActions: Story = {
- render: () => (
- <div className="flex items-center gap-2">
- <span className="text-text-secondary">Item name</span>
- <ActionButton size="xs">
- <RiEditLine className="size-3.5" />
- </ActionButton>
- <ActionButton size="xs">
- <RiMore2Fill className="size-3.5" />
- </ActionButton>
- </div>
- ),
-}
-
-export const SizeComparison: Story = {
- render: () => (
- <div className="flex items-center gap-4">
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="xs">
- <RiEditLine className="size-3" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">XS</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="xs">
- <RiEditLine className="size-3.5" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">S</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m">
- <RiEditLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">M</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="l">
- <RiEditLine className="size-5" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">L</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="xl">
- <RiEditLine className="size-6" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">XL</span>
- </div>
- </div>
- ),
-}
-
-export const StateComparison: Story = {
- render: () => (
- <div className="flex items-center gap-4">
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m" state={ActionButtonState.Default}>
- <RiEditLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">Default</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m" state={ActionButtonState.Active}>
- <RiEditLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">Active</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m" state={ActionButtonState.Hover}>
- <RiEditLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">Hover</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m" state={ActionButtonState.Disabled}>
- <RiEditLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">Disabled</span>
- </div>
- <div className="flex flex-col items-center gap-2">
- <ActionButton size="m" state={ActionButtonState.Destructive}>
- <RiDeleteBinLine className="size-4" />
- </ActionButton>
- <span className="text-xs text-text-tertiary">Destructive</span>
- </div>
- </div>
- ),
-}
-
-// Interactive playground
-export const Playground: Story = {
- args: {
- size: 'm',
- state: ActionButtonState.Default,
- children: <RiEditLine className="size-4" />,
- },
-}
diff --git a/web/app/components/base/action-button/index.tsx b/web/app/components/base/action-button/index.tsx
deleted file mode 100644
index 87cc1104f80..00000000000
--- a/web/app/components/base/action-button/index.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import type { VariantProps } from 'class-variance-authority'
-import type { CSSProperties } from 'react'
-import { cn } from '@langgenius/dify-ui/cn'
-import { cva } from 'class-variance-authority'
-import * as React from 'react'
-
-enum ActionButtonState {
- Destructive = 'destructive',
- Active = 'active',
- Disabled = 'disabled',
- Default = '',
- Hover = 'hover',
-}
-
-const actionButtonVariants = cva('action-btn', {
- variants: {
- size: {
- xs: 'action-btn-xs',
- s: 'action-btn-s',
- m: 'action-btn-m',
- l: 'action-btn-l',
- xl: 'action-btn-xl',
- },
- },
- defaultVariants: {
- size: 'm',
- },
-})
-
-type ActionButtonProps = {
- size?: 'xs' | 's' | 'm' | 'l' | 'xl'
- state?: ActionButtonState
- styleCss?: CSSProperties
- ref?: React.Ref<HTMLButtonElement>
-} & React.ButtonHTMLAttributes<HTMLButtonElement> &
- VariantProps<typeof actionButtonVariants>
-
-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'
- case ActionButtonState.Hover:
- return 'action-btn-hover'
- default:
- return ''
- }
-}
-
-const ActionButton = ({
- className,
- size,
- state = ActionButtonState.Default,
- styleCss,
- children,
- ref,
- disabled,
- ...props
-}: ActionButtonProps) => {
- return (
- <button
- type="button"
- className={cn(
- actionButtonVariants({ className, size }),
- getActionButtonState(state),
- disabled &&
- 'cursor-not-allowed text-text-disabled hover:bg-transparent hover:text-text-disabled',
- )}
- disabled={disabled}
- ref={ref}
- style={styleCss}
- {...props}
- >
- {children}
- </button>
- )
-}
-ActionButton.displayName = 'ActionButton'
-
-export default ActionButton
-export { ActionButtonState }
diff --git a/web/app/components/base/chat/chat-with-history/header/__tests__/mobile-operation-dropdown.spec.tsx b/web/app/components/base/chat/chat-with-history/header/__tests__/mobile-operation-dropdown.spec.tsx
index b222ab20db1..d55e07b6b16 100644
--- a/web/app/components/base/chat/chat-with-history/header/__tests__/mobile-operation-dropdown.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/header/__tests__/mobile-operation-dropdown.spec.tsx
@@ -18,19 +18,15 @@ describe('MobileOperationDropdown Component', () => {
const user = userEvent.setup()
render(<MobileOperationDropdown {...defaultProps} />)
- // Trigger button should be present (ActionButton renders a button)
const trigger = screen.getByRole('button', { name: 'common.operation.more' })
expect(trigger).toBeInTheDocument()
- // Menu should be hidden initially
expect(screen.queryByText('share.chat.resetChat')).not.toBeInTheDocument()
- // Click to open
await user.click(trigger)
expect(screen.getByText('share.chat.resetChat')).toBeInTheDocument()
expect(screen.getByText('share.chat.viewChatSettings')).toBeInTheDocument()
- // Click to close
await user.click(trigger)
expect(screen.queryByText('share.chat.resetChat')).not.toBeInTheDocument()
})
@@ -51,14 +47,12 @@ describe('MobileOperationDropdown Component', () => {
await user.click(screen.getByRole('button', { name: 'common.operation.more' }))
- // Reset Chat
await user.click(screen.getByText('share.chat.resetChat'))
await waitFor(() => {
expect(defaultProps.handleResetChat).toHaveBeenCalledTimes(1)
})
await user.click(screen.getByRole('button', { name: 'common.operation.more' }))
- // View Chat Settings
await user.click(screen.getByText('share.chat.viewChatSettings'))
await waitFor(() => {
expect(defaultProps.handleViewChatSettings).toHaveBeenCalledTimes(1)
@@ -70,10 +64,8 @@ describe('MobileOperationDropdown Component', () => {
render(<MobileOperationDropdown {...defaultProps} />)
const trigger = screen.getByRole('button', { name: 'common.operation.more' })
- // closed state
expect(trigger).not.toHaveAttribute('data-popup-open')
- // open state
await user.click(trigger)
expect(trigger).toHaveAttribute('data-popup-open')
})
diff --git a/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx b/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx
index e15f369b779..4b778e00de5 100644
--- a/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx
+++ b/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx
@@ -5,7 +5,6 @@ import {
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
import { IconButton } from '@langgenius/dify-ui/icon-button'
-import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
type Props = Readonly<{
@@ -20,14 +19,12 @@ const MobileOperationDropdown = ({
hideViewChatSettings = false,
}: Props) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
- const handleMenuAction = useCallback((callback: () => void) => {
- setOpen(false)
+ const handleMenuAction = (callback: () => void) => {
queueMicrotask(callback)
- }, [])
+ }
return (
- <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenu>
<DropdownMenuTrigger
render={
<IconButton
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/__tests__/operation.spec.tsx b/web/app/components/base/chat/chat-with-history/sidebar/__tests__/operation.spec.tsx
index e535fa42a51..49e4284388f 100644
--- a/web/app/components/base/chat/chat-with-history/sidebar/__tests__/operation.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/sidebar/__tests__/operation.spec.tsx
@@ -109,7 +109,7 @@ describe('Operation', () => {
expect(screen.getByText('explore.sidebar.action.pin')).toBeInTheDocument()
})
- it('should close dropdown when item hovering stops', async () => {
+ it('should let the menu primitive own open state when item hovering stops', async () => {
const user = userEvent.setup()
const { rerender } = render(<Operation {...defaultProps} isItemHovering={true} />)
@@ -118,9 +118,8 @@ describe('Operation', () => {
rerender(<Operation {...defaultProps} isItemHovering={false} />)
- await waitFor(() => {
- expect(screen.queryByText('explore.sidebar.action.pin')).not.toBeInTheDocument()
- })
+ expect(screen.getByText('explore.sidebar.action.pin')).toBeInTheDocument()
+ expect(getTrigger()).toHaveAttribute('data-popup-open')
})
it('should keep the trigger mounted while visually hidden', () => {
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/operation.tsx b/web/app/components/base/chat/chat-with-history/sidebar/operation.tsx
index 350fc3fec19..84373c01f4b 100644
--- a/web/app/components/base/chat/chat-with-history/sidebar/operation.tsx
+++ b/web/app/components/base/chat/chat-with-history/sidebar/operation.tsx
@@ -7,11 +7,10 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
-import { useBoolean } from 'ahooks'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import * as React from 'react'
-import { useCallback, useEffect, useState } from 'react'
+import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
type Props = Readonly<{
isActive?: boolean
@@ -35,40 +34,25 @@ const Operation: FC<Props> = ({
onDelete,
}) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
- const [isHovering, { setTrue: setIsHovering, setFalse: setNotHovering }] = useBoolean(false)
- useEffect(() => {
- if (!isItemHovering && !isHovering) setOpen(false)
- }, [isItemHovering, isHovering])
const handleDeferredAction = useCallback((action?: () => void) => {
if (!action) return
- setOpen(false)
queueMicrotask(action)
}, [])
return (
- <DropdownMenu modal={false} open={open} onOpenChange={setOpen}>
+ <DropdownMenu modal={false}>
<DropdownMenuTrigger
- render={(props, state) => (
- <ActionButton
- {...props}
+ render={
+ <IconButton
aria-label={t(($) => $['operation.more'], { ns: 'common' })}
+ data-active={isActive ? '' : undefined}
className={cn(
- isItemHovering || state.open
- ? 'pointer-events-auto opacity-100'
- : 'pointer-events-none opacity-0',
- props.className,
+ 'pointer-events-none opacity-0 data-active:bg-state-accent-active data-active:text-text-accent data-active:hover:bg-state-accent-active-alt data-popup-open:pointer-events-auto data-popup-open:bg-state-base-hover data-popup-open:opacity-100 data-active:data-popup-open:bg-state-accent-active data-active:data-popup-open:text-text-accent',
+ isItemHovering && 'pointer-events-auto opacity-100',
)}
- state={
- isActive
- ? ActionButtonState.Active
- : state.open
- ? ActionButtonState.Hover
- : ActionButtonState.Default
- }
>
<span aria-hidden className="i-ri-more-fill size-4" />
- </ActionButton>
- )}
+ </IconButton>
+ }
onClick={(e) => e.stopPropagation()}
/>
<DropdownMenuContent
@@ -76,8 +60,6 @@ const Operation: FC<Props> = ({
sideOffset={4}
popupClassName="min-w-[120px]"
popupProps={{
- onMouseEnter: setIsHovering,
- onMouseLeave: setNotHovering,
onClick: (e) => e.stopPropagation(),
}}
>
diff --git a/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx b/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx
index ef5d4158c76..bf8742b74f5 100644
--- a/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx
+++ b/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx
@@ -794,7 +794,10 @@ describe('Operation', () => {
}),
).toBeInTheDocument()
expect(
- screen.getByRole('button', { name: 'table.header.adminRate: operation.remove' }),
+ screen.getByRole('button', {
+ name: 'table.header.adminRate: detail.operation.dislike',
+ pressed: true,
+ }),
).toBeInTheDocument()
})
diff --git a/web/app/components/base/chat/chat/answer/operation.tsx b/web/app/components/base/chat/chat/answer/operation.tsx
index 4c5e8516ca3..8550cc695c2 100644
--- a/web/app/components/base/chat/chat/answer/operation.tsx
+++ b/web/app/components/base/chat/chat/answer/operation.tsx
@@ -12,12 +12,12 @@ import {
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Textarea } from '@langgenius/dify-ui/textarea'
import { toast } from '@langgenius/dify-ui/toast'
+import { Toggle } from '@langgenius/dify-ui/toggle'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import copy from 'copy-to-clipboard'
import { memo, useId, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
import Log from '@/app/components/base/chat/chat/log'
import AnnotationCtrlButton from '@/app/components/base/features/new-feature-panel/annotation-reply/annotation-ctrl-button'
import NewAudioButton from '@/app/components/base/new-audio-button'
@@ -45,6 +45,10 @@ type FeedbackTooltipProps = {
const feedbackTooltipClassName = 'max-w-[260px]'
const answerActiveFlexClassName = 'group-hover:flex group-has-[[data-popup-open]]:flex'
const answerActiveBlockClassName = 'group-hover:block group-has-[[data-popup-open]]:block'
+const accentPressedClassName =
+ 'data-pressed:bg-state-accent-active data-pressed:text-text-accent data-pressed:hover:bg-state-accent-active-alt'
+const destructivePressedClassName =
+ 'data-pressed:bg-state-destructive-hover data-pressed:text-text-destructive data-pressed:hover:bg-state-destructive-hover data-pressed:hover:text-text-destructive'
function joinPublicContent(blocks: Array<string | undefined>) {
return blocks.filter((block): block is string => !!block?.trim()).join('\n\n')
@@ -132,7 +136,6 @@ function Operation({
t(($) => $['table.header.adminRate'], { ns: 'appLog' }) || 'Admin feedback'
const likeLabel = t(($) => $['detail.operation.like'], { ns: 'appLog' }) || 'Like'
const dislikeLabel = t(($) => $['detail.operation.dislike'], { ns: 'appLog' }) || 'Dislike'
- const removeFeedbackLabel = t(($) => $['operation.remove'], { ns: 'common' }) || 'Remove'
const copyLabel = t(($) => $['operation.copy'], { ns: 'common' }) || 'Copy'
const regenerateLabel = t(($) => $['operation.regenerate'], { ns: 'common' }) || 'Regenerate'
@@ -243,46 +246,51 @@ function Operation({
<FeedbackTooltip
content={buildFeedbackTooltip(displayUserFeedback, userFeedbackLabel)}
>
- <ActionButton
- aria-label={`${userFeedbackLabel}: ${removeFeedbackLabel}`}
- state={
+ <Toggle
+ className={
displayUserFeedback?.rating === 'like'
- ? ActionButtonState.Active
- : ActionButtonState.Destructive
+ ? accentPressedClassName
+ : destructivePressedClassName
}
- onClick={() => handleFeedback(null, undefined, 'user')}
- >
- {displayUserFeedback?.rating === 'like' ? (
- <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
- ) : (
- <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
- )}
- </ActionButton>
+ pressed
+ onPressedChange={(pressed) =>
+ !pressed && void handleFeedback(null, undefined, 'user')
+ }
+ render={
+ <IconButton
+ aria-label={`${userFeedbackLabel}: ${displayUserFeedback?.rating === 'like' ? likeLabel : dislikeLabel}`}
+ >
+ {displayUserFeedback?.rating === 'like' ? (
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ ) : (
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ )}
+ </IconButton>
+ }
+ />
</FeedbackTooltip>
) : (
<>
- <ActionButton
- aria-label={`${userFeedbackLabel}: ${likeLabel}`}
- state={
- displayUserFeedback?.rating === 'like'
- ? ActionButtonState.Active
- : ActionButtonState.Default
+ <Toggle
+ className={accentPressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && handleLikeClick('user')}
+ render={
+ <IconButton aria-label={`${userFeedbackLabel}: ${likeLabel}`}>
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ </IconButton>
}
- onClick={() => handleLikeClick('user')}
- >
- <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
- </ActionButton>
- <ActionButton
- aria-label={`${userFeedbackLabel}: ${dislikeLabel}`}
- state={
- displayUserFeedback?.rating === 'dislike'
- ? ActionButtonState.Destructive
- : ActionButtonState.Default
+ />
+ <Toggle
+ className={destructivePressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && handleDislikeClick('user')}
+ render={
+ <IconButton aria-label={`${userFeedbackLabel}: ${dislikeLabel}`}>
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ </IconButton>
}
- onClick={() => handleDislikeClick('user')}
- >
- <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
- </ActionButton>
+ />
</>
)}
</div>
@@ -328,53 +336,58 @@ function Operation({
<FeedbackTooltip
content={buildFeedbackTooltip(displayAdminFeedback, adminFeedbackLabel)}
>
- <ActionButton
- aria-label={`${adminFeedbackLabel}: ${removeFeedbackLabel}`}
- state={
+ <Toggle
+ className={
displayAdminFeedback?.rating === 'like'
- ? ActionButtonState.Active
- : ActionButtonState.Destructive
+ ? accentPressedClassName
+ : destructivePressedClassName
}
- onClick={() => handleFeedback(null, undefined, 'admin')}
- >
- {displayAdminFeedback?.rating === 'like' ? (
- <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
- ) : (
- <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
- )}
- </ActionButton>
+ pressed
+ onPressedChange={(pressed) =>
+ !pressed && void handleFeedback(null, undefined, 'admin')
+ }
+ render={
+ <IconButton
+ aria-label={`${adminFeedbackLabel}: ${displayAdminFeedback?.rating === 'like' ? likeLabel : dislikeLabel}`}
+ >
+ {displayAdminFeedback?.rating === 'like' ? (
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ ) : (
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ )}
+ </IconButton>
+ }
+ />
</FeedbackTooltip>
) : (
<>
<FeedbackTooltip
content={buildFeedbackTooltip(displayAdminFeedback, adminFeedbackLabel)}
>
- <ActionButton
- aria-label={`${adminFeedbackLabel}: ${likeLabel}`}
- state={
- displayAdminFeedback?.rating === 'like'
- ? ActionButtonState.Active
- : ActionButtonState.Default
+ <Toggle
+ className={accentPressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && handleLikeClick('admin')}
+ render={
+ <IconButton aria-label={`${adminFeedbackLabel}: ${likeLabel}`}>
+ <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
+ </IconButton>
}
- onClick={() => handleLikeClick('admin')}
- >
- <span aria-hidden="true" className="i-ri-thumb-up-line size-4" />
- </ActionButton>
+ />
</FeedbackTooltip>
<FeedbackTooltip
content={buildFeedbackTooltip(displayAdminFeedback, adminFeedbackLabel)}
>
- <ActionButton
- aria-label={`${adminFeedbackLabel}: ${dislikeLabel}`}
- state={
- displayAdminFeedback?.rating === 'dislike'
- ? ActionButtonState.Destructive
- : ActionButtonState.Default
+ <Toggle
+ className={destructivePressedClassName}
+ pressed={false}
+ onPressedChange={(pressed) => pressed && handleDislikeClick('admin')}
+ render={
+ <IconButton aria-label={`${adminFeedbackLabel}: ${dislikeLabel}`}>
+ <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
+ </IconButton>
}
- onClick={() => handleDislikeClick('admin')}
- >
- <span aria-hidden="true" className="i-ri-thumb-down-line size-4" />
- </ActionButton>
+ />
</FeedbackTooltip>
</>
)}
diff --git a/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.json b/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.json
deleted file mode 100644
index 98b22dbdcd5..00000000000
--- a/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "icon": {
- "type": "element",
- "isRootNode": true,
- "name": "svg",
- "attributes": {
- "width": "24",
- "height": "24",
- "viewBox": "0 0 24 24",
- "fill": "none",
- "xmlns": "http://www.w3.org/2000/svg"
- },
- "children": [
- {
- "type": "element",
- "name": "path",
- "attributes": {
- "d": "M2 10C2 10 4.00498 7.26822 5.63384 5.63824C7.26269 4.00827 9.5136 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.89691 21 4.43511 18.2543 3.35177 14.5M2 10V4M2 10H8",
- "stroke": "currentColor",
- "stroke-width": "2",
- "stroke-linecap": "round",
- "stroke-linejoin": "round"
- },
- "children": []
- }
- ]
- },
- "name": "RefreshCcw01"
-}
diff --git a/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.tsx b/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.tsx
deleted file mode 100644
index 04962b04836..00000000000
--- a/web/app/components/base/icons/src/vender/line/arrows/RefreshCcw01.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-// GENERATE BY script
-// DON NOT EDIT IT MANUALLY
-
-import type { IconData } from '@/app/components/base/icons/IconBase'
-import * as React from 'react'
-import IconBase from '@/app/components/base/icons/IconBase'
-import data from './RefreshCcw01.json'
-
-const Icon = ({
- ref,
- ...props
-}: React.SVGProps<SVGSVGElement> & {
- ref?: React.RefObject<React.RefObject<HTMLOrSVGElement>>
-}) => <IconBase {...props} ref={ref} data={data as IconData} />
-
-Icon.displayName = 'RefreshCcw01'
-
-export default Icon
diff --git a/web/app/components/base/icons/src/vender/line/arrows/index.ts b/web/app/components/base/icons/src/vender/line/arrows/index.ts
index 24ef12775ad..0c17880beaa 100644
--- a/web/app/components/base/icons/src/vender/line/arrows/index.ts
+++ b/web/app/components/base/icons/src/vender/line/arrows/index.ts
@@ -3,5 +3,3 @@ export { default as ArrowUpRight } from './ArrowUpRight'
export { default as ChevronRight } from './ChevronRight'
export { default as ChevronSelectorVertical } from './ChevronSelectorVertical'
-
-export { default as RefreshCcw01 } from './RefreshCcw01'
diff --git a/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.json b/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.json
deleted file mode 100644
index c0d9b9a4fe6..00000000000
--- a/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "icon": {
- "type": "element",
- "isRootNode": true,
- "name": "svg",
- "attributes": {
- "width": "21",
- "height": "8",
- "viewBox": "0 0 21 8",
- "fill": "none",
- "xmlns": "http://www.w3.org/2000/svg"
- },
- "children": [
- {
- "type": "element",
- "name": "path",
- "attributes": {
- "d": "M0.646446 3.64645C0.451185 3.84171 0.451185 4.15829 0.646446 4.35355L3.82843 7.53553C4.02369 7.7308 4.34027 7.7308 4.53553 7.53553C4.7308 7.34027 4.7308 7.02369 4.53553 6.82843L1.70711 4L4.53553 1.17157C4.7308 0.976311 4.7308 0.659728 4.53553 0.464466C4.34027 0.269204 4.02369 0.269204 3.82843 0.464466L0.646446 3.64645ZM21 3.5L1 3.5V4.5L21 4.5V3.5Z",
- "fill": "currentColor",
- "fill-opacity": "0.3"
- },
- "children": []
- }
- ]
- },
- "name": "LongArrowLeft"
-}
diff --git a/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.tsx b/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.tsx
deleted file mode 100644
index 779252c07a1..00000000000
--- a/web/app/components/base/icons/src/vender/line/others/LongArrowLeft.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-// GENERATE BY script
-// DON NOT EDIT IT MANUALLY
-
-import type { IconData } from '@/app/components/base/icons/IconBase'
-import * as React from 'react'
-import IconBase from '@/app/components/base/icons/IconBase'
-import data from './LongArrowLeft.json'
-
-const Icon = ({
- ref,
- ...props
-}: React.SVGProps<SVGSVGElement> & {
- ref?: React.RefObject<React.RefObject<HTMLOrSVGElement>>
-}) => <IconBase {...props} ref={ref} data={data as IconData} />
-
-Icon.displayName = 'LongArrowLeft'
-
-export default Icon
diff --git a/web/app/components/base/icons/src/vender/line/others/LongArrowRight.json b/web/app/components/base/icons/src/vender/line/others/LongArrowRight.json
deleted file mode 100644
index a6c48652612..00000000000
--- a/web/app/components/base/icons/src/vender/line/others/LongArrowRight.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "icon": {
- "type": "element",
- "isRootNode": true,
- "name": "svg",
- "attributes": {
- "width": "26",
- "height": "8",
- "viewBox": "0 0 26 8",
- "fill": "none",
- "xmlns": "http://www.w3.org/2000/svg"
- },
- "children": [
- {
- "type": "element",
- "name": "path",
- "attributes": {
- "d": "M25.3536 4.35355C25.5488 4.15829 25.5488 3.84171 25.3536 3.64644L22.1716 0.464465C21.9763 0.269202 21.6597 0.269202 21.4645 0.464465C21.2692 0.659727 21.2692 0.976309 21.4645 1.17157L24.2929 4L21.4645 6.82843C21.2692 7.02369 21.2692 7.34027 21.4645 7.53553C21.6597 7.73079 21.9763 7.73079 22.1716 7.53553L25.3536 4.35355ZM3.59058e-08 4.5L25 4.5L25 3.5L-3.59058e-08 3.5L3.59058e-08 4.5Z",
- "fill": "currentColor",
- "fill-opacity": "0.3"
- },
- "children": []
- }
- ]
- },
- "name": "LongArrowRight"
-}
diff --git a/web/app/components/base/icons/src/vender/line/others/LongArrowRight.tsx b/web/app/components/base/icons/src/vender/line/others/LongArrowRight.tsx
deleted file mode 100644
index 995e6af0116..00000000000
--- a/web/app/components/base/icons/src/vender/line/others/LongArrowRight.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-// GENERATE BY script
-// DON NOT EDIT IT MANUALLY
-
-import type { IconData } from '@/app/components/base/icons/IconBase'
-import * as React from 'react'
-import IconBase from '@/app/components/base/icons/IconBase'
-import data from './LongArrowRight.json'
-
-const Icon = ({
- ref,
- ...props
-}: React.SVGProps<SVGSVGElement> & {
- ref?: React.RefObject<React.RefObject<HTMLOrSVGElement>>
-}) => <IconBase {...props} ref={ref} data={data as IconData} />
-
-Icon.displayName = 'LongArrowRight'
-
-export default Icon
diff --git a/web/app/components/base/icons/src/vender/line/others/index.ts b/web/app/components/base/icons/src/vender/line/others/index.ts
index 0425327c6c0..21c8edfa278 100644
--- a/web/app/components/base/icons/src/vender/line/others/index.ts
+++ b/web/app/components/base/icons/src/vender/line/others/index.ts
@@ -4,5 +4,3 @@ export { default as DragHandle } from './DragHandle'
export { default as Env } from './Env'
export { default as GlobalVariable } from './GlobalVariable'
export { default as Icon3Dots } from './Icon3Dots'
-export { default as LongArrowLeft } from './LongArrowLeft'
-export { default as LongArrowRight } from './LongArrowRight'
diff --git a/web/app/components/base/markdown-blocks/code-block.tsx b/web/app/components/base/markdown-blocks/code-block.tsx
index 17e6773fb3e..671d6f276fb 100644
--- a/web/app/components/base/markdown-blocks/code-block.tsx
+++ b/web/app/components/base/markdown-blocks/code-block.tsx
@@ -2,7 +2,6 @@ import type { JSX } from 'react'
import type { BundledLanguage, BundledTheme } from 'shiki/bundle/web'
import ReactEcharts from 'echarts-for-react'
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
-import ActionButton from '@/app/components/base/action-button'
import CopyIcon from '@/app/components/base/copy-icon'
import MarkdownMusic from '@/app/components/base/markdown-blocks/music'
import ErrorBoundary from '@/app/components/base/markdown/error-boundary'
@@ -545,9 +544,7 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
<div className="system-xs-semibold-uppercase text-text-secondary">{languageShowName}</div>
<div className="flex items-center gap-1">
{language === 'svg' && <SVGBtn isSVG={isSVG} setIsSVG={setIsSVG} />}
- <ActionButton>
- <CopyIcon content={String(children).replace(/\n$/, '')} />
- </ActionButton>
+ <CopyIcon content={String(children).replace(/\n$/, '')} />
</div>
</div>
{renderCodeContent}
diff --git a/web/app/components/base/new-audio-button/__tests__/index.spec.tsx b/web/app/components/base/new-audio-button/__tests__/index.spec.tsx
index ea2f6a41a6e..0f94406ff98 100644
--- a/web/app/components/base/new-audio-button/__tests__/index.spec.tsx
+++ b/web/app/components/base/new-audio-button/__tests__/index.spec.tsx
@@ -98,7 +98,7 @@ describe('AudioBtn', () => {
render(<AudioBtn value="test" />)
await hoverAndCheckTooltip('play')
- expect(getButton())!.toHaveClass('action-btn')
+ expect(getButton()).toHaveAccessibleName('play')
expect(getButton()).not.toBeDisabled()
})
@@ -111,7 +111,7 @@ describe('AudioBtn', () => {
})
await hoverAndCheckTooltip('playing')
- expect(getButton())!.toHaveClass('action-btn-active')
+ expect(getButton()).toHaveAccessibleName('playing')
})
it('should transition to ended state', async () => {
@@ -126,7 +126,7 @@ describe('AudioBtn', () => {
})
await hoverAndCheckTooltip('play')
- expect(getButton()).not.toHaveClass('action-btn-active')
+ expect(getButton()).toHaveAccessibleName('play')
})
it('should handle paused event', async () => {
diff --git a/web/app/components/base/new-audio-button/index.tsx b/web/app/components/base/new-audio-button/index.tsx
index bc4772d6b5e..0628b9e871b 100644
--- a/web/app/components/base/new-audio-button/index.tsx
+++ b/web/app/components/base/new-audio-button/index.tsx
@@ -1,9 +1,8 @@
'use client'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
-import { RiVolumeUpLine } from '@remixicon/react'
import { t } from 'i18next'
import { useState } from 'react'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
import { AudioPlayerManager } from '@/app/components/base/audio-btn/audio.player.manager'
import { isInstalledAppPath } from '@/app/components/explore/installed-app/routes'
import { useParams, usePathname } from '@/next/navigation'
@@ -77,18 +76,17 @@ const AudioBtn = ({ id, voice, value }: AudioBtnProps) => {
<TooltipTrigger
render={
<span className="inline-flex">
- <ActionButton
- state={
- audioState === 'loading' || audioState === 'playing'
- ? ActionButtonState.Active
- : ActionButtonState.Default
+ <IconButton
+ data-audio-active={
+ audioState === 'loading' || audioState === 'playing' ? '' : undefined
}
+ className="data-audio-active:bg-state-accent-active data-audio-active:text-text-accent data-audio-active:hover:bg-state-accent-active-alt data-disabled:bg-transparent data-disabled:text-text-disabled"
aria-label={tooltipContent}
onClick={handleToggle}
disabled={audioState === 'loading'}
>
- <RiVolumeUpLine className="size-4" aria-hidden="true" />
- </ActionButton>
+ <span aria-hidden="true" className="i-ri-volume-up-line size-4" />
+ </IconButton>
</span>
}
/>
diff --git a/web/app/components/base/svg/__tests__/index.spec.tsx b/web/app/components/base/svg/__tests__/index.spec.tsx
index 527cbc7a1cc..1eca0acff91 100644
--- a/web/app/components/base/svg/__tests__/index.spec.tsx
+++ b/web/app/components/base/svg/__tests__/index.spec.tsx
@@ -11,7 +11,7 @@ describe('SVGBtn', () => {
await user.click(screen.getByRole('button', { name: 'SVG', pressed: false }))
expect(setIsSVG).toHaveBeenCalledOnce()
- expect(setIsSVG.mock.calls[0]![0](false)).toBe(true)
+ expect(setIsSVG.mock.calls[0]![0]).toBe(true)
rerender(<SVGBtn isSVG setIsSVG={setIsSVG} />)
diff --git a/web/app/components/base/svg/index.tsx b/web/app/components/base/svg/index.tsx
index 5586a49b04a..1cf7574067f 100644
--- a/web/app/components/base/svg/index.tsx
+++ b/web/app/components/base/svg/index.tsx
@@ -1,6 +1,7 @@
import { cn } from '@langgenius/dify-ui/cn'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
+import { Toggle } from '@langgenius/dify-ui/toggle'
import * as React from 'react'
-import ActionButton from '../action-button'
import s from './style.module.css'
type ISVGBtnProps = {
@@ -10,15 +11,18 @@ type ISVGBtnProps = {
const SVGBtn = ({ isSVG, setIsSVG }: ISVGBtnProps) => {
return (
- <ActionButton
- aria-label="SVG"
- aria-pressed={isSVG}
- onClick={() => {
- setIsSVG((prevIsSVG) => !prevIsSVG)
- }}
- >
- <span aria-hidden="true" className={cn('block size-4', isSVG ? s.svgIconed : s.svgIcon)} />
- </ActionButton>
+ <Toggle
+ pressed={isSVG}
+ onPressedChange={setIsSVG}
+ render={
+ <IconButton aria-label="SVG">
+ <span
+ aria-hidden="true"
+ className={cn('block size-4', isSVG ? s.svgIconed : s.svgIcon)}
+ />
+ </IconButton>
+ }
+ />
)
}
diff --git a/web/app/components/datasets/documents/detail/__tests__/index.spec.tsx b/web/app/components/datasets/documents/detail/__tests__/index.spec.tsx
index 390dc673bb4..a501800e291 100644
--- a/web/app/components/datasets/documents/detail/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/detail/__tests__/index.spec.tsx
@@ -405,10 +405,10 @@ describe('DocumentDetail', () => {
render(<DocumentDetail datasetId="ds-1" documentId="doc-1" />)
const toggle = screen.getByRole('button', { name: /metadata\.title/ })
expect(toggle).toHaveAttribute('aria-label')
- expect(toggle).toHaveAttribute('aria-pressed', 'true')
+ expect(toggle).toHaveAttribute('aria-expanded', 'true')
fireEvent.click(toggle)
- expect(toggle).toHaveAttribute('aria-pressed', 'false')
+ expect(toggle).toHaveAttribute('aria-expanded', 'false')
})
it('should pass correct props to Metadata', () => {
diff --git a/web/app/components/datasets/documents/detail/index.tsx b/web/app/components/datasets/documents/detail/index.tsx
index 4d442f6dc22..680bdc953a4 100644
--- a/web/app/components/datasets/documents/detail/index.tsx
+++ b/web/app/components/datasets/documents/detail/index.tsx
@@ -4,6 +4,7 @@ import type { FC } from 'react'
import type { DocumentDisplayStatus, FileItem, FullDocumentDetail } from '@/models/datasets'
import type { SegmentImportStatus } from '@/types/dataset'
import { cn } from '@langgenius/dify-ui/cn'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { toast } from '@langgenius/dify-ui/toast'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -42,7 +43,6 @@ import { DocumentContext } from './context'
import { DocumentTitle } from './document-title'
import Embedding from './embedding'
import { SegmentAdd } from './segment-add'
-import style from './style.module.css'
type DocumentDetailProps = {
datasetId: string
@@ -262,6 +262,7 @@ const DocumentDetail: FC<DocumentDetailProps> = ({ datasetId, documentId }) => {
} ${t(($) => $['metadata.title'], { ns: 'datasetDocuments' })}`
return (
+ // oxlint-disable-next-line eslint-react/no-context-provider -- use-context-selector contexts are not React 19 context components.
<DocumentContext.Provider value={contextValue}>
<div className="flex h-full flex-col bg-background-default">
<div className="flex min-h-16 flex-wrap items-center justify-between border-b border-b-divider-subtle py-2.5 pr-4 pl-3">
@@ -324,12 +325,13 @@ const DocumentDetail: FC<DocumentDetailProps> = ({ datasetId, documentId }) => {
canDelete={datasetACLCapabilities.canDeleteFile}
canViewSettings={canEditDocument}
/>
- <button
- type="button"
+ <IconButton
+ variant="secondary"
+ size="lg"
aria-label={metadataToggleLabel}
- aria-pressed={showMetadata}
+ aria-expanded={showMetadata}
title={metadataToggleLabel}
- className={style.layoutRightIcon}
+ className="ml-2"
onClick={() => setShowMetadata(!showMetadata)}
>
{showMetadata ? (
@@ -343,7 +345,7 @@ const DocumentDetail: FC<DocumentDetailProps> = ({ datasetId, documentId }) => {
className="i-ri-layout-right-2-line size-4 text-components-button-secondary-text"
/>
)}
- </button>
+ </IconButton>
</div>
</div>
<div className="flex flex-1 flex-row" style={{ height: 'calc(100% - 4rem)' }}>
diff --git a/web/app/components/datasets/documents/detail/style.module.css b/web/app/components/datasets/documents/detail/style.module.css
deleted file mode 100644
index 046c2edb083..00000000000
--- a/web/app/components/datasets/documents/detail/style.module.css
+++ /dev/null
@@ -1,11 +0,0 @@
-@reference "../../../../styles/globals.css";
-
-.titleIcon {
- background-position-x: center;
- background-repeat: no-repeat;
- background-size: 28px 28px;
- @apply !h-6 !w-6;
-}
-.layoutRightIcon {
- @apply ml-2 cursor-pointer rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg p-2 shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px] hover:border-components-button-secondary-border-hover hover:bg-components-button-secondary-bg-hover;
-}
diff --git a/web/app/components/header/account-setting/access-rules-page/__tests__/access-rule-section.spec.tsx b/web/app/components/header/account-setting/access-rules-page/__tests__/access-rule-section.spec.tsx
index 2f7b61b036d..5eed388f2fa 100644
--- a/web/app/components/header/account-setting/access-rules-page/__tests__/access-rule-section.spec.tsx
+++ b/web/app/components/header/account-setting/access-rules-page/__tests__/access-rule-section.spec.tsx
@@ -93,7 +93,7 @@ describe('AccessRuleSection', () => {
expect(screen.queryByText('Full Control')).not.toBeInTheDocument()
- await userEvent.click(screen.getByRole('button', { expanded: false }))
+ await userEvent.click(screen.getByRole('button', { name: /^App Access Rules/ }))
expect(screen.getByText('Full Control')).toBeInTheDocument()
})
diff --git a/web/app/components/header/account-setting/access-rules-page/access-rule-section.tsx b/web/app/components/header/account-setting/access-rules-page/access-rule-section.tsx
index 4743c9a9a8d..67cd0a4cb11 100644
--- a/web/app/components/header/account-setting/access-rules-page/access-rule-section.tsx
+++ b/web/app/components/header/account-setting/access-rules-page/access-rule-section.tsx
@@ -3,10 +3,11 @@
import type { AccessPolicyWithBindings } from '@/models/access-control'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useAtomValue } from 'jotai'
import { memo, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import ActionButton from '@/app/components/base/action-button'
import Loading from '@/app/components/base/loading'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { hasPermission } from '@/utils/permission'
@@ -84,18 +85,22 @@ const AccessRuleSection = ({
}, [error, expanded, fetchNextPage, hasNextPage, isFetchingNextPage, isLoadingRules])
return (
- <section
- className={cn(
- 'overflow-hidden rounded-xl border border-components-panel-border bg-components-panel-bg',
- className,
- )}
+ <Collapsible
+ open={expanded}
+ onOpenChange={setExpanded}
+ render={
+ <section
+ className={cn(
+ 'overflow-hidden rounded-xl border border-components-panel-border bg-components-panel-bg',
+ className,
+ )}
+ />
+ }
>
<div className="flex items-center gap-4 p-4">
- <button
- type="button"
- className="min-w-0 flex-1 text-left"
- onClick={() => setExpanded((expanded) => !expanded)}
- aria-expanded={expanded}
+ <CollapsibleTrigger
+ className="min-h-0 w-auto min-w-0 flex-1 justify-start gap-0 rounded-none px-0 hover:not-data-disabled:bg-transparent"
+ render={<button type="button" className="min-w-0 flex-1 text-left" />}
>
<div className="flex min-w-0 items-center gap-4">
<span className="truncate system-sm-semibold text-text-primary">{title}</span>
@@ -103,7 +108,7 @@ const AccessRuleSection = ({
{t(($) => $['accessRule.summary'], { ns: 'permission', count: ruleCount })}
</span>
</div>
- </button>
+ </CollapsibleTrigger>
<div className="flex shrink-0 items-center gap-3">
{canManage && (
<Button variant="primary" size="medium" onClick={onCreate} disabled={isLoadingRules}>
@@ -111,61 +116,64 @@ const AccessRuleSection = ({
<span>{t(($) => $['accessRule.newPermissionSet'], { ns: 'permission' })}</span>
</Button>
)}
- <ActionButton
- size="l"
- aria-label={
- expanded
- ? t(($) => $['accessRule.collapseSection'], { ns: 'permission', title })
- : t(($) => $['accessRule.expandSection'], { ns: 'permission', title })
+ <CollapsibleTrigger
+ className="size-8 min-h-0 justify-center gap-0 p-1.5 hover:not-data-disabled:text-text-secondary data-panel-open:bg-state-accent-active data-panel-open:text-text-accent data-panel-open:hover:bg-state-accent-active-alt"
+ render={
+ <IconButton
+ size="lg"
+ aria-label={
+ expanded
+ ? t(($) => $['accessRule.collapseSection'], { ns: 'permission', title })
+ : t(($) => $['accessRule.expandSection'], { ns: 'permission', title })
+ }
+ >
+ <span
+ aria-hidden="true"
+ className="i-ri-arrow-right-s-line size-4 text-text-tertiary transition-transform group-data-panel-open:rotate-90"
+ />
+ </IconButton>
}
- onClick={() => setExpanded((expanded) => !expanded)}
- >
- <span
- aria-hidden
- className={cn(
- 'i-ri-arrow-right-s-line size-4 text-text-tertiary transition-transform',
- expanded && 'rotate-90',
- )}
- />
- </ActionButton>
+ />
</div>
</div>
- {expanded && (
- <div
- ref={listRef}
- className="max-h-105 overflow-y-auto overscroll-contain border-t border-divider-deep px-4"
- >
- {isLoadingRules ? (
- <div className="px-1 py-8 text-center">
- <Loading type="app" />
- </div>
- ) : rules.length === 0 ? (
- <div className="px-1 py-8 text-center system-sm-regular text-text-tertiary">
- {t(($) => $['accessRule.noRules'], { ns: 'permission' })}
- </div>
- ) : (
- <>
- {rules.map((rule, index) => (
- <AccessRuleRow
- key={rule.policy.id}
- rule={rule}
- canManage={canManage}
- className={cn(index > 0 && 'border-t border-divider-regular')}
- onView={onViewRule}
- onEdit={onEditRule}
- />
- ))}
- <div ref={anchorRef} className="h-1" />
- {isFetchingNextPage && (
- <div className="px-1 py-3 text-center system-xs-regular text-text-tertiary">
- <Loading type="app" />
- </div>
- )}
- </>
- )}
- </div>
- )}
- </section>
+ <CollapsiblePanel
+ render={
+ <div
+ ref={listRef}
+ className="max-h-105 overflow-y-auto overscroll-contain border-t border-divider-deep px-4"
+ />
+ }
+ >
+ {isLoadingRules ? (
+ <div className="px-1 py-8 text-center">
+ <Loading type="app" />
+ </div>
+ ) : rules.length === 0 ? (
+ <div className="px-1 py-8 text-center system-sm-regular text-text-tertiary">
+ {t(($) => $['accessRule.noRules'], { ns: 'permission' })}
+ </div>
+ ) : (
+ <>
+ {rules.map((rule, index) => (
+ <AccessRuleRow
+ key={rule.policy.id}
+ rule={rule}
+ canManage={canManage}
+ className={cn(index > 0 && 'border-t border-divider-regular')}
+ onView={onViewRule}
+ onEdit={onEditRule}
+ />
+ ))}
+ <div ref={anchorRef} className="h-1" />
+ {isFetchingNextPage && (
+ <div className="px-1 py-3 text-center system-xs-regular text-text-tertiary">
+ <Loading type="app" />
+ </div>
+ )}
+ </>
+ )}
+ </CollapsiblePanel>
+ </Collapsible>
)
}
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 7c706c585c9..124282ce406 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
@@ -1,9 +1,9 @@
'use client'
import type { FC } from 'react'
-import { RiCollapseDiagonalLine, RiExpandDiagonalLine } from '@remixicon/react'
+import { cn } from '@langgenius/dify-ui/cn'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import * as React from 'react'
import { useCallback } from 'react'
-import ActionButton from '@/app/components/base/action-button'
type Props = Readonly<{
isExpand: boolean
@@ -13,13 +13,18 @@ type Props = Readonly<{
const ExpandBtn: FC<Props> = ({ isExpand, onExpandChange }) => {
const handleToggle = useCallback(() => {
onExpandChange(!isExpand)
- }, [isExpand])
+ }, [isExpand, onExpandChange])
- const Icon = isExpand ? RiCollapseDiagonalLine : RiExpandDiagonalLine
return (
- <ActionButton onClick={handleToggle}>
- <Icon className="size-4" />
- </ActionButton>
+ <IconButton aria-label={isExpand ? 'Collapse' : 'Expand'} onClick={handleToggle}>
+ <span
+ aria-hidden="true"
+ className={cn(
+ 'size-4',
+ isExpand ? 'i-ri-collapse-diagonal-line' : 'i-ri-expand-diagonal-line',
+ )}
+ />
+ </IconButton>
)
}
export default React.memo(ExpandBtn)
diff --git a/web/app/components/workflow/panel/chat-variable-panel/index.tsx b/web/app/components/workflow/panel/chat-variable-panel/index.tsx
index 0fd31bbc345..fc4566d1d3c 100644
--- a/web/app/components/workflow/panel/chat-variable-panel/index.tsx
+++ b/web/app/components/workflow/panel/chat-variable-panel/index.tsx
@@ -1,14 +1,9 @@
import type { ConversationVariable } from '@/app/components/workflow/types'
import { cn } from '@langgenius/dify-ui/cn'
-import { RiBookOpenLine, RiCloseLine } from '@remixicon/react'
+import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { memo, useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
-import {
- BubbleX,
- LongArrowLeft,
- LongArrowRight,
-} from '@/app/components/base/icons/src/vender/line/others'
import BlockIcon from '@/app/components/workflow/block-icon'
import { webSocketClient } from '@/app/components/workflow/collaboration/core/websocket-manager'
import RemoveEffectVarConfirm from '@/app/components/workflow/nodes/_base/components/remove-effect-var-confirm'
@@ -203,74 +198,85 @@ const ChatVariablePanel = () => {
)
return (
- <div
- className={cn(
- 'relative flex h-full w-105 flex-col rounded-l-2xl border border-components-panel-border bg-components-panel-bg-alt',
- )}
+ <Collapsible
+ open={showTip}
+ onOpenChange={setShowTip}
+ render={
+ <div
+ className={cn(
+ 'relative flex h-full w-105 flex-col rounded-l-2xl border border-components-panel-border bg-components-panel-bg-alt',
+ )}
+ />
+ }
>
<div className="flex shrink-0 items-center justify-between p-4 pb-0 system-xl-semibold text-text-primary">
{t(($) => $['chatVariable.panelTitle'], { ns: 'workflow' })}
<div className="flex items-center gap-1">
- <ActionButton
- aria-label={t(($) => $['chatVariable.tips'], { ns: 'workflow' })}
- aria-expanded={showTip}
- state={showTip ? ActionButtonState.Active : undefined}
- onClick={() => setShowTip(!showTip)}
- >
- <RiBookOpenLine aria-hidden="true" className="size-4" />
- </ActionButton>
- <button
- type="button"
+ <CollapsibleTrigger
+ className="size-6 min-h-0 justify-center gap-0 p-0.5 hover:not-data-disabled:text-text-secondary data-panel-open:bg-state-accent-active data-panel-open:text-text-accent data-panel-open:hover:bg-state-accent-active-alt"
+ render={
+ <IconButton aria-label={t(($) => $['chatVariable.tips'], { ns: 'workflow' })}>
+ <span aria-hidden="true" className="i-ri-book-open-line size-4" />
+ </IconButton>
+ }
+ />
+ <IconButton
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
- className="flex size-6 cursor-pointer appearance-none items-center justify-center rounded-md border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
onClick={() => setShowChatVariablePanel(false)}
>
- <RiCloseLine aria-hidden="true" className="size-4 text-text-tertiary" />
- </button>
+ <span aria-hidden="true" className="i-ri-close-line size-4 text-text-tertiary" />
+ </IconButton>
</div>
</div>
- {showTip && (
- <div className="shrink-0 px-3 pt-2.5 pb-2">
- <div className="relative rounded-2xl bg-background-section-burn p-3">
- <div className="inline-block rounded-[5px] border border-divider-deep px-1.25 py-0.75 system-2xs-medium-uppercase text-text-tertiary">
- TIPS
- </div>
- <div className="mt-1 mb-4 system-sm-regular text-text-secondary">
- {t(($) => $['chatVariable.panelDescription'], { ns: 'workflow' })}
+ <CollapsiblePanel render={<div className="shrink-0 px-3 pt-2.5 pb-2" />}>
+ <div className="relative rounded-2xl bg-background-section-burn p-3">
+ <div className="inline-block rounded-[5px] border border-divider-deep px-1.25 py-0.75 system-2xs-medium-uppercase text-text-tertiary">
+ TIPS
+ </div>
+ <div className="mt-1 mb-4 system-sm-regular text-text-secondary">
+ {t(($) => $['chatVariable.panelDescription'], { ns: 'workflow' })}
+ </div>
+ <div className="flex items-center gap-2">
+ <div className="flex flex-col rounded-[10px] border border-workflow-block-border bg-workflow-block-bg p-3 pb-4 shadow-md">
+ <span
+ aria-hidden="true"
+ className="mb-1 i-custom-vender-line-others-bubble-x size-4 shrink-0 text-util-colors-teal-teal-700"
+ />
+ <div className="system-xs-semibold text-text-secondary">conversation_var</div>
+ <div className="system-2xs-regular text-text-tertiary">String</div>
</div>
- <div className="flex items-center gap-2">
- <div className="flex flex-col rounded-[10px] border border-workflow-block-border bg-workflow-block-bg p-3 pb-4 shadow-md">
- <BubbleX className="mb-1 size-4 shrink-0 text-util-colors-teal-teal-700" />
- <div className="system-xs-semibold text-text-secondary">conversation_var</div>
- <div className="system-2xs-regular text-text-tertiary">String</div>
+ <div className="grow">
+ <div className="mb-2 flex items-center gap-2 py-1">
+ <div className="flex h-3 w-16 shrink-0 items-center gap-1 px-1">
+ <span
+ aria-hidden="true"
+ className="i-custom-vender-line-others-long-arrow-left h-2 grow text-text-quaternary"
+ />
+ <div className="shrink-0 system-2xs-medium text-text-tertiary">WRITE</div>
+ </div>
+ <BlockIcon className="shrink-0" type={BlockEnum.Assigner} />
+ <div className="grow truncate system-xs-semibold text-text-secondary">
+ {t(($) => $['blocks.assigner'], { ns: 'workflow' })}
+ </div>
</div>
- <div className="grow">
- <div className="mb-2 flex items-center gap-2 py-1">
- <div className="flex h-3 w-16 shrink-0 items-center gap-1 px-1">
- <LongArrowLeft className="h-2 grow text-text-quaternary" />
- <div className="shrink-0 system-2xs-medium text-text-tertiary">WRITE</div>
- </div>
- <BlockIcon className="shrink-0" type={BlockEnum.Assigner} />
- <div className="grow truncate system-xs-semibold text-text-secondary">
- {t(($) => $['blocks.assigner'], { ns: 'workflow' })}
- </div>
+ <div className="flex items-center gap-2 py-1">
+ <div className="flex h-3 w-16 shrink-0 items-center gap-1 px-1">
+ <div className="shrink-0 system-2xs-medium text-text-tertiary">READ</div>
+ <span
+ aria-hidden="true"
+ className="i-custom-vender-line-others-long-arrow-right h-2 grow text-text-quaternary"
+ />
</div>
- <div className="flex items-center gap-2 py-1">
- <div className="flex h-3 w-16 shrink-0 items-center gap-1 px-1">
- <div className="shrink-0 system-2xs-medium text-text-tertiary">READ</div>
- <LongArrowRight className="h-2 grow text-text-quaternary" />
- </div>
- <BlockIcon className="shrink-0" type={BlockEnum.LLM} />
- <div className="grow truncate system-xs-semibold text-text-secondary">
- {t(($) => $['blocks.llm'], { ns: 'workflow' })}
- </div>
+ <BlockIcon className="shrink-0" type={BlockEnum.LLM} />
+ <div className="grow truncate system-xs-semibold text-text-secondary">
+ {t(($) => $['blocks.llm'], { ns: 'workflow' })}
</div>
</div>
</div>
- <div className="absolute -top-1 right-9.5 z-10 h-3 w-3 rotate-45 bg-background-section-burn" />
</div>
+ <div className="absolute -top-1 right-9.5 z-10 h-3 w-3 rotate-45 bg-background-section-burn" />
</div>
- )}
+ </CollapsiblePanel>
<div className="shrink-0 px-4 pt-2 pb-3">
<VariableModalTrigger
open={showVariableModal}
@@ -296,7 +302,7 @@ const ChatVariablePanel = () => {
onCancel={() => setShowRemoveConfirm(false)}
onConfirm={() => cacheForDelete && handleDelete(cacheForDelete)}
/>
- </div>
+ </Collapsible>
)
}
diff --git a/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
index 7d1436bb69e..1bf37f13372 100644
--- a/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
@@ -87,11 +87,11 @@ describe('DebugAndPreview', () => {
})
const toggle = screen.getByRole('button', { name: /panel\.userInputField/ })
- expect(toggle).toHaveAttribute('aria-pressed', 'true')
+ expect(toggle).toHaveAttribute('aria-expanded', 'true')
await user.click(toggle)
- expect(toggle).toHaveAttribute('aria-pressed', 'false')
+ expect(toggle).toHaveAttribute('aria-expanded', 'false')
})
it('closes the panel through a named keyboard action', async () => {
diff --git a/web/app/components/workflow/panel/debug-and-preview/index.tsx b/web/app/components/workflow/panel/debug-and-preview/index.tsx
index 7e6cf5c7819..a9777d21d92 100644
--- a/web/app/components/workflow/panel/debug-and-preview/index.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/index.tsx
@@ -2,14 +2,11 @@ import type { StartNodeType } from '../../nodes/start/types'
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
-import { RiCloseLine, RiEqualizer2Line } from '@remixicon/react'
import { debounce } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { memo, useCallback, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useNodes } from 'reactflow'
-import ActionButton, { ActionButtonState } from '@/app/components/base/action-button'
-import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
import { useStore } from '@/app/components/workflow/store'
import { useEdgesInteractionsWithoutSync } from '../../hooks/use-edges-interactions-without-sync'
import { useNodesInteractionsWithoutSync } from '../../hooks/use-nodes-interactions-without-sync'
@@ -99,7 +96,10 @@ const DebugAndPreview = () => {
<TooltipTrigger
render={
<IconButton aria-label={restartLabel} onClick={() => handleRestartChat()}>
- <RefreshCcw01 aria-hidden="true" className="size-4" />
+ <span
+ aria-hidden="true"
+ className="i-custom-vender-line-arrows-refresh-ccw-01 size-4"
+ />
</IconButton>
}
/>
@@ -110,14 +110,14 @@ const DebugAndPreview = () => {
<Tooltip>
<TooltipTrigger
render={
- <ActionButton
+ <IconButton
aria-label={userInputFieldLabel}
- aria-pressed={expanded}
- state={expanded ? ActionButtonState.Active : undefined}
+ aria-expanded={expanded}
+ className="aria-expanded:bg-state-accent-active aria-expanded:text-text-accent aria-expanded:hover:bg-state-accent-active-alt"
onClick={() => setExpanded(!expanded)}
>
- <RiEqualizer2Line aria-hidden="true" className="size-4" />
- </ActionButton>
+ <span aria-hidden="true" className="i-ri-equalizer-2-line size-4" />
+ </IconButton>
}
/>
<TooltipContent>{userInputFieldLabel}</TooltipContent>
@@ -128,14 +128,9 @@ const DebugAndPreview = () => {
</div>
)}
<div className="mx-3 h-3.5 w-px bg-divider-regular"></div>
- <button
- type="button"
- aria-label={closeLabel}
- className="flex size-6 cursor-pointer appearance-none items-center justify-center rounded-md border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
- onClick={handleCancelDebugAndPreviewPanel}
- >
- <RiCloseLine aria-hidden="true" className="size-4 text-text-tertiary" />
- </button>
+ <IconButton aria-label={closeLabel} onClick={handleCancelDebugAndPreviewPanel}>
+ <span aria-hidden="true" className="i-ri-close-line size-4 text-text-tertiary" />
+ </IconButton>
</div>
</div>
<div className="grow overflow-y-auto rounded-b-2xl">
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
index 91a94ab6799..f05999f13f1 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
@@ -18,11 +18,11 @@ import {
DialogTitle,
} from '@langgenius/dify-ui/dialog'
import { FileTreeIcon } from '@langgenius/dify-ui/file-tree'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { toast } from '@langgenius/dify-ui/toast'
import { useMutation } from '@tanstack/react-query'
import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import ActionButton from '@/app/components/base/action-button'
import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { getSupportFileType } from '@/app/components/base/file-uploader/utils'
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
@@ -190,9 +190,12 @@ function AgentFileUploader({ file, onChange }: { file?: File; onChange: (file?:
</div>
</div>
<div className="hidden items-center pr-3 group-hover:flex">
- <ActionButton onClick={() => onChange(undefined)}>
+ <IconButton
+ aria-label={tCommon(($) => $['operation.remove'])}
+ onClick={() => onChange(undefined)}
+ >
<span aria-hidden className="i-ri-delete-bin-line size-4 text-text-tertiary" />
- </ActionButton>
+ </IconButton>
</div>
</div>
)}
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
index 59170deffbd..f7c8c314d1a 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
@@ -14,11 +14,11 @@ import {
DialogDescription,
DialogTitle,
} from '@langgenius/dify-ui/dialog'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { toast } from '@langgenius/dify-ui/toast'
import { useMutation } from '@tanstack/react-query'
import { useRef, useState } from 'react'
import { Trans, useTranslation } from 'react-i18next'
-import ActionButton from '@/app/components/base/action-button'
import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import Link from '@/next/link'
import { consoleQuery } from '@/service/client'
@@ -70,6 +70,7 @@ function AgentSkillPackageUploader({
showWarning: boolean
}) {
const { t } = useTranslation('agentV2')
+ const { t: tCommon } = useTranslation('common')
const { data: fileUploadConfig } = useFileUploadConfig()
const { skillSizeLimit } = useFileSizeLimit(fileUploadConfig)
const fileInputRef = useRef<HTMLInputElement>(null)
@@ -193,9 +194,12 @@ function AgentSkillPackageUploader({
</div>
</div>
<div className="hidden items-center pr-3 group-hover:flex">
- <ActionButton onClick={() => onChange(undefined)}>
+ <IconButton
+ aria-label={tCommon(($) => $['operation.remove'])}
+ onClick={() => onChange(undefined)}
+ >
<span aria-hidden className="i-ri-delete-bin-line size-4 text-text-tertiary" />
- </ActionButton>
+ </IconButton>
</div>
</div>
)}
diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx
index 235924cd44e..0e0d0768baa 100644
--- a/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/preview/header.tsx
@@ -239,7 +239,7 @@ export function AgentPreviewHeader({
<SegmentedControlDivider className="mx-3" />
<button
type="button"
- aria-pressed={isChatFeaturesOpen}
+ aria-expanded={isChatFeaturesOpen}
onClick={onToggleChatFeatures}
className={cn(
'flex h-8 items-center justify-center gap-1 rounded-lg px-2 py-2 text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',
diff --git a/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx b/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx
index 098bda318c1..99425a44891 100644
--- a/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx
+++ b/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx
@@ -4,11 +4,11 @@ import type {
} from '@dify/contracts/api/console/agent/types.gen'
import type { IChatItem } from '@/app/components/base/chat/chat/type'
import type { ChatConfig, OnFeedback } from '@/app/components/base/chat/types'
+import { IconButton } from '@langgenius/dify-ui/icon-button'
import { toast } from '@langgenius/dify-ui/toast'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { skipToken, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
-import ActionButton from '@/app/components/base/action-button'
import Chat from '@/app/components/base/chat/chat'
import CopyIcon from '@/app/components/base/copy-icon'
import Loading from '@/app/components/base/loading'
@@ -112,13 +112,13 @@ export function AgentLogDetailPanel({
{log?.title || log?.conversation_id}
</div>
</div>
- <ActionButton
- size="l"
+ <IconButton
+ size="lg"
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
onClick={onClose}
>
<span aria-hidden className="i-ri-close-line size-4 text-text-tertiary" />
- </ActionButton>
+ </IconButton>
</div>
<div className="shrink-0 px-1 pt-1">
<div className="rounded-t-xl bg-background-section-burn p-3 pb-2" />