ywana-core8 0.1.56 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +36 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +36 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +39 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/site/navigation.js +4 -1
- package/src/site/site.css +5 -0
- package/src/site/site.js +19 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ywana-core8",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.57",
|
4
4
|
"description": "ywana-core8",
|
5
5
|
"homepage": "https://ywana.github.io/workspace",
|
6
6
|
"author": "Ernesto Roldan Garcia",
|
@@ -36,6 +36,7 @@
|
|
36
36
|
"axios": "^1.3.4",
|
37
37
|
"crypto-js": "^4.1.1",
|
38
38
|
"deep-equal": "^2.0.5",
|
39
|
+
"framer-motion": "^5.6.0",
|
39
40
|
"material-design-icons-iconfont": "^6.7.0",
|
40
41
|
"moment": "^2.29.1",
|
41
42
|
"moment-range": "^4.0.2",
|
package/src/site/navigation.js
CHANGED
@@ -13,6 +13,7 @@ export function useHashPage(defaultPage = "home") {
|
|
13
13
|
|
14
14
|
const [page, setPage] = useState(getCurrentPageFromURL())
|
15
15
|
const [history, setHistory] = useState([])
|
16
|
+
const [direction, setDirection] = useState("left")
|
16
17
|
const isFirstLoad = useRef(true)
|
17
18
|
|
18
19
|
useEffect(() => {
|
@@ -30,10 +31,11 @@ export function useHashPage(defaultPage = "home") {
|
|
30
31
|
return () => window.removeEventListener("hashchange", handleHashChange)
|
31
32
|
}, [page])
|
32
33
|
|
33
|
-
const goto = (id) => {
|
34
|
+
const goto = (id, dir = "left") => {
|
34
35
|
if (page) {
|
35
36
|
setHistory(prev => [...prev, page])
|
36
37
|
}
|
38
|
+
setDirection(dir)
|
37
39
|
setPage(id)
|
38
40
|
window.location.hash = id
|
39
41
|
}
|
@@ -42,6 +44,7 @@ export function useHashPage(defaultPage = "home") {
|
|
42
44
|
if (history.length > 0) {
|
43
45
|
const lastPage = history[history.length - 1]
|
44
46
|
setHistory(prev => prev.slice(0, -1))
|
47
|
+
setDirection("right")
|
45
48
|
setPage(lastPage)
|
46
49
|
window.location.hash = lastPage
|
47
50
|
}
|
package/src/site/site.css
CHANGED
package/src/site/site.js
CHANGED
@@ -7,6 +7,7 @@ import { Page } from './page'
|
|
7
7
|
import { SiteContext } from './siteContext'
|
8
8
|
import { ReactNotifications, Store } from 'react-notifications-component'
|
9
9
|
import { useHashPage } from './navigation'
|
10
|
+
import { AnimatePresence, motion } from 'framer-motion'
|
10
11
|
import 'react-notifications-component/dist/theme.css'
|
11
12
|
import './site.css'
|
12
13
|
|
@@ -253,7 +254,7 @@ const SiteMenu = ({ iconSrc, title, children, min }) => {
|
|
253
254
|
*/
|
254
255
|
const SitePage = ({ children, init }) => {
|
255
256
|
const context = useContext(SiteContext)
|
256
|
-
const { page } = context
|
257
|
+
const { page, direction } = context
|
257
258
|
useEffect(() => {
|
258
259
|
if (init) {
|
259
260
|
context.goto(init)
|
@@ -261,9 +262,24 @@ const SitePage = ({ children, init }) => {
|
|
261
262
|
context.goto("EMPTY")
|
262
263
|
}
|
263
264
|
}, [])
|
265
|
+
|
266
|
+
const currentPage = React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)
|
267
|
+
const xOffset = direction === "left" ? 40 : -40
|
264
268
|
return (
|
265
|
-
<main>
|
266
|
-
|
269
|
+
<main className='site-page-container'>
|
270
|
+
<AnimatePresence exitBeforeEnter>
|
271
|
+
{currentPage && (
|
272
|
+
<motion.div
|
273
|
+
key={page}
|
274
|
+
initial={{ opacity: 0, x: xOffset }}
|
275
|
+
animate={{ opacity: 1, x: 0 }}
|
276
|
+
exit={{ opacity: 0, x: -xOffset }}
|
277
|
+
transition={{ duration: 0.3 }}
|
278
|
+
>
|
279
|
+
{currentPage}
|
280
|
+
</motion.div>
|
281
|
+
)}
|
282
|
+
</AnimatePresence>
|
267
283
|
</main>
|
268
284
|
)
|
269
285
|
}
|