ywana-core8 0.1.56 → 0.1.58

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
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.3.1",
39
40
  "material-design-icons-iconfont": "^6.7.0",
40
41
  "moment": "^2.29.1",
41
42
  "moment-range": "^4.0.2",
@@ -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
@@ -118,6 +118,11 @@
118
118
  align-items: center;
119
119
  }
120
120
 
121
+ .site-page-container {
122
+ position:relative;
123
+ overflow: hidden;
124
+ }
125
+
121
126
  .site6>main {
122
127
  grid-area: main;
123
128
  overflow: hidden;
package/src/site/site.js CHANGED
@@ -9,6 +9,8 @@ import { ReactNotifications, Store } from 'react-notifications-component'
9
9
  import { useHashPage } from './navigation'
10
10
  import 'react-notifications-component/dist/theme.css'
11
11
  import './site.css'
12
+ import motion from "framer-motion/dist/framer-motion.cjs"
13
+ const { AnimatePresence, motion: MotionDiv } = motion
12
14
 
13
15
  /**
14
16
  * Site Provider
@@ -253,7 +255,7 @@ const SiteMenu = ({ iconSrc, title, children, min }) => {
253
255
  */
254
256
  const SitePage = ({ children, init }) => {
255
257
  const context = useContext(SiteContext)
256
- const { page } = context
258
+ const { page, direction } = context
257
259
  useEffect(() => {
258
260
  if (init) {
259
261
  context.goto(init)
@@ -261,9 +263,24 @@ const SitePage = ({ children, init }) => {
261
263
  context.goto("EMPTY")
262
264
  }
263
265
  }, [])
266
+
267
+ const currentPage = React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)
268
+ const xOffset = direction === "left" ? 40 : -40
264
269
  return (
265
- <main>
266
- {React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)}
270
+ <main className='site-page-container'>
271
+ <AnimatePresence exitBeforeEnter>
272
+ {currentPage && (
273
+ <MotionDiv
274
+ key={page}
275
+ initial={{ opacity: 0, x: xOffset }}
276
+ animate={{ opacity: 1, x: 0 }}
277
+ exit={{ opacity: 0, x: -xOffset }}
278
+ transition={{ duration: 0.3 }}
279
+ >
280
+ {currentPage}
281
+ </MotionDiv>
282
+ )}
283
+ </AnimatePresence>
267
284
  </main>
268
285
  )
269
286
  }