accessify-widget 0.3.38 → 0.3.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accessify-widget",
3
- "version": "0.3.38",
3
+ "version": "0.3.40",
4
4
  "description": "Accessify-Widget accessibility widget for any website",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/maddesv1-ctrl/accessify-widget",
@@ -1,139 +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 "light":
8
- return `
9
- html {
10
- color-scheme: light !important;
11
- }
12
-
13
- body,
14
- body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {
15
- background-color: #fbf7ef !important;
16
- color: #161616 !important;
17
- border-color: #6f675d !important;
18
- }
19
-
20
- body :where(h1, h2, h3, h4, h5, h6, strong, b):not(#accessify-root):not(#accessify-root *) {
21
- color: #0f1720 !important;
22
- }
23
-
24
- body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {
25
- color: #0047b3 !important;
26
- text-decoration-color: currentColor !important;
27
- }
28
-
29
- body :where(button, input, textarea, select):not(#accessify-root):not(#accessify-root *) {
30
- box-shadow: none !important;
31
- }
32
- `;
33
- case "dark":
34
- return `
35
- html {
36
- color-scheme: dark !important;
37
- }
38
-
39
- body,
40
- body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {
41
- background-color: #101418 !important;
42
- color: #f5f1e8 !important;
43
- border-color: #9bb4c7 !important;
44
- }
45
-
46
- body :where(h1, h2, h3, h4, h5, h6, strong, b):not(#accessify-root):not(#accessify-root *) {
47
- color: #ffffff !important;
48
- }
49
-
50
- body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {
51
- color: #8fd8ff !important;
52
- text-decoration-color: currentColor !important;
53
- }
54
-
55
- body :where(img, video, svg, canvas):not(#accessify-root):not(#accessify-root *) {
56
- filter: brightness(0.92) contrast(1.08) !important;
57
- }
58
- `;
59
- case "high":
60
- return `
61
- html {
62
- color-scheme: dark !important;
63
- }
64
-
65
- body,
66
- body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {
67
- background: #000000 !important;
68
- color: #ffffff !important;
69
- border-color: #ffffff !important;
70
- box-shadow: none !important;
71
- }
72
-
73
- body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {
74
- color: #fff35c !important;
75
- text-decoration: underline !important;
76
- text-decoration-thickness: 3px !important;
77
- text-underline-offset: 3px !important;
78
- }
79
-
80
- body :where(button, input, textarea, select):not(#accessify-root):not(#accessify-root *) {
81
- outline: 2px solid #fff35c !important;
82
- outline-offset: 2px !important;
83
- }
84
-
85
- body :where(img, video, svg, canvas):not(#accessify-root):not(#accessify-root *) {
86
- filter: contrast(1.25) brightness(0.95) !important;
87
- }
88
- `;
89
- default:
90
- return "";
91
- }
92
- }
93
- function applyStyles(mode) {
94
- let styleEl = document.getElementById(STYLE_ID);
95
- if (mode === "off") {
96
- styleEl?.remove();
97
- return;
98
- }
99
- if (!styleEl) {
100
- styleEl = document.createElement("style");
101
- styleEl.id = STYLE_ID;
102
- document.head.appendChild(styleEl);
103
- }
104
- styleEl.textContent = getStyles(mode);
105
- }
106
- function activate() {
107
- const saved = localStorage.getItem(STORAGE_KEY);
108
- currentMode = saved === "light" || saved === "dark" || saved === "high" ? saved : "dark";
109
- applyStyles(currentMode);
110
- }
111
- function deactivate() {
112
- currentMode = "off";
113
- applyStyles("off");
114
- localStorage.removeItem(STORAGE_KEY);
115
- }
116
- return {
117
- id: "contrast",
118
- name: () => "Contrast",
119
- description: "Increase contrast for better readability",
120
- icon: "contrast",
121
- category: "visual",
122
- activate,
123
- deactivate,
124
- getState: () => ({ id: "contrast", enabled: currentMode !== "off", value: currentMode }),
125
- setState: (mode) => {
126
- currentMode = mode === "light" || mode === "dark" || mode === "high" ? mode : "off";
127
- applyStyles(mode);
128
- if (currentMode === "off") {
129
- localStorage.removeItem(STORAGE_KEY);
130
- } else {
131
- localStorage.setItem(STORAGE_KEY, currentMode);
132
- }
133
- }
134
- };
135
- }
136
- export {
137
- createContrastModule as default
138
- };
139
- //# sourceMappingURL=contrast-CqsICAkU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contrast-CqsICAkU.js","sources":["../src/features/contrast.ts"],"sourcesContent":["import type { FeatureModule, FeatureState } from '../types';\n\ntype ContrastMode = 'off' | 'light' | 'dark' | 'high';\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 'light':\n return `\n html {\n color-scheme: light !important;\n }\n\n body,\n body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {\n background-color: #fbf7ef !important;\n color: #161616 !important;\n border-color: #6f675d !important;\n }\n\n body :where(h1, h2, h3, h4, h5, h6, strong, b):not(#accessify-root):not(#accessify-root *) {\n color: #0f1720 !important;\n }\n\n body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {\n color: #0047b3 !important;\n text-decoration-color: currentColor !important;\n }\n\n body :where(button, input, textarea, select):not(#accessify-root):not(#accessify-root *) {\n box-shadow: none !important;\n }\n `;\n case 'dark':\n return `\n html {\n color-scheme: dark !important;\n }\n\n body,\n body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {\n background-color: #101418 !important;\n color: #f5f1e8 !important;\n border-color: #9bb4c7 !important;\n }\n\n body :where(h1, h2, h3, h4, h5, h6, strong, b):not(#accessify-root):not(#accessify-root *) {\n color: #ffffff !important;\n }\n\n body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {\n color: #8fd8ff !important;\n text-decoration-color: currentColor !important;\n }\n\n body :where(img, video, svg, canvas):not(#accessify-root):not(#accessify-root *) {\n filter: brightness(0.92) contrast(1.08) !important;\n }\n `;\n case 'high':\n return `\n html {\n color-scheme: dark !important;\n }\n\n body,\n body :where(main, section, article, aside, nav, header, footer, div, p, li, dt, dd, blockquote, figcaption, table, thead, tbody, tr, th, td, ul, ol, form, fieldset, button, input, textarea, select, label, details, summary):not(#accessify-root):not(#accessify-root *) {\n background: #000000 !important;\n color: #ffffff !important;\n border-color: #ffffff !important;\n box-shadow: none !important;\n }\n\n body :where(a, a:visited):not(#accessify-root):not(#accessify-root *) {\n color: #fff35c !important;\n text-decoration: underline !important;\n text-decoration-thickness: 3px !important;\n text-underline-offset: 3px !important;\n }\n\n body :where(button, input, textarea, select):not(#accessify-root):not(#accessify-root *) {\n outline: 2px solid #fff35c !important;\n outline-offset: 2px !important;\n }\n\n body :where(img, video, svg, canvas):not(#accessify-root):not(#accessify-root *) {\n filter: contrast(1.25) brightness(0.95) !important;\n }\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 === 'light' || saved === 'dark' || saved === 'high' ? saved : 'dark';\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 === 'light' || mode === 'dark' || mode === 'high' ? mode : 'off';\n applyStyles(mode);\n if (currentMode === 'off') {\n localStorage.removeItem(STORAGE_KEY);\n } else {\n localStorage.setItem(STORAGE_KEY, currentMode);\n }\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAyBT,KAAK;AACH,eAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAyBT,KAAK;AACH,eAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MA6BT;AACE,eAAO;AAAA,IAAA;AAAA,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