Files
Folo/apps/renderer/src/components/ui/button/command-button.tsx
T
Innei 77fa6088fb refactor: streamline entry action handling and replace ActionButton with CommandActionButton
- Removed unused imports and simplified the use of commands in `useEntryActions`.
- Updated `EntryItemWrapper`, `HeaderActions`, and `MoreActions` components to utilize `CommandActionButton` for better command handling.
- Introduced `CommandDropdownMenuItem` for consistent command representation in dropdowns.
- Enhanced readability and maintainability by reducing redundant code and improving type safety.

Signed-off-by: Innei <tukon479@gmail.com>
2024-12-17 20:07:33 +08:00

29 lines
853 B
TypeScript

import type { ActionButtonProps } from "@follow/components/ui/button/action-button.js"
import { ActionButton } from "@follow/components/ui/button/action-button.js"
import { forwardRef } from "react"
import { useCommand } from "~/modules/command/hooks/use-command"
import type { FollowCommandId } from "~/modules/command/types"
export interface CommandActionButtonProps extends ActionButtonProps {
commandId: FollowCommandId
onClick: () => void
}
export const CommandActionButton = forwardRef<HTMLButtonElement, CommandActionButtonProps>(
(props, ref) => {
const command = useCommand(props.commandId)
if (!command) return null
const { icon, label } = command
return (
<ActionButton
ref={ref}
{...props}
icon={icon}
onClick={props.onClick}
tooltip={label.title}
/>
)
},
)