summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-11-02 02:10:17 +0800
committerGravatar GitHub <noreply@github.com> 2023-11-01 18:10:17 +0000
commit02ad1640aac87a7e60d22487e06a4dc3ba5c23e4 (patch)
tree6b55dd6c50ec92bca46663faad2ec2f3ebdb2f9f
parent731abb84b65591f6738968d55542fb5488aa14d2 (diff)
downloadrefined-github-02ad1640aac87a7e60d22487e06a4dc3ba5c23e4.tar.gz
refined-github-02ad1640aac87a7e60d22487e06a4dc3ba5c23e4.tar.zst
refined-github-02ad1640aac87a7e60d22487e06a4dc3ba5c23e4.zip
`collapsible-content-button` - Restore feature (#7021)
-rw-r--r--source/features/collapsible-content-button.tsx29
1 files changed, 27 insertions, 2 deletions
diff --git a/source/features/collapsible-content-button.tsx b/source/features/collapsible-content-button.tsx
index 93fb5469..5eeae580 100644
--- a/source/features/collapsible-content-button.tsx
+++ b/source/features/collapsible-content-button.tsx
@@ -3,6 +3,7 @@ import {FoldDownIcon} from '@primer/octicons-react';
import * as pageDetect from 'github-url-detection';
import * as textFieldEdit from 'text-field-edit';
import delegate, {DelegateEvent} from 'delegate-it';
+import {elementExists} from 'select-dom';
import features from '../feature-manager.js';
import smartBlockWrap from '../helpers/smart-block-wrap.js';
@@ -35,15 +36,39 @@ function addContentToDetails({delegateTarget}: DelegateEvent<MouseEvent, HTMLBut
}
function addButtons(referenceButton: HTMLElement): void {
+ const classes
+ = elementExists('md-ref', referenceButton)
+ ? [
+ 'toolbar-item',
+ 'btn-octicon',
+ 'p-2',
+ 'p-md-1',
+ 'tooltipped',
+ 'tooltipped-sw',
+ 'rgh-collapsible-content-btn',
+ ]
+ : [
+ 'Button',
+ 'Button--iconOnly',
+ 'Button--invisible',
+ 'Button--medium',
+ 'tooltipped',
+ 'tooltipped-sw',
+ 'rgh-collapsible-content-btn',
+ ];
+
referenceButton.after(
- <button type="button" className="toolbar-item btn-octicon p-2 p-md-1 tooltipped tooltipped-sw rgh-collapsible-content-btn" aria-label="Add collapsible content">
+ <button type="button" className={classes.join(' ')} aria-label="Add collapsible content">
<FoldDownIcon/>
</button>,
);
}
function init(signal: AbortSignal): void {
- observe('md-ref', addButtons, {signal});
+ observe([
+ 'md-ref', // TODO: Drop in June 2024
+ '.ActionBar-item:has([data-md-button=\'ref\'])',
+ ], addButtons, {signal});
delegate('.rgh-collapsible-content-btn', 'click', addContentToDetails, {signal});
}