summaryrefslogtreecommitdiff
path: root/source/features/clean-repo-filelist-actions.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2022-06-06 23:59:52 +0800
committerGravatar GitHub <noreply@github.com> 2022-06-06 17:59:52 +0200
commit50c6fafc9692daa97daf894b5af5d4acb0caf7d8 (patch)
treecb541117f6d97b1af1a1ea00c92a947e338c98e2 /source/features/clean-repo-filelist-actions.tsx
parentfb994afa17888a0ce9029febdc9d7ae4ae94c8e4 (diff)
downloadrefined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.tar.gz
refined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.tar.zst
refined-github-50c6fafc9692daa97daf894b5af5d4acb0caf7d8.zip
Lint (#5654)
Co-authored-by: cheap-glitch <cheap.glitch@gmail.com>
Diffstat (limited to 'source/features/clean-repo-filelist-actions.tsx')
-rw-r--r--source/features/clean-repo-filelist-actions.tsx62
1 files changed, 32 insertions, 30 deletions
diff --git a/source/features/clean-repo-filelist-actions.tsx b/source/features/clean-repo-filelist-actions.tsx
index 9105826f..4c3f7b06 100644
--- a/source/features/clean-repo-filelist-actions.tsx
+++ b/source/features/clean-repo-filelist-actions.tsx
@@ -15,42 +15,44 @@ function addTooltipToSummary(childElement: Element, tooltip: string): void {
);
}
-function init(): Deinit {
- // `.btn` selects the desktop version
- return observe('.btn[data-hotkey="t"]:not(.rgh-repo-filelist-actions)', {
- add(searchButton) {
- searchButton.classList.add('tooltipped', 'tooltipped-ne', 'rgh-repo-filelist-actions');
- searchButton.setAttribute('aria-label', 'Go to file');
+function cleanFilelistActions(searchButton: Element): void {
+ searchButton.classList.add('tooltipped', 'tooltipped-ne', 'rgh-repo-filelist-actions');
+ searchButton.setAttribute('aria-label', 'Go to file');
+
+ // Replace "Go to file" with icon
+ searchButton.firstChild!.replaceWith(<SearchIcon/>);
- // Replace "Go to file" with icon
- searchButton.firstChild!.replaceWith(<SearchIcon/>);
+ // This button doesn't appear on `isSingleFile`
+ const addFileDropdown = searchButton.nextElementSibling!.querySelector('.dropdown-caret');
+ if (addFileDropdown) {
+ addFileDropdown.parentElement!.classList.replace('d-md-flex', 'd-md-block');
- // This button doesn't appear on `isSingleFile`
- const addFileDropdown = searchButton.nextElementSibling!.querySelector('.dropdown-caret');
- if (addFileDropdown) {
- addFileDropdown.parentElement!.classList.replace('d-md-flex', 'd-md-block');
+ // Replace "Add file" with icon
+ addFileDropdown.previousSibling!.replaceWith(<PlusIcon/>);
- // Replace "Add file" with icon
- addFileDropdown.previousSibling!.replaceWith(<PlusIcon/>);
+ addTooltipToSummary(addFileDropdown, 'Add file');
+ }
- addTooltipToSummary(addFileDropdown, 'Add file');
- }
+ const codeDropdownButton = select('get-repo summary');
+ if (codeDropdownButton) { // This dropdown doesn't appear on `isSingleFile`
+ addTooltipToSummary(codeDropdownButton, 'Clone, open or download');
- const codeDropdownButton = select('get-repo summary');
- if (codeDropdownButton) { // This dropdown doesn't appear on `isSingleFile`
- addTooltipToSummary(codeDropdownButton, 'Clone, open or download');
+ // Users with Codespaces enabled already have an icon in the button https://github.com/refined-github/refined-github/pull/5074#issuecomment-983251719
+ const codeIcon = select('.octicon-code', codeDropdownButton);
+ if (codeIcon) {
+ // Remove "Code" text
+ codeIcon.nextSibling!.remove();
+ } else {
+ // Replace "Code" text with icon
+ codeDropdownButton.firstChild!.replaceWith(<CodeIcon/>);
+ }
+ }
+}
- // Users with Codespaces enabled already have an icon in the button https://github.com/refined-github/refined-github/pull/5074#issuecomment-983251719
- const codeIcon = select('.octicon-code', codeDropdownButton);
- if (codeIcon) {
- // Remove "Code" text
- codeIcon.nextSibling!.remove();
- } else {
- // Replace "Code" text with icon
- codeDropdownButton.firstChild!.replaceWith(<CodeIcon/>);
- }
- }
- },
+function init(): Deinit {
+ // `.btn` selects the desktop version
+ return observe('.btn[data-hotkey="t"]:not(.rgh-repo-filelist-actions)', {
+ add: cleanFilelistActions,
});
}