7e7ef50e40
新增 PlatformBackActionButton 共享返回动作与行为测试 迁移登录、绑定手机号和世界实体目录的共享组件直引 扩展示展示页示例并同步组件库文档与决策记录
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { ArrowLeft } from 'lucide-react';
|
|
import type { ButtonHTMLAttributes } from 'react';
|
|
|
|
import { PlatformActionButton } from './PlatformActionButton';
|
|
import type { PlatformActionButtonSurface } from './platformActionButtonModel';
|
|
|
|
export type PlatformBackActionButtonVariant = 'compact' | 'regular';
|
|
|
|
export type PlatformBackActionButtonProps = Omit<
|
|
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
'children'
|
|
> & {
|
|
label?: string;
|
|
variant?: PlatformBackActionButtonVariant;
|
|
surface?: PlatformActionButtonSurface;
|
|
};
|
|
|
|
const VARIANT_CLASS: Record<PlatformBackActionButtonVariant, string> = {
|
|
compact: 'gap-1.5 py-1.5 text-[11px]',
|
|
regular: 'gap-2 py-2 text-sm',
|
|
};
|
|
|
|
const ICON_CLASS: Record<PlatformBackActionButtonVariant, string> = {
|
|
compact: 'h-3.5 w-3.5',
|
|
regular: 'h-4 w-4',
|
|
};
|
|
|
|
/**
|
|
* 平台轻量返回动作按钮。
|
|
* 统一结果页、工作台等白底场景里的“左箭头 + 返回文案”按钮骨架。
|
|
*/
|
|
export function PlatformBackActionButton({
|
|
label = '返回',
|
|
variant = 'compact',
|
|
surface = 'platform',
|
|
className,
|
|
...buttonProps
|
|
}: PlatformBackActionButtonProps) {
|
|
return (
|
|
<PlatformActionButton
|
|
{...buttonProps}
|
|
surface={surface}
|
|
tone="ghost"
|
|
size="xs"
|
|
className={['min-h-0 self-start', VARIANT_CLASS[variant], className]
|
|
.filter(Boolean)
|
|
.join(' ')}
|
|
>
|
|
<ArrowLeft className={ICON_CLASS[variant]} />
|
|
{label}
|
|
</PlatformActionButton>
|
|
);
|
|
}
|