Skip to content

Commit

Permalink
* list: add more attrs to LIstitem.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Oct 17, 2023
1 parent 6f2abd8 commit 3f84c21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/list/src/component/listitem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ export class Listitem<P extends ListitemProps = ListitemProps, S = {}> extends H
const {
textClass,
titleClass,
titleAttrs,
subtitle,
subtitleClass,
url,
target,
content,
contentClass,
contentAttrs,
hint,
} = props;
const titleAsLink = url && !linkRendered;
const TitleComponent = titleAsLink ? 'a' : 'div';
Expand All @@ -66,8 +69,8 @@ export class Listitem<P extends ListitemProps = ListitemProps, S = {}> extends H
text = null;
}
return [
<div className={classes('item-content', contentClass)} key="content">
{title ? <TitleComponent key="title" className={classes('item-title', titleClass)} href={titleAsLink ? url : undefined} target={titleAsLink ? target : undefined}><CustomContent content={title} /></TitleComponent> : null}
<div className={classes('item-content', contentClass)} key="content" title={hint} {...contentAttrs}>
{title ? <TitleComponent key="title" className={classes('item-title', titleClass)} href={titleAsLink ? url : undefined} target={titleAsLink ? target : undefined} {...titleAttrs}><CustomContent content={title} /></TitleComponent> : null}
{subtitle ? <div key="subtitle" className={classes('item-subtitle', subtitleClass)}><CustomContent content={subtitle} /></div> : null}
{text ? <div key="text" className={classes('item-text text', textClass)}>{text}</div> : null}
{content ? <CustomContent key="extraContent" content={content} /> : null}
Expand Down
3 changes: 3 additions & 0 deletions lib/list/src/types/listitem-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ListitemProps extends Item {
textClass?: ClassNameLike;
title?: CustomContentType;
titleClass?: ClassNameLike;
titleAttrs?: Record<string, unknown>;
subtitle?: CustomContentType;
subtitleClass?: ClassNameLike;
trailing?: CustomContentType;
Expand All @@ -35,4 +36,6 @@ export interface ListitemProps extends Item {
actions?: ToolbarSetting<[Item]>;
contentClass?: ClassNameLike;
content?: CustomContentType;
contentAttrs?: Record<string, unknown>;
hint?: string;
}

0 comments on commit 3f84c21

Please sign in to comment.