Skip to content

Commit

Permalink
Add "scroll to npmhub" to the sidebar (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nisgrak committed May 29, 2023
1 parent e81d847 commit 261203a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/components/ScrollButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="mt-2">
<a href="#dependencies" class="Link--muted">
<svg version="1.1" aria-hidden="true" height="16" width="16" viewBox="150 50 250 450" data-view-component="true" class="octicon mr-2">
<path fill-rule="evenodd" d="M416 451h-64V195h-96v256H96V198.727c0-28.22 9.69-49.527 25.002-67.985l.944-1.127-.095-.37-.686-2.554-.17-.648-.267-1.056-.281-1.154-.289-1.25-.194-.887-.194-.927a97.932 97.932 0 0 1-.097-.48l-.192-.989-.188-1.029a97.118 97.118 0 0 1-.093-.529l-.18-1.088-.174-1.127a97.488 97.488 0 0 1-.465-3.607l-.132-1.276c-1.15-11.862-.555-28.255 6.58-47.26l.219-.053.392-.076.27-.043.321-.045.371-.043.205-.02.447-.038.498-.031.55-.022c.479-.013 1.012-.018 1.6-.004l.731.025c8.84.393 28.414 4.525 60.702 27.706 20.18-5.76 41.802-8.639 63.424-8.639 21.621 0 43.243 2.88 63.423 8.64 35.676-24.838 56.757-26.997 65.068-26.525l.637.043c.204.016.398.033.584.052l.529.059.475.063.422.065.368.065.453.092.334.079.215.058.104.031c9.225 22.116 9.004 40.693 6.893 52.712l-.203 1.108-.213 1.068a68.017 68.017 0 0 1-.683 2.966l-.237.907-.12.438-.242.845c-.04.137-.08.272-.121.406l-.242.78-.24.737-.12.352-.236.67-.23.626-.114.296-.221.558-.213.511-.103.238-.198.442-.186.393-.088.18c15.697 17.104 25.744 39.854 25.946 66.851V451z" />
</svg>
Scroll to npmhub
</a>
</div>
<h3 class="sr-only">Dependency List via N P M Hub</h3>
11 changes: 11 additions & 0 deletions source/npmhub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import githubInjection from 'github-injection';
import elementReady from 'element-ready';
import App from './components/App.svelte';
import ScrollButton from './components/ScrollButton.svelte';

function isPackageJson() {
// Example URLs:
Expand Down Expand Up @@ -56,6 +57,16 @@ async function init() {
'.repository-content', // Old container https://github.com/refined-github/refined-github/issues/5751
]),
});

const position = document.querySelector(['.BorderGrid-cell [href$=\'/forks\']'])?.parentElement;

if (position) {
const frag = document.createDocumentFragment();

new ScrollButton({target: frag});

position.after(frag);
}
}

githubInjection(init);

0 comments on commit 261203a

Please sign in to comment.