Skip to content

Commit 8ebde80

Browse files
committed
Add shortcut settings
1 parent aad096f commit 8ebde80

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/WidgetMap.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BatteryWidget } from "./widgets/BatteryWidget";
22
import { Clock, ClockSettings } from "./widgets/Clock";
33
import { Notepad } from "./widgets/Notepad";
44
import { Search, SearchSettings } from "./widgets/Search";
5-
import { Shortcut } from "./widgets/Shortcut";
5+
import { Shortcut, ShortcutSettings } from "./widgets/Shortcut";
66
import { ToDoList } from "./widgets/ToDoList";
77
import { Weather } from "./widgets/Weather";
88

@@ -38,6 +38,10 @@ const WidgetMap = {
3838
component: Shortcut,
3939
resizable: { x: false, y: false },
4040
size: { width: 1, height: 1 },
41+
settings: {
42+
website: "",
43+
openInNewTab: false,
44+
} satisfies ShortcutSettings,
4145
},
4246

4347
todo: {

src/widgets/Shortcut.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import React, { useEffect, useState } from "react";
2-
import Widget from "../Widget";
2+
import { WidgetState } from "../Widget";
33
import { LinkIcon } from "@phosphor-icons/react";
44
import globalStyles from "../App.css";
55
import styles from "./Shortcut.css";
66

7-
export function Shortcut({ url = "" }: { url?: string }) {
7+
export interface ShortcutSettings {
8+
website: string;
9+
openInNewTab: boolean;
10+
}
11+
12+
export function Shortcut({ settings }: WidgetState<ShortcutSettings>) {
813
const [loaded, setLoaded] = useState(false);
914

1015
// useEffect(() => {
@@ -14,13 +19,14 @@ export function Shortcut({ url = "" }: { url?: string }) {
1419
return (
1520
<a
1621
className={[globalStyles.container, styles.shortcut].join(" ")}
17-
href={url}
18-
title={url}
22+
href={settings.website}
23+
title={settings.website}
24+
target={settings.openInNewTab ? "_blank" : "_self"}
1925
>
2026
{!loaded && <LinkIcon className={styles.icon} weight="bold"></LinkIcon>}
2127
<img
2228
className={styles.icon}
23-
src={url + "/favicon.ico"}
29+
src={settings.website + "/favicon.ico"}
2430
style={{
2531
display: loaded ? "initial" : "none",
2632
}}

0 commit comments

Comments
 (0)