Skip to content
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

Control button util: Implement descriptive text #1404

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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