Skip to content

LF-4718: fix web deploy tsc error #3679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 LiteFarm.org
* This file is part of LiteFarm.
*
* LiteFarm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiteFarm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/
import React, { forwardRef } from 'react';
import clsx from 'clsx';
import MenuItem from '@mui/material/MenuItem';
import MenuList from '@mui/material/MenuList';
import styles from './styles.module.scss';

export type FloatingMenuProps = {
options: { label: React.ReactNode; onClick: () => void }[];
classes?: { menuList?: string; menuItem?: string };
onCloseMenu?: () => void;
};

const FloatingMenu = forwardRef<HTMLUListElement, FloatingMenuProps>(
({ options, classes = {}, onCloseMenu, ...props }, ref) => {
return (
<MenuList ref={ref} className={clsx(styles.menuList, classes.menuList)} {...props}>
{options.map(({ label, onClick }, index) => {
return (
<MenuItem
key={index}
onClick={() => {
onClick();
onCloseMenu?.();
}}
className={clsx(styles.menuItem, classes.menuItem)}
>
{label}
</MenuItem>
);
})}
</MenuList>
);
},
);

FloatingMenu.displayName = 'FloatingMenu';

export default FloatingMenu;
16 changes: 7 additions & 9 deletions packages/webapp/src/components/Menu/MeatballsMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { forwardRef, ReactNode } from 'react';
import clsx from 'clsx';
import { BsThreeDots } from 'react-icons/bs';
import FloatingMenu from '../FloatingButtonMenu/FloatingMenu';
import FloatingMenu, { FloatingMenuProps } from '../FloatingButtonMenu/FloatingMenu';
import DropdownButton from '../../Form/DropDownButton';
import styles from './styles.module.scss';

Expand All @@ -26,19 +26,17 @@ export type MeatballsMenuProps = {
};

const MeatballsMenu = ({ options, classes, disabled = false }: MeatballsMenuProps) => {
const Menu = forwardRef<HTMLUListElement, FloatingMenuProps>((menuProps, ref) => (
<FloatingMenu ref={ref} classes={{ menuItem: styles.menuItem }} {...menuProps} />
));
Menu.displayName = 'Menu';

return (
<DropdownButton
type={'v2'}
noIcon
classes={{ button: clsx(styles.menuButton, classes?.button) }}
Menu={forwardRef((menuProps, ref) => (
<FloatingMenu
ref={ref}
options={options}
classes={{ menuItem: styles.menuItem }}
{...menuProps}
/>
))}
Menu={Menu}
menuPositionOffset={[0, 1]}
disabled={disabled}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BsX } from 'react-icons/bs';
import { Close } from '@mui/icons-material';

export default function ModalComponent({
title,
title = '',
Copy link
Collaborator

@kathyavini kathyavini Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solves the issue for me in that file, but I get a different tsc error in components/Drawer on build 😂

src/components/Drawer/index.tsx:69:7 - error TS2322: Type 'NonNullable<ReactNode>' is not assignable to type 'string | undefined'.
  Type 'number' is not assignable to type 'string'.

69       title={title}
         ~~~~~


Found 1 error in src/components/Drawer/index.tsx:69

I appreciate that you are actually solving the errors, though, I would have so totally used // @ts-ignore 😅

titleClassName,
icon,
contents,
Expand Down
Loading