Skip to content

Commit

Permalink
Control button util: Implement descriptive text (#1404)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Feb 22, 2024
1 parent 0f98234 commit 6453cae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/scripts/quick_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ popupForm.addEventListener('submit', processFormSubmit);
postOptionPopupElement.addEventListener('click', processPostOptionBundleClick);

export const main = async function () {
controlButtonTemplate = createControlButtonTemplate(symbolId, buttonClass);
controlButtonTemplate = createControlButtonTemplate(symbolId, buttonClass, 'Quick Tags');

pageModifications.register(`${postSelector} footer ${controlIconSelector} a[href*="/edit/"]`, addControlButtons);
registerPostOption('quick-tags', { symbolId, onclick: togglePostOptionPopupDisplay });
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/trim_reblogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const processPosts = postElements => filterPostElements(postElements).forEach(as
});

export const main = async function () {
controlButtonTemplate = createControlButtonTemplate(symbolId, buttonClass);
controlButtonTemplate = createControlButtonTemplate(symbolId, buttonClass, 'Trim Reblogs');
onNewPosts.addListener(processPosts);
};

Expand Down
5 changes: 3 additions & 2 deletions src/util/control_buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ $('.xkit-control-button-container').remove();
* Create a button template that can be cloned with cloneControlButton() for inserting into the controls of a post.
* @param {string} symbolId - The name of the RemixIcon to use
* @param {string} buttonClass - An extra class to identify the extension that added the button
* @param {string} label - Descriptive text to be set as the button aria-label property and tooltip
* @returns {HTMLDivElement} A button that can be cloned with cloneControlButton()
*/
export const createControlButtonTemplate = function (symbolId, buttonClass) {
export const createControlButtonTemplate = function (symbolId, buttonClass, label = '') {
return dom('div', { class: `xkit-control-button-container ${buttonClass}` }, null, [
dom('button', { class: 'xkit-control-button' }, null, [
dom('button', { class: 'xkit-control-button', 'aria-label': label, title: label }, null, [
dom('span', { class: 'xkit-control-button-inner', tabindex: '-1' }, null, [
buildSvg(symbolId)
])
Expand Down

0 comments on commit 6453cae

Please sign in to comment.