mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore] fix lint errors
This commit is contained in:
@@ -32,7 +32,7 @@ type Props<T> = {
|
||||
onDoubleClick?: (value: T) => void
|
||||
} & Partial<MSModel> & Partial<BsmLocalModel> & Omit<React.ComponentProps<"li">, "id" | "onDoubleClick">
|
||||
|
||||
function modelItem<T = unknown>(props: Props<T>) {
|
||||
function ModelItemElement<T = unknown>(props: Props<T>) {
|
||||
|
||||
const t = useTranslation();
|
||||
const color = useThemeColor("first-color");
|
||||
@@ -66,7 +66,7 @@ function modelItem<T = unknown>(props: Props<T>) {
|
||||
if(!props.thumbnail){ return null; }
|
||||
if(isValidUrl(props.thumbnail)){ return props.thumbnail; }
|
||||
const [file, ext] = props.thumbnail.split(".");
|
||||
return props.download.split("/").slice(0, -1).join("/") + `/${file}.${ext.toLowerCase()}`;
|
||||
return `${props.download.split("/").slice(0, -1).join("/")}/${file}.${ext.toLowerCase()}`
|
||||
})();
|
||||
|
||||
const modelTags = (() => {
|
||||
@@ -74,19 +74,19 @@ function modelItem<T = unknown>(props: Props<T>) {
|
||||
return [...new Set(props.tags)];
|
||||
})();
|
||||
|
||||
const actionButtons = (): {icon: BsmIconType, action: () => void, iconColor?: string}[] => {
|
||||
const buttons: {icon: BsmIconType, action: () => void, iconColor?: string}[] = [];
|
||||
const actionButtons = (): {id: number, icon: BsmIconType, action: () => void, iconColor?: string}[] => {
|
||||
const buttons: {id: number, icon: BsmIconType, action: () => void, iconColor?: string}[] = [];
|
||||
|
||||
if(props.onDownload && !props.onCancelDownload){
|
||||
buttons.push({ icon: "download", action: () => props.onDownload(props.callbackValue) });
|
||||
buttons.push({id: 0, icon: "download", action: () => props.onDownload(props.callbackValue) });
|
||||
}
|
||||
|
||||
if(props.onDelete){
|
||||
buttons.push({ icon: "trash", action: () => props.onDelete(props.callbackValue) });
|
||||
buttons.push({ id: 1,icon: "trash", action: () => props.onDelete(props.callbackValue) });
|
||||
}
|
||||
|
||||
if(props.onCancelDownload){
|
||||
buttons.push({ icon: "cross", action: () => props.onCancelDownload(props.callbackValue), iconColor: "red" });
|
||||
buttons.push({ id: 2,icon: "cross", action: () => props.onCancelDownload(props.callbackValue), iconColor: "red" });
|
||||
}
|
||||
|
||||
return buttons;
|
||||
@@ -105,12 +105,12 @@ function modelItem<T = unknown>(props: Props<T>) {
|
||||
<GlowEffect visible={props.selected || hovered}/>
|
||||
<div className="absolute top-0 left-0 w-full h-full rounded-lg overflow-hidden blur-none bg-black shadow-sm shadow-black">
|
||||
<div ref={ref} className="contents">
|
||||
<BsmImage className={`absolute top-0 left-0 w-full h-full object-cover brightness-50 scale-[200%] blur-md`} image={thumbnailUrl} placeholder={defaultImage} loading="lazy"/>
|
||||
<BsmImage className={`absolute top-0 left-1/2 -translate-x-1/2 max-w-[20rem] w-full h-full object-cover`} image={thumbnailUrl} placeholder={defaultImage} loading="lazy"/>
|
||||
<BsmImage className="absolute top-0 left-0 w-full h-full object-cover brightness-50 scale-[200%] blur-md" image={thumbnailUrl} placeholder={defaultImage} loading="lazy"/>
|
||||
<BsmImage className="absolute top-0 left-1/2 -translate-x-1/2 max-w-[20rem] w-full h-full object-cover" image={thumbnailUrl} placeholder={defaultImage} loading="lazy"/>
|
||||
<div className="absolute top-0 right-0 h-full w-0 flex flex-col items-end gap-1 pt-1.5 pr-1.5">
|
||||
{!props.isDownloading ? (
|
||||
actionButtons().map((button, index) => (
|
||||
<BsmButton key={index} className="w-8 h-8 p-1 rounded-md transition-transform duration-150 shadow-black shadow-sm" style={{transitionDelay: `${index * 50}ms`, transform: hovered ? "translate(0%)" : "translate(150%)"}} icon={button.icon} iconColor={button.iconColor} onClick={e => {e.stopPropagation(); e.preventDefault(); button.action();}} withBar={false}/>
|
||||
<BsmButton key={button.id} className="w-8 h-8 p-1 rounded-md transition-transform duration-150 shadow-black shadow-sm" style={{transitionDelay: `${index * 50}ms`, transform: hovered ? "translate(0%)" : "translate(150%)"}} icon={button.icon} iconColor={button.iconColor} onClick={e => {e.stopPropagation(); e.preventDefault(); button.action();}} withBar={false}/>
|
||||
))
|
||||
): (
|
||||
<BsmBasicSpinner className="w-7 h-7 p-1 rounded-md bg-main-color-2 flex items-center justify-center shadow-black shadow-sm" spinnerClassName="brightness-200" thikness="3.5px" style={{color}}/>
|
||||
@@ -157,4 +157,4 @@ function modelItem<T = unknown>(props: Props<T>) {
|
||||
|
||||
const typedMemo: <T, P>(c: T, propsAreEqual?: (prevProps: Readonly<P>, nextProps: Readonly<P>) => boolean) => T = memo;
|
||||
|
||||
export const ModelItem = typedMemo(modelItem, equal);
|
||||
export const ModelItem = typedMemo(ModelItemElement, equal);
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useOnUpdate } from "renderer/hooks/use-on-update.hook";
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
import { ConfigurationService } from "renderer/services/configuration.service";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { gte, lt } from "semver";
|
||||
import { lt } from "semver";
|
||||
|
||||
export function ModelsPanel({version, isActive, goToMods}: {version?: BSVersion, isActive: boolean, goToMods?: () => void}) {
|
||||
|
||||
@@ -85,7 +85,7 @@ export function ModelsPanel({version, isActive, goToMods}: {version?: BSVersion,
|
||||
<BsmDropdownButton items={threeDotsItems} className="h-full flex aspect-square relative rounded-full z-[1] bg-light-main-color-1 dark:bg-main-color-3" buttonClassName="rounded-full h-full w-full p-[6px]" icon="three-dots" withBar={false} menuTranslationY="6px" align="center"/>
|
||||
</div>
|
||||
<div className="w-full h-full flex flex-row bg-light-main-color-3 dark:bg-main-color-2 rounded-md shadow-black shadow-md overflow-hidden">
|
||||
<ModelsTabsNavbar className="flex-shrink-0" version={version} tabIndex={currentTabIndex} onTabChange={(index, tab) => {setModelTypeTab(() => tab.extra), setCurrentTabIndex(() => index)}}/>
|
||||
<ModelsTabsNavbar className="flex-shrink-0" version={version} tabIndex={currentTabIndex} onTabChange={(index, tab) => {setModelTypeTab(() => tab.extra); setCurrentTabIndex(() => index)}}/>
|
||||
|
||||
<div className="flex-grow h-full flex flex-col transition-all duration-300" style={{translate: `0 ${0 - currentTabIndex * 100}%`}}>
|
||||
<ModelsGrid ref={modelsGridRefs[0]} version={version} type={MSModelType.Avatar} active={isActive && modelTypeTab === MSModelType.Avatar} search={search} downloadModels={openDownloadModal}/>
|
||||
|
||||
Reference in New Issue
Block a user