mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-07 22:44:19 -05:00
248fc3699a
* adding classes according to bootstrap 5 tabs * adding JS for tabs handeling in BS5 * adding styling for tabs to match the redesign styling * making sure tabs are being highlighted when active * adding a scroll-margin-top to have some extra space * removing extra import, it is not needed here because we already import it in bootstrap-x.js files * using the media-breakpoint-down for a media query styling * introducing .nav-tabs-container to make the tab triggers horizontally scrollable * creating a mixin box-shadow-button-input under scss for bootstrap-5 * moving border-width-base to tabs.scss * aligning tabs to the left under screen size of 768px * removing focus-style mixin from scss files becuase it was a duplicate GitOrigin-RevId: 45780c62681fc9b61961f5436d2d55de66a976b6
30 lines
728 B
TypeScript
30 lines
728 B
TypeScript
import { Tab } from 'bootstrap-5'
|
|
|
|
function bookmarkableTab(tabEl: HTMLElement) {
|
|
tabEl.addEventListener('click', () => {
|
|
window.location.hash = tabEl.getAttribute('href') as string
|
|
})
|
|
}
|
|
|
|
function handleHashChange() {
|
|
const hash = window.location.hash
|
|
if (!hash) return
|
|
|
|
// Find the bookmarkable tab that links to the hash
|
|
const tabEl = document.querySelector(
|
|
`[data-ol-bookmarkable-tab][href="${hash}"]`
|
|
)
|
|
|
|
if (!tabEl) return
|
|
|
|
// Select the tab via Bootstrap 5
|
|
const tab = new Tab(tabEl)
|
|
tab.show()
|
|
}
|
|
|
|
document
|
|
.querySelectorAll('[data-ol-bookmarkable-tab]')
|
|
.forEach(tabEl => bookmarkableTab(tabEl as HTMLElement))
|
|
|
|
window.addEventListener('hashchange', handleHashChange)
|
|
handleHashChange()
|