1
1
import { mdiChevronDown } from "@mdi/js" ;
2
2
import type { PropertyValues , TemplateResult } from "lit" ;
3
- import { css , html , LitElement } from "lit" ;
3
+ import { css , html , LitElement , nothing } from "lit" ;
4
4
import { customElement , property , query , state } from "lit/decorators" ;
5
5
import { classMap } from "lit/directives/class-map" ;
6
6
import { fireEvent } from "../common/dom/fire_event" ;
@@ -13,11 +13,11 @@ export class HaExpansionPanel extends LitElement {
13
13
14
14
@property ( { type : Boolean , reflect : true } ) outlined = false ;
15
15
16
- @property ( { attribute : false , type : Boolean , reflect : true } ) leftChevron =
17
- false ;
16
+ @property ( { attribute : "left-chevron" , type : Boolean , reflect : true } )
17
+ public leftChevron = false ;
18
18
19
- @property ( { attribute : false , type : Boolean , reflect : true } ) noCollapse =
20
- false ;
19
+ @property ( { attribute : "no-collapse" , type : Boolean , reflect : true } )
20
+ public noCollapse = false ;
21
21
22
22
@property ( ) header ?: string ;
23
23
@@ -28,6 +28,14 @@ export class HaExpansionPanel extends LitElement {
28
28
@query ( ".container" ) private _container ! : HTMLDivElement ;
29
29
30
30
protected render ( ) : TemplateResult {
31
+ const chevronIcon = this . noCollapse
32
+ ? nothing
33
+ : html `
34
+ <ha- svg- icon
35
+ .path = ${ mdiChevronDown }
36
+ class= "summary-icon ${ classMap ( { expanded : this . expanded } ) } "
37
+ > </ ha- svg- icon>
38
+ ` ;
31
39
return html `
32
40
<div class= "top ${ classMap ( { expanded : this . expanded } ) } " >
33
41
<div
@@ -42,28 +50,15 @@ export class HaExpansionPanel extends LitElement {
42
50
aria- expand ed= ${ this . expanded }
43
51
aria- controls= "sect1"
44
52
>
45
- ${ this . leftChevron && ! this . noCollapse
46
- ? html `
47
- <ha- svg- icon
48
- .path = ${ mdiChevronDown }
49
- class= "summary-icon ${ classMap ( { expanded : this . expanded } ) } "
50
- > </ ha- svg- icon>
51
- `
52
- : "" }
53
+ ${ this . leftChevron ? chevronIcon : nothing }
54
+ <slot name= "leading-icon" > </ slot>
53
55
<slot name= "header" >
54
56
<div class= "header" >
55
57
${ this . header }
56
58
<slot class= "secondary" name = "secondary" > ${ this . secondary } </ slot>
57
59
</ div>
58
60
</ slot>
59
- ${ ! this . leftChevron && ! this . noCollapse
60
- ? html `
61
- <ha- svg- icon
62
- .path = ${ mdiChevronDown }
63
- class= "summary-icon ${ classMap ( { expanded : this . expanded } ) } "
64
- > </ ha- svg- icon>
65
- `
66
- : "" }
61
+ ${ ! this . leftChevron ? chevronIcon : nothing }
67
62
<slot name= "icons" > </ slot>
68
63
</ div>
69
64
</ div>
@@ -177,7 +172,8 @@ export class HaExpansionPanel extends LitElement {
177
172
margin-inline-end : initial;
178
173
}
179
174
180
- : host ([leftchevron ]) .summary-icon {
175
+ : host ([left-chevron ]) .summary-icon ,
176
+ ::slotted ([slot = "leading-icon" ]) {
181
177
margin-left : 0 ;
182
178
margin-right : 8px ;
183
179
margin-inline-start : 0 ;
0 commit comments