mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-560] applied PR comments
This commit is contained in:
@@ -2,6 +2,7 @@ import { lastValueFrom } from "rxjs";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { useService } from "renderer/hooks/use-service.hook";
|
||||
import Tippy from "@tippyjs/react";
|
||||
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { ModalComponent, ModalExitCode } from "renderer/services/modale.service";
|
||||
@@ -79,17 +80,24 @@ export const AskInstallPathModal: ModalComponent<{ installPath: string }, {}> =
|
||||
</div>
|
||||
|
||||
<div className="grid grid-flow-col grid-cols-3 gap-4">
|
||||
<BsmButton
|
||||
typeColor="cancel"
|
||||
className="h-8 col-start-2 rounded-md text-center transition-all"
|
||||
onClick={onDefaultButtonPressed}
|
||||
withBar={false}
|
||||
text="modals.ask-install-path.default"
|
||||
tooltip="modals.ask-install-path.default-tooltip"
|
||||
/>
|
||||
<Tippy
|
||||
className="!bg-main-color-1"
|
||||
content={t("modals.ask-install-path.default-tooltip")}
|
||||
delay={[300, 0]}
|
||||
arrow={false}
|
||||
placement="bottom"
|
||||
>
|
||||
<BsmButton
|
||||
typeColor="cancel"
|
||||
className="col-start-2 rounded-md text-center transition-all"
|
||||
onClick={onDefaultButtonPressed}
|
||||
withBar={false}
|
||||
text="modals.ask-install-path.default"
|
||||
/>
|
||||
</Tippy>
|
||||
<BsmButton
|
||||
typeColor="primary"
|
||||
className="h-8 col-start-3 z-0 px-1 rounded-md text-center transition-all"
|
||||
className="col-start-3 z-0 px-1 rounded-md text-center transition-all"
|
||||
type="submit"
|
||||
withBar={false}
|
||||
text="misc.confirm"
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { useClickOutside } from "renderer/hooks/use-click-outside.hook";
|
||||
import { useThemeColor } from "renderer/hooks/use-theme-color.hook";
|
||||
import { getCorrectTextColor } from "renderer/helpers/correct-text-color";
|
||||
import Tippy from "@tippyjs/react";
|
||||
|
||||
export type BsmButtonType = "primary" | "secondary" | "success" | "cancel" | "error" | "none";
|
||||
|
||||
@@ -29,17 +28,9 @@ type Props = {
|
||||
title?: string;
|
||||
iconColor?: string;
|
||||
textClassName?: string;
|
||||
tooltip?: string;
|
||||
tooltipIcon?: BsmIconType;
|
||||
};
|
||||
|
||||
export const BsmButton = forwardRef<unknown, Props>(({
|
||||
className, style, iconStyle, imgClassName, iconClassName,
|
||||
icon, image, text, type, active, withBar = true, disabled,
|
||||
onClickOutside, onClick,
|
||||
typeColor, color, title, iconColor, textClassName,
|
||||
tooltip, tooltipIcon
|
||||
}, forwardedRef) => {
|
||||
export const BsmButton = forwardRef<unknown, Props>(({ className, style, iconStyle, imgClassName, iconClassName, icon, image, text, type, active, withBar = true, disabled, onClickOutside, onClick, typeColor, color, title, iconColor, textClassName }, forwardedRef) => {
|
||||
const t = useTranslation();
|
||||
const { firstColor, secondColor } = useThemeColor();
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
@@ -93,35 +84,18 @@ export const BsmButton = forwardRef<unknown, Props>(({
|
||||
|
||||
const handleClick = (e: MouseEvent<HTMLDivElement>) => !disabled && onClick?.(e);
|
||||
|
||||
const renderTooltip = () => {
|
||||
return (
|
||||
<Tippy
|
||||
className="!bg-main-color-1"
|
||||
content={t(tooltip)}
|
||||
delay={[300, 0]}
|
||||
arrow={false}
|
||||
>
|
||||
<div className="h-[20px] w-[20px] p-1.5 rounded-full cursor-help bg-light-main-color-1 dark:bg-main-color-3 hover:brightness-110">
|
||||
<BsmIcon className="w-full h-full" icon={tooltipIcon || "info"} />
|
||||
</div>
|
||||
</Tippy>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={setRef} onClick={handleClick} title={t(title)} className={`${className} overflow-hidden group ${!withBar && !disabled && (!!typeColor || !!color) && "hover:brightness-[1.15]"} ${disabled ? "brightness-75 cursor-not-allowed" : "cursor-pointer"} ${renderTypeColor}`} style={{ ...style, backgroundColor: primaryColor || color }}>
|
||||
{image && <BsmImage image={image} className={imgClassName} />}
|
||||
{icon && <BsmIcon icon={icon} className={iconClassName ?? "size-full text-gray-800 dark:text-white"} style={{ ...(iconStyle ?? {}), color: (iconColor || textColor) }} />}
|
||||
{text &&
|
||||
(type === "submit" ? (
|
||||
<button type="submit" className={`h-full flex items-center justify-center gap-x-2 ${!textClassName && "size-full"}`} style={{ ...(!!textColor && { color: textColor }) }}>
|
||||
<span className={textClassName}>{t(text)}</span>
|
||||
{tooltip && renderTooltip()}
|
||||
<button type="submit" className={textClassName || "size-full"} style={{ ...(!!textColor && { color: textColor }) }}>
|
||||
{t(text)}
|
||||
</button>
|
||||
) : (
|
||||
<span className="h-full flex items-center justify-center gap-x-2" style={{ ...(!!textColor && { color: `${textColor}` }) }}>
|
||||
<span className={textClassName}>{t(text)}</span>
|
||||
{tooltip && renderTooltip()}
|
||||
<span className={textClassName} style={{ ...(!!textColor && { color: `${textColor}` }) }}>
|
||||
{t(text)}
|
||||
</span>
|
||||
))}
|
||||
{withBar && (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { logRenderError } from "renderer";
|
||||
|
||||
import { BSVersionManagerService } from "./bs-version-manager.service";
|
||||
import { IpcService } from "./ipc.service";
|
||||
import { ModalExitCode, ModalResponse, ModalService } from "./modale.service";
|
||||
import { ModalService } from "./modale.service";
|
||||
import { SteamDownloaderService } from "./bs-version-download/steam-downloader.service";
|
||||
|
||||
import { AskInstallPathModal } from "renderer/components/modal/modal-types/ask-install-path.component";
|
||||
@@ -42,18 +42,15 @@ export class SetupService {
|
||||
|
||||
private async checkInstallationPath(): Promise<void> {
|
||||
try {
|
||||
const exists = await lastValueFrom(this.ipcService.sendV2("bs-installer.folder-exists"))
|
||||
const exists = await lastValueFrom(this.ipcService.sendV2("bs-installer.folder-exists"));
|
||||
if (exists) {
|
||||
return;
|
||||
}
|
||||
|
||||
let modalResponse: ModalResponse<{ installPath: string }> = { exitCode: ModalExitCode.NO_CHOICE };
|
||||
while (modalResponse.exitCode !== ModalExitCode.COMPLETED) {
|
||||
modalResponse = await this.modalService.openModal(
|
||||
AskInstallPathModal,
|
||||
{ closable: false }
|
||||
);
|
||||
}
|
||||
const modalResponse = await this.modalService.openModal(
|
||||
AskInstallPathModal,
|
||||
{ closable: false }
|
||||
);
|
||||
|
||||
await lastValueFrom(this.steamDownloaderService.setInstallationFolder(modalResponse.data.installPath));
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export interface IpcChannelMapping {
|
||||
"bsv-get-playlist-details-by-id": {request: {id: string, page: number}, response: BsvPlaylistPage};
|
||||
|
||||
/* ** bs-installer-ipcs ** */
|
||||
"bs-installer.folder-exists": { require: void, response: boolean };
|
||||
"bs-installer.folder-exists": { request: void, response: boolean };
|
||||
"bs-installer.default-install-path": { request: void, response: string };
|
||||
"bs-installer.install-path": { request: void, response: string};
|
||||
"bs-installer.set-install-path": { request: string, response: string};
|
||||
|
||||
Reference in New Issue
Block a user