Skip to content

Commit

Permalink
Migrate icons into separate file in order to lazy load them
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Tinland committed Aug 5, 2024
1 parent 8571abf commit a1eb609
Show file tree
Hide file tree
Showing 241 changed files with 3,347 additions and 1,716 deletions.
2 changes: 1 addition & 1 deletion lib/app-icons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Icons from "./components/icons.jsx";
import * as Icons from "./components/icons/icons.jsx";

export const apps = {
"1Password 7": Icons.OnePassword,
Expand Down
13 changes: 10 additions & 3 deletions lib/components/data/battery.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import { SuspenseIcon } from "../icons/icon.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down Expand Up @@ -94,7 +95,11 @@ export const Widget = React.memo(() => {
const Icon = () => (
<div className="battery__icon">
<div className="battery__icon-inner">
{charging && <Icons.Charging className="battery__charging-icon" />}
{charging && (
<SuspenseIcon>
<Icons.Charging className="battery__charging-icon" />
</SuspenseIcon>
)}
<div
className="battery__icon-filler"
style={{ transform: transformValue }}
Expand All @@ -111,7 +116,9 @@ export const Widget = React.memo(() => {
{...onClickProp}
>
{caffeinate.length > 0 && (
<Icons.Coffee className="battery__caffeinate-icon" />
<SuspenseIcon>
<Icons.Coffee className="battery__caffeinate-icon" />
</SuspenseIcon>
)}
{percentage}%
</DataWidget.Widget>
Expand Down
9 changes: 6 additions & 3 deletions lib/components/data/browser-track.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import { SuspenseIcon } from "../icons/icon.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down Expand Up @@ -86,8 +87,10 @@ export const Widget = React.memo(() => {
const BrowserIcon = getIcon(browser);
return (
<div className="browser-track__icons">
<BrowserIcon />
<Icons.Playing />
<SuspenseIcon>
<BrowserIcon />
<Icons.Playing />
</SuspenseIcon>
</div>
);
};
Expand Down
8 changes: 4 additions & 4 deletions lib/components/data/cpu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import Graph from "./graph.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down Expand Up @@ -47,10 +47,10 @@ export const Widget = React.memo(() => {
const usage = await Uebersicht.run(
`top -l 1 | grep -E "^CPU" | grep -Eo '[^[:space:]]+%' | head -1 | sed s/%//`
);
const formatedUsage = { usage: parseInt(usage, 10).toFixed(0) };
setState(formatedUsage);
const formattedUsage = { usage: parseInt(usage, 10).toFixed(0) };
setState(formattedUsage);
if (displayAsGraph) {
Utils.addToGraphHistory(formatedUsage, setGraph, GRAPH_LENGTH);
Utils.addToGraphHistory(formattedUsage, setGraph, GRAPH_LENGTH);
}
setLoading(false);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/crypto.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
8 changes: 6 additions & 2 deletions lib/components/data/data-widget.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as Specter from "./specter.jsx";
import * as Utils from "../../utils";

import { SuspenseIcon } from "../icons/icon.jsx";
export { dataWidgetStyles as styles } from "../../styles/components/data/data-widget";

const { React } = Uebersicht;
Expand Down Expand Up @@ -53,7 +53,11 @@ export function Widget({
onMouseLeave={!disableSlider ? onMouseLeave : undefined}
style={style}
>
{Icon && <Icon />}
{Icon && (
<SuspenseIcon>
<Icon />
</SuspenseIcon>
)}
{showSpecter && <Specter.Widget />}
<Inner disableSlider={disableSlider}>{children}</Inner>
</Tag>
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/date-display.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import * as Utils from "../../utils";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
Expand Down
15 changes: 10 additions & 5 deletions lib/components/data/graph.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import * as Uebersicht from "uebersicht";
import * as Utils from "../../utils.js";
import { SuspenseIcon } from "../icons/icon.jsx";

const { React } = Uebersicht;

export { graphStyles as styles } from "../../styles/components/data/graph";

Expand Down Expand Up @@ -46,14 +50,15 @@ export default function Graph({
<div className="graph__data">
{captionKeys.map((key) => {
const { value, icon: Icon, color } = caption[key];

return (
<div key={key} className="graph__data-item">
{Icon && (
<Icon
className="graph__data-item-icon"
style={{ fill: color }}
/>
<SuspenseIcon>
<Icon
className="graph__data-item-icon"
style={{ fill: color }}
/>
</SuspenseIcon>
)}
<span
className="graph__data-item-value"
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/keyboard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
7 changes: 5 additions & 2 deletions lib/components/data/mic.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import { SuspenseIcon } from "../icons/icon.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import * as Utils from "../../utils";
Expand Down Expand Up @@ -87,7 +88,9 @@ export const Widget = React.memo(() => {
return (
<DataWidget.Widget classes={classes} disableSlider>
<div className="mic__display">
<Icon />
<SuspenseIcon>
<Icon />
</SuspenseIcon>
<span className="mic__value">{formattedVolume}</span>
</div>
<div className="mic__slider-container">
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/mpd.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/music.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
14 changes: 7 additions & 7 deletions lib/components/data/netstats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Graph from "./graph.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh.js";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import * as Utils from "../../utils.js";

export { netstatsStyles as styles } from "../../styles/components/data/netstats";
Expand Down Expand Up @@ -89,8 +89,8 @@ export const Widget = React.memo(() => {
return null;
}

const formatedDownload = formatBytes(download);
const formatedUpload = formatBytes(upload);
const formattedDownload = formatBytes(download);
const formattedUpload = formatBytes(upload);

if (displayAsGraph) {
return (
Expand All @@ -99,12 +99,12 @@ export const Widget = React.memo(() => {
className="netstats__graph"
caption={{
download: {
value: formatedDownload,
value: formattedDownload,
icon: Icons.Download,
color: "var(--magenta)",
},
upload: {
value: formatedUpload,
value: formattedUpload,
icon: Icons.Upload,
color: "var(--blue)",
},
Expand All @@ -123,7 +123,7 @@ export const Widget = React.memo(() => {
<Icons.Download className="netstats__icon netstats__icon--download" />
<span
className="netstats__value"
dangerouslySetInnerHTML={{ __html: formatedDownload }}
dangerouslySetInnerHTML={{ __html: formattedDownload }}
/>
</div>
</DataWidget.Widget>
Expand All @@ -132,7 +132,7 @@ export const Widget = React.memo(() => {
<Icons.Upload className="netstats__icon netstats__icon--upload" />
<span
className="netstats__value"
dangerouslySetInnerHTML={{ __html: formatedUpload }}
dangerouslySetInnerHTML={{ __html: formattedUpload }}
/>
</div>
</DataWidget.Widget>
Expand Down
7 changes: 5 additions & 2 deletions lib/components/data/sound.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import { SuspenseIcon } from "../icons/icon.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down Expand Up @@ -97,7 +98,9 @@ export const Widget = React.memo(() => {
return (
<DataWidget.Widget classes={classes} disableSlider>
<div className="sound__display">
<Icon />
<SuspenseIcon>
<Icon />
</SuspenseIcon>
<span className="sound__value">{formattedVolume}</span>
</div>
<div className="sound__slider-container">
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/spotify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as DataWidgetLoader from "./data-widget-loader.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import * as Utils from "../../utils";

export { spotifyStyles as styles } from "../../styles/components/data/spotify";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/stock.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/time.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/user-widgets.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/viscosity-vpn.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/weather.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import * as Utils from "../../utils";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/wifi.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
2 changes: 1 addition & 1 deletion lib/components/data/zoom.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Uebersicht from "uebersicht";
import * as DataWidget from "./data-widget.jsx";
import * as DataWidgetLoader from "./data-widget-loader.jsx";
import * as Icons from "../icons.jsx";
import * as Icons from "../icons/icons.jsx";
import useWidgetRefresh from "../../hooks/use-widget-refresh";
import useServerSocket from "../../hooks/use-server-socket";
import { useSimpleBarContext } from "../simple-bar-context.jsx";
Expand Down
Loading

0 comments on commit a1eb609

Please sign in to comment.