mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
refactor: simplify theme structure and remove color-related code
This commit is contained in:
parent
0a37ce4cda
commit
ec638d1a7a
5 changed files with 9 additions and 80 deletions
|
@ -81,17 +81,6 @@ export const ThemeCard = ({ theme, onListUpdated }: ThemeCardProps) => {
|
||||||
>
|
>
|
||||||
<div className="theme-card__header">
|
<div className="theme-card__header">
|
||||||
<div className="theme-card__header__title">{theme.name}</div>
|
<div className="theme-card__header__title">{theme.name}</div>
|
||||||
|
|
||||||
<div className="theme-card__header__colors">
|
|
||||||
{Object.entries(theme.colors).map(([key, color]) => (
|
|
||||||
<div
|
|
||||||
title={color}
|
|
||||||
style={{ backgroundColor: color }}
|
|
||||||
className="theme-card__header__colors__color"
|
|
||||||
key={key}
|
|
||||||
></div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{theme.authorName && (
|
{theme.authorName && (
|
||||||
|
|
|
@ -41,11 +41,6 @@ export const AddThemeModal = ({
|
||||||
isActive: false,
|
isActive: false,
|
||||||
author: userDetails?.id || undefined,
|
author: userDetails?.id || undefined,
|
||||||
authorName: userDetails?.username || undefined,
|
authorName: userDetails?.username || undefined,
|
||||||
colors: {
|
|
||||||
accent: "",
|
|
||||||
background: "",
|
|
||||||
surface: "",
|
|
||||||
},
|
|
||||||
code: "",
|
code: "",
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
&__header {
|
&__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: calc(globals.$spacing-unit * 2);
|
padding: calc(globals.$spacing-unit + 1px);
|
||||||
background-color: globals.$dark-background-color;
|
background-color: globals.$dark-background-color;
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
&-actions {
|
&-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
&__tabs {
|
&__tabs {
|
||||||
|
|
|
@ -4,11 +4,7 @@ import Editor from "@monaco-editor/react";
|
||||||
import { Theme } from "@types";
|
import { Theme } from "@types";
|
||||||
import { useSearchParams } from "react-router-dom";
|
import { useSearchParams } from "react-router-dom";
|
||||||
import { Button } from "@renderer/components";
|
import { Button } from "@renderer/components";
|
||||||
import {
|
import { CheckIcon } from "@primer/octicons-react";
|
||||||
CheckIcon,
|
|
||||||
CodeIcon,
|
|
||||||
ProjectRoadmapIcon,
|
|
||||||
} from "@primer/octicons-react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
|
|
||||||
|
@ -16,17 +12,12 @@ export default function ThemeEditor() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [theme, setTheme] = useState<Theme | null>(null);
|
const [theme, setTheme] = useState<Theme | null>(null);
|
||||||
const [code, setCode] = useState("");
|
const [code, setCode] = useState("");
|
||||||
const [activeTab, setActiveTab] = useState("code");
|
|
||||||
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
||||||
|
|
||||||
const themeId = searchParams.get("themeId");
|
const themeId = searchParams.get("themeId");
|
||||||
|
|
||||||
const { t } = useTranslation("settings");
|
const { t } = useTranslation("settings");
|
||||||
|
|
||||||
const handleTabChange = (tab: string) => {
|
|
||||||
setActiveTab(tab);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (themeId) {
|
if (themeId) {
|
||||||
window.electron.getCustomThemeById(themeId).then((loadedTheme) => {
|
window.electron.getCustomThemeById(themeId).then((loadedTheme) => {
|
||||||
|
@ -90,12 +81,11 @@ export default function ThemeEditor() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeTab === "code" && (
|
<Editor
|
||||||
<Editor
|
theme="vs-dark"
|
||||||
theme="vs-dark"
|
defaultLanguage="css"
|
||||||
defaultLanguage="css"
|
value={code}
|
||||||
value={code}
|
onChange={handleEditorChange}
|
||||||
onChange={handleEditorChange}
|
|
||||||
options={{
|
options={{
|
||||||
minimap: { enabled: false },
|
minimap: { enabled: false },
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
@ -103,37 +93,10 @@ export default function ThemeEditor() {
|
||||||
wordWrap: "on",
|
wordWrap: "on",
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
{activeTab === "info" && (
|
|
||||||
<div className="theme-editor__info">
|
|
||||||
entao mano eu ate fiz isso aqui mas tava feio dms ai deu vergonha e
|
|
||||||
removi kkkk
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="theme-editor__footer">
|
<div className="theme-editor__footer">
|
||||||
<div className="theme-editor__footer-actions">
|
<div className="theme-editor__footer-actions">
|
||||||
<div className="theme-editor__footer-actions__tabs">
|
|
||||||
<Button
|
|
||||||
onClick={() => handleTabChange("code")}
|
|
||||||
theme="dark"
|
|
||||||
className={activeTab === "code" ? "active" : ""}
|
|
||||||
>
|
|
||||||
<CodeIcon />
|
|
||||||
{t("editor_tab_code")}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => handleTabChange("info")}
|
|
||||||
theme="dark"
|
|
||||||
className={activeTab === "info" ? "active" : ""}
|
|
||||||
>
|
|
||||||
<ProjectRoadmapIcon />
|
|
||||||
{t("editor_tab_info")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button onClick={handleSave}>
|
<Button onClick={handleSave}>
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
{t("editor_tab_save")}
|
{t("editor_tab_save")}
|
||||||
|
|
|
@ -1,24 +1,6 @@
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
const isValidHexColor = (color: string): boolean => {
|
|
||||||
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
||||||
return hexColorRegex.test(color);
|
|
||||||
};
|
|
||||||
|
|
||||||
const hexColorSchema = z.string().refine(isValidHexColor);
|
|
||||||
type HexColorType = z.infer<typeof hexColorSchema>;
|
|
||||||
|
|
||||||
export interface Theme {
|
export interface Theme {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
colors: {
|
|
||||||
accent: HexColorType;
|
|
||||||
background: HexColorType;
|
|
||||||
surface: HexColorType;
|
|
||||||
optional1?: HexColorType;
|
|
||||||
optional2?: HexColorType;
|
|
||||||
};
|
|
||||||
description?: string;
|
|
||||||
author: string | undefined;
|
author: string | undefined;
|
||||||
authorName: string | undefined;
|
authorName: string | undefined;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue