Skip to content

Commit e206e62

Browse files
authored
feat(list-item): add selected property (#1590)
Closes #968
1 parent fea3e04 commit e206e62

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
### Added
9+
- #### List
10+
- The `igc-list-item` component exposes a new `selected` property. When set on a list item, the item will become visually highlighted.
11+
712
## [5.2.4] - 2025-02-24
813
### Changed
914
- #### Carousel - **Potential visual breaking change.**

src/components/list/list-item.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LitElement, html } from 'lit';
22

3+
import { property } from 'lit/decorators.js';
34
import { themes } from '../../theming/theming-decorator.js';
45
import { registerComponent } from '../common/definitions/register.js';
56
import { styles } from './themes/item.base.css.js';
@@ -35,6 +36,13 @@ export default class IgcListItemComponent extends LitElement {
3536
registerComponent(IgcListItemComponent);
3637
}
3738

39+
/**
40+
* Defines if the list item is selected or not.
41+
* @attr
42+
*/
43+
@property({ type: Boolean, reflect: true })
44+
public selected = false;
45+
3846
private _internals: ElementInternals;
3947

4048
constructor() {

src/components/list/themes/shared/item/list-item.common.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ $theme: $material;
77
border-radius: var-get($theme, 'item-border-radius');
88
color: var-get($theme, 'item-text-color');
99
background: var-get($theme, 'item-background');
10-
border-bottom: var-get($theme, 'border-width') solid var-get($theme, 'border-color');
10+
border-bottom: var-get($theme, 'border-width') solid
11+
var-get($theme, 'border-color');
1112
}
1213

1314
:host(:last-of-type) {
@@ -30,6 +31,27 @@ $theme: $material;
3031
color: var-get($theme, 'item-action-color');
3132
}
3233

34+
:host([selected]) {
35+
color: var-get($theme, 'item-text-color-selected');
36+
background: var-get($theme, 'item-background-selected');
37+
38+
[part='title'] {
39+
color: var-get($theme, 'item-title-color-selected');
40+
}
41+
42+
[part='subtitle'] {
43+
color: var-get($theme, 'item-subtitle-color-selected');
44+
}
45+
46+
[part='start'] {
47+
color: var-get($theme, 'item-thumbnail-color-selected');
48+
}
49+
50+
[part='end'] {
51+
color: var-get($theme, 'item-action-color-selected');
52+
}
53+
}
54+
3355
:host(:hover),
3456
:host(:focus-within) {
3557
background: var-get($theme, 'item-background-hover');

stories/avatar.stories.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
IgcAvatarComponent,
55
IgcIconComponent,
66
defineComponents,
7-
registerIcon,
87
} from 'igniteui-webcomponents';
98
import { html } from 'lit';
109

@@ -63,11 +62,6 @@ interface IgcAvatarArgs {
6362
}
6463
type Story = StoryObj<IgcAvatarArgs>;
6564

66-
registerIcon(
67-
'home',
68-
'https://unpkg.com/[email protected]/action/svg/production/ic_home_24px.svg'
69-
);
70-
7165
// endregion
7266

7367
export const Image: Story = {

0 commit comments

Comments
 (0)