Skip to content

Commit

Permalink
* list: support for setting icon class.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Sep 12, 2024
1 parent 4e01473 commit 239187e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/list/src/component/listitem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Listitem<P extends ListitemProps = ListitemProps, S = {}> extends H
protected _renderLeading(props: RenderableProps<P>): ComponentChild[] {
const {
icon,
iconClass,
avatar,
toggleIcon,
leading,
Expand All @@ -27,7 +28,7 @@ export class Listitem<P extends ListitemProps = ListitemProps, S = {}> extends H
contents.push(<Checkbox key="checkbox" className="item-checkbox" checked={checked} {...checkbox} />);
}
if (icon) {
contents.push(<Icon key="icon" className="item-icon" icon={icon} />);
contents.push(<Icon key="icon" className={classes('item-icon', iconClass)} icon={icon} />);
}
if (avatar) {
const avatarProps = typeof avatar === 'function' ? avatar.call(this, props) : avatar;
Expand Down Expand Up @@ -84,11 +85,12 @@ export class Listitem<P extends ListitemProps = ListitemProps, S = {}> extends H
trailing,
trailingClass,
trailingIcon,
trailingIconClass,
actions,
} = props;
const contents: ComponentChild[] = [];
if (trailingIcon) {
contents.push(<Icon key="trailing-icon" className="item-trailing-icon" icon={trailingIcon} />);
contents.push(<Icon key="trailing-icon" className={classes('item-trailing-icon', trailingIconClass)} icon={trailingIcon} />);
}
if (actions) {
contents.push(Toolbar.render(actions, [props], {key: 'actions', relativeTarget: props, size: 'sm'}, this));
Expand Down
2 changes: 2 additions & 0 deletions lib/list/src/types/listitem-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ListitemProps extends Item {
divider?: boolean;
toggleIcon?: CustomContentType;
icon?: IconType;
iconClass?: ClassNameLike;
selected?: boolean;
avatar?: AvatarOptions | ((item: Item) => AvatarOptions);
leading?: CustomContentType;
Expand All @@ -33,6 +34,7 @@ export interface ListitemProps extends Item {
trailing?: CustomContentType;
trailingClass?: ClassNameLike;
trailingIcon?: IconType;
trailingIconClass?: ClassNameLike;
actions?: ToolbarSetting<[Item]>;
contentClass?: ClassNameLike;
content?: CustomContentType;
Expand Down

0 comments on commit 239187e

Please sign in to comment.