Skip to content

Commit

Permalink
* list: add hoverItemActions option for showing actions on hover.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Sep 19, 2024
1 parent 44fd8f0 commit a250b09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/list/src/component/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class List<P extends ListProps = ListProps, S extends ListState = ListSta

protected _getClassName(props: RenderableProps<P>): 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<P>): Record<string, unknown> {
Expand Down
10 changes: 10 additions & 0 deletions lib/list/src/style/list.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions lib/list/src/types/list-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ListProps<T extends Item = ListItem> extends CommonListProps<T>
active?: string | string[] | Record<string, boolean>;
multipleActive?: boolean;
activeOnHover?: boolean;
hoverItemActions?: boolean;
onActive?: (keys: string[], active: boolean) => void;
onCheck?: (change: Record<ItemKey, CheckedType>, checks: ItemKey[]) => void;
onLoad?: (items: T[]) => void | T[];
Expand Down

0 comments on commit a250b09

Please sign in to comment.