Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offcanvas filters for document listing #1908

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 0 additions & 215 deletions peachjam/js/components/ListFacets.vue

This file was deleted.

48 changes: 48 additions & 0 deletions peachjam/js/components/document-filter-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default class DocumentFilterForm {
public root: HTMLElement;
public offCanvasUsed: boolean = false;

constructor (root: HTMLElement) {
this.root = root;

// setup a resize observer to move the filters when the window is resized
const observer = new ResizeObserver(() => this.moveFilters());
observer.observe(this.root);
this.moveFilters();
}

moveFilters () {
// on small displays, move the filters into the offcanvas element
if (window.innerWidth < 992) {
this.moveFiltersToOffcanvas();
} else {
this.moveFiltersToMainContent();
}
}

moveFiltersToOffcanvas () {
if (!this.offCanvasUsed) {
const offcanvas = this.root.querySelector('.offcanvas-body');
const content = this.root.querySelector('.document-list-facets');
if (offcanvas && content) {
requestAnimationFrame(() => {
offcanvas.appendChild(content);
this.offCanvasUsed = true;
});
}
}
}

moveFiltersToMainContent () {
if (this.offCanvasUsed) {
const wrapper = this.root.querySelector('.document-list-facets-wrapper');
const content = this.root.querySelector('.document-list-facets');
if (wrapper && content) {
requestAnimationFrame(() => {
wrapper.appendChild(content);
this.offCanvasUsed = false;
});
}
}
}
}
31 changes: 0 additions & 31 deletions peachjam/js/components/document-list.ts

This file was deleted.

4 changes: 2 additions & 2 deletions peachjam/js/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CopyToClipboard } from './clipboard';
import { RelationshipEnrichments } from './RelationshipEnrichment';
import DocumentList from './document-list';
import DocumentFilterForm from './document-filter-form';
import DocumentTable from './document-table';
import DocumentContent from './DocumentContent/index';
import NavigationSelect from './navigation-select';
Expand All @@ -16,8 +16,8 @@ const components: Record<string, any> = {
// Data components
CopyToClipboard,
DocumentContent,
DocumentFilterForm,
DocumentTable,
DocumentList,
NavigationSelect,
RelationshipEnrichments,
ToggleTab,
Expand Down
2 changes: 1 addition & 1 deletion peachjam/static/js/app-prod.js

Large diffs are not rendered by default.

Loading
Loading