@m00rl0ck/a11y-widget 0.1.0
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/index.js +247 -0
- package/dist/index.js.map +7 -0
- package/dist/vision-a11y.js +247 -0
- package/dist/vision-a11y.js.map +7 -0
- package/package.json +41 -0
- package/src/index.js +1 -0
- package/src/vision-a11y/index.js +399 -0
- package/src/vision-a11y/locales.js +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oleksandr Vasyliev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @m00rl0ck/a11y-widget
|
|
2
|
+
|
|
3
|
+
Collection of lightweight **accessibility web components** for websites. Zero dependencies. Works with any framework.
|
|
4
|
+
|
|
5
|
+
## Widgets
|
|
6
|
+
|
|
7
|
+
### vision-a11y
|
|
8
|
+
|
|
9
|
+
Accessibility panel for vision-impaired users. Adjust font size, contrast, readable font, and letter spacing.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @m00rl0ck/a11y-widget
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script type="module">
|
|
17
|
+
import '@m00rl0ck/a11y-widget/vision-a11y'
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<vision-accessibility-widget></vision-accessibility-widget>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
#### Attributes
|
|
24
|
+
|
|
25
|
+
| Attribute | Type | Default | Description |
|
|
26
|
+
|-----------|------|---------|-------------|
|
|
27
|
+
| `lang` | `uk` / `en` / `de` | auto | UI language |
|
|
28
|
+
| `position` | `right-bottom`, `left-bottom`, `right-top`, `left-top` | `right-bottom` | Widget position |
|
|
29
|
+
| `label-title` | string | — | Override panel title |
|
|
30
|
+
| `label-subtitle` | string | — | Override panel subtitle |
|
|
31
|
+
| `label-reset` | string | — | Override reset button text |
|
|
32
|
+
|
|
33
|
+
#### Example
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<vision-accessibility-widget
|
|
37
|
+
lang="en"
|
|
38
|
+
position="left-bottom"
|
|
39
|
+
label-title="Accessibility"
|
|
40
|
+
></vision-accessibility-widget>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
npm run dev # watch mode
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
var b=Object.defineProperty;var g=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>g(o,typeof t!="symbol"?t+"":t,e);var n={uk:{panelTitle:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",panelSubtitle:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.",closeLabel:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",fontSizeLabel:"\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:",themeLabel:"\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:",extraLabel:"\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:",readableFont:"\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442",letterSpacing:"\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438",reset:"\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443",toggleLabel:"\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",toggleText:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443"},en:{panelTitle:"Vision Accessibility",panelSubtitle:"Adjust text size, contrast, and readability of the site.",closeLabel:"Close panel",fontSizeLabel:"Font size:",themeLabel:"Color scheme:",extraLabel:"Additional:",readableFont:"Readable font",letterSpacing:"Letter spacing",reset:"Default view",toggleLabel:"Open vision accessibility settings",toggleText:"Vision accessibility"},de:{panelTitle:"Barrierefreiheit",panelSubtitle:"Passen Sie Schriftgr\xF6\xDFe, Kontrast und Lesbarkeit der Seite an.",closeLabel:"Schlie\xDFen",fontSizeLabel:"Schriftgr\xF6\xDFe:",themeLabel:"Farbschema:",extraLabel:"Zus\xE4tzlich:",readableFont:"Lesbare Schrift",letterSpacing:"Buchstabenabstand",reset:"Standardansicht",toggleLabel:"Barrierefreiheit-Einstellungen \xF6ffnen",toggleText:"Barrierefreiheit"}};function h(){let t=(document.documentElement.lang||navigator.language||"en").slice(0,2).toLowerCase();return t in n?t:"en"}var r="vision-a11y-settings",p="vision-a11y-global-styles",c={fontSize:"normal",theme:"default",letterSpacing:!1,readableFont:!1},l=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._state={...c,open:!1}}get lang(){return this.getAttribute("lang")||h()}t(t){let e=n[this.lang]||n.en;return this._getLabelOverrides()[t]||e[t]||t}_getLabelOverrides(){let t={"label-title":"panelTitle","label-subtitle":"panelSubtitle","label-reset":"reset"},e={};for(let[a,s]of Object.entries(t)){let i=this.getAttribute(a);i&&(e[s]=i)}return e}connectedCallback(){this._loadState(),this._render(),this._applySettings()}attributeChangedCallback(){this.shadowRoot.innerHTML&&this._render()}_loadState(){try{let t=JSON.parse(localStorage.getItem(r));t&&(this._state={...c,...t,open:!1})}catch{}}_saveState(){let{open:t,...e}=this._state;localStorage.setItem(r,JSON.stringify(e))}_setState(t){this._state={...this._state,...t},this._saveState(),this._render(),this._applySettings()}_reset(){localStorage.removeItem(r),this._state={...c,open:!1},this._render(),this._applySettings()}_applySettings(){let t=document.documentElement;t.classList.remove("va-font-normal","va-font-large","va-font-xlarge","va-theme-default","va-theme-contrast","va-theme-light","va-readable-font","va-letter-spacing"),t.classList.add(`va-font-${this._state.fontSize}`),t.classList.add(`va-theme-${this._state.theme}`),this._state.readableFont&&t.classList.add("va-readable-font"),this._state.letterSpacing&&t.classList.add("va-letter-spacing"),this._ensureGlobalStyles()}_ensureGlobalStyles(){if(document.getElementById(p))return;let t=document.createElement("style");t.id=p,t.textContent=`
|
|
2
|
+
html.va-font-large { font-size: 112.5%; }
|
|
3
|
+
html.va-font-xlarge { font-size: 125%; }
|
|
4
|
+
|
|
5
|
+
html.va-readable-font body,
|
|
6
|
+
html.va-readable-font button,
|
|
7
|
+
html.va-readable-font input,
|
|
8
|
+
html.va-readable-font textarea,
|
|
9
|
+
html.va-readable-font select {
|
|
10
|
+
font-family: Arial, Helvetica, sans-serif !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
html.va-letter-spacing body {
|
|
14
|
+
letter-spacing: 0.04em;
|
|
15
|
+
line-height: 1.7;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
html.va-theme-contrast body {
|
|
19
|
+
background: #000 !important;
|
|
20
|
+
color: #fff !important;
|
|
21
|
+
}
|
|
22
|
+
html.va-theme-contrast a {
|
|
23
|
+
color: #ffff00 !important;
|
|
24
|
+
text-decoration: underline !important;
|
|
25
|
+
}
|
|
26
|
+
html.va-theme-contrast button,
|
|
27
|
+
html.va-theme-contrast input,
|
|
28
|
+
html.va-theme-contrast textarea,
|
|
29
|
+
html.va-theme-contrast select {
|
|
30
|
+
background: #000 !important;
|
|
31
|
+
color: #fff !important;
|
|
32
|
+
border-color: #fff !important;
|
|
33
|
+
}
|
|
34
|
+
html.va-theme-contrast img,
|
|
35
|
+
html.va-theme-contrast video,
|
|
36
|
+
html.va-theme-contrast canvas {
|
|
37
|
+
filter: grayscale(1) contrast(1.15);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
html.va-theme-light body {
|
|
41
|
+
background: #fff !important;
|
|
42
|
+
color: #000 !important;
|
|
43
|
+
}
|
|
44
|
+
html.va-theme-light a {
|
|
45
|
+
color: #003cff !important;
|
|
46
|
+
text-decoration: underline !important;
|
|
47
|
+
}
|
|
48
|
+
html.va-theme-light button,
|
|
49
|
+
html.va-theme-light input,
|
|
50
|
+
html.va-theme-light textarea,
|
|
51
|
+
html.va-theme-light select {
|
|
52
|
+
background: #fff !important;
|
|
53
|
+
color: #000 !important;
|
|
54
|
+
border-color: #000 !important;
|
|
55
|
+
}
|
|
56
|
+
`,document.head.appendChild(t)}_render(){let t=this._state,e=t.open;this.shadowRoot.innerHTML=`
|
|
57
|
+
<style>
|
|
58
|
+
:host {
|
|
59
|
+
position: fixed;
|
|
60
|
+
${this._getPositionStyles()}
|
|
61
|
+
z-index: 99999;
|
|
62
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
63
|
+
}
|
|
64
|
+
* { box-sizing: border-box; }
|
|
65
|
+
.widget {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
align-items: flex-end;
|
|
69
|
+
gap: 10px;
|
|
70
|
+
}
|
|
71
|
+
.toggle {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: 8px;
|
|
75
|
+
border: 2px solid #111;
|
|
76
|
+
border-radius: 999px;
|
|
77
|
+
padding: 12px 16px;
|
|
78
|
+
background: #fff;
|
|
79
|
+
color: #111;
|
|
80
|
+
font-size: 15px;
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
box-shadow: 0 10px 30px rgba(0,0,0,.18);
|
|
84
|
+
transition: transform 160ms ease, box-shadow 160ms ease;
|
|
85
|
+
}
|
|
86
|
+
.toggle:hover {
|
|
87
|
+
transform: translateY(-1px);
|
|
88
|
+
box-shadow: 0 14px 34px rgba(0,0,0,.22);
|
|
89
|
+
}
|
|
90
|
+
.toggle:focus-visible,
|
|
91
|
+
.control:focus-visible,
|
|
92
|
+
.reset:focus-visible,
|
|
93
|
+
.close:focus-visible {
|
|
94
|
+
outline: 3px solid #ffcc00;
|
|
95
|
+
outline-offset: 3px;
|
|
96
|
+
}
|
|
97
|
+
.icon { font-size: 20px; line-height: 1; }
|
|
98
|
+
.panel {
|
|
99
|
+
width: min(340px, calc(100vw - 32px));
|
|
100
|
+
padding: 18px;
|
|
101
|
+
border: 2px solid #111;
|
|
102
|
+
border-radius: 18px;
|
|
103
|
+
background: #fff;
|
|
104
|
+
color: #111;
|
|
105
|
+
box-shadow: 0 18px 50px rgba(0,0,0,.25);
|
|
106
|
+
}
|
|
107
|
+
.panel[hidden] { display: none; }
|
|
108
|
+
.header {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: flex-start;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
gap: 12px;
|
|
113
|
+
margin-bottom: 14px;
|
|
114
|
+
}
|
|
115
|
+
.title {
|
|
116
|
+
margin: 0;
|
|
117
|
+
font-size: 18px;
|
|
118
|
+
line-height: 1.25;
|
|
119
|
+
font-weight: 800;
|
|
120
|
+
}
|
|
121
|
+
.subtitle {
|
|
122
|
+
margin: 4px 0 0;
|
|
123
|
+
font-size: 13px;
|
|
124
|
+
line-height: 1.4;
|
|
125
|
+
color: #555;
|
|
126
|
+
}
|
|
127
|
+
.close {
|
|
128
|
+
width: 32px; height: 32px;
|
|
129
|
+
border: 1px solid #ddd;
|
|
130
|
+
border-radius: 50%;
|
|
131
|
+
background: #f7f7f7;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
font-size: 20px;
|
|
134
|
+
line-height: 1;
|
|
135
|
+
}
|
|
136
|
+
.group {
|
|
137
|
+
padding-top: 14px;
|
|
138
|
+
margin-top: 14px;
|
|
139
|
+
border-top: 1px solid #e5e5e5;
|
|
140
|
+
}
|
|
141
|
+
.label {
|
|
142
|
+
display: block;
|
|
143
|
+
margin-bottom: 8px;
|
|
144
|
+
font-size: 14px;
|
|
145
|
+
font-weight: 700;
|
|
146
|
+
}
|
|
147
|
+
.controls {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: repeat(3, 1fr);
|
|
150
|
+
gap: 8px;
|
|
151
|
+
}
|
|
152
|
+
.controls.two { grid-template-columns: repeat(2, 1fr); }
|
|
153
|
+
.control, .reset {
|
|
154
|
+
min-height: 42px;
|
|
155
|
+
border: 2px solid #d6d6d6;
|
|
156
|
+
border-radius: 12px;
|
|
157
|
+
background: #fafafa;
|
|
158
|
+
color: #111;
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
font-weight: 700;
|
|
161
|
+
transition: border-color 140ms ease, background 140ms ease;
|
|
162
|
+
}
|
|
163
|
+
.control:hover, .reset:hover {
|
|
164
|
+
border-color: #111;
|
|
165
|
+
background: #f0f0f0;
|
|
166
|
+
}
|
|
167
|
+
.control.active {
|
|
168
|
+
border-color: #111;
|
|
169
|
+
background: #111;
|
|
170
|
+
color: #fff;
|
|
171
|
+
}
|
|
172
|
+
.font-a { font-size: 16px; }
|
|
173
|
+
.font-aa { font-size: 20px; }
|
|
174
|
+
.font-aaa { font-size: 24px; }
|
|
175
|
+
.theme-default { background: #fff; color: #111; }
|
|
176
|
+
.theme-contrast { background: #000; color: #fff; border-color: #000; }
|
|
177
|
+
.theme-light { background: #fff; color: #000; border-color: #000; }
|
|
178
|
+
.reset {
|
|
179
|
+
width: 100%;
|
|
180
|
+
margin-top: 14px;
|
|
181
|
+
background: #fff4f4;
|
|
182
|
+
border-color: #f0b4b4;
|
|
183
|
+
color: #8a0000;
|
|
184
|
+
}
|
|
185
|
+
@media (max-width: 520px) {
|
|
186
|
+
:host {
|
|
187
|
+
right: 12px !important;
|
|
188
|
+
bottom: 12px !important;
|
|
189
|
+
}
|
|
190
|
+
.toggle {
|
|
191
|
+
padding: 11px 14px;
|
|
192
|
+
font-size: 14px;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
196
|
+
|
|
197
|
+
<div class="widget">
|
|
198
|
+
<section class="panel" ${e?"":"hidden"} aria-label="${this.t("panelTitle")}">
|
|
199
|
+
<div class="header">
|
|
200
|
+
<div>
|
|
201
|
+
<h2 class="title">${this.t("panelTitle")}</h2>
|
|
202
|
+
<p class="subtitle">${this.t("panelSubtitle")}</p>
|
|
203
|
+
</div>
|
|
204
|
+
<button class="close" type="button" aria-label="${this.t("closeLabel")}">\xD7</button>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<div class="group">
|
|
208
|
+
<span class="label">${this.t("fontSizeLabel")}</span>
|
|
209
|
+
<div class="controls">
|
|
210
|
+
<button class="control font-a ${t.fontSize==="normal"?"active":""}" data-font="normal" type="button">A</button>
|
|
211
|
+
<button class="control font-aa ${t.fontSize==="large"?"active":""}" data-font="large" type="button">A</button>
|
|
212
|
+
<button class="control font-aaa ${t.fontSize==="xlarge"?"active":""}" data-font="xlarge" type="button">A</button>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<div class="group">
|
|
217
|
+
<span class="label">${this.t("themeLabel")}</span>
|
|
218
|
+
<div class="controls">
|
|
219
|
+
<button class="control theme-default ${t.theme==="default"?"active":""}" data-theme="default" type="button">A</button>
|
|
220
|
+
<button class="control theme-contrast ${t.theme==="contrast"?"active":""}" data-theme="contrast" type="button">A</button>
|
|
221
|
+
<button class="control theme-light ${t.theme==="light"?"active":""}" data-theme="light" type="button">A</button>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div class="group">
|
|
226
|
+
<span class="label">${this.t("extraLabel")}</span>
|
|
227
|
+
<div class="controls two">
|
|
228
|
+
<button class="control ${t.readableFont?"active":""}" data-toggle="readableFont" type="button">${this.t("readableFont")}</button>
|
|
229
|
+
<button class="control ${t.letterSpacing?"active":""}" data-toggle="letterSpacing" type="button">${this.t("letterSpacing")}</button>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<button class="reset" type="button">${this.t("reset")}</button>
|
|
234
|
+
</section>
|
|
235
|
+
|
|
236
|
+
<button
|
|
237
|
+
class="toggle"
|
|
238
|
+
type="button"
|
|
239
|
+
aria-expanded="${e?"true":"false"}"
|
|
240
|
+
aria-label="${this.t("toggleLabel")}"
|
|
241
|
+
>
|
|
242
|
+
<span class="icon" aria-hidden="true">\u{1F441}</span>
|
|
243
|
+
<span>${this.t("toggleText")}</span>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
`,this.shadowRoot.querySelector(".toggle").addEventListener("click",()=>{this._setState({open:!this._state.open})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>{this._setState({open:!1})}),this.shadowRoot.querySelectorAll("[data-font]").forEach(a=>{a.addEventListener("click",()=>this._setState({fontSize:a.dataset.font}))}),this.shadowRoot.querySelectorAll("[data-theme]").forEach(a=>{a.addEventListener("click",()=>this._setState({theme:a.dataset.theme}))}),this.shadowRoot.querySelectorAll("[data-toggle]").forEach(a=>{a.addEventListener("click",()=>this._setState({[a.dataset.toggle]:!this._state[a.dataset.toggle]}))}),this.shadowRoot.querySelector(".reset").addEventListener("click",()=>this._reset())}_getPositionStyles(){let t=this.getAttribute("position")||"right-bottom",[e,a]=t.split("-"),s={};return e==="right"?s.right="20px":s.left="20px",a==="bottom"?s.bottom="20px":s.top="20px",Object.entries(s).map(([i,f])=>`${i}: ${f};`).join(" ")}};d(l,"observedAttributes",["lang","position","label-title","label-subtitle","label-reset"]);var m=l;customElements.get("vision-accessibility-widget")||customElements.define("vision-accessibility-widget",l);export{m as VisionA11y,l as VisionAccessibilityWidget};
|
|
247
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vision-a11y/locales.js", "../src/vision-a11y/index.js"],
|
|
4
|
+
"sourcesContent": ["export const locales = {\n uk: {\n panelTitle: '\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n panelSubtitle: '\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.',\n closeLabel: '\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C',\n fontSizeLabel: '\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:',\n themeLabel: '\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:',\n extraLabel: '\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:',\n readableFont: '\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442',\n letterSpacing: '\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438',\n reset: '\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443',\n toggleLabel: '\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n toggleText: '\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n },\n en: {\n panelTitle: 'Vision Accessibility',\n panelSubtitle: 'Adjust text size, contrast, and readability of the site.',\n closeLabel: 'Close panel',\n fontSizeLabel: 'Font size:',\n themeLabel: 'Color scheme:',\n extraLabel: 'Additional:',\n readableFont: 'Readable font',\n letterSpacing: 'Letter spacing',\n reset: 'Default view',\n toggleLabel: 'Open vision accessibility settings',\n toggleText: 'Vision accessibility',\n },\n de: {\n panelTitle: 'Barrierefreiheit',\n panelSubtitle: 'Passen Sie Schriftgr\u00F6\u00DFe, Kontrast und Lesbarkeit der Seite an.',\n closeLabel: 'Schlie\u00DFen',\n fontSizeLabel: 'Schriftgr\u00F6\u00DFe:',\n themeLabel: 'Farbschema:',\n extraLabel: 'Zus\u00E4tzlich:',\n readableFont: 'Lesbare Schrift',\n letterSpacing: 'Buchstabenabstand',\n reset: 'Standardansicht',\n toggleLabel: 'Barrierefreiheit-Einstellungen \u00F6ffnen',\n toggleText: 'Barrierefreiheit',\n },\n}\n\nexport function detectLang() {\n const html = document.documentElement\n const htmlLang = (html.lang || navigator.language || 'en').slice(0, 2).toLowerCase()\n return htmlLang in locales ? htmlLang : 'en'\n}\n", "import { locales, detectLang } from './locales.js'\n\nconst storageKey = 'vision-a11y-settings'\nconst styleId = 'vision-a11y-global-styles'\n\nconst defaults = {\n fontSize: 'normal',\n theme: 'default',\n letterSpacing: false,\n readableFont: false,\n}\n\nclass VisionAccessibilityWidget extends HTMLElement {\n static observedAttributes = ['lang', 'position', 'label-title', 'label-subtitle', 'label-reset']\n\n constructor() {\n super()\n this.attachShadow({ mode: 'open' })\n this._state = { ...defaults, open: false }\n }\n\n get lang() {\n return this.getAttribute('lang') || detectLang()\n }\n\n t(key) {\n const dict = locales[this.lang] || locales.en\n const overrides = this._getLabelOverrides()\n return overrides[key] || dict[key] || key\n }\n\n _getLabelOverrides() {\n const map = {\n 'label-title': 'panelTitle',\n 'label-subtitle': 'panelSubtitle',\n 'label-reset': 'reset',\n }\n const overrides = {}\n for (const [attr, key] of Object.entries(map)) {\n const val = this.getAttribute(attr)\n if (val) overrides[key] = val\n }\n return overrides\n }\n\n connectedCallback() {\n this._loadState()\n this._render()\n this._applySettings()\n }\n\n attributeChangedCallback() {\n if (this.shadowRoot.innerHTML) {\n this._render()\n }\n }\n\n _loadState() {\n try {\n const saved = JSON.parse(localStorage.getItem(storageKey))\n if (saved) {\n this._state = { ...defaults, ...saved, open: false }\n }\n } catch {}\n }\n\n _saveState() {\n const { open, ...settings } = this._state\n localStorage.setItem(storageKey, JSON.stringify(settings))\n }\n\n _setState(next) {\n this._state = { ...this._state, ...next }\n this._saveState()\n this._render()\n this._applySettings()\n }\n\n _reset() {\n localStorage.removeItem(storageKey)\n this._state = { ...defaults, open: false }\n this._render()\n this._applySettings()\n }\n\n _applySettings() {\n const root = document.documentElement\n\n root.classList.remove(\n 'va-font-normal', 'va-font-large', 'va-font-xlarge',\n 'va-theme-default', 'va-theme-contrast', 'va-theme-light',\n 'va-readable-font', 'va-letter-spacing',\n )\n\n root.classList.add(`va-font-${this._state.fontSize}`)\n root.classList.add(`va-theme-${this._state.theme}`)\n\n if (this._state.readableFont) root.classList.add('va-readable-font')\n if (this._state.letterSpacing) root.classList.add('va-letter-spacing')\n\n this._ensureGlobalStyles()\n }\n\n _ensureGlobalStyles() {\n if (document.getElementById(styleId)) return\n\n const style = document.createElement('style')\n style.id = styleId\n style.textContent = `\n html.va-font-large { font-size: 112.5%; }\n html.va-font-xlarge { font-size: 125%; }\n\n html.va-readable-font body,\n html.va-readable-font button,\n html.va-readable-font input,\n html.va-readable-font textarea,\n html.va-readable-font select {\n font-family: Arial, Helvetica, sans-serif !important;\n }\n\n html.va-letter-spacing body {\n letter-spacing: 0.04em;\n line-height: 1.7;\n }\n\n html.va-theme-contrast body {\n background: #000 !important;\n color: #fff !important;\n }\n html.va-theme-contrast a {\n color: #ffff00 !important;\n text-decoration: underline !important;\n }\n html.va-theme-contrast button,\n html.va-theme-contrast input,\n html.va-theme-contrast textarea,\n html.va-theme-contrast select {\n background: #000 !important;\n color: #fff !important;\n border-color: #fff !important;\n }\n html.va-theme-contrast img,\n html.va-theme-contrast video,\n html.va-theme-contrast canvas {\n filter: grayscale(1) contrast(1.15);\n }\n\n html.va-theme-light body {\n background: #fff !important;\n color: #000 !important;\n }\n html.va-theme-light a {\n color: #003cff !important;\n text-decoration: underline !important;\n }\n html.va-theme-light button,\n html.va-theme-light input,\n html.va-theme-light textarea,\n html.va-theme-light select {\n background: #fff !important;\n color: #000 !important;\n border-color: #000 !important;\n }\n `\n document.head.appendChild(style)\n }\n\n _render() {\n const s = this._state\n const open = s.open\n\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n position: fixed;\n ${this._getPositionStyles()}\n z-index: 99999;\n font-family: Arial, Helvetica, sans-serif;\n }\n * { box-sizing: border-box; }\n .widget {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 10px;\n }\n .toggle {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n border: 2px solid #111;\n border-radius: 999px;\n padding: 12px 16px;\n background: #fff;\n color: #111;\n font-size: 15px;\n font-weight: 700;\n cursor: pointer;\n box-shadow: 0 10px 30px rgba(0,0,0,.18);\n transition: transform 160ms ease, box-shadow 160ms ease;\n }\n .toggle:hover {\n transform: translateY(-1px);\n box-shadow: 0 14px 34px rgba(0,0,0,.22);\n }\n .toggle:focus-visible,\n .control:focus-visible,\n .reset:focus-visible,\n .close:focus-visible {\n outline: 3px solid #ffcc00;\n outline-offset: 3px;\n }\n .icon { font-size: 20px; line-height: 1; }\n .panel {\n width: min(340px, calc(100vw - 32px));\n padding: 18px;\n border: 2px solid #111;\n border-radius: 18px;\n background: #fff;\n color: #111;\n box-shadow: 0 18px 50px rgba(0,0,0,.25);\n }\n .panel[hidden] { display: none; }\n .header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n margin-bottom: 14px;\n }\n .title {\n margin: 0;\n font-size: 18px;\n line-height: 1.25;\n font-weight: 800;\n }\n .subtitle {\n margin: 4px 0 0;\n font-size: 13px;\n line-height: 1.4;\n color: #555;\n }\n .close {\n width: 32px; height: 32px;\n border: 1px solid #ddd;\n border-radius: 50%;\n background: #f7f7f7;\n cursor: pointer;\n font-size: 20px;\n line-height: 1;\n }\n .group {\n padding-top: 14px;\n margin-top: 14px;\n border-top: 1px solid #e5e5e5;\n }\n .label {\n display: block;\n margin-bottom: 8px;\n font-size: 14px;\n font-weight: 700;\n }\n .controls {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 8px;\n }\n .controls.two { grid-template-columns: repeat(2, 1fr); }\n .control, .reset {\n min-height: 42px;\n border: 2px solid #d6d6d6;\n border-radius: 12px;\n background: #fafafa;\n color: #111;\n cursor: pointer;\n font-weight: 700;\n transition: border-color 140ms ease, background 140ms ease;\n }\n .control:hover, .reset:hover {\n border-color: #111;\n background: #f0f0f0;\n }\n .control.active {\n border-color: #111;\n background: #111;\n color: #fff;\n }\n .font-a { font-size: 16px; }\n .font-aa { font-size: 20px; }\n .font-aaa { font-size: 24px; }\n .theme-default { background: #fff; color: #111; }\n .theme-contrast { background: #000; color: #fff; border-color: #000; }\n .theme-light { background: #fff; color: #000; border-color: #000; }\n .reset {\n width: 100%;\n margin-top: 14px;\n background: #fff4f4;\n border-color: #f0b4b4;\n color: #8a0000;\n }\n @media (max-width: 520px) {\n :host {\n right: 12px !important;\n bottom: 12px !important;\n }\n .toggle {\n padding: 11px 14px;\n font-size: 14px;\n }\n }\n </style>\n\n <div class=\"widget\">\n <section class=\"panel\" ${open ? '' : 'hidden'} aria-label=\"${this.t('panelTitle')}\">\n <div class=\"header\">\n <div>\n <h2 class=\"title\">${this.t('panelTitle')}</h2>\n <p class=\"subtitle\">${this.t('panelSubtitle')}</p>\n </div>\n <button class=\"close\" type=\"button\" aria-label=\"${this.t('closeLabel')}\">\u00D7</button>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('fontSizeLabel')}</span>\n <div class=\"controls\">\n <button class=\"control font-a ${s.fontSize === 'normal' ? 'active' : ''}\" data-font=\"normal\" type=\"button\">A</button>\n <button class=\"control font-aa ${s.fontSize === 'large' ? 'active' : ''}\" data-font=\"large\" type=\"button\">A</button>\n <button class=\"control font-aaa ${s.fontSize === 'xlarge' ? 'active' : ''}\" data-font=\"xlarge\" type=\"button\">A</button>\n </div>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('themeLabel')}</span>\n <div class=\"controls\">\n <button class=\"control theme-default ${s.theme === 'default' ? 'active' : ''}\" data-theme=\"default\" type=\"button\">A</button>\n <button class=\"control theme-contrast ${s.theme === 'contrast' ? 'active' : ''}\" data-theme=\"contrast\" type=\"button\">A</button>\n <button class=\"control theme-light ${s.theme === 'light' ? 'active' : ''}\" data-theme=\"light\" type=\"button\">A</button>\n </div>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('extraLabel')}</span>\n <div class=\"controls two\">\n <button class=\"control ${s.readableFont ? 'active' : ''}\" data-toggle=\"readableFont\" type=\"button\">${this.t('readableFont')}</button>\n <button class=\"control ${s.letterSpacing ? 'active' : ''}\" data-toggle=\"letterSpacing\" type=\"button\">${this.t('letterSpacing')}</button>\n </div>\n </div>\n\n <button class=\"reset\" type=\"button\">${this.t('reset')}</button>\n </section>\n\n <button\n class=\"toggle\"\n type=\"button\"\n aria-expanded=\"${open ? 'true' : 'false'}\"\n aria-label=\"${this.t('toggleLabel')}\"\n >\n <span class=\"icon\" aria-hidden=\"true\">\uD83D\uDC41</span>\n <span>${this.t('toggleText')}</span>\n </button>\n </div>\n `\n\n this.shadowRoot.querySelector('.toggle').addEventListener('click', () => {\n this._setState({ open: !this._state.open })\n })\n this.shadowRoot.querySelector('.close').addEventListener('click', () => {\n this._setState({ open: false })\n })\n this.shadowRoot.querySelectorAll('[data-font]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ fontSize: btn.dataset.font }))\n })\n this.shadowRoot.querySelectorAll('[data-theme]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ theme: btn.dataset.theme }))\n })\n this.shadowRoot.querySelectorAll('[data-toggle]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ [btn.dataset.toggle]: !this._state[btn.dataset.toggle] }))\n })\n this.shadowRoot.querySelector('.reset').addEventListener('click', () => this._reset())\n }\n\n _getPositionStyles() {\n const pos = this.getAttribute('position') || 'right-bottom'\n const [h, v] = pos.split('-')\n const styles = {}\n if (h === 'right') styles.right = '20px'\n else styles.left = '20px'\n if (v === 'bottom') styles.bottom = '20px'\n else styles.top = '20px'\n return Object.entries(styles).map(([k, v]) => `${k}: ${v};`).join(' ')\n }\n}\n\nexport { VisionAccessibilityWidget }\nexport default VisionAccessibilityWidget\n\nif (!customElements.get('vision-accessibility-widget')) {\n customElements.define('vision-accessibility-widget', VisionAccessibilityWidget)\n}\n"],
|
|
5
|
+
"mappings": "oKAAO,IAAMA,EAAU,CACrB,GAAI,CACF,WAAY,oIACZ,cAAe,iTACf,WAAY,kFACZ,cAAe,6EACf,WAAY,iEACZ,WAAY,0DACZ,aAAc,4EACd,cAAe,8FACf,MAAO,uHACP,YAAa,iRACb,WAAY,mIACd,EACA,GAAI,CACF,WAAY,uBACZ,cAAe,2DACf,WAAY,cACZ,cAAe,aACf,WAAY,gBACZ,WAAY,cACZ,aAAc,gBACd,cAAe,iBACf,MAAO,eACP,YAAa,qCACb,WAAY,sBACd,EACA,GAAI,CACF,WAAY,mBACZ,cAAe,uEACf,WAAY,eACZ,cAAe,sBACf,WAAY,cACZ,WAAY,iBACZ,aAAc,kBACd,cAAe,oBACf,MAAO,kBACP,YAAa,2CACb,WAAY,kBACd,CACF,EAEO,SAASC,GAAa,CAE3B,IAAMC,GADO,SAAS,gBACC,MAAQ,UAAU,UAAY,MAAM,MAAM,EAAG,CAAC,EAAE,YAAY,EACnF,OAAOA,KAAYF,EAAUE,EAAW,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,UAAU,CAAE,CAACA,EAAI,QAAQ,MAAM,EAAG,CAAC,KAAK,OAAOA,EAAI,QAAQ,MAAM,CAAE,CAAC,CAAC,CAChH,CAAC,EACD,KAAK,WAAW,cAAc,QAAQ,EAAE,iBAAiB,QAAS,IAAM,KAAK,OAAO,CAAC,CACvF,CAEA,oBAAqB,CACnB,IAAMC,EAAM,KAAK,aAAa,UAAU,GAAK,eACvC,CAACC,EAAGC,CAAC,EAAIF,EAAI,MAAM,GAAG,EACtBG,EAAS,CAAC,EAChB,OAAIF,IAAM,QAASE,EAAO,MAAQ,OAC7BA,EAAO,KAAO,OACfD,IAAM,SAAUC,EAAO,OAAS,OAC/BA,EAAO,IAAM,OACX,OAAO,QAAQA,CAAM,EAAE,IAAI,CAAC,CAACC,EAAGF,CAAC,IAAM,GAAGE,CAAC,KAAKF,CAAC,GAAG,EAAE,KAAK,GAAG,CACvE,CACF,EA1XEG,EADItB,EACG,qBAAqB,CAAC,OAAQ,WAAY,cAAe,iBAAkB,aAAa,GA6XjG,IAAOuB,EAAQC,EAEV,eAAe,IAAI,6BAA6B,GACnD,eAAe,OAAO,8BAA+BA,CAAyB",
|
|
6
|
+
"names": ["locales", "detectLang", "htmlLang", "storageKey", "styleId", "defaults", "VisionAccessibilityWidget", "detectLang", "key", "dict", "locales", "map", "overrides", "attr", "val", "saved", "open", "settings", "next", "root", "style", "s", "btn", "pos", "h", "v", "styles", "k", "__publicField", "vision_a11y_default", "VisionAccessibilityWidget"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
var b=Object.defineProperty;var g=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>g(o,typeof t!="symbol"?t+"":t,e);var i={uk:{panelTitle:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",panelSubtitle:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.",closeLabel:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",fontSizeLabel:"\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:",themeLabel:"\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:",extraLabel:"\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:",readableFont:"\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442",letterSpacing:"\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438",reset:"\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443",toggleLabel:"\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",toggleText:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443"},en:{panelTitle:"Vision Accessibility",panelSubtitle:"Adjust text size, contrast, and readability of the site.",closeLabel:"Close panel",fontSizeLabel:"Font size:",themeLabel:"Color scheme:",extraLabel:"Additional:",readableFont:"Readable font",letterSpacing:"Letter spacing",reset:"Default view",toggleLabel:"Open vision accessibility settings",toggleText:"Vision accessibility"},de:{panelTitle:"Barrierefreiheit",panelSubtitle:"Passen Sie Schriftgr\xF6\xDFe, Kontrast und Lesbarkeit der Seite an.",closeLabel:"Schlie\xDFen",fontSizeLabel:"Schriftgr\xF6\xDFe:",themeLabel:"Farbschema:",extraLabel:"Zus\xE4tzlich:",readableFont:"Lesbare Schrift",letterSpacing:"Buchstabenabstand",reset:"Standardansicht",toggleLabel:"Barrierefreiheit-Einstellungen \xF6ffnen",toggleText:"Barrierefreiheit"}};function h(){let t=(document.documentElement.lang||navigator.language||"en").slice(0,2).toLowerCase();return t in i?t:"en"}var r="vision-a11y-settings",p="vision-a11y-global-styles",c={fontSize:"normal",theme:"default",letterSpacing:!1,readableFont:!1},l=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._state={...c,open:!1}}get lang(){return this.getAttribute("lang")||h()}t(t){let e=i[this.lang]||i.en;return this._getLabelOverrides()[t]||e[t]||t}_getLabelOverrides(){let t={"label-title":"panelTitle","label-subtitle":"panelSubtitle","label-reset":"reset"},e={};for(let[a,s]of Object.entries(t)){let n=this.getAttribute(a);n&&(e[s]=n)}return e}connectedCallback(){this._loadState(),this._render(),this._applySettings()}attributeChangedCallback(){this.shadowRoot.innerHTML&&this._render()}_loadState(){try{let t=JSON.parse(localStorage.getItem(r));t&&(this._state={...c,...t,open:!1})}catch{}}_saveState(){let{open:t,...e}=this._state;localStorage.setItem(r,JSON.stringify(e))}_setState(t){this._state={...this._state,...t},this._saveState(),this._render(),this._applySettings()}_reset(){localStorage.removeItem(r),this._state={...c,open:!1},this._render(),this._applySettings()}_applySettings(){let t=document.documentElement;t.classList.remove("va-font-normal","va-font-large","va-font-xlarge","va-theme-default","va-theme-contrast","va-theme-light","va-readable-font","va-letter-spacing"),t.classList.add(`va-font-${this._state.fontSize}`),t.classList.add(`va-theme-${this._state.theme}`),this._state.readableFont&&t.classList.add("va-readable-font"),this._state.letterSpacing&&t.classList.add("va-letter-spacing"),this._ensureGlobalStyles()}_ensureGlobalStyles(){if(document.getElementById(p))return;let t=document.createElement("style");t.id=p,t.textContent=`
|
|
2
|
+
html.va-font-large { font-size: 112.5%; }
|
|
3
|
+
html.va-font-xlarge { font-size: 125%; }
|
|
4
|
+
|
|
5
|
+
html.va-readable-font body,
|
|
6
|
+
html.va-readable-font button,
|
|
7
|
+
html.va-readable-font input,
|
|
8
|
+
html.va-readable-font textarea,
|
|
9
|
+
html.va-readable-font select {
|
|
10
|
+
font-family: Arial, Helvetica, sans-serif !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
html.va-letter-spacing body {
|
|
14
|
+
letter-spacing: 0.04em;
|
|
15
|
+
line-height: 1.7;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
html.va-theme-contrast body {
|
|
19
|
+
background: #000 !important;
|
|
20
|
+
color: #fff !important;
|
|
21
|
+
}
|
|
22
|
+
html.va-theme-contrast a {
|
|
23
|
+
color: #ffff00 !important;
|
|
24
|
+
text-decoration: underline !important;
|
|
25
|
+
}
|
|
26
|
+
html.va-theme-contrast button,
|
|
27
|
+
html.va-theme-contrast input,
|
|
28
|
+
html.va-theme-contrast textarea,
|
|
29
|
+
html.va-theme-contrast select {
|
|
30
|
+
background: #000 !important;
|
|
31
|
+
color: #fff !important;
|
|
32
|
+
border-color: #fff !important;
|
|
33
|
+
}
|
|
34
|
+
html.va-theme-contrast img,
|
|
35
|
+
html.va-theme-contrast video,
|
|
36
|
+
html.va-theme-contrast canvas {
|
|
37
|
+
filter: grayscale(1) contrast(1.15);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
html.va-theme-light body {
|
|
41
|
+
background: #fff !important;
|
|
42
|
+
color: #000 !important;
|
|
43
|
+
}
|
|
44
|
+
html.va-theme-light a {
|
|
45
|
+
color: #003cff !important;
|
|
46
|
+
text-decoration: underline !important;
|
|
47
|
+
}
|
|
48
|
+
html.va-theme-light button,
|
|
49
|
+
html.va-theme-light input,
|
|
50
|
+
html.va-theme-light textarea,
|
|
51
|
+
html.va-theme-light select {
|
|
52
|
+
background: #fff !important;
|
|
53
|
+
color: #000 !important;
|
|
54
|
+
border-color: #000 !important;
|
|
55
|
+
}
|
|
56
|
+
`,document.head.appendChild(t)}_render(){let t=this._state,e=t.open;this.shadowRoot.innerHTML=`
|
|
57
|
+
<style>
|
|
58
|
+
:host {
|
|
59
|
+
position: fixed;
|
|
60
|
+
${this._getPositionStyles()}
|
|
61
|
+
z-index: 99999;
|
|
62
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
63
|
+
}
|
|
64
|
+
* { box-sizing: border-box; }
|
|
65
|
+
.widget {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
align-items: flex-end;
|
|
69
|
+
gap: 10px;
|
|
70
|
+
}
|
|
71
|
+
.toggle {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: 8px;
|
|
75
|
+
border: 2px solid #111;
|
|
76
|
+
border-radius: 999px;
|
|
77
|
+
padding: 12px 16px;
|
|
78
|
+
background: #fff;
|
|
79
|
+
color: #111;
|
|
80
|
+
font-size: 15px;
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
box-shadow: 0 10px 30px rgba(0,0,0,.18);
|
|
84
|
+
transition: transform 160ms ease, box-shadow 160ms ease;
|
|
85
|
+
}
|
|
86
|
+
.toggle:hover {
|
|
87
|
+
transform: translateY(-1px);
|
|
88
|
+
box-shadow: 0 14px 34px rgba(0,0,0,.22);
|
|
89
|
+
}
|
|
90
|
+
.toggle:focus-visible,
|
|
91
|
+
.control:focus-visible,
|
|
92
|
+
.reset:focus-visible,
|
|
93
|
+
.close:focus-visible {
|
|
94
|
+
outline: 3px solid #ffcc00;
|
|
95
|
+
outline-offset: 3px;
|
|
96
|
+
}
|
|
97
|
+
.icon { font-size: 20px; line-height: 1; }
|
|
98
|
+
.panel {
|
|
99
|
+
width: min(340px, calc(100vw - 32px));
|
|
100
|
+
padding: 18px;
|
|
101
|
+
border: 2px solid #111;
|
|
102
|
+
border-radius: 18px;
|
|
103
|
+
background: #fff;
|
|
104
|
+
color: #111;
|
|
105
|
+
box-shadow: 0 18px 50px rgba(0,0,0,.25);
|
|
106
|
+
}
|
|
107
|
+
.panel[hidden] { display: none; }
|
|
108
|
+
.header {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: flex-start;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
gap: 12px;
|
|
113
|
+
margin-bottom: 14px;
|
|
114
|
+
}
|
|
115
|
+
.title {
|
|
116
|
+
margin: 0;
|
|
117
|
+
font-size: 18px;
|
|
118
|
+
line-height: 1.25;
|
|
119
|
+
font-weight: 800;
|
|
120
|
+
}
|
|
121
|
+
.subtitle {
|
|
122
|
+
margin: 4px 0 0;
|
|
123
|
+
font-size: 13px;
|
|
124
|
+
line-height: 1.4;
|
|
125
|
+
color: #555;
|
|
126
|
+
}
|
|
127
|
+
.close {
|
|
128
|
+
width: 32px; height: 32px;
|
|
129
|
+
border: 1px solid #ddd;
|
|
130
|
+
border-radius: 50%;
|
|
131
|
+
background: #f7f7f7;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
font-size: 20px;
|
|
134
|
+
line-height: 1;
|
|
135
|
+
}
|
|
136
|
+
.group {
|
|
137
|
+
padding-top: 14px;
|
|
138
|
+
margin-top: 14px;
|
|
139
|
+
border-top: 1px solid #e5e5e5;
|
|
140
|
+
}
|
|
141
|
+
.label {
|
|
142
|
+
display: block;
|
|
143
|
+
margin-bottom: 8px;
|
|
144
|
+
font-size: 14px;
|
|
145
|
+
font-weight: 700;
|
|
146
|
+
}
|
|
147
|
+
.controls {
|
|
148
|
+
display: grid;
|
|
149
|
+
grid-template-columns: repeat(3, 1fr);
|
|
150
|
+
gap: 8px;
|
|
151
|
+
}
|
|
152
|
+
.controls.two { grid-template-columns: repeat(2, 1fr); }
|
|
153
|
+
.control, .reset {
|
|
154
|
+
min-height: 42px;
|
|
155
|
+
border: 2px solid #d6d6d6;
|
|
156
|
+
border-radius: 12px;
|
|
157
|
+
background: #fafafa;
|
|
158
|
+
color: #111;
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
font-weight: 700;
|
|
161
|
+
transition: border-color 140ms ease, background 140ms ease;
|
|
162
|
+
}
|
|
163
|
+
.control:hover, .reset:hover {
|
|
164
|
+
border-color: #111;
|
|
165
|
+
background: #f0f0f0;
|
|
166
|
+
}
|
|
167
|
+
.control.active {
|
|
168
|
+
border-color: #111;
|
|
169
|
+
background: #111;
|
|
170
|
+
color: #fff;
|
|
171
|
+
}
|
|
172
|
+
.font-a { font-size: 16px; }
|
|
173
|
+
.font-aa { font-size: 20px; }
|
|
174
|
+
.font-aaa { font-size: 24px; }
|
|
175
|
+
.theme-default { background: #fff; color: #111; }
|
|
176
|
+
.theme-contrast { background: #000; color: #fff; border-color: #000; }
|
|
177
|
+
.theme-light { background: #fff; color: #000; border-color: #000; }
|
|
178
|
+
.reset {
|
|
179
|
+
width: 100%;
|
|
180
|
+
margin-top: 14px;
|
|
181
|
+
background: #fff4f4;
|
|
182
|
+
border-color: #f0b4b4;
|
|
183
|
+
color: #8a0000;
|
|
184
|
+
}
|
|
185
|
+
@media (max-width: 520px) {
|
|
186
|
+
:host {
|
|
187
|
+
right: 12px !important;
|
|
188
|
+
bottom: 12px !important;
|
|
189
|
+
}
|
|
190
|
+
.toggle {
|
|
191
|
+
padding: 11px 14px;
|
|
192
|
+
font-size: 14px;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
196
|
+
|
|
197
|
+
<div class="widget">
|
|
198
|
+
<section class="panel" ${e?"":"hidden"} aria-label="${this.t("panelTitle")}">
|
|
199
|
+
<div class="header">
|
|
200
|
+
<div>
|
|
201
|
+
<h2 class="title">${this.t("panelTitle")}</h2>
|
|
202
|
+
<p class="subtitle">${this.t("panelSubtitle")}</p>
|
|
203
|
+
</div>
|
|
204
|
+
<button class="close" type="button" aria-label="${this.t("closeLabel")}">\xD7</button>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<div class="group">
|
|
208
|
+
<span class="label">${this.t("fontSizeLabel")}</span>
|
|
209
|
+
<div class="controls">
|
|
210
|
+
<button class="control font-a ${t.fontSize==="normal"?"active":""}" data-font="normal" type="button">A</button>
|
|
211
|
+
<button class="control font-aa ${t.fontSize==="large"?"active":""}" data-font="large" type="button">A</button>
|
|
212
|
+
<button class="control font-aaa ${t.fontSize==="xlarge"?"active":""}" data-font="xlarge" type="button">A</button>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<div class="group">
|
|
217
|
+
<span class="label">${this.t("themeLabel")}</span>
|
|
218
|
+
<div class="controls">
|
|
219
|
+
<button class="control theme-default ${t.theme==="default"?"active":""}" data-theme="default" type="button">A</button>
|
|
220
|
+
<button class="control theme-contrast ${t.theme==="contrast"?"active":""}" data-theme="contrast" type="button">A</button>
|
|
221
|
+
<button class="control theme-light ${t.theme==="light"?"active":""}" data-theme="light" type="button">A</button>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div class="group">
|
|
226
|
+
<span class="label">${this.t("extraLabel")}</span>
|
|
227
|
+
<div class="controls two">
|
|
228
|
+
<button class="control ${t.readableFont?"active":""}" data-toggle="readableFont" type="button">${this.t("readableFont")}</button>
|
|
229
|
+
<button class="control ${t.letterSpacing?"active":""}" data-toggle="letterSpacing" type="button">${this.t("letterSpacing")}</button>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<button class="reset" type="button">${this.t("reset")}</button>
|
|
234
|
+
</section>
|
|
235
|
+
|
|
236
|
+
<button
|
|
237
|
+
class="toggle"
|
|
238
|
+
type="button"
|
|
239
|
+
aria-expanded="${e?"true":"false"}"
|
|
240
|
+
aria-label="${this.t("toggleLabel")}"
|
|
241
|
+
>
|
|
242
|
+
<span class="icon" aria-hidden="true">\u{1F441}</span>
|
|
243
|
+
<span>${this.t("toggleText")}</span>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
`,this.shadowRoot.querySelector(".toggle").addEventListener("click",()=>{this._setState({open:!this._state.open})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>{this._setState({open:!1})}),this.shadowRoot.querySelectorAll("[data-font]").forEach(a=>{a.addEventListener("click",()=>this._setState({fontSize:a.dataset.font}))}),this.shadowRoot.querySelectorAll("[data-theme]").forEach(a=>{a.addEventListener("click",()=>this._setState({theme:a.dataset.theme}))}),this.shadowRoot.querySelectorAll("[data-toggle]").forEach(a=>{a.addEventListener("click",()=>this._setState({[a.dataset.toggle]:!this._state[a.dataset.toggle]}))}),this.shadowRoot.querySelector(".reset").addEventListener("click",()=>this._reset())}_getPositionStyles(){let t=this.getAttribute("position")||"right-bottom",[e,a]=t.split("-"),s={};return e==="right"?s.right="20px":s.left="20px",a==="bottom"?s.bottom="20px":s.top="20px",Object.entries(s).map(([n,f])=>`${n}: ${f};`).join(" ")}};d(l,"observedAttributes",["lang","position","label-title","label-subtitle","label-reset"]);var x=l;customElements.get("vision-accessibility-widget")||customElements.define("vision-accessibility-widget",l);export{l as VisionAccessibilityWidget,x as default};
|
|
247
|
+
//# sourceMappingURL=vision-a11y.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vision-a11y/locales.js", "../src/vision-a11y/index.js"],
|
|
4
|
+
"sourcesContent": ["export const locales = {\n uk: {\n panelTitle: '\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n panelSubtitle: '\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.',\n closeLabel: '\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C',\n fontSizeLabel: '\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:',\n themeLabel: '\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:',\n extraLabel: '\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:',\n readableFont: '\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442',\n letterSpacing: '\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438',\n reset: '\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443',\n toggleLabel: '\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n toggleText: '\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443',\n },\n en: {\n panelTitle: 'Vision Accessibility',\n panelSubtitle: 'Adjust text size, contrast, and readability of the site.',\n closeLabel: 'Close panel',\n fontSizeLabel: 'Font size:',\n themeLabel: 'Color scheme:',\n extraLabel: 'Additional:',\n readableFont: 'Readable font',\n letterSpacing: 'Letter spacing',\n reset: 'Default view',\n toggleLabel: 'Open vision accessibility settings',\n toggleText: 'Vision accessibility',\n },\n de: {\n panelTitle: 'Barrierefreiheit',\n panelSubtitle: 'Passen Sie Schriftgr\u00F6\u00DFe, Kontrast und Lesbarkeit der Seite an.',\n closeLabel: 'Schlie\u00DFen',\n fontSizeLabel: 'Schriftgr\u00F6\u00DFe:',\n themeLabel: 'Farbschema:',\n extraLabel: 'Zus\u00E4tzlich:',\n readableFont: 'Lesbare Schrift',\n letterSpacing: 'Buchstabenabstand',\n reset: 'Standardansicht',\n toggleLabel: 'Barrierefreiheit-Einstellungen \u00F6ffnen',\n toggleText: 'Barrierefreiheit',\n },\n}\n\nexport function detectLang() {\n const html = document.documentElement\n const htmlLang = (html.lang || navigator.language || 'en').slice(0, 2).toLowerCase()\n return htmlLang in locales ? htmlLang : 'en'\n}\n", "import { locales, detectLang } from './locales.js'\n\nconst storageKey = 'vision-a11y-settings'\nconst styleId = 'vision-a11y-global-styles'\n\nconst defaults = {\n fontSize: 'normal',\n theme: 'default',\n letterSpacing: false,\n readableFont: false,\n}\n\nclass VisionAccessibilityWidget extends HTMLElement {\n static observedAttributes = ['lang', 'position', 'label-title', 'label-subtitle', 'label-reset']\n\n constructor() {\n super()\n this.attachShadow({ mode: 'open' })\n this._state = { ...defaults, open: false }\n }\n\n get lang() {\n return this.getAttribute('lang') || detectLang()\n }\n\n t(key) {\n const dict = locales[this.lang] || locales.en\n const overrides = this._getLabelOverrides()\n return overrides[key] || dict[key] || key\n }\n\n _getLabelOverrides() {\n const map = {\n 'label-title': 'panelTitle',\n 'label-subtitle': 'panelSubtitle',\n 'label-reset': 'reset',\n }\n const overrides = {}\n for (const [attr, key] of Object.entries(map)) {\n const val = this.getAttribute(attr)\n if (val) overrides[key] = val\n }\n return overrides\n }\n\n connectedCallback() {\n this._loadState()\n this._render()\n this._applySettings()\n }\n\n attributeChangedCallback() {\n if (this.shadowRoot.innerHTML) {\n this._render()\n }\n }\n\n _loadState() {\n try {\n const saved = JSON.parse(localStorage.getItem(storageKey))\n if (saved) {\n this._state = { ...defaults, ...saved, open: false }\n }\n } catch {}\n }\n\n _saveState() {\n const { open, ...settings } = this._state\n localStorage.setItem(storageKey, JSON.stringify(settings))\n }\n\n _setState(next) {\n this._state = { ...this._state, ...next }\n this._saveState()\n this._render()\n this._applySettings()\n }\n\n _reset() {\n localStorage.removeItem(storageKey)\n this._state = { ...defaults, open: false }\n this._render()\n this._applySettings()\n }\n\n _applySettings() {\n const root = document.documentElement\n\n root.classList.remove(\n 'va-font-normal', 'va-font-large', 'va-font-xlarge',\n 'va-theme-default', 'va-theme-contrast', 'va-theme-light',\n 'va-readable-font', 'va-letter-spacing',\n )\n\n root.classList.add(`va-font-${this._state.fontSize}`)\n root.classList.add(`va-theme-${this._state.theme}`)\n\n if (this._state.readableFont) root.classList.add('va-readable-font')\n if (this._state.letterSpacing) root.classList.add('va-letter-spacing')\n\n this._ensureGlobalStyles()\n }\n\n _ensureGlobalStyles() {\n if (document.getElementById(styleId)) return\n\n const style = document.createElement('style')\n style.id = styleId\n style.textContent = `\n html.va-font-large { font-size: 112.5%; }\n html.va-font-xlarge { font-size: 125%; }\n\n html.va-readable-font body,\n html.va-readable-font button,\n html.va-readable-font input,\n html.va-readable-font textarea,\n html.va-readable-font select {\n font-family: Arial, Helvetica, sans-serif !important;\n }\n\n html.va-letter-spacing body {\n letter-spacing: 0.04em;\n line-height: 1.7;\n }\n\n html.va-theme-contrast body {\n background: #000 !important;\n color: #fff !important;\n }\n html.va-theme-contrast a {\n color: #ffff00 !important;\n text-decoration: underline !important;\n }\n html.va-theme-contrast button,\n html.va-theme-contrast input,\n html.va-theme-contrast textarea,\n html.va-theme-contrast select {\n background: #000 !important;\n color: #fff !important;\n border-color: #fff !important;\n }\n html.va-theme-contrast img,\n html.va-theme-contrast video,\n html.va-theme-contrast canvas {\n filter: grayscale(1) contrast(1.15);\n }\n\n html.va-theme-light body {\n background: #fff !important;\n color: #000 !important;\n }\n html.va-theme-light a {\n color: #003cff !important;\n text-decoration: underline !important;\n }\n html.va-theme-light button,\n html.va-theme-light input,\n html.va-theme-light textarea,\n html.va-theme-light select {\n background: #fff !important;\n color: #000 !important;\n border-color: #000 !important;\n }\n `\n document.head.appendChild(style)\n }\n\n _render() {\n const s = this._state\n const open = s.open\n\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n position: fixed;\n ${this._getPositionStyles()}\n z-index: 99999;\n font-family: Arial, Helvetica, sans-serif;\n }\n * { box-sizing: border-box; }\n .widget {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 10px;\n }\n .toggle {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n border: 2px solid #111;\n border-radius: 999px;\n padding: 12px 16px;\n background: #fff;\n color: #111;\n font-size: 15px;\n font-weight: 700;\n cursor: pointer;\n box-shadow: 0 10px 30px rgba(0,0,0,.18);\n transition: transform 160ms ease, box-shadow 160ms ease;\n }\n .toggle:hover {\n transform: translateY(-1px);\n box-shadow: 0 14px 34px rgba(0,0,0,.22);\n }\n .toggle:focus-visible,\n .control:focus-visible,\n .reset:focus-visible,\n .close:focus-visible {\n outline: 3px solid #ffcc00;\n outline-offset: 3px;\n }\n .icon { font-size: 20px; line-height: 1; }\n .panel {\n width: min(340px, calc(100vw - 32px));\n padding: 18px;\n border: 2px solid #111;\n border-radius: 18px;\n background: #fff;\n color: #111;\n box-shadow: 0 18px 50px rgba(0,0,0,.25);\n }\n .panel[hidden] { display: none; }\n .header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n margin-bottom: 14px;\n }\n .title {\n margin: 0;\n font-size: 18px;\n line-height: 1.25;\n font-weight: 800;\n }\n .subtitle {\n margin: 4px 0 0;\n font-size: 13px;\n line-height: 1.4;\n color: #555;\n }\n .close {\n width: 32px; height: 32px;\n border: 1px solid #ddd;\n border-radius: 50%;\n background: #f7f7f7;\n cursor: pointer;\n font-size: 20px;\n line-height: 1;\n }\n .group {\n padding-top: 14px;\n margin-top: 14px;\n border-top: 1px solid #e5e5e5;\n }\n .label {\n display: block;\n margin-bottom: 8px;\n font-size: 14px;\n font-weight: 700;\n }\n .controls {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: 8px;\n }\n .controls.two { grid-template-columns: repeat(2, 1fr); }\n .control, .reset {\n min-height: 42px;\n border: 2px solid #d6d6d6;\n border-radius: 12px;\n background: #fafafa;\n color: #111;\n cursor: pointer;\n font-weight: 700;\n transition: border-color 140ms ease, background 140ms ease;\n }\n .control:hover, .reset:hover {\n border-color: #111;\n background: #f0f0f0;\n }\n .control.active {\n border-color: #111;\n background: #111;\n color: #fff;\n }\n .font-a { font-size: 16px; }\n .font-aa { font-size: 20px; }\n .font-aaa { font-size: 24px; }\n .theme-default { background: #fff; color: #111; }\n .theme-contrast { background: #000; color: #fff; border-color: #000; }\n .theme-light { background: #fff; color: #000; border-color: #000; }\n .reset {\n width: 100%;\n margin-top: 14px;\n background: #fff4f4;\n border-color: #f0b4b4;\n color: #8a0000;\n }\n @media (max-width: 520px) {\n :host {\n right: 12px !important;\n bottom: 12px !important;\n }\n .toggle {\n padding: 11px 14px;\n font-size: 14px;\n }\n }\n </style>\n\n <div class=\"widget\">\n <section class=\"panel\" ${open ? '' : 'hidden'} aria-label=\"${this.t('panelTitle')}\">\n <div class=\"header\">\n <div>\n <h2 class=\"title\">${this.t('panelTitle')}</h2>\n <p class=\"subtitle\">${this.t('panelSubtitle')}</p>\n </div>\n <button class=\"close\" type=\"button\" aria-label=\"${this.t('closeLabel')}\">\u00D7</button>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('fontSizeLabel')}</span>\n <div class=\"controls\">\n <button class=\"control font-a ${s.fontSize === 'normal' ? 'active' : ''}\" data-font=\"normal\" type=\"button\">A</button>\n <button class=\"control font-aa ${s.fontSize === 'large' ? 'active' : ''}\" data-font=\"large\" type=\"button\">A</button>\n <button class=\"control font-aaa ${s.fontSize === 'xlarge' ? 'active' : ''}\" data-font=\"xlarge\" type=\"button\">A</button>\n </div>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('themeLabel')}</span>\n <div class=\"controls\">\n <button class=\"control theme-default ${s.theme === 'default' ? 'active' : ''}\" data-theme=\"default\" type=\"button\">A</button>\n <button class=\"control theme-contrast ${s.theme === 'contrast' ? 'active' : ''}\" data-theme=\"contrast\" type=\"button\">A</button>\n <button class=\"control theme-light ${s.theme === 'light' ? 'active' : ''}\" data-theme=\"light\" type=\"button\">A</button>\n </div>\n </div>\n\n <div class=\"group\">\n <span class=\"label\">${this.t('extraLabel')}</span>\n <div class=\"controls two\">\n <button class=\"control ${s.readableFont ? 'active' : ''}\" data-toggle=\"readableFont\" type=\"button\">${this.t('readableFont')}</button>\n <button class=\"control ${s.letterSpacing ? 'active' : ''}\" data-toggle=\"letterSpacing\" type=\"button\">${this.t('letterSpacing')}</button>\n </div>\n </div>\n\n <button class=\"reset\" type=\"button\">${this.t('reset')}</button>\n </section>\n\n <button\n class=\"toggle\"\n type=\"button\"\n aria-expanded=\"${open ? 'true' : 'false'}\"\n aria-label=\"${this.t('toggleLabel')}\"\n >\n <span class=\"icon\" aria-hidden=\"true\">\uD83D\uDC41</span>\n <span>${this.t('toggleText')}</span>\n </button>\n </div>\n `\n\n this.shadowRoot.querySelector('.toggle').addEventListener('click', () => {\n this._setState({ open: !this._state.open })\n })\n this.shadowRoot.querySelector('.close').addEventListener('click', () => {\n this._setState({ open: false })\n })\n this.shadowRoot.querySelectorAll('[data-font]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ fontSize: btn.dataset.font }))\n })\n this.shadowRoot.querySelectorAll('[data-theme]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ theme: btn.dataset.theme }))\n })\n this.shadowRoot.querySelectorAll('[data-toggle]').forEach((btn) => {\n btn.addEventListener('click', () => this._setState({ [btn.dataset.toggle]: !this._state[btn.dataset.toggle] }))\n })\n this.shadowRoot.querySelector('.reset').addEventListener('click', () => this._reset())\n }\n\n _getPositionStyles() {\n const pos = this.getAttribute('position') || 'right-bottom'\n const [h, v] = pos.split('-')\n const styles = {}\n if (h === 'right') styles.right = '20px'\n else styles.left = '20px'\n if (v === 'bottom') styles.bottom = '20px'\n else styles.top = '20px'\n return Object.entries(styles).map(([k, v]) => `${k}: ${v};`).join(' ')\n }\n}\n\nexport { VisionAccessibilityWidget }\nexport default VisionAccessibilityWidget\n\nif (!customElements.get('vision-accessibility-widget')) {\n customElements.define('vision-accessibility-widget', VisionAccessibilityWidget)\n}\n"],
|
|
5
|
+
"mappings": "oKAAO,IAAMA,EAAU,CACrB,GAAI,CACF,WAAY,oIACZ,cAAe,iTACf,WAAY,kFACZ,cAAe,6EACf,WAAY,iEACZ,WAAY,0DACZ,aAAc,4EACd,cAAe,8FACf,MAAO,uHACP,YAAa,iRACb,WAAY,mIACd,EACA,GAAI,CACF,WAAY,uBACZ,cAAe,2DACf,WAAY,cACZ,cAAe,aACf,WAAY,gBACZ,WAAY,cACZ,aAAc,gBACd,cAAe,iBACf,MAAO,eACP,YAAa,qCACb,WAAY,sBACd,EACA,GAAI,CACF,WAAY,mBACZ,cAAe,uEACf,WAAY,eACZ,cAAe,sBACf,WAAY,cACZ,WAAY,iBACZ,aAAc,kBACd,cAAe,oBACf,MAAO,kBACP,YAAa,2CACb,WAAY,kBACd,CACF,EAEO,SAASC,GAAa,CAE3B,IAAMC,GADO,SAAS,gBACC,MAAQ,UAAU,UAAY,MAAM,MAAM,EAAG,CAAC,EAAE,YAAY,EACnF,OAAOA,KAAYF,EAAUE,EAAW,IAC1C,CC5CA,IAAMC,EAAa,uBACbC,EAAU,4BAEVC,EAAW,CACf,SAAU,SACV,MAAO,UACP,cAAe,GACf,aAAc,EAChB,EAEMC,EAAN,cAAwC,WAAY,CAGlD,aAAc,CACZ,MAAM,EACN,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAClC,KAAK,OAAS,CAAE,GAAGD,EAAU,KAAM,EAAM,CAC3C,CAEA,IAAI,MAAO,CACT,OAAO,KAAK,aAAa,MAAM,GAAKE,EAA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AS,CAAC,EAChB,OAAIF,IAAM,QAASE,EAAO,MAAQ,OAC7BA,EAAO,KAAO,OACfD,IAAM,SAAUC,EAAO,OAAS,OAC/BA,EAAO,IAAM,OACX,OAAO,QAAQA,CAAM,EAAE,IAAI,CAAC,CAACC,EAAGF,CAAC,IAAM,GAAGE,CAAC,KAAKF,CAAC,GAAG,EAAE,KAAK,GAAG,CACvE,CACF,EA1XEG,EADItB,EACG,qBAAqB,CAAC,OAAQ,WAAY,cAAe,iBAAkB,aAAa,GA6XjG,IAAOuB,EAAQC,EAEV,eAAe,IAAI,6BAA6B,GACnD,eAAe,OAAO,8BAA+BA,CAAyB",
|
|
6
|
+
"names": ["locales", "detectLang", "htmlLang", "storageKey", "styleId", "defaults", "VisionAccessibilityWidget", "detectLang", "key", "dict", "locales", "map", "overrides", "attr", "val", "saved", "open", "settings", "next", "root", "style", "s", "btn", "pos", "h", "v", "styles", "k", "__publicField", "vision_a11y_default", "VisionAccessibilityWidget"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@m00rl0ck/a11y-widget",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Collection of lightweight accessibility web components for websites",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"a11y",
|
|
8
|
+
"accessibility",
|
|
9
|
+
"web-component",
|
|
10
|
+
"widget",
|
|
11
|
+
"vision",
|
|
12
|
+
"wcag"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/m00rl0ck/a11y-widget#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/m00rl0ck/a11y-widget/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Oleksandr Vasyliev <m00rl0ck@proton.me> (https://github.com/m00rl0ck)",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./vision-a11y": "./dist/vision-a11y.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node build.js",
|
|
35
|
+
"prepublishOnly": "npm run build",
|
|
36
|
+
"dev": "node build.js --watch"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"esbuild": "^0.25.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VisionAccessibilityWidget, default as VisionA11y } from './vision-a11y/index.js'
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { locales, detectLang } from './locales.js'
|
|
2
|
+
|
|
3
|
+
const storageKey = 'vision-a11y-settings'
|
|
4
|
+
const styleId = 'vision-a11y-global-styles'
|
|
5
|
+
|
|
6
|
+
const defaults = {
|
|
7
|
+
fontSize: 'normal',
|
|
8
|
+
theme: 'default',
|
|
9
|
+
letterSpacing: false,
|
|
10
|
+
readableFont: false,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class VisionAccessibilityWidget extends HTMLElement {
|
|
14
|
+
static observedAttributes = ['lang', 'position', 'label-title', 'label-subtitle', 'label-reset']
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super()
|
|
18
|
+
this.attachShadow({ mode: 'open' })
|
|
19
|
+
this._state = { ...defaults, open: false }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get lang() {
|
|
23
|
+
return this.getAttribute('lang') || detectLang()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
t(key) {
|
|
27
|
+
const dict = locales[this.lang] || locales.en
|
|
28
|
+
const overrides = this._getLabelOverrides()
|
|
29
|
+
return overrides[key] || dict[key] || key
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_getLabelOverrides() {
|
|
33
|
+
const map = {
|
|
34
|
+
'label-title': 'panelTitle',
|
|
35
|
+
'label-subtitle': 'panelSubtitle',
|
|
36
|
+
'label-reset': 'reset',
|
|
37
|
+
}
|
|
38
|
+
const overrides = {}
|
|
39
|
+
for (const [attr, key] of Object.entries(map)) {
|
|
40
|
+
const val = this.getAttribute(attr)
|
|
41
|
+
if (val) overrides[key] = val
|
|
42
|
+
}
|
|
43
|
+
return overrides
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this._loadState()
|
|
48
|
+
this._render()
|
|
49
|
+
this._applySettings()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
attributeChangedCallback() {
|
|
53
|
+
if (this.shadowRoot.innerHTML) {
|
|
54
|
+
this._render()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_loadState() {
|
|
59
|
+
try {
|
|
60
|
+
const saved = JSON.parse(localStorage.getItem(storageKey))
|
|
61
|
+
if (saved) {
|
|
62
|
+
this._state = { ...defaults, ...saved, open: false }
|
|
63
|
+
}
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_saveState() {
|
|
68
|
+
const { open, ...settings } = this._state
|
|
69
|
+
localStorage.setItem(storageKey, JSON.stringify(settings))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_setState(next) {
|
|
73
|
+
this._state = { ...this._state, ...next }
|
|
74
|
+
this._saveState()
|
|
75
|
+
this._render()
|
|
76
|
+
this._applySettings()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_reset() {
|
|
80
|
+
localStorage.removeItem(storageKey)
|
|
81
|
+
this._state = { ...defaults, open: false }
|
|
82
|
+
this._render()
|
|
83
|
+
this._applySettings()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_applySettings() {
|
|
87
|
+
const root = document.documentElement
|
|
88
|
+
|
|
89
|
+
root.classList.remove(
|
|
90
|
+
'va-font-normal', 'va-font-large', 'va-font-xlarge',
|
|
91
|
+
'va-theme-default', 'va-theme-contrast', 'va-theme-light',
|
|
92
|
+
'va-readable-font', 'va-letter-spacing',
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
root.classList.add(`va-font-${this._state.fontSize}`)
|
|
96
|
+
root.classList.add(`va-theme-${this._state.theme}`)
|
|
97
|
+
|
|
98
|
+
if (this._state.readableFont) root.classList.add('va-readable-font')
|
|
99
|
+
if (this._state.letterSpacing) root.classList.add('va-letter-spacing')
|
|
100
|
+
|
|
101
|
+
this._ensureGlobalStyles()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
_ensureGlobalStyles() {
|
|
105
|
+
if (document.getElementById(styleId)) return
|
|
106
|
+
|
|
107
|
+
const style = document.createElement('style')
|
|
108
|
+
style.id = styleId
|
|
109
|
+
style.textContent = `
|
|
110
|
+
html.va-font-large { font-size: 112.5%; }
|
|
111
|
+
html.va-font-xlarge { font-size: 125%; }
|
|
112
|
+
|
|
113
|
+
html.va-readable-font body,
|
|
114
|
+
html.va-readable-font button,
|
|
115
|
+
html.va-readable-font input,
|
|
116
|
+
html.va-readable-font textarea,
|
|
117
|
+
html.va-readable-font select {
|
|
118
|
+
font-family: Arial, Helvetica, sans-serif !important;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
html.va-letter-spacing body {
|
|
122
|
+
letter-spacing: 0.04em;
|
|
123
|
+
line-height: 1.7;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
html.va-theme-contrast body {
|
|
127
|
+
background: #000 !important;
|
|
128
|
+
color: #fff !important;
|
|
129
|
+
}
|
|
130
|
+
html.va-theme-contrast a {
|
|
131
|
+
color: #ffff00 !important;
|
|
132
|
+
text-decoration: underline !important;
|
|
133
|
+
}
|
|
134
|
+
html.va-theme-contrast button,
|
|
135
|
+
html.va-theme-contrast input,
|
|
136
|
+
html.va-theme-contrast textarea,
|
|
137
|
+
html.va-theme-contrast select {
|
|
138
|
+
background: #000 !important;
|
|
139
|
+
color: #fff !important;
|
|
140
|
+
border-color: #fff !important;
|
|
141
|
+
}
|
|
142
|
+
html.va-theme-contrast img,
|
|
143
|
+
html.va-theme-contrast video,
|
|
144
|
+
html.va-theme-contrast canvas {
|
|
145
|
+
filter: grayscale(1) contrast(1.15);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
html.va-theme-light body {
|
|
149
|
+
background: #fff !important;
|
|
150
|
+
color: #000 !important;
|
|
151
|
+
}
|
|
152
|
+
html.va-theme-light a {
|
|
153
|
+
color: #003cff !important;
|
|
154
|
+
text-decoration: underline !important;
|
|
155
|
+
}
|
|
156
|
+
html.va-theme-light button,
|
|
157
|
+
html.va-theme-light input,
|
|
158
|
+
html.va-theme-light textarea,
|
|
159
|
+
html.va-theme-light select {
|
|
160
|
+
background: #fff !important;
|
|
161
|
+
color: #000 !important;
|
|
162
|
+
border-color: #000 !important;
|
|
163
|
+
}
|
|
164
|
+
`
|
|
165
|
+
document.head.appendChild(style)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_render() {
|
|
169
|
+
const s = this._state
|
|
170
|
+
const open = s.open
|
|
171
|
+
|
|
172
|
+
this.shadowRoot.innerHTML = `
|
|
173
|
+
<style>
|
|
174
|
+
:host {
|
|
175
|
+
position: fixed;
|
|
176
|
+
${this._getPositionStyles()}
|
|
177
|
+
z-index: 99999;
|
|
178
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
179
|
+
}
|
|
180
|
+
* { box-sizing: border-box; }
|
|
181
|
+
.widget {
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
align-items: flex-end;
|
|
185
|
+
gap: 10px;
|
|
186
|
+
}
|
|
187
|
+
.toggle {
|
|
188
|
+
display: inline-flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
gap: 8px;
|
|
191
|
+
border: 2px solid #111;
|
|
192
|
+
border-radius: 999px;
|
|
193
|
+
padding: 12px 16px;
|
|
194
|
+
background: #fff;
|
|
195
|
+
color: #111;
|
|
196
|
+
font-size: 15px;
|
|
197
|
+
font-weight: 700;
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
box-shadow: 0 10px 30px rgba(0,0,0,.18);
|
|
200
|
+
transition: transform 160ms ease, box-shadow 160ms ease;
|
|
201
|
+
}
|
|
202
|
+
.toggle:hover {
|
|
203
|
+
transform: translateY(-1px);
|
|
204
|
+
box-shadow: 0 14px 34px rgba(0,0,0,.22);
|
|
205
|
+
}
|
|
206
|
+
.toggle:focus-visible,
|
|
207
|
+
.control:focus-visible,
|
|
208
|
+
.reset:focus-visible,
|
|
209
|
+
.close:focus-visible {
|
|
210
|
+
outline: 3px solid #ffcc00;
|
|
211
|
+
outline-offset: 3px;
|
|
212
|
+
}
|
|
213
|
+
.icon { font-size: 20px; line-height: 1; }
|
|
214
|
+
.panel {
|
|
215
|
+
width: min(340px, calc(100vw - 32px));
|
|
216
|
+
padding: 18px;
|
|
217
|
+
border: 2px solid #111;
|
|
218
|
+
border-radius: 18px;
|
|
219
|
+
background: #fff;
|
|
220
|
+
color: #111;
|
|
221
|
+
box-shadow: 0 18px 50px rgba(0,0,0,.25);
|
|
222
|
+
}
|
|
223
|
+
.panel[hidden] { display: none; }
|
|
224
|
+
.header {
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: flex-start;
|
|
227
|
+
justify-content: space-between;
|
|
228
|
+
gap: 12px;
|
|
229
|
+
margin-bottom: 14px;
|
|
230
|
+
}
|
|
231
|
+
.title {
|
|
232
|
+
margin: 0;
|
|
233
|
+
font-size: 18px;
|
|
234
|
+
line-height: 1.25;
|
|
235
|
+
font-weight: 800;
|
|
236
|
+
}
|
|
237
|
+
.subtitle {
|
|
238
|
+
margin: 4px 0 0;
|
|
239
|
+
font-size: 13px;
|
|
240
|
+
line-height: 1.4;
|
|
241
|
+
color: #555;
|
|
242
|
+
}
|
|
243
|
+
.close {
|
|
244
|
+
width: 32px; height: 32px;
|
|
245
|
+
border: 1px solid #ddd;
|
|
246
|
+
border-radius: 50%;
|
|
247
|
+
background: #f7f7f7;
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
font-size: 20px;
|
|
250
|
+
line-height: 1;
|
|
251
|
+
}
|
|
252
|
+
.group {
|
|
253
|
+
padding-top: 14px;
|
|
254
|
+
margin-top: 14px;
|
|
255
|
+
border-top: 1px solid #e5e5e5;
|
|
256
|
+
}
|
|
257
|
+
.label {
|
|
258
|
+
display: block;
|
|
259
|
+
margin-bottom: 8px;
|
|
260
|
+
font-size: 14px;
|
|
261
|
+
font-weight: 700;
|
|
262
|
+
}
|
|
263
|
+
.controls {
|
|
264
|
+
display: grid;
|
|
265
|
+
grid-template-columns: repeat(3, 1fr);
|
|
266
|
+
gap: 8px;
|
|
267
|
+
}
|
|
268
|
+
.controls.two { grid-template-columns: repeat(2, 1fr); }
|
|
269
|
+
.control, .reset {
|
|
270
|
+
min-height: 42px;
|
|
271
|
+
border: 2px solid #d6d6d6;
|
|
272
|
+
border-radius: 12px;
|
|
273
|
+
background: #fafafa;
|
|
274
|
+
color: #111;
|
|
275
|
+
cursor: pointer;
|
|
276
|
+
font-weight: 700;
|
|
277
|
+
transition: border-color 140ms ease, background 140ms ease;
|
|
278
|
+
}
|
|
279
|
+
.control:hover, .reset:hover {
|
|
280
|
+
border-color: #111;
|
|
281
|
+
background: #f0f0f0;
|
|
282
|
+
}
|
|
283
|
+
.control.active {
|
|
284
|
+
border-color: #111;
|
|
285
|
+
background: #111;
|
|
286
|
+
color: #fff;
|
|
287
|
+
}
|
|
288
|
+
.font-a { font-size: 16px; }
|
|
289
|
+
.font-aa { font-size: 20px; }
|
|
290
|
+
.font-aaa { font-size: 24px; }
|
|
291
|
+
.theme-default { background: #fff; color: #111; }
|
|
292
|
+
.theme-contrast { background: #000; color: #fff; border-color: #000; }
|
|
293
|
+
.theme-light { background: #fff; color: #000; border-color: #000; }
|
|
294
|
+
.reset {
|
|
295
|
+
width: 100%;
|
|
296
|
+
margin-top: 14px;
|
|
297
|
+
background: #fff4f4;
|
|
298
|
+
border-color: #f0b4b4;
|
|
299
|
+
color: #8a0000;
|
|
300
|
+
}
|
|
301
|
+
@media (max-width: 520px) {
|
|
302
|
+
:host {
|
|
303
|
+
right: 12px !important;
|
|
304
|
+
bottom: 12px !important;
|
|
305
|
+
}
|
|
306
|
+
.toggle {
|
|
307
|
+
padding: 11px 14px;
|
|
308
|
+
font-size: 14px;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
</style>
|
|
312
|
+
|
|
313
|
+
<div class="widget">
|
|
314
|
+
<section class="panel" ${open ? '' : 'hidden'} aria-label="${this.t('panelTitle')}">
|
|
315
|
+
<div class="header">
|
|
316
|
+
<div>
|
|
317
|
+
<h2 class="title">${this.t('panelTitle')}</h2>
|
|
318
|
+
<p class="subtitle">${this.t('panelSubtitle')}</p>
|
|
319
|
+
</div>
|
|
320
|
+
<button class="close" type="button" aria-label="${this.t('closeLabel')}">×</button>
|
|
321
|
+
</div>
|
|
322
|
+
|
|
323
|
+
<div class="group">
|
|
324
|
+
<span class="label">${this.t('fontSizeLabel')}</span>
|
|
325
|
+
<div class="controls">
|
|
326
|
+
<button class="control font-a ${s.fontSize === 'normal' ? 'active' : ''}" data-font="normal" type="button">A</button>
|
|
327
|
+
<button class="control font-aa ${s.fontSize === 'large' ? 'active' : ''}" data-font="large" type="button">A</button>
|
|
328
|
+
<button class="control font-aaa ${s.fontSize === 'xlarge' ? 'active' : ''}" data-font="xlarge" type="button">A</button>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<div class="group">
|
|
333
|
+
<span class="label">${this.t('themeLabel')}</span>
|
|
334
|
+
<div class="controls">
|
|
335
|
+
<button class="control theme-default ${s.theme === 'default' ? 'active' : ''}" data-theme="default" type="button">A</button>
|
|
336
|
+
<button class="control theme-contrast ${s.theme === 'contrast' ? 'active' : ''}" data-theme="contrast" type="button">A</button>
|
|
337
|
+
<button class="control theme-light ${s.theme === 'light' ? 'active' : ''}" data-theme="light" type="button">A</button>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
<div class="group">
|
|
342
|
+
<span class="label">${this.t('extraLabel')}</span>
|
|
343
|
+
<div class="controls two">
|
|
344
|
+
<button class="control ${s.readableFont ? 'active' : ''}" data-toggle="readableFont" type="button">${this.t('readableFont')}</button>
|
|
345
|
+
<button class="control ${s.letterSpacing ? 'active' : ''}" data-toggle="letterSpacing" type="button">${this.t('letterSpacing')}</button>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<button class="reset" type="button">${this.t('reset')}</button>
|
|
350
|
+
</section>
|
|
351
|
+
|
|
352
|
+
<button
|
|
353
|
+
class="toggle"
|
|
354
|
+
type="button"
|
|
355
|
+
aria-expanded="${open ? 'true' : 'false'}"
|
|
356
|
+
aria-label="${this.t('toggleLabel')}"
|
|
357
|
+
>
|
|
358
|
+
<span class="icon" aria-hidden="true">👁</span>
|
|
359
|
+
<span>${this.t('toggleText')}</span>
|
|
360
|
+
</button>
|
|
361
|
+
</div>
|
|
362
|
+
`
|
|
363
|
+
|
|
364
|
+
this.shadowRoot.querySelector('.toggle').addEventListener('click', () => {
|
|
365
|
+
this._setState({ open: !this._state.open })
|
|
366
|
+
})
|
|
367
|
+
this.shadowRoot.querySelector('.close').addEventListener('click', () => {
|
|
368
|
+
this._setState({ open: false })
|
|
369
|
+
})
|
|
370
|
+
this.shadowRoot.querySelectorAll('[data-font]').forEach((btn) => {
|
|
371
|
+
btn.addEventListener('click', () => this._setState({ fontSize: btn.dataset.font }))
|
|
372
|
+
})
|
|
373
|
+
this.shadowRoot.querySelectorAll('[data-theme]').forEach((btn) => {
|
|
374
|
+
btn.addEventListener('click', () => this._setState({ theme: btn.dataset.theme }))
|
|
375
|
+
})
|
|
376
|
+
this.shadowRoot.querySelectorAll('[data-toggle]').forEach((btn) => {
|
|
377
|
+
btn.addEventListener('click', () => this._setState({ [btn.dataset.toggle]: !this._state[btn.dataset.toggle] }))
|
|
378
|
+
})
|
|
379
|
+
this.shadowRoot.querySelector('.reset').addEventListener('click', () => this._reset())
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
_getPositionStyles() {
|
|
383
|
+
const pos = this.getAttribute('position') || 'right-bottom'
|
|
384
|
+
const [h, v] = pos.split('-')
|
|
385
|
+
const styles = {}
|
|
386
|
+
if (h === 'right') styles.right = '20px'
|
|
387
|
+
else styles.left = '20px'
|
|
388
|
+
if (v === 'bottom') styles.bottom = '20px'
|
|
389
|
+
else styles.top = '20px'
|
|
390
|
+
return Object.entries(styles).map(([k, v]) => `${k}: ${v};`).join(' ')
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export { VisionAccessibilityWidget }
|
|
395
|
+
export default VisionAccessibilityWidget
|
|
396
|
+
|
|
397
|
+
if (!customElements.get('vision-accessibility-widget')) {
|
|
398
|
+
customElements.define('vision-accessibility-widget', VisionAccessibilityWidget)
|
|
399
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const locales = {
|
|
2
|
+
uk: {
|
|
3
|
+
panelTitle: 'Людям із порушенням зору',
|
|
4
|
+
panelSubtitle: 'Налаштуйте розмір тексту, контраст і читабельність сайту.',
|
|
5
|
+
closeLabel: 'Закрити панель',
|
|
6
|
+
fontSizeLabel: 'Розмір шрифту:',
|
|
7
|
+
themeLabel: 'Колір сайту:',
|
|
8
|
+
extraLabel: 'Додатково:',
|
|
9
|
+
readableFont: 'Простий шрифт',
|
|
10
|
+
letterSpacing: 'Більші інтервали',
|
|
11
|
+
reset: 'Звичайна версія сайту',
|
|
12
|
+
toggleLabel: 'Відкрити налаштування для людей із порушенням зору',
|
|
13
|
+
toggleText: 'Людям із порушенням зору',
|
|
14
|
+
},
|
|
15
|
+
en: {
|
|
16
|
+
panelTitle: 'Vision Accessibility',
|
|
17
|
+
panelSubtitle: 'Adjust text size, contrast, and readability of the site.',
|
|
18
|
+
closeLabel: 'Close panel',
|
|
19
|
+
fontSizeLabel: 'Font size:',
|
|
20
|
+
themeLabel: 'Color scheme:',
|
|
21
|
+
extraLabel: 'Additional:',
|
|
22
|
+
readableFont: 'Readable font',
|
|
23
|
+
letterSpacing: 'Letter spacing',
|
|
24
|
+
reset: 'Default view',
|
|
25
|
+
toggleLabel: 'Open vision accessibility settings',
|
|
26
|
+
toggleText: 'Vision accessibility',
|
|
27
|
+
},
|
|
28
|
+
de: {
|
|
29
|
+
panelTitle: 'Barrierefreiheit',
|
|
30
|
+
panelSubtitle: 'Passen Sie Schriftgröße, Kontrast und Lesbarkeit der Seite an.',
|
|
31
|
+
closeLabel: 'Schließen',
|
|
32
|
+
fontSizeLabel: 'Schriftgröße:',
|
|
33
|
+
themeLabel: 'Farbschema:',
|
|
34
|
+
extraLabel: 'Zusätzlich:',
|
|
35
|
+
readableFont: 'Lesbare Schrift',
|
|
36
|
+
letterSpacing: 'Buchstabenabstand',
|
|
37
|
+
reset: 'Standardansicht',
|
|
38
|
+
toggleLabel: 'Barrierefreiheit-Einstellungen öffnen',
|
|
39
|
+
toggleText: 'Barrierefreiheit',
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function detectLang() {
|
|
44
|
+
const html = document.documentElement
|
|
45
|
+
const htmlLang = (html.lang || navigator.language || 'en').slice(0, 2).toLowerCase()
|
|
46
|
+
return htmlLang in locales ? htmlLang : 'en'
|
|
47
|
+
}
|