Skip to content

Commit

Permalink
fix(ui): lib page enocide bg image uri
Browse files Browse the repository at this point in the history
  • Loading branch information
prostarz committed Nov 11, 2024
1 parent bb921cc commit d971897
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 11 deletions.
9 changes: 7 additions & 2 deletions backend/handlers/updater/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { app } from "electron";
import electronUpdater from "electron-updater";
import { settings } from "../../utils/settings/settings";

const { autoUpdater } = electronUpdater;

autoUpdater.setFeedURL({
provider: "github",
owner: "team-falkor",
repo: "app",
});

class Updater {
private settings = settings;
private updateAvailable = false;
Expand All @@ -15,7 +20,7 @@ class Updater {
if (!check) return false;

// Return true if update is available
if (check.updateInfo.version === app.getVersion()) return false;
if (!check?.updateInfo?.version) return false;

this.updateAvailable = true;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const BackgroundImage: React.FC<BackgroundImageProps> = ({
className,
}) => {
const isRemoteImage = /^https?:\/\//i.test(bgImage);
const realImagePath = isRemoteImage ? bgImage : `local:${bgImage}`;
const realImagePath = isRemoteImage ? bgImage : `local:${encodeURI(bgImage)}`;

return (
<div
Expand Down
21 changes: 15 additions & 6 deletions src/features/settings/components/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@ import { PropsWithChildren } from "react";

interface Props {
title?: string;
description?: string;
}

export const SettingsSection = ({
children,
title,
description,
}: PropsWithChildren<Props>) => {
const { t } = useLanguageContext();

return (
<div className="p-4 space-y-5 bg-white rounded-lg shadow-md dark:bg-card/40">
{!!title && (
<h2 className="text-xl font-semibold ">
<span>{t("settings.settings." + title)}</span>
</h2>
)}
<div className="p-4 space-y-4 bg-white rounded-lg shadow-md dark:bg-card/40">
<div className="flex flex-col">
{!!title && (
<h2 className="text-xl font-semibold">
<span>{t("settings.settings." + title)}</span>
</h2>
)}
{!!description && (
<p className="text-sm text-muted-foreground">
{t("settings.settings." + description)}
</p>
)}
</div>
{children}
</div>
);
Expand Down
12 changes: 11 additions & 1 deletion src/features/settings/components/tabs/general/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SettingsSection } from "../../section";
import SettingTitle from "../../title";
import SettingsContainer from "../container";
import LanguageDropdown from "./settings/language";
import TitleBarDropdown from "./settings/title-bar";

const GeneralSetting = () => {
const { t } = useLanguageContext();
Expand Down Expand Up @@ -50,8 +51,17 @@ const GeneralSetting = () => {
</div>
</SettingsSection>

<SettingsSection
title="change-title-bar-style"
description="change_title_bar_style_description"
>
<div className="w-64">
<TitleBarDropdown />
</div>
</SettingsSection>

<SettingsSection title="change_language">
<div className="w-56">
<div className="w-64">
<LanguageDropdown />
</div>
</SettingsSection>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { SettingsTitleBarStyle } from "@/@types";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { useSettings } from "@/hooks";

const TitleBarDropdown = () => {
const { settings, updateSetting } = useSettings();

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="w-full capitalize">
{settings?.titleBarStyle}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-full">
<DropdownMenuLabel>Title Bar Style</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={settings?.titleBarStyle}
onValueChange={(value) =>
updateSetting("titleBarStyle", value as SettingsTitleBarStyle)
}
>
<DropdownMenuRadioItem value="native">Native</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="icons">Icons</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="traffic-lights">
Traffic Lights
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="none">None</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
);
};

export default TitleBarDropdown;
4 changes: 3 additions & 1 deletion src/i18n/translations/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"check-for-plugin-updates-on-startup": "Check for plugin updates on startup",
"check-for-app-updates-on-startup": "Check for app updates on startup",
"update_settings": "Update Settings",
"enable_developer_console": "Enable Developer Console"
"enable_developer_console": "Enable Developer Console",
"change-title-bar-style": "Change Title Bar Style",
"change_title_bar_style_description": "Some options require a restart to take effect"
}
},
"view_more": "View More",
Expand Down

0 comments on commit d971897

Please sign in to comment.