feat: boards on desktop as on mobile
This commit is contained in:
63
src/app/deals/components/shared/Board/Board.tsx
Normal file
63
src/app/deals/components/shared/Board/Board.tsx
Normal file
@ -0,0 +1,63 @@
|
||||
import React, { FC, useState } from "react";
|
||||
import classNames from "classnames";
|
||||
import { Box, Group, Text } from "@mantine/core";
|
||||
import BoardMenu from "@/app/deals/components/shared/BoardMenu/BoardMenu";
|
||||
import { useBoardsContext } from "@/app/deals/contexts/BoardsContext";
|
||||
import InPlaceInput from "@/components/ui/InPlaceInput/InPlaceInput";
|
||||
import useIsMobile from "@/hooks/useIsMobile";
|
||||
import { BoardSchema } from "@/lib/client";
|
||||
import styles from "./Board.module.css";
|
||||
|
||||
type Props = {
|
||||
board: BoardSchema;
|
||||
};
|
||||
|
||||
const Board: FC<Props> = ({ board }) => {
|
||||
const { selectedBoard, onUpdateBoard } = useBoardsContext();
|
||||
const isMobile = useIsMobile();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
||||
return (
|
||||
<Group
|
||||
px={"md"}
|
||||
py={"xs"}
|
||||
className={classNames(
|
||||
styles.board,
|
||||
selectedBoard?.id === board.id && styles["board-selected"]
|
||||
)}
|
||||
justify={"space-between"}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}>
|
||||
<InPlaceInput
|
||||
defaultValue={board.name}
|
||||
onComplete={value => onUpdateBoard(board.id, { name: value })}
|
||||
inputStyles={{
|
||||
input: {
|
||||
height: 25,
|
||||
minHeight: 25,
|
||||
},
|
||||
}}
|
||||
getChildren={startEditing => (
|
||||
<>
|
||||
<Box>
|
||||
<Text style={{ textWrap: "nowrap" }}>
|
||||
{board.name}
|
||||
</Text>
|
||||
</Box>
|
||||
<BoardMenu
|
||||
isHovered={
|
||||
!isMobile &&
|
||||
(selectedBoard?.id === board.id || isHovered)
|
||||
}
|
||||
board={board}
|
||||
startEditing={startEditing}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
modalTitle={"Редактирование доски"}
|
||||
/>
|
||||
</Group>
|
||||
);
|
||||
};
|
||||
|
||||
export default Board;
|
||||
Reference in New Issue
Block a user