mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-11-04 13:31:45 +03:00
API: Re-ordered routes, Improved navigation
Updated route order to follow some kind of logic. Updated scrolling sidebar to not be so cut-off in various scenarios. Added new nav helper to quick jump to specific API models. Closes #5865
This commit is contained in:
32
resources/js/components/api-nav.ts
Normal file
32
resources/js/components/api-nav.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {Component} from "./component";
|
||||
|
||||
export class ApiNav extends Component {
|
||||
private select!: HTMLSelectElement;
|
||||
private sidebar!: HTMLElement;
|
||||
private body!: HTMLElement;
|
||||
|
||||
setup() {
|
||||
this.select = this.$refs.select as HTMLSelectElement;
|
||||
this.sidebar = this.$refs.sidebar;
|
||||
this.body = this.$el.ownerDocument.documentElement;
|
||||
this.select.addEventListener('change', () => {
|
||||
const section = this.select.value;
|
||||
const sidebarTarget = document.getElementById(`sidebar-header-${section}`);
|
||||
const contentTarget = document.getElementById(`section-${section}`);
|
||||
if (sidebarTarget && contentTarget) {
|
||||
|
||||
const sidebarPos = sidebarTarget.getBoundingClientRect().top - this.sidebar.getBoundingClientRect().top + this.sidebar.scrollTop;
|
||||
this.sidebar.scrollTo({
|
||||
top: sidebarPos - 120,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
|
||||
const bodyPos = contentTarget.getBoundingClientRect().top + this.body.scrollTop;
|
||||
this.body.scrollTo({
|
||||
top: bodyPos - 20,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user