Skip to content

Commit

Permalink
Merge pull request #1908 from laws-africa/offcanvas
Browse files Browse the repository at this point in the history
Offcanvas filters for document listing
  • Loading branch information
longhotsummer authored Jul 16, 2024
2 parents 6790de6 + f8f4881 commit 3f6b421
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 320 deletions.
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

0 comments on commit 3f6b421

Please sign in to comment.