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 all 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
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import React, { ReactNode } from 'react';
import { VscWarning } from 'react-icons/vsc';
import { Info, Semibold } from '../../../Typography';
import { Modal } from '../../index';
Expand All @@ -12,6 +12,20 @@ import { IconButton } from '@mui/material';
import { BsX } from 'react-icons/bs';
import { Close } from '@mui/icons-material';

export type ModalComponentProps = {
title: ReactNode;
titleClassName?: string;
icon?: React.ReactNode;
contents?: string[];
dismissModal: () => void;
buttonGroup?: React.ReactNode;
children?: React.ReactNode;
warning?: boolean;
error?: boolean;
tooltipContent?: string;
className?: string;
};

export default function ModalComponent({
title,
titleClassName,
Expand All @@ -24,7 +38,7 @@ export default function ModalComponent({
error,
tooltipContent,
className = '',
}) {
}: ModalComponentProps) {
if (warning && error) {
console.error('warning and error cannot be true at the same time');
}
Expand Down Expand Up @@ -60,9 +74,7 @@ export default function ModalComponent({
<Close />
</IconButton>
</div>
{contents?.map((line, index) => (
<Info key={index}>{line}</Info>
))}
{contents?.map((line, index) => <Info key={index}>{line}</Info>)}

{children}
{!!buttonGroup && <div className={styles.buttonGroup}>{buttonGroup}</div>}
Expand Down
Loading