Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
LuckySwap
interface
Commits
ac1bc3b3
Unverified
Commit
ac1bc3b3
authored
Jun 15, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup(modal): clean up modal code a bit
parent
d1063d50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
index.tsx
src/components/Modal/index.tsx
+12
-17
No files found.
src/components/Modal/index.tsx
View file @
ac1bc3b3
...
...
@@ -87,14 +87,6 @@ const StyledDialogContent = styled(({ minHeight, maxHeight, mobile, isOpen, ...r
}
`
const
HiddenCloseButton
=
styled
.
button
`
margin: 0;
padding: 0;
width: 0;
height: 0;
border: none;
`
interface
ModalProps
{
isOpen
:
boolean
onDismiss
:
()
=>
void
...
...
@@ -119,7 +111,7 @@ export default function Modal({
leave
:
{
opacity
:
0
}
})
const
[{
xy
},
set
]
=
useSpring
(()
=>
({
xy
:
[
0
,
0
]
}))
const
[{
y
},
set
]
=
useSpring
(()
=>
({
y
:
0
,
config
:
{
mass
:
1
,
tension
:
210
,
friction
:
20
}
}))
const
bind
=
useGesture
({
onDrag
:
state
=>
{
let
velocity
=
state
.
velocity
...
...
@@ -130,8 +122,7 @@ export default function Modal({
velocity
=
8
}
set
({
xy
:
state
.
down
?
state
.
movement
:
[
0
,
0
],
config
:
{
mass
:
1
,
tension
:
210
,
friction
:
20
}
y
:
state
.
down
?
state
.
movement
[
1
]
:
0
})
if
(
velocity
>
3
&&
state
.
direction
[
1
]
>
0
)
{
onDismiss
()
...
...
@@ -164,18 +155,17 @@ export default function Modal({
<
animated
.
div
{
...
bind
()}
style=
{
{
transform
:
(
xy
as
any
).
interpolate
((
x
,
y
)
=>
`translate3d(${0}px,${y > 0 ? y : 0}px,0
)`
)
transform
:
y
.
interpolate
(
y
=>
`translateY(${y > 0 ? y : 0}px
)`
)
}
}
>
<
StyledDialogContent
aria
Label=
"tes
t"
aria
-
label=
"dialog conten
t"
style=
{
props
}
hidden=
{
true
}
minHeight=
{
minHeight
}
maxHeight=
{
maxHeight
}
mobile=
{
isMobile
??
undefined
}
mobile=
{
isMobile
}
>
<
HiddenCloseButton
onClick=
{
onDismiss
}
/>
{
children
}
</
StyledDialogContent
>
</
animated
.
div
>
...
...
@@ -193,8 +183,13 @@ export default function Modal({
({
item
,
key
,
props
})
=>
item
&&
(
<
StyledDialogOverlay
key=
{
key
}
style=
{
props
}
onDismiss=
{
onDismiss
}
initialFocusRef=
{
initialFocusRef
}
>
<
StyledDialogContent
hidden=
{
true
}
minHeight=
{
minHeight
}
maxHeight=
{
maxHeight
}
isOpen=
{
isOpen
}
>
<
HiddenCloseButton
onClick=
{
onDismiss
}
/>
<
StyledDialogContent
aria
-
label=
"dialog content"
hidden=
{
true
}
minHeight=
{
minHeight
}
maxHeight=
{
maxHeight
}
isOpen=
{
isOpen
}
>
{
children
}
</
StyledDialogContent
>
</
StyledDialogOverlay
>
...
...
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