1
0
Fork 0

Make CopyableInputBox more usable when using accessability solutions.

This commit is contained in:
Kitteh 2021-04-29 11:12:17 +01:00
parent 4fefad2c16
commit 8e970a75e4
3 changed files with 13 additions and 6 deletions

View file

@ -1,13 +1,22 @@
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
import { addClipboardNotifications } from "../pageUtils.js"; import { addClipboardNotifications } from "../pageUtils.js";
import { makeFormIcon, makeElement } from "../htmlUtils.js"; import { makeElement } from "../htmlUtils.js";
import { MarginInline } from "./MarginInline.js"; import { MarginInline } from "./MarginInline.js";
import i18next from "i18next";
export function CopyableInputBox(text, copyable = true) { export function CopyableInputBox(text, copyable = true) {
let inputBoxDiv = makeElement({ tag: "div" }); let inputBoxDiv = makeElement({ tag: "div" });
let inputBoxCopyButton = null; let inputBoxCopyButton = null;
if (copyable) { if (copyable) {
inputBoxCopyButton = makeFormIcon("copy"); inputBoxCopyButton = makeElement({
tag: "a",
class: "uk-form-icon",
attributes: {
"uk-icon": "icon: copy",
"role": "img",
"aria-label": i18next.t("copy_input_box_copy_icon_text")
}
});
let clipboard = new ClipboardJS(inputBoxCopyButton); let clipboard = new ClipboardJS(inputBoxCopyButton);
addClipboardNotifications(clipboard, 600); addClipboardNotifications(clipboard, 600);
} }

View file

@ -34,7 +34,3 @@ export function setElementAttributes(element, attributes) {
element.setAttribute(key, attributes[key]); element.setAttribute(key, attributes[key]);
} }
} }
export function makeFormIcon(icon) {
return makeElement({ tag: "a", class: "uk-form-icon", attributes: { "uk-icon": `icon: ${icon}` } });
}

View file

@ -16,6 +16,8 @@ module.exports = {
"copy_modal_copy_btn": "Copy", "copy_modal_copy_btn": "Copy",
"copy_modal_close_btn": "Close", "copy_modal_close_btn": "Close",
// Copyable Input Box
"copy_input_box_copy_icon_text": "Copy Button",
// Me Page // Me Page
"me_page_title": "Me/Settings", "me_page_title": "Me/Settings",