content/static: directory tree fixes

- Reduces padding inside of directories rows.
- Directories expand when entering text search.

Change-Id: Idba574f0b6ca71d6bb940553f2a3e727b07218ef
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290070
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
This commit is contained in:
Jamal Carvalho 2021-02-05 16:39:40 -05:00
Родитель 0b6828017d
Коммит 54d798018a
5 изменённых файлов: 27 добавлений и 10 удалений

Просмотреть файл

@ -37,7 +37,7 @@
border-bottom: 0.0625rem solid var(--gray-8);
max-width: 32rem;
min-width: 12rem;
padding: 0.5rem 1rem;
padding: 0.25rem 1rem;
word-break: break-word;
}
.UnitDirectories th {

Просмотреть файл

@ -25,12 +25,15 @@ export class ExpandableRowsTableController {
this.toggles.forEach(t => {
t.addEventListener('click', e => {
this.handleToggleClick(e);
this.updateVisibleItems();
});
});
this.expandAll?.addEventListener('click', () => {
this.handleExpandAllClick();
this.updateVisibleItems();
this.expandAllItems();
});
document.addEventListener('keydown', e => {
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
this.expandAllItems();
}
});
}
handleToggleClick(e) {
@ -43,11 +46,13 @@ export class ExpandableRowsTableController {
const isExpanded = target?.getAttribute('aria-expanded') === 'true';
target?.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
e.stopPropagation();
this.updateVisibleItems();
}
handleExpandAllClick() {
expandAllItems() {
this.table
.querySelectorAll('[aria-expanded=false]')
.forEach(t => t.setAttribute('aria-expanded', 'true'));
this.updateVisibleItems();
}
updateVisibleItems() {
this.toggles.forEach(t => {

Просмотреть файл

@ -1 +1 @@
{"version":3,"file":"table.js","sourceRoot":"","sources":["table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,MAAM,OAAO,6BAA6B;IASxC,YAAY,KAAuB,EAAE,SAA6B;QAChE,IAAI,CAAC,KAAK,GA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G,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;YAC/D,MAAM,MAAM,GAAG,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE;gBACnB,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAChD,IAAI,UAAU,EAAE;oBACd,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBACjC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;iBACpC;qBAAM;oBACL,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBAChC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;iBACrC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}

Просмотреть файл

@ -87,4 +87,10 @@ describe('ExpandableRowsTableController', () => {
expect(document.querySelector('#hidden-row-id-1').classList).toContain('visible');
expect(document.querySelector('#hidden-row-id-2').classList).toContain('visible');
});
it('expands rows when entering text search', () => {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'f', ctrlKey: true }));
expect(document.querySelector('#hidden-row-id-1').classList).toContain('visible');
expect(document.querySelector('#hidden-row-id-2').classList).toContain('visible');
});
});

Просмотреть файл

@ -53,12 +53,16 @@ export class ExpandableRowsTableController {
this.toggles.forEach(t => {
t.addEventListener('click', e => {
this.handleToggleClick(e);
this.updateVisibleItems();
});
});
this.expandAll?.addEventListener('click', () => {
this.handleExpandAllClick();
this.updateVisibleItems();
this.expandAllItems();
});
document.addEventListener('keydown', e => {
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
this.expandAllItems();
}
});
}
@ -72,12 +76,14 @@ export class ExpandableRowsTableController {
const isExpanded = target?.getAttribute('aria-expanded') === 'true';
target?.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
e.stopPropagation();
this.updateVisibleItems();
}
private handleExpandAllClick() {
private expandAllItems() {
this.table
.querySelectorAll('[aria-expanded=false]')
.forEach(t => t.setAttribute('aria-expanded', 'true'));
this.updateVisibleItems();
}
private updateVisibleItems() {