-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Upgraded packages & Refactored scroll position hook (#435)
- upgrade packages - refactored useNewScrollPosition - update restyled yaml
- Loading branch information
1 parent
13d534e
commit 7a59cd3
Showing
30 changed files
with
2,872 additions
and
5,996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ exclude: | |
- ".gitignore" | ||
- "pnpm-lock.yaml" | ||
- "**/tsconfig.json" | ||
- coverage/** | ||
- coverage/**/* |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.
7a59cd3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-chrono-uc7v – ./
react-chrono-uc7v-git-master-prabhuignoto.vercel.app
react-chrono-uc7v-prabhuignoto.vercel.app
react-chrono-kitchen-sink.prabhumurthy.com