Skip to content

Commit 8c5acff

Browse files
committed
More icons
1 parent a707393 commit 8c5acff

File tree

5 files changed

+83
-28
lines changed

5 files changed

+83
-28
lines changed
Lines changed: 3 additions & 0 deletions
Loading

src/main/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const App: Preact.FunctionComponent = () => {
2626
const showSelector = extensions.length === 0 || selector;
2727

2828
useEffect(() => {
29-
wrappedWorker.loadExtension("/test/extension.xpi").then((data) => setExtensions([data]));
29+
wrappedWorker.loadExtension("/test/extension3.xpi").then((data) => setExtensions([data]));
3030
}, []);
3131

3232
return (

src/main/ui/common/DonutChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DonutChart: FunctionComponent<ChartProps> = ({ data }) => {
1818
let offset = 0;
1919

2020
return (
21-
<svg viewBox="0 0 100 100" aria-hidden="true">
21+
<svg class="donut-chart" viewBox="0 0 100 100" aria-hidden="true">
2222
{data.map((dp, i) => {
2323
const size = Math.ceil(circumference * dp.amount / total);
2424
const angle = Math.round((360 * offset) - 90);

src/main/ui/tiles/TranslationsTile.tsx

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,48 @@ import type { ExtensionData } from "../../../extension/types/ExtensionData";
33
import Tile from "./Tile";
44
import TranslationsViewer from "../translations/TranslationsViewer";
55
import type { PopupWindowOptions } from "../popups/PopupWindow";
6+
import DonutChart from "../common/DonutChart";
67

78
const TranslationsTile: FunctionComponent<ExtensionData["translations"]> = (meta) => {
89
const { locales, messages, defaultLocale, percentage } = meta;
10+
const donutData =
11+
percentage === undefined
12+
? []
13+
: [
14+
{ amount: percentage, color: `hsl(${Math.round(10 + 65 * percentage)} 90% 48%)` },
15+
{ amount: 1 - percentage, color: "rgb(128, 128, 128)" }
16+
];
917

1018
return (
1119
<Tile title="Translations" cssClass="translations" popup={(id) => createPopupOptions(id, meta)}>
1220
{locales.length === 0 ? (
13-
<span>no translations</span>
21+
<span class="none">no translations</span>
1422
) : (
15-
<table>
16-
<tbody>
17-
<tr>
18-
<td class="count">{locales.length}</td>
19-
<td>Locales</td>
20-
</tr>
21-
<tr>
22-
<td class="count">{messages}</td>
23-
<td>Strings</td>
24-
</tr>
25-
<tr>
26-
<td title="Default locale">{defaultLocale ?? "-"}</td>
27-
<td>Default</td>
28-
</tr>
29-
{percentage !== undefined ? (
23+
<div>
24+
{percentage === 1 ? <span class="full" /> : <DonutChart data={donutData} />}
25+
<table>
26+
<tbody>
3027
<tr>
31-
<td class="count">{Math.floor(100 * percentage)}%</td>
32-
<td>translated</td>
28+
<td class="count">{locales.length}</td>
29+
<td>Locales</td>
3330
</tr>
34-
) : null}
35-
</tbody>
36-
</table>
31+
<tr>
32+
<td class="count">{messages}</td>
33+
<td>Strings</td>
34+
</tr>
35+
<tr>
36+
<td title="Default locale">{defaultLocale ?? "-"}</td>
37+
<td>Default</td>
38+
</tr>
39+
{percentage !== undefined ? (
40+
<tr>
41+
<td class="count">{Math.floor(100 * percentage)}%</td>
42+
<td>translated</td>
43+
</tr>
44+
) : null}
45+
</tbody>
46+
</table>
47+
</div>
3748
)}
3849
</Tile>
3950
);

src/main/ui/tiles/tiles.css

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
}
9090
}
9191

92+
.donut-chart {
93+
aspect-ratio: 1;
94+
width: 64px;
95+
}
96+
9297
&.meta > .content {
9398
flex-direction: row;
9499
justify-content: space-around;
@@ -147,11 +152,6 @@
147152
flex-direction: column;
148153
}
149154

150-
svg {
151-
aspect-ratio: 1;
152-
width: 64px;
153-
}
154-
155155
table {
156156
font-size: 0.9em;
157157
margin-bottom: 0.5em;
@@ -183,6 +183,47 @@
183183
border-radius: 8px;
184184
border: 1px solid rgba(255, 255, 255, 0.25);
185185
margin-left: 0.2em;
186+
187+
tr.none & {
188+
display: none;
189+
}
190+
}
191+
}
192+
193+
&.translations {
194+
& > .content > div {
195+
display: flex;
196+
flex-direction: row;
197+
gap: var(--base-offset);
198+
}
199+
200+
span.none,
201+
span.full {
202+
line-height: 2rem;
203+
204+
&::before {
205+
content: " ";
206+
display: inline-block;
207+
vertical-align: middle;
208+
background-size: cover;
209+
width: 2rem;
210+
height: 2rem;
211+
margin-right: var(--base-offset);
212+
}
213+
}
214+
215+
span.none::before {
216+
background-image: url("../../../assets/bootstrap-icons/x-circle-fill.svg");
217+
218+
/* Make it red-ish (gray -> add color -> change color -> increase saturation */
219+
filter: invert(0.5) sepia(1) hue-rotate(320deg) saturate(6);
220+
}
221+
222+
span.full::before {
223+
background-image: url("../../../assets/bootstrap-icons/check-circle-fill.svg");
224+
225+
/* Make it green-ish */
226+
filter: invert(0.5) sepia(1) hue-rotate(39deg) saturate(10);
186227
}
187228
}
188229

0 commit comments

Comments
 (0)