diff --git a/resources/js/components/api-nav.ts b/resources/js/components/api-nav.ts new file mode 100644 index 000000000..a84c1cb33 --- /dev/null +++ b/resources/js/components/api-nav.ts @@ -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', + }); + } + }); + } +} \ No newline at end of file diff --git a/resources/js/components/index.ts b/resources/js/components/index.ts index 63e1ad0db..736d93f05 100644 --- a/resources/js/components/index.ts +++ b/resources/js/components/index.ts @@ -1,6 +1,7 @@ export {AddRemoveRows} from './add-remove-rows'; export {AjaxDeleteRow} from './ajax-delete-row'; export {AjaxForm} from './ajax-form'; +export {ApiNav} from './api-nav'; export {Attachments} from './attachments'; export {AttachmentsList} from './attachments-list'; export {AutoSuggest} from './auto-suggest'; diff --git a/resources/sass/_blocks.scss b/resources/sass/_blocks.scss index 8c248caee..4857c2cee 100644 --- a/resources/sass/_blocks.scss +++ b/resources/sass/_blocks.scss @@ -274,7 +274,19 @@ .sticky-sidebar { position: sticky; - top: vars.$m; - max-height: calc(100vh - #{vars.$m}); + top: 0; + padding-left: 2px; + max-height: calc(100vh); overflow-y: auto; + .sticky-sidebar-header { + position: sticky; + top: 0; + background: #F2F2F2; + background: linear-gradient(180deg,rgba(242, 242, 242, 1) 66%, rgba(242, 242, 242, 0) 100%); + z-index: 4; + } +} +.dark-mode .sticky-sidebar-header { + background: #111; + background: linear-gradient(180deg,rgba(17, 17, 17, 1) 66%, rgba(17, 17, 17, 0) 100%); } diff --git a/resources/views/api-docs/index.blade.php b/resources/views/api-docs/index.blade.php index 84c6d21ac..c331f0707 100644 --- a/resources/views/api-docs/index.blade.php +++ b/resources/views/api-docs/index.blade.php @@ -2,48 +2,65 @@ @section('body') -