@dile/ui 2.8.5 → 2.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/accordion/accordion-item.js +3 -0
- package/components/accordion/accordion.js +3 -0
- package/components/accordion/index.js +2 -0
- package/components/accordion/src/DileAccordion.js +39 -0
- package/components/accordion/src/DileAccordionItem.js +175 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class DileAccordion extends LitElement {
|
|
4
|
+
|
|
5
|
+
static styles = [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--dile-accordion-gap, .5rem);
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
connectedCallback(){
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
this.addEventListener('accordion-item-opened', (e) => {
|
|
18
|
+
const openedItem = e.detail.item;
|
|
19
|
+
this.closeOtherItems(openedItem);
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
closeOtherItems(openedItem) {
|
|
24
|
+
const items = this.getElementsByTagName('dile-accordion-item');
|
|
25
|
+
|
|
26
|
+
for (const item of items) {
|
|
27
|
+
if (item !== openedItem) {
|
|
28
|
+
item.opened = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
return html`
|
|
35
|
+
<slot></slot>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { arrowDropDownIcon } from '@dile/icons/index.js';
|
|
3
|
+
import { DileSlideDown } from '@dile/ui/mixins/slide-down';
|
|
4
|
+
|
|
5
|
+
export class DileAccordionItem extends DileSlideDown(LitElement) {
|
|
6
|
+
|
|
7
|
+
static styles = [
|
|
8
|
+
css`
|
|
9
|
+
:host {
|
|
10
|
+
/** Display */
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
justify-content: end;
|
|
14
|
+
align-items: start;
|
|
15
|
+
|
|
16
|
+
/** Container */
|
|
17
|
+
width: 100%;
|
|
18
|
+
max-width: var(--dile-accordion-item-max-width, 100%);
|
|
19
|
+
border-radius: var(--dile-accordion-item-border-radius, none);
|
|
20
|
+
|
|
21
|
+
/** Others */
|
|
22
|
+
color: var(--dile-accordion-item-color, white);
|
|
23
|
+
background: var(--dile-accordion-item-background, transparent);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button{
|
|
27
|
+
/** Container */
|
|
28
|
+
width: 100%;
|
|
29
|
+
max-width: var(--dile-accordion-item-max-width, 100%);
|
|
30
|
+
height: 100%;
|
|
31
|
+
padding: var(--dile-accordion-item-button-padding, .7rem);
|
|
32
|
+
border: var(--dile-accordion-item-button-border, none);
|
|
33
|
+
border-radius: var(--dile-accordion-item-button-border-radius, var(--dile-accordion-item-border-radius, .5rem));
|
|
34
|
+
box-shadow: var(--dile-accordion-item-button-box-shadow, 2px 2px 10px gray);
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
transition: margin-bottom .2s .3s ease-in-out;
|
|
37
|
+
|
|
38
|
+
/** Others */
|
|
39
|
+
font-family: inherit;
|
|
40
|
+
font-size: var(--dile-accordion-item-button-font-size, 1.1rem);
|
|
41
|
+
background: var(--dile-accordion-item-button-background, var(--dile-accordion-item-background, black));
|
|
42
|
+
color: var(--dile-accordion-item-button-color, var(--dile-accordion-item-color, white));
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
button.opened{
|
|
48
|
+
margin-bottom: var(--dile-accordion-item-inner-separation, .5rem);
|
|
49
|
+
transition: margin-bottom .3s ease-in-out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.buttonContent{
|
|
53
|
+
/** Display */
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
gap: 1rem;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
span.icon svg{
|
|
62
|
+
fill: var(--dile-accordion-item-button-icon-closed-color, var(--dile-accordion-item-button-icon-color, var(--dile-accordion-item-button-color, var(--dile-accordion-item-color, white))));
|
|
63
|
+
scale: 1.8;
|
|
64
|
+
transition: fill .3s ease-in-out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
span.icon{
|
|
68
|
+
transition: transform .3s ease-in-out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
span.icon.opened{
|
|
72
|
+
transform-origin: center;
|
|
73
|
+
transform: rotate(180deg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
span.icon.opened svg{
|
|
77
|
+
fill: var(--dile-accordion-item-button-icon-opened-color, var(--dile-accordion-item-button-icon-color, var(--dile-accordion-item-button-color, var(--dile-accordion-item-color, white))));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.contentContainer{
|
|
81
|
+
/** Container */
|
|
82
|
+
width: 100%;
|
|
83
|
+
max-width: var(--dile-accordion-item-max-width, 100%);
|
|
84
|
+
height: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
|
|
87
|
+
/** Others */
|
|
88
|
+
border: var(--dile-accordion-item-content-border, none);
|
|
89
|
+
border-radius: var(--dile-accordion-item-content-border-radius, var(--dile-accordion-item-border-radius, .5rem));
|
|
90
|
+
box-shadow: var(--dile-accordion-item-content-box-shadow, 2px 2px 10px gray);
|
|
91
|
+
background: var(--dile-accordion-item-content-background, var(--dile-accordion-item-background, black));
|
|
92
|
+
color: var(--dile-accordion-item-content-color, var(--dile-accordion-item-color, white));
|
|
93
|
+
transition: height .3s ease-in-out;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.content{
|
|
97
|
+
font-size: var(--dile-accordion-item-content-font-size, 1rem);
|
|
98
|
+
padding: var(--dile-accordion-item-content-padding, .7rem);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#content {
|
|
102
|
+
transition: height 0.3s ease-in;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
`
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
static properties = {
|
|
110
|
+
title: { type: String, reflect: true },
|
|
111
|
+
opened: { type: Boolean, reflect: true },
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
constructor(){
|
|
115
|
+
super();
|
|
116
|
+
this.opened = false;
|
|
117
|
+
this.title = '';
|
|
118
|
+
this.expandableContent = null;
|
|
119
|
+
|
|
120
|
+
if(this.hasAttribute('dile-cloak')) this.removeAttribute('dile-cloak');
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
firstUpdated(){
|
|
124
|
+
this.expandableContent = this.shadowRoot.getElementById('content');
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
updated(changed){
|
|
129
|
+
if(changed.has('opened')){
|
|
130
|
+
this.opened ? this.open() : this.close();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
render() {
|
|
135
|
+
return html`
|
|
136
|
+
<button @click=${this.toggle} class="${this.opened ? 'opened' : ''}">
|
|
137
|
+
<div class="buttonContent">
|
|
138
|
+
<span>${this.title}</span>
|
|
139
|
+
<span class="icon ${this.opened ? 'opened' : ''}">${arrowDropDownIcon}</span>
|
|
140
|
+
</div>
|
|
141
|
+
</button>
|
|
142
|
+
|
|
143
|
+
<div class="contentContainer" id="content">
|
|
144
|
+
<div class="content">
|
|
145
|
+
<slot name="accordion-item-content"></slot>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
toggle(){
|
|
152
|
+
this.opened = !this.opened;
|
|
153
|
+
|
|
154
|
+
if (this.opened) {
|
|
155
|
+
this.dispatchEvent(
|
|
156
|
+
new CustomEvent('accordion-item-opened', {
|
|
157
|
+
detail: {
|
|
158
|
+
item: this
|
|
159
|
+
},
|
|
160
|
+
bubbles: true,
|
|
161
|
+
composed: true
|
|
162
|
+
})
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
open() {
|
|
168
|
+
this.slideShow(this.expandableContent);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
close() {
|
|
172
|
+
this.slideHide(this.expandableContent);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://dile-components.com/",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dile/icons": "^2.4.
|
|
23
|
+
"@dile/icons": "^2.4.2",
|
|
24
24
|
"lit": "^2.7.0 || ^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "5138edc657a45031d845fb30ebf9b8cf7d77e9ef"
|
|
30
30
|
}
|