Skip to content

Commit 7a93686

Browse files
committed
amount and winsize
1 parent 739302c commit 7a93686

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

client/src/NoteComponents/ModalNoteEdit.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ function ModalNoteEdit() {
102102
close()
103103
}
104104

105+
const sizeRef = React.useRef()
106+
105107
/**рендер */
106108
return (
107109
<Modal {...modalProps.bind()}>
108-
<div className="container p-2">
110+
<div ref={sizeRef} className="container p-2">
109111
{/**Блок редактирования контента */}
110112
<div>
111113
{note ? (
@@ -160,6 +162,7 @@ function ModalNoteEdit() {
160162
mediaList={note ? note.media || [] : []}
161163
setNoteMedia={trySetNoteMedia}
162164
noteId={note ? note.id : null}
165+
sizeData={sizeRef}
163166
></Media>
164167
<button
165168
className="btn btn-light"

client/src/NoteComponents/media/media.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const MAX_PAYLOAD_SIZE = 100 * 1024
1414
* @param {*} param0
1515
*
1616
*/
17-
function Media({ setNoteMedia, mediaList = [], style, className, disabled, noteId }) {
17+
function Media({ setNoteMedia, mediaList = [], style, className, disabled, noteId, sizeData }) {
1818
const { addMedia, removeMedia, getMediaById, getNoteById } = useContext(NotesContext)
1919

2020
const limited = getNoteById(noteId).media.length >= 3
@@ -79,23 +79,27 @@ function Media({ setNoteMedia, mediaList = [], style, className, disabled, noteI
7979

8080
{/**Форма media */}
8181
<Modal {...modalProps.bind()} >
82-
<div className="p-1 d-flex flex-row flex-wrap justify-content-center align-items-center">
82+
<div style={{ minHeight: `${sizeData.current ? sizeData.current.parentElement.clientHeight : 100}px` }} className="p-1 d-flex flex-wrap align-content-between align-items-center justify-content-center">
8383

84-
<div className="form-group container d-flex flex-row flex-wrap mb-0">
85-
{Array.isArray(mediaList) ? (mediaList.map((imgId, index) => {
84+
<div className="form-group container d-flex flex-row flex-wrap align-items-start mb-0">
85+
{Array.isArray(mediaList) && mediaList.length ? (mediaList.map((imgId, index) => {
8686
const media = getMediaById(imgId)
8787
const src = typeof media === "object" && media && media.data
8888
return (
8989
<div className="card p-1 m-1" key={imgId} style={{ position: "relative" }}>
90-
<img style={{ maxWidth: "8em", maxHeight: "8em" }} src={src} alt="note img"></img>
90+
<img style={{ maxWidth: "13em", maxHeight: "13em" }} src={src} alt="note img"></img>
9191
<button
9292
style={{ position: "absolute", bottom: "0", right: "0", lineHeight: "1em", padding: "0.05em" }}
9393
className={`btn btn-danger m-1`}
9494
onClick={() => delImg(imgId, index)}
9595
>&#10007;</button>
9696
</div>
9797
)
98-
})) : null}
98+
})) : (
99+
<div className="p-1 m-1 text-center" style={{ minWidth: '100%' }}>
100+
No images
101+
</div>
102+
)}
99103
</div>
100104

101105
<div className="form-group container d-flex flex-wrap justify-content-between mb-0">

0 commit comments

Comments
 (0)