fix: fixing download sources migration

This commit is contained in:
Chubby Granny Chaser 2024-12-23 00:05:27 +00:00
parent 496924b2a4
commit c9c6d5ee46
No known key found for this signature in database
5 changed files with 86 additions and 125 deletions

View File

@ -74,16 +74,28 @@ export const search = recipe({
},
});
export const searchButton = recipe({
base: {
WebkitAppRegion: "no-drag",
} as ComplexStyleRule,
variants: {
hidden: {
true: {
visibility: "hidden",
},
},
export const searchInput = style({
backgroundColor: "transparent",
border: "none",
width: "100%",
height: "100%",
outline: "none",
color: "#DADBE1",
cursor: "default",
fontFamily: "inherit",
textOverflow: "ellipsis",
":focus": {
cursor: "text",
},
});
export const actionButton = style({
color: "inherit",
cursor: "pointer",
transition: "all ease 0.2s",
padding: `${SPACING_UNIT}px`,
":hover": {
color: "#DADBE1",
},
});

View File

@ -1,13 +1,13 @@
import { useTranslation } from "react-i18next";
import { useMemo } from "react";
import { useMemo, useRef, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { ArrowLeftIcon, SearchIcon } from "@primer/octicons-react";
import { ArrowLeftIcon, SearchIcon, XIcon } from "@primer/octicons-react";
import { useAppSelector } from "@renderer/hooks";
import { useAppDispatch, useAppSelector } from "@renderer/hooks";
import * as styles from "./header.css";
import { AutoUpdateSubHeader } from "./auto-update-sub-header";
import { Button } from "../button/button";
import { setSearch } from "@renderer/features";
const pathTitle: Record<string, string> = {
"/": "home",
@ -17,6 +17,8 @@ const pathTitle: Record<string, string> = {
};
export function Header() {
const inputRef = useRef<HTMLInputElement>(null);
const navigate = useNavigate();
const location = useLocation();
@ -24,6 +26,14 @@ export function Header() {
(state) => state.window
);
const searchValue = useAppSelector(
(state) => state.catalogueSearch.value.title
);
const dispatch = useAppDispatch();
const [isFocused, setIsFocused] = useState(false);
const { t } = useTranslation("header");
const title = useMemo(() => {
@ -35,14 +45,27 @@ export function Header() {
return t(pathTitle[location.pathname]);
}, [location.pathname, headerTitle, t]);
const showSearchButton = useMemo(() => {
return location.pathname.startsWith("/catalogue");
}, [location.pathname]);
const focusInput = () => {
setIsFocused(true);
inputRef.current?.focus();
};
const handleBlur = () => {
setIsFocused(false);
};
const handleBackButtonClick = () => {
navigate(-1);
};
const handleSearch = (value: string) => {
dispatch(setSearch({ title: value }));
if (!location.pathname.startsWith("/catalogue")) {
navigate("/catalogue");
}
};
return (
<>
<header
@ -73,14 +96,37 @@ export function Header() {
</section>
<section className={styles.section}>
<Button
theme="outline"
className={styles.searchButton({ hidden: showSearchButton })}
onClick={() => navigate("/catalogue?search=true")}
>
<SearchIcon />
{t("search")}
</Button>
<div className={styles.search({ focused: isFocused })}>
<button
type="button"
className={styles.actionButton}
onClick={focusInput}
>
<SearchIcon />
</button>
<input
ref={inputRef}
type="text"
name="search"
placeholder={t("search")}
value={searchValue}
className={styles.searchInput}
onChange={(event) => handleSearch(event.target.value)}
onFocus={() => setIsFocused(true)}
onBlur={handleBlur}
/>
{searchValue && (
<button
type="button"
onClick={() => dispatch(setSearch({ title: "" }))}
className={styles.actionButton}
>
<XIcon />
</button>
)}
</div>
</section>
</header>
<AutoUpdateSubHeader />

View File

@ -18,7 +18,9 @@ export function useRepacks() {
const updateRepacks = useCallback(() => {
repacksTable.toArray().then((repacks) => {
dispatch(setRepacks(repacks));
dispatch(
setRepacks(repacks.filter((repack) => Array.isArray(repack.objectIds)))
);
});
}, [dispatch]);

View File

@ -19,60 +19,6 @@
width: 100%;
padding: 16px;
&__search-container {
background-color: globals.$dark-background-color;
display: inline-flex;
transition: all ease 0.2s;
width: 200px;
align-items: center;
border-radius: 8px;
border: 1px solid globals.$border-color;
height: 40px;
&:hover {
border-color: rgba(255, 255, 255, 0.5);
}
&--focused {
width: 250px;
border-color: #dadbe1;
}
}
&__search-icon-button {
color: inherit;
cursor: pointer;
transition: all ease 0.2s;
padding: 8px;
&:hover {
color: #dadbe1;
}
}
&__search-clear-button {
color: inherit;
cursor: pointer;
transition: all ease 0.2s;
padding: 8px;
&:hover {
color: #dadbe1;
}
}
&__search-input {
background-color: transparent;
border: none;
width: 100%;
height: 100%;
outline: none;
color: #dadbe1;
cursor: default;
font-family: inherit;
text-overflow: ellipsis;
}
&__game-item {
background-color: globals.$dark-background-color;
width: 100%;

View File

@ -141,51 +141,6 @@ export default function Catalogue() {
return (
<div className="catalogue">
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
}}
>
<div
className={cn("catalogue__search-container", {
["catalogue__search-container--focused"]:
focused || !!filters.title,
})}
>
<button
type="button"
className="catalogue__search-icon-button"
onClick={focusInput}
>
<SearchIcon />
</button>
<input
ref={inputRef}
type="text"
name="search"
placeholder={t("search")}
value={filters.title}
className="catalogue__search-input"
onChange={(event) => onSearch(event.target.value)}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
{filters.title && (
<button
type="button"
onClick={() => dispatch(setSearch({ title: "" }))}
className="catalogue__search-clear-button"
>
<XIcon />
</button>
)}
</div>
</div>
<div
style={{
display: "flex",