Repository navigation
Expand file tree
/
Copy pathpopup.html
More file actions
218 lines (197 loc) · 6.4 KB
/
Copy pathpopup.html
File metadata and controls
218 lines (197 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Feham</title>
<style>
@font-face {
font-family: 'Feham Nastaliq';
src: url('fonts/NotoNastaliqUrdu.woff2') format('woff2');
font-display: swap;
}
@font-face {
font-family: 'Feham Naskh';
src: url('fonts/NotoNaskhArabic.woff2') format('woff2');
font-display: swap;
}
/* Pakistan flag green, kept as tokens so there's one place to retune it. */
:root {
--green: #01411c;
--green-mid: #046a38;
--tint: #e8f5ec;
--line: #cfe3d6;
--ink: #1e293b;
--muted: #64748b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 290px;
font: 13px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: var(--ink);
background: #ffffff;
}
.header {
text-align: center;
padding: 10px 20px 16px;
background: var(--green);
color: #fff;
}
/* Nastaliq glyphs sit well above and below the em box, so this needs a
generous line-height or the title gets clipped by the top of the popup. */
.header h1 {
font-family: 'Feham Nastaliq', serif;
font-size: 30px;
font-weight: 400;
line-height: 2.6;
direction: rtl;
}
.header p { font-size: 11px; color: #b9dcc6; }
.content { padding: 16px; display: grid; gap: 10px; }
.row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 12px 14px;
border: 1px solid var(--line);
border-radius: 10px;
}
.row .label { font-weight: 600; }
.row .hint { display: block; font-weight: 400; font-size: 11px; color: var(--muted); margin-top: 2px; }
.switch {
position: relative;
flex: 0 0 auto;
width: 44px;
height: 24px;
border: 0;
border-radius: 12px;
background: #cbd5e1;
cursor: pointer;
transition: background .2s ease;
}
.switch[aria-checked="true"] { background: var(--green-mid); }
.switch::after {
content: '';
position: absolute;
top: 3px;
left: 3px;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
box-shadow: 0 1px 3px rgba(0,0,0,.3);
transition: transform .2s ease;
}
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
/* Font picker */
.picker { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.picker > .label { font-weight: 600; display: block; margin-bottom: 10px; }
.fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.font-opt {
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
padding: 10px 6px 8px;
cursor: pointer;
text-align: center;
transition: border-color .15s ease, background .15s ease;
}
.font-opt:hover { border-color: var(--green-mid); }
.font-opt[aria-checked="true"] {
border-color: var(--green);
background: var(--tint);
box-shadow: inset 0 0 0 1px var(--green);
}
.font-opt:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
/* The preview word is the whole point of the picker — show each face
rendering real Urdu rather than just naming it. */
.font-opt .sample {
display: block;
direction: rtl;
color: var(--green);
font-size: 21px;
margin-bottom: 4px;
}
.font-opt .sample.nastaliq { font-family: 'Feham Nastaliq', serif; line-height: 2.1; }
.font-opt .sample.naskh { font-family: 'Feham Naskh', serif; line-height: 1.7; }
.font-opt .name { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.font-opt[aria-checked="true"] .name { color: var(--green-mid); font-weight: 600; }
.keys {
background: #f7faf8;
border: 1px solid var(--line);
border-radius: 10px;
padding: 12px 14px;
font-size: 11px;
color: #475569;
display: grid;
gap: 5px;
}
.keys div { display: flex; justify-content: space-between; gap: 10px; }
kbd {
font: 600 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
background: #fff;
border: 1px solid var(--line);
border-bottom-width: 2px;
border-radius: 4px;
padding: 1px 5px;
}
.footer { padding: 0 16px 16px; }
.link {
display: block;
width: 100%;
padding: 8px;
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
font: inherit;
font-size: 11px;
color: var(--muted);
cursor: pointer;
}
.link:hover { background: var(--tint); color: var(--green); }
</style>
</head>
<body>
<div class="header">
<h1>فہم</h1>
<p>Hover-to-read Urdu</p>
</div>
<div class="content">
<div class="row">
<span class="label">Enabled
<span class="hint">Works on the pages you already have open</span>
</span>
<button class="switch" id="enabled" role="switch" aria-checked="true" aria-label="Enable Feham"></button>
</div>
<div class="row">
<span class="label">Hold <kbd>Shift</kbd> to look up
<span class="hint">Stops tooltips appearing as you read</span>
</span>
<button class="switch" id="requireShift" role="switch" aria-checked="false" aria-label="Require Shift key"></button>
</div>
<div class="picker">
<span class="label">Urdu font</span>
<div class="fonts" role="radiogroup" aria-label="Urdu font">
<button class="font-opt" role="radio" data-font="nastaliq" aria-checked="true">
<span class="sample nastaliq">محبت</span>
<span class="name">Nastaliq</span>
</button>
<button class="font-opt" role="radio" data-font="naskh" aria-checked="false">
<span class="sample naskh">محبت</span>
<span class="name">Naskh</span>
</button>
</div>
</div>
<div class="keys">
<div><span>Copy the Urdu word</span> <kbd>C</kbd></div>
<div><span>Full dictionary entry</span> <kbd>K</kbd></div>
<div><span>Dismiss</span> <kbd>Esc</kbd></div>
</div>
</div>
<div class="footer">
<button class="link" id="clearCache">Clear cached translations</button>
</div>
<script src="popup.js"></script>
</body>
</html>