Repository navigation
dim-viewed-files - New feature
#10172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xremix
wants to merge
32
commits into
refined-github:main
Choose a base branch
from
xremix:feat/dim-viewed-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7a7b6fb
`dim-viewed-files` - Dim viewed files in the PR file tree
xremix 4dde146
`dim-viewed-files` - Dim folders whose files are all viewed
xremix b17715a
Attached screenshot
xremix dc98122
add screenshot to features meta data
xremix 068982a
Apply suggestion from @xremix
xremix d91a927
undo changes
xremix 4f698ff
Merge branch 'feat/dim-viewed-files' of https://github.com/xremix/ref…
xremix 25fd5a3
fix build
xremix 06684c3
simplify code
xremix 58eb1f2
improve performance
xremix 3604d1b
move folder implementation to an CSS approach
xremix 1b640c6
Update dim-viewed-files.test.ts
xremix 832f431
improve performance of loading viewed files
xremix 5cab09e
fix formatting and linting
xremix e5fc52e
Discard changes to test/dim-viewed-files.test.ts
fregante be97e34
Scope viewed file tree selector
xremix 479e5bf
Move feature to bottom of imports
xremix a3847ba
Remove redundant dimming cleanup
xremix 88d356b
Run tree update through observer
xremix 7139a0a
Reuse debounce-fn for viewed file tree updates
xremix 2997fa3
Drop legacy viewed-file support
xremix 4c38456
Fix folder dimming in the new PR view
xremix f4cda77
Use CSS nesting for scoped folder selectors
xremix 0327da6
Simplify viewed-file dimming for the new PR view
xremix 787acea
Observe viewed buttons only after their state loads
xremix 6b24211
Check viewed state directly in the tree link loop
xremix ec0e5a2
Remove redundant viewed-state callback wrapper
xremix 5147ccc
Use an array for new-view observer selectors
xremix b3ac41d
move feature in readme to bottom
xremix 7ac37a8
Simplify folder selector
xremix ee2407c
Merge remote-tracking branch 'origin/main' into pr/10172
fregante b40ea2e
Fix viewed button selector in dim-viewed-files
xremix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* Files: rows marked as viewed by the JS */ | ||
| .rgh-dim-viewed-files:not(:hover, :focus-within) { | ||
| opacity: 50%; | ||
| } | ||
|
|
||
| /* Folders: dim only the folder's own row (not its subtree, to avoid compounding opacity) when it contains viewed files and no unviewed ones */ | ||
| ul[aria-label='File Tree'] { | ||
| [role='treeitem'][aria-expanded] { | ||
| &:has(.rgh-dim-viewed-files):not( | ||
| :has( | ||
| [role='treeitem']:not([aria-expanded], .rgh-dim-viewed-files) | ||
| ) | ||
| ) | ||
| > div:not(:hover, :focus-within) { | ||
| opacity: 50%; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import './dim-viewed-files.css'; | ||
|
|
||
| import debounce from 'debounce-fn'; | ||
| import delegate from 'delegate-it'; | ||
| import * as pageDetect from 'github-url-detection'; | ||
| import {$$optional, closestElement, elementExists} from 'select-dom'; | ||
|
|
||
| import features from '../feature-manager.js'; | ||
| import observe from '../helpers/selector-observer.js'; | ||
|
|
||
| const viewedToggleSelector = | ||
| ':is(button[class*="MarkAsViewedButton"], [class*="diff-file-header"] button[aria-pressed])'; | ||
| const treeLinkSelector = 'ul[aria-label="File Tree"] a[href*="#"]'; | ||
| const dimmedClass = 'rgh-dim-viewed-files'; | ||
|
|
||
| const updateTree = debounce((): void => { | ||
| for (const link of $$optional(treeLinkSelector)) { | ||
| const row = closestElement('[role="treeitem"]', link); | ||
| const viewed = elementExists( | ||
| `#${CSS.escape(link.hash.slice(1))} ${viewedToggleSelector}[aria-pressed="true"]`, | ||
| ); | ||
| row.classList.toggle(dimmedClass, viewed); | ||
| } | ||
| }, {wait: 100}); | ||
|
|
||
| export function init(signal: AbortSignal): void { | ||
| observe( | ||
| [ | ||
| treeLinkSelector, | ||
| // The pressed selector also catches viewed state loaded after the button renders. | ||
| `${viewedToggleSelector}[aria-pressed="true"]`, | ||
| ], | ||
| updateTree, | ||
| {signal}, | ||
| ); | ||
| delegate(viewedToggleSelector, 'click', updateTree, {signal}); | ||
| } | ||
|
|
||
| void features.add(import.meta.url, { | ||
| include: [pageDetect.isPRFiles], | ||
| exclude: [pageDetect.isPRFile404, pageDetect.isPRCommit], | ||
| init, | ||
| }); | ||
|
|
||
| /* | ||
|
|
||
| Test URLs | ||
|
|
||
| https://github.com/refined-github/sandbox/pull/55/files | ||
|
|
||
| */ |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.