[chore] fix lint errors

This commit is contained in:
MathieuG-P
2023-07-01 03:01:38 +02:00
parent 7addb57613
commit d62727c3f9
55 changed files with 176 additions and 181 deletions
@@ -24,7 +24,7 @@ export function BsContentNavBar<T>({className, tabIndex, tabs, renderTab, onTabC
return (
<nav className={`h-full grid grid-flow-row ${className ?? ""}`}>
{tabs.map((tab, i) => (
<Fragment key={i}>
<Fragment key={JSON.stringify(tab)}>
{ renderTab({onClick: () => handleTabClick(i)}, tab, tabs[tabIndex]) }
</Fragment>
))}
@@ -20,8 +20,8 @@ type Props = {
active?: boolean,
withBar?: boolean,
disabled?: boolean,
onClickOutside?: (e: MouseEvent) => void,
onClick?: (e: React.MouseEvent) => void,
onClickOutside?: React.ComponentProps<"div">["onClick"],
onClick?: React.ComponentProps<"div">["onClick"],
typeColor?:BsmButtonType,
color?: string,
title?: string,
@@ -37,7 +37,11 @@ export function BsmButton({className, style, imgClassName, iconClassName, icon,
useClickOutside(ref, onClickOutside);
const primaryColor = typeColor === "primary" ? firstColor : typeColor === "secondary" ? secondColor : undefined;
const primaryColor = (() => {
if(typeColor === "primary"){ return firstColor; }
if(typeColor === "secondary"){ return secondColor; }
return undefined;
})();
const textColor = (() => {
if(primaryColor){
@@ -54,7 +58,7 @@ export function BsmButton({className, style, imgClassName, iconClassName, icon,
return "";
})();
const handleClick = (e: MouseEvent) => !disabled && onClick?.(e);
const handleClick = (e: MouseEvent<HTMLDivElement>) => !disabled && onClick?.(e);
return (
<div ref={ref} onClick={handleClick} title={t(title)} className={`${className} overflow-hidden cursor-pointer group ${(!withBar && !disabled && (!!typeColor || !!color)) && "hover:brightness-[1.15]"} ${disabled && "brightness-75 cursor-not-allowed"} ${renderTypeColor}`} style={{...style, backgroundColor: primaryColor || color}}>
@@ -1,4 +1,4 @@
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react"
import { forwardRef, useImperativeHandle, useRef, useState } from "react"
import { BsmIconType, BsmIcon } from "../svgs/bsm-icon.component"
import { BsmButton } from "./bsm-button.component"
import { useTranslation } from "renderer/hooks/use-translation.hook"
@@ -52,8 +52,7 @@ export const BsmDropdownButton = forwardRef(({className, items, align, withBar =
})()
return (
// @ts-ignore
<div ref={ref} className={className}>
<div ref={ref as unknown as React.LegacyRef<HTMLDivElement>} className={className}>
<BsmButton onClick={() => setExpanded(!expanded)} className={buttonClassName ?? defaultButtonClassName} icon={icon} active={expanded} onClickOutside={handleClickOutside} withBar={withBar} text={text}/>
<div className={`py-1 w-fit absolute cursor-pointer top-[calc(100%-4px)] rounded-md bg-inherit text-sm text-gray-800 dark:text-gray-200 shadow-md shadow-black transition-[scale] ease-in-out ${alignClass}`} style={{scale: expanded ? "1" : "0", translate: `0 ${menuTranslationY}`}}>
{ items?.map((i) => i && (
@@ -36,7 +36,6 @@ export const BsmImage = forwardRef(({className, image, errorImage, placeholder,
}
return (
// @ts-ignore
<img ref={ref} title={title} className={className} src={image} loading={loading} onLoad={handleLoaded} onError={handleError} style={styles} onClick={(e) => onClick?.(e)} alt=" " decoding="async"/>
)
})
@@ -18,6 +18,7 @@ export function BsmLink({className, href, children, style, internal}: Props) {
}
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid -- Will be reworked later
<a className={`${className} ${href && "cursor-pointer"}`} onClick={e => {e.stopPropagation(); openLink()}} style={style}>{children}</a>
)
}
@@ -20,7 +20,7 @@ export function BsmSelect<T = unknown>(props: Props<T>) {
return (
<select {...props} onChange={handleChange} defaultValue={props.options?.findIndex(opt => equal(opt.value, props.selected))}>
{props.options && props.options.map((option, index) => (
<option key={index} value={index}>{t(option.text)}</option>
<option key={JSON.stringify(option)} value={index}>{t(option.text)}</option>
))}
</select>
)