Skip to content

Commit 1764486

Browse files
committed
Merge branch 'main' of github.com:adobe/da-live
2 parents b56b9c8 + 68a29c7 commit 1764486

File tree

3 files changed

+96
-4
lines changed

3 files changed

+96
-4
lines changed
Lines changed: 3 additions & 0 deletions
Loading

blocks/browse/da-list/da-list.css

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ da-list-item.is-expanded::after {
7171
justify-content: start;
7272
}
7373

74+
.da-browse-filter {
75+
cursor: pointer;
76+
background: none;
77+
border: none;
78+
display: flex;
79+
justify-content: center;
80+
align-items: center;
81+
padding: 2px;
82+
height: 18px;
83+
}
84+
85+
.da-browse-filter img {
86+
opacity: 0.4;
87+
}
88+
89+
.da-browse-filter.selected img {
90+
opacity: 1;
91+
}
92+
93+
.da-browse-filter:hover img {
94+
opacity: 1;
95+
}
96+
7497
.da-browse-header-name {
7598
position: relative;
7699
margin: 0;
@@ -79,11 +102,41 @@ da-list-item.is-expanded::after {
79102
background: none;
80103
text-transform: uppercase;
81104
line-height: 18px;
105+
font-size: 14px;
82106
color: var(--s2-gray-700);
107+
font-family: var(--body-font-family);
83108
font-weight: 700;
84109
cursor: pointer;
85110
}
86111

112+
.da-browse-header-container input {
113+
padding: 0;
114+
border: none;
115+
display: none;
116+
font-family: var(--body-font-family);
117+
font-size: 14px;
118+
line-height: 18px;
119+
color: var(--s2-gray-800);
120+
}
121+
122+
.da-browse-header-container input::placeholder {
123+
font-weight: 700;
124+
text-transform: uppercase;
125+
color: #8f8f8f;
126+
}
127+
128+
.da-browse-header-container .hide {
129+
display: none;
130+
}
131+
132+
.da-browse-header-container input.show {
133+
display: block;
134+
}
135+
136+
.da-browse-header-container input:focus {
137+
outline: none;
138+
}
139+
87140
.da-browse-header-name:hover::after {
88141
position: absolute;
89142
content: '';
@@ -100,7 +153,6 @@ da-list-item.is-expanded::after {
100153
position: absolute;
101154
content: '';
102155
right: -20px;
103-
top: 0;
104156
width: 18px;
105157
height: 18px;
106158
filter: invert(26%) sepia(0%) saturate(946%) hue-rotate(145deg) brightness(102%) contrast(81%);

blocks/browse/da-list/da-list.js

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default class DaList extends LitElement {
2828
newItem: { attribute: false },
2929
_permissions: { state: true },
3030
_listItems: { state: true },
31+
_filter: { state: true },
32+
_showFilter: { state: true },
3133
_selectedItems: { state: true },
3234
_dropFiles: { state: true },
3335
_dropMessage: { state: true },
@@ -39,6 +41,7 @@ export default class DaList extends LitElement {
3941
this._dropFiles = [];
4042
this._dropMessage = 'Drop content here';
4143
this._lastCheckedIndex = null;
44+
this._filter = '';
4245
}
4346

4447
connectedCallback() {
@@ -378,6 +381,28 @@ export default class DaList extends LitElement {
378381
this.handleSort(this._sortDate, 'lastModified');
379382
}
380383

384+
toggleFilterView() {
385+
this._filter = '';
386+
this._showFilter = !this._showFilter;
387+
const filterInput = this.shadowRoot?.querySelector('input[name="filter"]');
388+
filterInput.value = '';
389+
if (this._showFilter) {
390+
this.wait(1).then(() => { filterInput.focus(); });
391+
}
392+
}
393+
394+
handleFilterBlur(e) {
395+
if (e.target.value === '') {
396+
this._showFilter = false;
397+
}
398+
}
399+
400+
handleNameFilter(e) {
401+
this._sortName = undefined;
402+
this._sortDate = undefined;
403+
this._filter = e.target.value;
404+
}
405+
381406
get isSelectAll() {
382407
const selectCount = this._listItems.filter((item) => item.isChecked).length;
383408
return selectCount === this._listItems.length && this._listItems.length !== 0;
@@ -440,21 +465,33 @@ export default class DaList extends LitElement {
440465
}
441466

442467
render() {
468+
const filteredItems = this._listItems.filter((item) => item.name.includes(this._filter));
469+
443470
return html`
444471
<div class="da-browse-panel-header">
445472
${this.renderCheckBox()}
446473
<div class="da-browse-sort">
447-
<span></span>
474+
<!-- Toggle button is split into 2 buttons (enable/disable) to prevent bug re-toggling on blur event -->
475+
${!this._showFilter ? html`
476+
<button class="da-browse-filter" name="toggle-filter" @click=${() => this.toggleFilterView()}>
477+
<img class="toggle-icon-dark" width="20" src="/blocks/browse/da-browse/img/Filter20.svg" />
478+
</button>
479+
` : html`
480+
<button class="da-browse-filter selected" name="toggle-filter" @click=${() => this.toggleFilterView()}>
481+
<img class="toggle-icon-dark" width="20" src="/blocks/browse/da-browse/img/Filter20.svg" />
482+
</button>
483+
`}
448484
<div class="da-browse-header-container">
449-
<button class="da-browse-header-name ${this._sortName}" @click=${this.handleNameSort}>Name</button>
485+
<input @blur=${this.handleFilterBlur} name="filter" class=${this._showFilter ? 'show' : nothing} @change=${this.handleNameFilter} @keyup=${this.handleNameFilter} type="text" placeholder="Filter">
486+
<button class="da-browse-header-name ${this._sortName} ${this._showFilter ? 'hide' : ''}" @click=${this.handleNameSort}>Name</button>
450487
</div>
451488
<div class="da-browse-header-container">
452489
<button class="da-browse-header-name ${this._sortDate}" @click=${this.handleDateSort}>Modified</button>
453490
</div>
454491
</div>
455492
</div>
456493
<div class="da-browse-panel" @dragenter=${this.drag ? this.dragenter : nothing} @dragleave=${this.drag ? this.dragleave : nothing}>
457-
${this._listItems?.length > 0 ? this.renderList(this._listItems, true) : this.renderEmpty()}
494+
${filteredItems?.length > 0 ? this.renderList(filteredItems, true) : this.renderEmpty()}
458495
${this.drag ? this.renderDropArea() : nothing}
459496
</div>
460497
<da-actionbar

0 commit comments

Comments
 (0)