MCPcopy Index your code
hub / github.com/refined-github/refined-github / groupButtons

Function groupButtons

source/github-helpers/group-buttons.tsx:7–30  ·  view source on GitHub ↗
(buttons: Element[], ...classes: string[])

Source from the content-addressed store, hash-verified

5
6// Wrap a list of elements with BtnGroup + ensure each has BtnGroup-item
7export function groupButtons(buttons: Element[], ...classes: string[]): HTMLElement {
8 // Ensure every button has this class
9 for (let button of buttons) {
10 if (!button.matches('button, .btn')) {
11 button.classList.add('BtnGroup-parent');
12 button = $('.btn', button);
13 }
14
15 button.classList.add('BtnGroup-item');
16 }
17
18 // They may already be part of a group
19 let group = closestElementOptional('.BtnGroup', buttons[0]);
20
21 // If it doesn't exist, wrap them in a new group
22 if (!group) {
23 group = <div className="BtnGroup" />;
24 wrapAll(group, ...buttons);
25 }
26
27 group.classList.add(...classes);
28
29 return group;
30}
31
32// Find immediate `.btn` siblings of `button` and wrap them with groupButtons
33export function groupSiblings(button: Element): Element {

Callers 4

groupSiblingsFunction · 0.85
createLinkGroupFunction · 0.85
addToReleasesFunction · 0.85
wrapButtonsFunction · 0.85

Calls 2

wrapAllFunction · 0.85
matchesMethod · 0.80

Tested by

no test coverage detected