From a250b09960f07db1df43df3192671212840db23c Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 19 Sep 2024 10:36:23 +0800 Subject: [PATCH] * list: add hoverItemActions option for showing actions on hover. --- lib/list/src/component/list.tsx | 2 +- lib/list/src/style/list.css | 10 ++++++++++ lib/list/src/types/list-props.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/list/src/component/list.tsx b/lib/list/src/component/list.tsx index 4a226b76da..eb897c1717 100644 --- a/lib/list/src/component/list.tsx +++ b/lib/list/src/component/list.tsx @@ -337,7 +337,7 @@ export class List

): ClassNameLike { const {loading, loadFailed} = this.state; - return [super._getClassName(props), loading ? 'loading' : (loadFailed ? 'is-load-failed' : '')]; + return [super._getClassName(props), loading ? 'loading' : (loadFailed ? 'is-load-failed' : ''), props.hoverItemActions ? 'with-hover-actions' : '']; } protected _getProps(props: RenderableProps

): Record { diff --git a/lib/list/src/style/list.css b/lib/list/src/style/list.css index 482a907bae..3701bcfd03 100644 --- a/lib/list/src/style/list.css +++ b/lib/list/src/style/list.css @@ -4,3 +4,13 @@ .list-heading-inner .item-title { @apply -font-bold -text-gray-500; } + +.with-hover-actions .item { + @apply -relative +} +.with-hover-actions .item-actions { + @apply -absolute -pointer-events-none -right-1 -top-0 -opacity-0 -transition-opacity; +} +.with-hover-actions .item:hover .item-actions { + @apply -static -pointer-events-auto -flex --mt-1 -opacity-100; +} diff --git a/lib/list/src/types/list-props.ts b/lib/list/src/types/list-props.ts index 10c0cb60fb..7eee89f5e0 100644 --- a/lib/list/src/types/list-props.ts +++ b/lib/list/src/types/list-props.ts @@ -14,6 +14,7 @@ export interface ListProps extends CommonListProps active?: string | string[] | Record; multipleActive?: boolean; activeOnHover?: boolean; + hoverItemActions?: boolean; onActive?: (keys: string[], active: boolean) => void; onCheck?: (change: Record, checks: ItemKey[]) => void; onLoad?: (items: T[]) => void | T[];