-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathApp.tsx
More file actions
50 lines (45 loc) · 1.38 KB
/
App.tsx
File metadata and controls
50 lines (45 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { useEffect, useRef, useState } from 'react'
import './style.css'
import { Blendy, createBlendy } from '../../src'
import { createPortal } from 'react-dom'
function App() {
const blendy = useRef<Blendy | null>(null)
const [showModal, setShowModal] = useState(false)
useEffect(() => {
blendy.current = createBlendy({ animation: 'dynamic' })
}, [])
return (
<div>
{showModal
&& createPortal(<Modal onClose={() => {
blendy.current?.untoggle('example', () => {
setShowModal(false)
})
}}></Modal>, document.body)
}
<button className="button" data-blendy-from="example" onClick={() => {
setShowModal(true)
blendy.current?.toggle('example')
}}><span>Open</span></button>
</div>
)
}
function Modal({ onClose }: { onClose: React.MouseEventHandler<HTMLElement> }) {
return (
<div className="modal" data-blendy-to="example">
<div>
<div className="modal__header">
<h2 className="modal__title">Blendy</h2>
<button className="modal__close" onClick={onClose}></button>
</div>
<div className="modal__content">
<p>
Meet Blendy, a framework-agnostic tool that smoothly transitions
one element into another with just a few lines of code.
</p>
</div>
</div>
</div>
)
}
export default App