Skip to content

Commit

Permalink
✨ Upgraded packages & Refactored scroll position hook (#435)
Browse files Browse the repository at this point in the history
- upgrade packages
- refactored useNewScrollPosition
- update restyled yaml
  • Loading branch information
prabhuignoto authored Nov 7, 2023
1 parent 13d534e commit 7a59cd3
Show file tree
Hide file tree
Showing 30 changed files with 2,872 additions and 5,996 deletions.
2 changes: 1 addition & 1 deletion .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ exclude:
- ".gitignore"
- "pnpm-lock.yaml"
- "**/tsconfig.json"
- coverage/**
- coverage/**/*
541 changes: 94 additions & 447 deletions coverage/clover.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions coverage/lcov-report/block-navigation.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
/* eslint-disable */
var jumpToCode = (function init() {
// Classes of code we would like to highlight in the file view
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
// Classes of code we would like to highlight in the file view
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];

// Elements to highlight in the file listing view
var fileListingElements = ['td.pct.low'];
// Elements to highlight in the file listing view
var fileListingElements = ['td.pct.low'];

// We don't want to select elements that are direct descendants of another
// match
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
// We don't want to select elements that are direct descendants of another match
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `

// Selecter that finds elements on the page to which we can jump
var selector =
fileListingElements.join(', ') +
', ' +
notSelector +
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
// Selecter that finds elements on the page to which we can jump
var selector =
fileListingElements.join(', ') +
', ' +
notSelector +
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`

// The NodeList of matching elements
var missingCoverageElements = document.querySelectorAll(selector);
// The NodeList of matching elements
var missingCoverageElements = document.querySelectorAll(selector);

var currentIndex;
var currentIndex;

function toggleClass(index) {
missingCoverageElements.item(currentIndex).classList.remove('highlighted');
missingCoverageElements.item(index).classList.add('highlighted');
}

function makeCurrent(index) {
toggleClass(index);
currentIndex = index;
missingCoverageElements.item(index).scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center',
});
}

function goToPrevious() {
var nextIndex = 0;
if (typeof currentIndex !== 'number' || currentIndex === 0) {
nextIndex = missingCoverageElements.length - 1;
} else if (missingCoverageElements.length > 1) {
nextIndex = currentIndex - 1;
function toggleClass(index) {
missingCoverageElements
.item(currentIndex)
.classList.remove('highlighted');
missingCoverageElements.item(index).classList.add('highlighted');
}

makeCurrent(nextIndex);
}
function makeCurrent(index) {
toggleClass(index);
currentIndex = index;
missingCoverageElements.item(index).scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center'
});
}

function goToNext() {
var nextIndex = 0;
function goToPrevious() {
var nextIndex = 0;
if (typeof currentIndex !== 'number' || currentIndex === 0) {
nextIndex = missingCoverageElements.length - 1;
} else if (missingCoverageElements.length > 1) {
nextIndex = currentIndex - 1;
}

if (
typeof currentIndex === 'number' &&
currentIndex < missingCoverageElements.length - 1
) {
nextIndex = currentIndex + 1;
makeCurrent(nextIndex);
}

makeCurrent(nextIndex);
}
function goToNext() {
var nextIndex = 0;

return function jump(event) {
if (
document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null
) {
// if we're currently focused on the search input, we don't want to
// navigate
return;
}
if (
typeof currentIndex === 'number' &&
currentIndex < missingCoverageElements.length - 1
) {
nextIndex = currentIndex + 1;
}

switch (event.which) {
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
makeCurrent(nextIndex);
}
};

return function jump(event) {
if (
document.getElementById('fileSearch') === document.activeElement &&
document.activeElement != null
) {
// if we're currently focused on the search input, we don't want to navigate
return;
}

switch (event.which) {
case 78: // n
case 74: // j
goToNext();
break;
case 66: // b
case 75: // k
case 80: // p
goToPrevious();
break;
}
};
})();
window.addEventListener('keydown', jumpToCode);
Loading

1 comment on commit 7a59cd3

@vercel
Copy link

@vercel vercel bot commented on 7a59cd3 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.