accessify-widget 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -3
- package/dist/accessify.min.js +1 -1
- package/dist/accessify.min.js.map +1 -1
- package/dist/accessify.mjs +1 -1
- package/dist/{alt-text-CLxbmwG6.js → alt-text-CgzNGvdT.js} +2 -2
- package/dist/{alt-text-CLxbmwG6.js.map → alt-text-CgzNGvdT.js.map} +1 -1
- package/dist/contrast-CqsICAkU.js +139 -0
- package/dist/contrast-CqsICAkU.js.map +1 -0
- package/dist/{index-CUQfpnwR.js → index-qmiN2JAz.js} +1811 -736
- package/dist/index-qmiN2JAz.js.map +1 -0
- package/dist/{keyboard-nav-BdPyLaZt.js → keyboard-nav-DH4qBThF.js} +16 -12
- package/dist/keyboard-nav-DH4qBThF.js.map +1 -0
- package/dist/{page-structure-2X8mOSpC.js → page-structure-DTBqkrYs.js} +11 -7
- package/dist/page-structure-DTBqkrYs.js.map +1 -0
- package/dist/text-size-C6OFhCGi.js +186 -0
- package/dist/text-size-C6OFhCGi.js.map +1 -0
- package/dist/widget.js +1 -1
- package/dist/widget.js.map +1 -1
- package/package.json +1 -1
- package/dist/color-blind-0LFng55r.js +0 -108
- package/dist/color-blind-0LFng55r.js.map +0 -1
- package/dist/contrast-DCkE0NXZ.js +0 -64
- package/dist/contrast-DCkE0NXZ.js.map +0 -1
- package/dist/dyslexia-font-wONgIy2T.js +0 -77
- package/dist/dyslexia-font-wONgIy2T.js.map +0 -1
- package/dist/index-CUQfpnwR.js.map +0 -1
- package/dist/keyboard-nav-BdPyLaZt.js.map +0 -1
- package/dist/line-height-BT98qgEF.js +0 -54
- package/dist/line-height-BT98qgEF.js.map +0 -1
- package/dist/page-structure-2X8mOSpC.js.map +0 -1
- package/dist/saturation-D8ZXpWAN.js +0 -59
- package/dist/saturation-D8ZXpWAN.js.map +0 -1
- package/dist/spacing-DENai3JU.js +0 -106
- package/dist/spacing-DENai3JU.js.map +0 -1
- package/dist/text-align-BDRPqPvl.js +0 -51
- package/dist/text-align-BDRPqPvl.js.map +0 -1
- package/dist/text-size-B-uv436p.js +0 -69
- package/dist/text-size-B-uv436p.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const COLOR_MATRICES = {
|
|
2
|
-
protanopia: `
|
|
3
|
-
0.567, 0.433, 0, 0, 0
|
|
4
|
-
0.558, 0.442, 0, 0, 0
|
|
5
|
-
0, 0.242, 0.758, 0, 0
|
|
6
|
-
0, 0, 0, 1, 0
|
|
7
|
-
`,
|
|
8
|
-
deuteranopia: `
|
|
9
|
-
0.625, 0.375, 0, 0, 0
|
|
10
|
-
0.7, 0.3, 0, 0, 0
|
|
11
|
-
0, 0.3, 0.7, 0, 0
|
|
12
|
-
0, 0, 0, 1, 0
|
|
13
|
-
`,
|
|
14
|
-
tritanopia: `
|
|
15
|
-
0.95, 0.05, 0, 0, 0
|
|
16
|
-
0, 0.433, 0.567, 0, 0
|
|
17
|
-
0, 0.475, 0.525, 0, 0
|
|
18
|
-
0, 0, 0, 1, 0
|
|
19
|
-
`,
|
|
20
|
-
achromatopsia: `
|
|
21
|
-
0.299, 0.587, 0.114, 0, 0
|
|
22
|
-
0.299, 0.587, 0.114, 0, 0
|
|
23
|
-
0.299, 0.587, 0.114, 0, 0
|
|
24
|
-
0, 0, 0, 1, 0
|
|
25
|
-
`
|
|
26
|
-
};
|
|
27
|
-
const MODE_LABELS = {
|
|
28
|
-
protanopia: "Protanopia (Red-blind)",
|
|
29
|
-
deuteranopia: "Deuteranopia (Green-blind)",
|
|
30
|
-
tritanopia: "Tritanopia (Blue-blind)",
|
|
31
|
-
achromatopsia: "Achromatopsia (Total color blindness)"
|
|
32
|
-
};
|
|
33
|
-
function createColorBlindModule() {
|
|
34
|
-
let currentMode = "off";
|
|
35
|
-
const SVG_ID = "accessify-colorblind-svg";
|
|
36
|
-
const STYLE_ID = "accessify-colorblind-style";
|
|
37
|
-
const STORAGE_KEY = "accessify-colorblind-mode";
|
|
38
|
-
function createSvgFilter(mode) {
|
|
39
|
-
const filterId = `accessify-filter-${mode}`;
|
|
40
|
-
return `
|
|
41
|
-
<svg id="${SVG_ID}" xmlns="http://www.w3.org/2000/svg" style="position:absolute;width:0;height:0;overflow:hidden;">
|
|
42
|
-
<defs>
|
|
43
|
-
<filter id="${filterId}" color-interpolation-filters="sRGB">
|
|
44
|
-
<feColorMatrix type="matrix" values="${COLOR_MATRICES[mode]}" />
|
|
45
|
-
</filter>
|
|
46
|
-
</defs>
|
|
47
|
-
</svg>
|
|
48
|
-
`;
|
|
49
|
-
}
|
|
50
|
-
function applyFilter(mode) {
|
|
51
|
-
document.getElementById(SVG_ID)?.remove();
|
|
52
|
-
document.getElementById(STYLE_ID)?.remove();
|
|
53
|
-
if (mode === "off") return;
|
|
54
|
-
const filterId = `accessify-filter-${mode}`;
|
|
55
|
-
const svgContainer = document.createElement("div");
|
|
56
|
-
svgContainer.innerHTML = createSvgFilter(mode);
|
|
57
|
-
const svgEl = svgContainer.firstElementChild;
|
|
58
|
-
if (svgEl) {
|
|
59
|
-
document.body.appendChild(svgEl);
|
|
60
|
-
}
|
|
61
|
-
const styleEl = document.createElement("style");
|
|
62
|
-
styleEl.id = STYLE_ID;
|
|
63
|
-
styleEl.textContent = `
|
|
64
|
-
/* accessify color blindness filter: ${MODE_LABELS[mode]} */
|
|
65
|
-
html {
|
|
66
|
-
filter: url(#${filterId}) !important;
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
document.head.appendChild(styleEl);
|
|
70
|
-
}
|
|
71
|
-
function activate() {
|
|
72
|
-
const saved = localStorage.getItem(STORAGE_KEY);
|
|
73
|
-
currentMode = saved && saved !== "off" ? saved : "protanopia";
|
|
74
|
-
applyFilter(currentMode);
|
|
75
|
-
}
|
|
76
|
-
function deactivate() {
|
|
77
|
-
currentMode = "off";
|
|
78
|
-
applyFilter("off");
|
|
79
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
id: "color-blind",
|
|
83
|
-
name: () => "Color Blindness",
|
|
84
|
-
description: "Apply color vision deficiency filters for testing and correction",
|
|
85
|
-
icon: "color-blind",
|
|
86
|
-
category: "visual",
|
|
87
|
-
activate,
|
|
88
|
-
deactivate,
|
|
89
|
-
getState: () => ({
|
|
90
|
-
id: "color-blind",
|
|
91
|
-
enabled: currentMode !== "off",
|
|
92
|
-
value: currentMode
|
|
93
|
-
}),
|
|
94
|
-
setState: (mode) => {
|
|
95
|
-
currentMode = mode;
|
|
96
|
-
applyFilter(mode);
|
|
97
|
-
if (mode === "off") {
|
|
98
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
99
|
-
} else {
|
|
100
|
-
localStorage.setItem(STORAGE_KEY, mode);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
export {
|
|
106
|
-
createColorBlindModule as default
|
|
107
|
-
};
|
|
108
|
-
//# sourceMappingURL=color-blind-0LFng55r.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-blind-0LFng55r.js","sources":["../src/features/color-blind.ts"],"sourcesContent":["import type { FeatureModule, FeatureState } from '../types';\n\ntype ColorBlindMode = 'off' | 'protanopia' | 'deuteranopia' | 'tritanopia' | 'achromatopsia';\n\n/**\n * Color matrix values for simulating / correcting color vision deficiencies.\n * These are standard color transformation matrices used in accessibility tools.\n */\nconst COLOR_MATRICES: Record<Exclude<ColorBlindMode, 'off'>, string> = {\n protanopia: `\n 0.567, 0.433, 0, 0, 0\n 0.558, 0.442, 0, 0, 0\n 0, 0.242, 0.758, 0, 0\n 0, 0, 0, 1, 0\n `,\n deuteranopia: `\n 0.625, 0.375, 0, 0, 0\n 0.7, 0.3, 0, 0, 0\n 0, 0.3, 0.7, 0, 0\n 0, 0, 0, 1, 0\n `,\n tritanopia: `\n 0.95, 0.05, 0, 0, 0\n 0, 0.433, 0.567, 0, 0\n 0, 0.475, 0.525, 0, 0\n 0, 0, 0, 1, 0\n `,\n achromatopsia: `\n 0.299, 0.587, 0.114, 0, 0\n 0.299, 0.587, 0.114, 0, 0\n 0.299, 0.587, 0.114, 0, 0\n 0, 0, 0, 1, 0\n `,\n};\n\nconst MODE_LABELS: Record<Exclude<ColorBlindMode, 'off'>, string> = {\n protanopia: 'Protanopia (Red-blind)',\n deuteranopia: 'Deuteranopia (Green-blind)',\n tritanopia: 'Tritanopia (Blue-blind)',\n achromatopsia: 'Achromatopsia (Total color blindness)',\n};\n\nexport default function createColorBlindModule(): FeatureModule {\n let currentMode: ColorBlindMode = 'off';\n const SVG_ID = 'accessify-colorblind-svg';\n const STYLE_ID = 'accessify-colorblind-style';\n const STORAGE_KEY = 'accessify-colorblind-mode';\n\n function createSvgFilter(mode: Exclude<ColorBlindMode, 'off'>): string {\n const filterId = `accessify-filter-${mode}`;\n return `\n <svg id=\"${SVG_ID}\" xmlns=\"http://www.w3.org/2000/svg\" style=\"position:absolute;width:0;height:0;overflow:hidden;\">\n <defs>\n <filter id=\"${filterId}\" color-interpolation-filters=\"sRGB\">\n <feColorMatrix type=\"matrix\" values=\"${COLOR_MATRICES[mode]}\" />\n </filter>\n </defs>\n </svg>\n `;\n }\n\n function applyFilter(mode: ColorBlindMode) {\n // Remove existing SVG and styles\n document.getElementById(SVG_ID)?.remove();\n document.getElementById(STYLE_ID)?.remove();\n\n if (mode === 'off') return;\n\n const filterId = `accessify-filter-${mode}`;\n\n // Inject inline SVG with filter definition\n const svgContainer = document.createElement('div');\n svgContainer.innerHTML = createSvgFilter(mode);\n const svgEl = svgContainer.firstElementChild;\n if (svgEl) {\n document.body.appendChild(svgEl);\n }\n\n // Apply CSS filter referencing the SVG filter\n const styleEl = document.createElement('style');\n styleEl.id = STYLE_ID;\n styleEl.textContent = `\n /* accessify color blindness filter: ${MODE_LABELS[mode]} */\n html {\n filter: url(#${filterId}) !important;\n }\n `;\n document.head.appendChild(styleEl);\n }\n\n function activate() {\n const saved = localStorage.getItem(STORAGE_KEY) as ColorBlindMode;\n currentMode = saved && saved !== 'off' ? saved : 'protanopia';\n applyFilter(currentMode);\n }\n\n function deactivate() {\n currentMode = 'off';\n applyFilter('off');\n localStorage.removeItem(STORAGE_KEY);\n }\n\n return {\n id: 'color-blind',\n name: () => 'Color Blindness',\n description: 'Apply color vision deficiency filters for testing and correction',\n icon: 'color-blind',\n category: 'visual',\n activate,\n deactivate,\n getState: (): FeatureState => ({\n id: 'color-blind',\n enabled: currentMode !== 'off',\n value: currentMode,\n }),\n setState: (mode: ColorBlindMode) => {\n currentMode = mode;\n applyFilter(mode);\n if (mode === 'off') {\n localStorage.removeItem(STORAGE_KEY);\n } else {\n localStorage.setItem(STORAGE_KEY, mode);\n }\n },\n };\n}\n"],"names":[],"mappings":"AAQA,MAAM,iBAAiE;AAAA,EACrE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMZ,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMZ,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAMjB;AAEA,MAAM,cAA8D;AAAA,EAClE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,eAAe;AACjB;AAEA,SAAwB,yBAAwC;AAC9D,MAAI,cAA8B;AAClC,QAAM,SAAS;AACf,QAAM,WAAW;AACjB,QAAM,cAAc;AAEpB,WAAS,gBAAgB,MAA8C;AACrE,UAAM,WAAW,oBAAoB,IAAI;AACzC,WAAO;AAAA,iBACM,MAAM;AAAA;AAAA,wBAEC,QAAQ;AAAA,mDACmB,eAAe,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrE;AAEA,WAAS,YAAY,MAAsB;AAEzC,aAAS,eAAe,MAAM,GAAG,OAAA;AACjC,aAAS,eAAe,QAAQ,GAAG,OAAA;AAEnC,QAAI,SAAS,MAAO;AAEpB,UAAM,WAAW,oBAAoB,IAAI;AAGzC,UAAM,eAAe,SAAS,cAAc,KAAK;AACjD,iBAAa,YAAY,gBAAgB,IAAI;AAC7C,UAAM,QAAQ,aAAa;AAC3B,QAAI,OAAO;AACT,eAAS,KAAK,YAAY,KAAK;AAAA,IACjC;AAGA,UAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,YAAQ,KAAK;AACb,YAAQ,cAAc;AAAA,6CACmB,YAAY,IAAI,CAAC;AAAA;AAAA,uBAEvC,QAAQ;AAAA;AAAA;AAG3B,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC;AAEA,WAAS,WAAW;AAClB,UAAM,QAAQ,aAAa,QAAQ,WAAW;AAC9C,kBAAc,SAAS,UAAU,QAAQ,QAAQ;AACjD,gBAAY,WAAW;AAAA,EACzB;AAEA,WAAS,aAAa;AACpB,kBAAc;AACd,gBAAY,KAAK;AACjB,iBAAa,WAAW,WAAW;AAAA,EACrC;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM,MAAM;AAAA,IACZ,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU,OAAqB;AAAA,MAC7B,IAAI;AAAA,MACJ,SAAS,gBAAgB;AAAA,MACzB,OAAO;AAAA,IAAA;AAAA,IAET,UAAU,CAAC,SAAyB;AAClC,oBAAc;AACd,kBAAY,IAAI;AAChB,UAAI,SAAS,OAAO;AAClB,qBAAa,WAAW,WAAW;AAAA,MACrC,OAAO;AACL,qBAAa,QAAQ,aAAa,IAAI;AAAA,MACxC;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
function createContrastModule() {
|
|
2
|
-
let currentMode = "off";
|
|
3
|
-
const STYLE_ID = "accessify-contrast";
|
|
4
|
-
const STORAGE_KEY = "accessify-contrast-mode";
|
|
5
|
-
function getStyles(mode) {
|
|
6
|
-
switch (mode) {
|
|
7
|
-
case "high":
|
|
8
|
-
return `
|
|
9
|
-
html { filter: contrast(1.5) !important; }
|
|
10
|
-
body { background: #000 !important; color: #fff !important; }
|
|
11
|
-
a { color: #ffff00 !important; }
|
|
12
|
-
img { filter: contrast(1.2) !important; }
|
|
13
|
-
`;
|
|
14
|
-
case "enhanced":
|
|
15
|
-
return `
|
|
16
|
-
html { filter: contrast(1.25) !important; }
|
|
17
|
-
`;
|
|
18
|
-
default:
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function applyStyles(mode) {
|
|
23
|
-
let styleEl = document.getElementById(STYLE_ID);
|
|
24
|
-
if (mode === "off") {
|
|
25
|
-
styleEl?.remove();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (!styleEl) {
|
|
29
|
-
styleEl = document.createElement("style");
|
|
30
|
-
styleEl.id = STYLE_ID;
|
|
31
|
-
document.head.appendChild(styleEl);
|
|
32
|
-
}
|
|
33
|
-
styleEl.textContent = getStyles(mode);
|
|
34
|
-
}
|
|
35
|
-
function activate() {
|
|
36
|
-
const saved = localStorage.getItem(STORAGE_KEY);
|
|
37
|
-
currentMode = saved || "high";
|
|
38
|
-
applyStyles(currentMode);
|
|
39
|
-
}
|
|
40
|
-
function deactivate() {
|
|
41
|
-
currentMode = "off";
|
|
42
|
-
applyStyles("off");
|
|
43
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
id: "contrast",
|
|
47
|
-
name: () => "Contrast",
|
|
48
|
-
description: "Increase contrast for better readability",
|
|
49
|
-
icon: "contrast",
|
|
50
|
-
category: "visual",
|
|
51
|
-
activate,
|
|
52
|
-
deactivate,
|
|
53
|
-
getState: () => ({ id: "contrast", enabled: currentMode !== "off", value: currentMode }),
|
|
54
|
-
setState: (mode) => {
|
|
55
|
-
currentMode = mode;
|
|
56
|
-
applyStyles(mode);
|
|
57
|
-
localStorage.setItem(STORAGE_KEY, mode);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
createContrastModule as default
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=contrast-DCkE0NXZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contrast-DCkE0NXZ.js","sources":["../src/features/contrast.ts"],"sourcesContent":["import type { FeatureModule, FeatureState } from '../types';\n\ntype ContrastMode = 'off' | 'high' | 'enhanced' | 'custom';\n\nexport default function createContrastModule(): FeatureModule {\n let currentMode: ContrastMode = 'off';\n const STYLE_ID = 'accessify-contrast';\n const STORAGE_KEY = 'accessify-contrast-mode';\n\n function getStyles(mode: ContrastMode): string {\n switch (mode) {\n case 'high':\n return `\n html { filter: contrast(1.5) !important; }\n body { background: #000 !important; color: #fff !important; }\n a { color: #ffff00 !important; }\n img { filter: contrast(1.2) !important; }\n `;\n case 'enhanced':\n return `\n html { filter: contrast(1.25) !important; }\n `;\n default:\n return '';\n }\n }\n\n function applyStyles(mode: ContrastMode) {\n let styleEl = document.getElementById(STYLE_ID);\n if (mode === 'off') {\n styleEl?.remove();\n return;\n }\n if (!styleEl) {\n styleEl = document.createElement('style');\n styleEl.id = STYLE_ID;\n document.head.appendChild(styleEl);\n }\n styleEl.textContent = getStyles(mode);\n }\n\n function activate() {\n const saved = localStorage.getItem(STORAGE_KEY) as ContrastMode;\n currentMode = saved || 'high';\n applyStyles(currentMode);\n }\n\n function deactivate() {\n currentMode = 'off';\n applyStyles('off');\n localStorage.removeItem(STORAGE_KEY);\n }\n\n return {\n id: 'contrast',\n name: () => 'Contrast',\n description: 'Increase contrast for better readability',\n icon: 'contrast',\n category: 'visual',\n activate,\n deactivate,\n getState: (): FeatureState => ({ id: 'contrast', enabled: currentMode !== 'off', value: currentMode }),\n setState: (mode: ContrastMode) => {\n currentMode = mode;\n applyStyles(mode);\n localStorage.setItem(STORAGE_KEY, mode);\n },\n };\n}\n"],"names":[],"mappings":"AAIA,SAAwB,uBAAsC;AAC5D,MAAI,cAA4B;AAChC,QAAM,WAAW;AACjB,QAAM,cAAc;AAEpB,WAAS,UAAU,MAA4B;AAC7C,YAAQ,MAAA;AAAA,MACN,KAAK;AACH,eAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,KAAK;AACH,eAAO;AAAA;AAAA;AAAA,MAGT;AACE,eAAO;AAAA,IAAA;AAAA,EAEb;AAEA,WAAS,YAAY,MAAoB;AACvC,QAAI,UAAU,SAAS,eAAe,QAAQ;AAC9C,QAAI,SAAS,OAAO;AAClB,eAAS,OAAA;AACT;AAAA,IACF;AACA,QAAI,CAAC,SAAS;AACZ,gBAAU,SAAS,cAAc,OAAO;AACxC,cAAQ,KAAK;AACb,eAAS,KAAK,YAAY,OAAO;AAAA,IACnC;AACA,YAAQ,cAAc,UAAU,IAAI;AAAA,EACtC;AAEA,WAAS,WAAW;AAClB,UAAM,QAAQ,aAAa,QAAQ,WAAW;AAC9C,kBAAc,SAAS;AACvB,gBAAY,WAAW;AAAA,EACzB;AAEA,WAAS,aAAa;AACpB,kBAAc;AACd,gBAAY,KAAK;AACjB,iBAAa,WAAW,WAAW;AAAA,EACrC;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM,MAAM;AAAA,IACZ,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU,OAAqB,EAAE,IAAI,YAAY,SAAS,gBAAgB,OAAO,OAAO;IACxF,UAAU,CAAC,SAAuB;AAChC,oBAAc;AACd,kBAAY,IAAI;AAChB,mBAAa,QAAQ,aAAa,IAAI;AAAA,IACxC;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
function createDyslexiaFontModule() {
|
|
2
|
-
let enabled = false;
|
|
3
|
-
let fontLoaded = false;
|
|
4
|
-
const STYLE_ID = "accessify-dyslexia-font";
|
|
5
|
-
const STORAGE_KEY = "accessify-dyslexia-font";
|
|
6
|
-
const FONT_URL = "https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff2";
|
|
7
|
-
const FONT_FAMILY = "OpenDyslexic";
|
|
8
|
-
async function loadFont() {
|
|
9
|
-
if (fontLoaded) return;
|
|
10
|
-
try {
|
|
11
|
-
const font = new FontFace(FONT_FAMILY, `url(${FONT_URL})`, {
|
|
12
|
-
style: "normal",
|
|
13
|
-
weight: "400",
|
|
14
|
-
display: "swap"
|
|
15
|
-
});
|
|
16
|
-
const loadedFont = await font.load();
|
|
17
|
-
document.fonts.add(loadedFont);
|
|
18
|
-
fontLoaded = true;
|
|
19
|
-
} catch (err) {
|
|
20
|
-
console.warn("[accessify] Failed to load OpenDyslexic font:", err);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function applyFont() {
|
|
24
|
-
let styleEl = document.getElementById(STYLE_ID);
|
|
25
|
-
if (!styleEl) {
|
|
26
|
-
styleEl = document.createElement("style");
|
|
27
|
-
styleEl.id = STYLE_ID;
|
|
28
|
-
document.head.appendChild(styleEl);
|
|
29
|
-
}
|
|
30
|
-
styleEl.textContent = `
|
|
31
|
-
/* accessify dyslexia-friendly font */
|
|
32
|
-
body, body * {
|
|
33
|
-
font-family: '${FONT_FAMILY}', sans-serif !important;
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
}
|
|
37
|
-
function removeFont() {
|
|
38
|
-
const styleEl = document.getElementById(STYLE_ID);
|
|
39
|
-
styleEl?.remove();
|
|
40
|
-
}
|
|
41
|
-
async function activate() {
|
|
42
|
-
enabled = true;
|
|
43
|
-
await loadFont();
|
|
44
|
-
applyFont();
|
|
45
|
-
localStorage.setItem(STORAGE_KEY, "true");
|
|
46
|
-
}
|
|
47
|
-
function deactivate() {
|
|
48
|
-
enabled = false;
|
|
49
|
-
removeFont();
|
|
50
|
-
localStorage.removeItem(STORAGE_KEY);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
id: "dyslexia-font",
|
|
54
|
-
name: () => "Dyslexia Font",
|
|
55
|
-
description: "Apply OpenDyslexic font for improved readability",
|
|
56
|
-
icon: "dyslexia-font",
|
|
57
|
-
category: "cognitive",
|
|
58
|
-
activate,
|
|
59
|
-
deactivate,
|
|
60
|
-
getState: () => ({
|
|
61
|
-
id: "dyslexia-font",
|
|
62
|
-
enabled,
|
|
63
|
-
value: { fontLoaded }
|
|
64
|
-
}),
|
|
65
|
-
setState: (state) => {
|
|
66
|
-
if (state.enabled) {
|
|
67
|
-
activate();
|
|
68
|
-
} else {
|
|
69
|
-
deactivate();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
createDyslexiaFontModule as default
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=dyslexia-font-wONgIy2T.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dyslexia-font-wONgIy2T.js","sources":["../src/features/dyslexia-font.ts"],"sourcesContent":["import type { FeatureModule, FeatureState } from '../types';\n\nexport default function createDyslexiaFontModule(): FeatureModule {\n let enabled = false;\n let fontLoaded = false;\n const STYLE_ID = 'accessify-dyslexia-font';\n const STORAGE_KEY = 'accessify-dyslexia-font';\n const FONT_URL = 'https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff2';\n const FONT_FAMILY = 'OpenDyslexic';\n\n async function loadFont(): Promise<void> {\n if (fontLoaded) return;\n try {\n const font = new FontFace(FONT_FAMILY, `url(${FONT_URL})`, {\n style: 'normal',\n weight: '400',\n display: 'swap',\n });\n const loadedFont = await font.load();\n document.fonts.add(loadedFont);\n fontLoaded = true;\n } catch (err) {\n console.warn('[accessify] Failed to load OpenDyslexic font:', err);\n }\n }\n\n function applyFont() {\n let styleEl = document.getElementById(STYLE_ID);\n if (!styleEl) {\n styleEl = document.createElement('style');\n styleEl.id = STYLE_ID;\n document.head.appendChild(styleEl);\n }\n styleEl.textContent = `\n /* accessify dyslexia-friendly font */\n body, body * {\n font-family: '${FONT_FAMILY}', sans-serif !important;\n }\n `;\n }\n\n function removeFont() {\n const styleEl = document.getElementById(STYLE_ID);\n styleEl?.remove();\n }\n\n async function activate() {\n enabled = true;\n await loadFont();\n applyFont();\n localStorage.setItem(STORAGE_KEY, 'true');\n }\n\n function deactivate() {\n enabled = false;\n removeFont();\n localStorage.removeItem(STORAGE_KEY);\n }\n\n return {\n id: 'dyslexia-font',\n name: () => 'Dyslexia Font',\n description: 'Apply OpenDyslexic font for improved readability',\n icon: 'dyslexia-font',\n category: 'cognitive',\n activate,\n deactivate,\n getState: (): FeatureState => ({\n id: 'dyslexia-font',\n enabled,\n value: { fontLoaded },\n }),\n setState: (state: { enabled: boolean }) => {\n if (state.enabled) {\n activate();\n } else {\n deactivate();\n }\n },\n };\n}\n"],"names":[],"mappings":"AAEA,SAAwB,2BAA0C;AAChE,MAAI,UAAU;AACd,MAAI,aAAa;AACjB,QAAM,WAAW;AACjB,QAAM,cAAc;AACpB,QAAM,WAAW;AACjB,QAAM,cAAc;AAEpB,iBAAe,WAA0B;AACvC,QAAI,WAAY;AAChB,QAAI;AACF,YAAM,OAAO,IAAI,SAAS,aAAa,OAAO,QAAQ,KAAK;AAAA,QACzD,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,SAAS;AAAA,MAAA,CACV;AACD,YAAM,aAAa,MAAM,KAAK,KAAA;AAC9B,eAAS,MAAM,IAAI,UAAU;AAC7B,mBAAa;AAAA,IACf,SAAS,KAAK;AACZ,cAAQ,KAAK,iDAAiD,GAAG;AAAA,IACnE;AAAA,EACF;AAEA,WAAS,YAAY;AACnB,QAAI,UAAU,SAAS,eAAe,QAAQ;AAC9C,QAAI,CAAC,SAAS;AACZ,gBAAU,SAAS,cAAc,OAAO;AACxC,cAAQ,KAAK;AACb,eAAS,KAAK,YAAY,OAAO;AAAA,IACnC;AACA,YAAQ,cAAc;AAAA;AAAA;AAAA,wBAGF,WAAW;AAAA;AAAA;AAAA,EAGjC;AAEA,WAAS,aAAa;AACpB,UAAM,UAAU,SAAS,eAAe,QAAQ;AAChD,aAAS,OAAA;AAAA,EACX;AAEA,iBAAe,WAAW;AACxB,cAAU;AACV,UAAM,SAAA;AACN,cAAA;AACA,iBAAa,QAAQ,aAAa,MAAM;AAAA,EAC1C;AAEA,WAAS,aAAa;AACpB,cAAU;AACV,eAAA;AACA,iBAAa,WAAW,WAAW;AAAA,EACrC;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM,MAAM;AAAA,IACZ,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU,OAAqB;AAAA,MAC7B,IAAI;AAAA,MACJ;AAAA,MACA,OAAO,EAAE,WAAA;AAAA,IAAW;AAAA,IAEtB,UAAU,CAAC,UAAgC;AACzC,UAAI,MAAM,SAAS;AACjB,iBAAA;AAAA,MACF,OAAO;AACL,mBAAA;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|