Skip to content

Commit

Permalink
feat: more robust default version selector injection location
Browse files Browse the repository at this point in the history
  • Loading branch information
0t4u committed Nov 3, 2024
1 parent cf9ab17 commit 98e961b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/assets/versionsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ select.onchange = () => {
const newUrl = new URL(newPaths, window.location.origin);
window.location.assign(newUrl);
};

const header = document.querySelector('header.tsd-page-toolbar #tsd-search');
if (!!header && select.className.includes('title')) {
header.prepend(select);
}
18 changes: 12 additions & 6 deletions src/etc/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ export function injectSelectHtml(
<select id="plugin-versions-select" name="versions"></select>
));
} else {
app.renderer.hooks.on('body.begin', () => (
<select
id="plugin-versions-select"
class="title"
name="versions"
></select>
app.renderer.hooks.on('head.end', () => (
<style>{`
.tsd-ext-version-select .settings-label {
margin: 0.75rem 0.75rem 0 0;
`}</style>
));

app.renderer.hooks.on('pageSidebar.begin', () => (
<div class="tsd-ext-version-select">
<label class="settings-label" for="plugin-versions-select">Version</label>
<select id="plugin-versions-select" name="versions"></select>
</div>
));
}
}

0 comments on commit 98e961b

Please sign in to comment.