-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(card) : #MAG-114 add board cards #365
base: dev
Are you sure you want to change the base?
Changes from 9 commits
b8d50ec
5662022
b45887b
128eacd
bfbee77
49d9264
a5b41aa
694d761
91218cb
e00d547
1d64a19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { FC, useState } from "react"; | ||
|
||
import { Button, SearchBar } from "@edifice-ui/react"; | ||
import CloseIcon from "@mui/icons-material/Close"; | ||
import { Box, IconButton, Modal, Typography } from "@mui/material"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { | ||
closeButtonStyle, | ||
contentContainerStyle, | ||
duplicateButtonStyle, | ||
headerStyle, | ||
modalContainerStyle, | ||
modalFooterStyle, | ||
titleStyle, | ||
} from "./style"; | ||
import { InputValueState, BoardCreateMagnetBoardModalProps } from "./types"; | ||
import { useRenderContent } from "./useRenderContent"; | ||
import { initialInputvalue } from "./utils"; | ||
import { TabList } from "../tab-list/TabList"; | ||
import { CURRENTTAB_STATE } from "../tab-list/types"; | ||
import { BOARD_TABS_CONFIG } from "../tab-list/utils"; | ||
import { useMediaLibrary } from "~/providers/MediaLibraryProvider"; | ||
|
||
export const BoardCreateMagnetBoardModal: FC< | ||
BoardCreateMagnetBoardModalProps | ||
> = ({ open, onClose }) => { | ||
const [inputValue, setInputValue] = | ||
useState<InputValueState>(initialInputvalue); | ||
const { currentTab } = inputValue; | ||
const { t } = useTranslation("magneto"); | ||
const { setIsCreateMagnetOpen, setSelectedBoardData } = useMediaLibrary(); | ||
|
||
const handleTabChange = (newValue: CURRENTTAB_STATE) => { | ||
setInputValue((prevState) => ({ | ||
...prevState, | ||
currentTab: newValue, | ||
selectedBoardId: null, | ||
})); | ||
}; | ||
|
||
const handleSearchChange = (newValue: string) => { | ||
setInputValue((prevState) => ({ | ||
...prevState, | ||
search: newValue, | ||
selectedBoardId: null, | ||
})); | ||
}; | ||
|
||
const onCloseModal = () => { | ||
setInputValue(initialInputvalue); | ||
onClose(); | ||
}; | ||
|
||
const handleSubmit = async () => { | ||
if (inputValue.selectedBoardId) { | ||
setSelectedBoardData(inputValue.selectedBoardId); | ||
setIsCreateMagnetOpen(true); | ||
onCloseModal(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Modal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. t'as la MessageModal d'Alice qui embarque le plus gros du style de nos modales There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai repris BoardCreateMagnetMagnetModal qui a sa propre Modal aussi, je verrais pour factoriser avec MessageModal si il faut, mais c'était pour gagner du temps vu qu'elles sont relativement ressemblantes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai essayé de reprendre avec MessageModal, mais comme le style de container principal de la modal n'est pas le même (au niveau de la height et width notamment) l'affichage est tout cassé, ça va demander plus de travail, je vois au retour des vacances si ça prendra beaucoup de temps |
||
open={open} | ||
onClose={onClose} | ||
aria-labelledby="modal-title" | ||
aria-describedby="modal-create-magnet-magnet" | ||
> | ||
<Box sx={modalContainerStyle}> | ||
<Box sx={headerStyle}> | ||
<Typography | ||
id="modal-title" | ||
variant="h4" | ||
component="h2" | ||
sx={titleStyle} | ||
> | ||
{t("magneto.boards.collection")} | ||
</Typography> | ||
<IconButton | ||
onClick={onClose} | ||
aria-label="close" | ||
sx={closeButtonStyle} | ||
> | ||
<CloseIcon fontSize="inherit" /> | ||
</IconButton> | ||
</Box> | ||
<Box sx={{ width: "100%", padding: "2rem 10%", margin: "auto" }}> | ||
<SearchBar | ||
onChange={(e) => { | ||
handleSearchChange(e.target.value); | ||
}} | ||
placeholder={t("magneto.search.placeholder")} | ||
size="md" | ||
isVariant | ||
className="searchbar" | ||
/> | ||
</Box> | ||
<Box | ||
sx={{ | ||
width: "100%", | ||
pb: "1rem", | ||
margin: "auto", | ||
display: "flex", | ||
justifyContent: "center", | ||
}} | ||
> | ||
<TabList | ||
currentTab={currentTab} | ||
onChange={handleTabChange} | ||
tabsConfig={BOARD_TABS_CONFIG} | ||
/> | ||
</Box> | ||
<Box sx={contentContainerStyle}> | ||
{useRenderContent(inputValue, setInputValue)} | ||
</Box> | ||
<Box sx={modalFooterStyle}> | ||
<Box sx={duplicateButtonStyle}> | ||
<Button | ||
color="tertiary" | ||
type="button" | ||
variant="ghost" | ||
onClick={() => onCloseModal()} | ||
> | ||
{t("magneto.cancel")} | ||
</Button> | ||
<Button | ||
onClick={() => handleSubmit()} | ||
disabled={!inputValue.selectedBoardId} | ||
> | ||
{t("magneto.add")} | ||
</Button> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</Modal> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
ul.grid { | ||
padding-top: 15px; | ||
display: grid; | ||
grid-template-columns: repeat( | ||
4, | ||
minmax(0, 1fr) | ||
); /* Force equal width columns */ | ||
gap: 16px; | ||
width: 100% !important; | ||
} | ||
|
||
li.boardSizing { | ||
/* Remove any width constraints */ | ||
min-width: 0; | ||
|
||
.card { | ||
width: 100%; | ||
padding: unset !important; | ||
margin: unset !important; | ||
display: flex; | ||
flex-wrap: wrap !important; | ||
flex-direction: column; | ||
max-width: 100%; /* Ensure card doesn't overflow */ | ||
|
||
.board-number-magnets { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
svg { | ||
color: #ffb600; | ||
font-size: 14px; | ||
} | ||
|
||
svg + p { | ||
font-size: 12px; | ||
margin: 0; | ||
} | ||
} | ||
|
||
.board-about { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
|
||
.board-about-left-content, | ||
.board-about-right-content { | ||
margin: 0 !important; | ||
display: flex; | ||
gap: 0.4rem; | ||
align-items: center; | ||
|
||
.med-resource-card-text { | ||
font-size: 12px; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.title { | ||
width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
font-size: 14px; | ||
} | ||
|
||
.card-body { | ||
width: 100%; | ||
padding: 12px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renommer en handleClose