Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
8b6c5d95
Commit
8b6c5d95
authored
Nov 25, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#66
Реализовал логику модалки, чтобы она не выходила за границы
parent
fb898090
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
8 deletions
+44
-8
CalendarTask.js
...components/MonthCalendarBody/CalendarTask/CalendarTask.js
+4
-4
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+3
-2
ModalTask.js
planner-front/src/components/UI/ModalTask/ModalTask.js
+37
-2
No files found.
planner-front/src/components/MonthCalendarBody/CalendarTask/CalendarTask.js
View file @
8b6c5d95
...
...
@@ -63,9 +63,9 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
<
/div
>
<
/div
>
<
div
>
<
span
>
{
task
.
title
}
<
/span
>
<
/div
>
<
/
>
...
...
@@ -76,9 +76,9 @@ const CalendarTask = ({setCurrentTask, handleOpen, task, line, setCurrentLine, i
<
ArrowBackIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
increaseTaskHandler
(
line
,
task
,
true
)}}
/
>
<
ArrowForwardIcon
sx
=
{
arrowClass
}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
reduceTaskHandler
(
line
,
task
,
true
)}}
/
>
<
/div
>
<
span
>
{
task
.
title
}
<
/span
>
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
}}
>
<
Button
sx
=
{{
color
:
'black'
,
fontWeight
:
'600'
}}
onClick
=
{(
e
)
=>
{
e
.
stopPropagation
();
setCopyTask
(
task
)}}
>
Copy
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
8b6c5d95
...
...
@@ -13,10 +13,11 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
const
[
currentLine
,
setCurrentLine
]
=
useState
(
''
)
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
y
:
0
,
x
:
0
,});
const
handleOpen
=
(
e
)
=>
{
console
.
log
(
e
)
setModal
(
{
open
:
true
,
y
Page
:
e
.
clientY
,
x
Page
:
e
.
clientX
,
y
Click
С
ordinates
:
e
.
clientY
,
x
Click
С
ordinates
:
e
.
clientX
,
yDivClick
:
e
.
nativeEvent
.
offsetY
,
xDivClick
:
e
.
nativeEvent
.
offsetX
,
yDiv
:
e
.
target
.
offsetHeight
,
...
...
planner-front/src/components/UI/ModalTask/ModalTask.js
View file @
8b6c5d95
import
Box
from
'@mui/material/Box'
;
import
Modal
from
'@mui/material/Modal'
;
import
{
useEffect
,
useState
}
from
'react'
;
export
default
function
ModalTask
({
modal
,
handleClose
,
children
})
{
const
[
windowDimenion
,
detectHW
]
=
useState
({
winWidth
:
window
.
innerWidth
,
winHeight
:
window
.
innerHeight
,
})
const
detectSize
=
()
=>
{
detectHW
({
winWidth
:
window
.
innerWidth
,
winHeight
:
window
.
innerHeight
,
})
}
useEffect
(()
=>
{
window
.
addEventListener
(
'resize'
,
detectSize
)
return
()
=>
{
window
.
removeEventListener
(
'resize'
,
detectSize
)
}
},
[
windowDimenion
])
const
getYCordinatesToModal
=
()
=>
{
if
(
windowDimenion
.
winHeight
>
modal
.
yClick
С
ordinates
+
350
)
{
return
modal
.
yClick
С
ordinates
-
modal
.
yDiv
-
modal
.
yDivClick
}
else
{
return
modal
.
yClick
С
ordinates
-
modal
.
yDiv
-
modal
.
yDivClick
-
((
modal
.
yClick
С
ordinates
+
350
)
-
windowDimenion
.
winHeight
)
-
10
}
}
const
getXCordinatesToModal
=
()
=>
{
if
(
windowDimenion
.
winWidth
>
modal
.
xClick
С
ordinates
+
modal
.
xDiv
+
250
+
modal
.
xDivClick
)
{
return
modal
.
xClick
С
ordinates
+
modal
.
xDiv
-
modal
.
xDivClick
+
10
}
else
{
return
modal
.
xClick
С
ordinates
-
modal
.
xDiv
-
((
modal
.
xClick
С
ordinates
+
250
)
-
windowDimenion
.
winWidth
)
-
120
}
}
const
style
=
{
position
:
'absolute'
,
top
:
modal
.
yPage
-
modal
.
yDiv
-
modal
.
yDivClick
,
left
:
modal
.
xPage
+
modal
.
xDiv
-
modal
.
xDivClick
+
10
,
top
:
getYCordinatesToModal
()
,
left
:
getXCordinatesToModal
()
,
width
:
250
,
height
:
350
,
bgcolor
:
'background.paper'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment