ywana-core8 0.1.58 → 0.1.59

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.58",
3
+ "version": "0.1.59",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/site/link.js CHANGED
@@ -1,55 +1,6 @@
1
- import { useEffect, useState, useRef } from "react"
2
1
  import React, { useContext } from 'react'
3
2
  import { SiteContext } from './siteContext'
4
3
 
5
- /**
6
- * Use Hash Page
7
- */
8
- export function useHashPage(defaultPage = "home") {
9
- const getCurrentPageFromURL = () => {
10
- const hash = window.location.hash.replace("#", "")
11
- return hash || defaultPage
12
- }
13
-
14
- const [page, setPage] = useState(getCurrentPageFromURL())
15
- const [history, setHistory] = useState([])
16
- const isFirstLoad = useRef(true)
17
-
18
- useEffect(() => {
19
- const handleHashChange = () => {
20
- const newPage = getCurrentPageFromURL()
21
- if (!isFirstLoad.current) {
22
- setHistory(prev => [...prev, page]) // Guarda la página anterior
23
- } else {
24
- isFirstLoad.current = false
25
- }
26
- setPage(newPage)
27
- }
28
-
29
- window.addEventListener("hashchange", handleHashChange)
30
- return () => window.removeEventListener("hashchange", handleHashChange)
31
- }, [page])
32
-
33
- const goto = (id) => {
34
- if (page) {
35
- setHistory(prev => [...prev, page])
36
- }
37
- setPage(id)
38
- window.location.hash = id
39
- }
40
-
41
- const goBack = () => {
42
- if (history.length > 0) {
43
- const lastPage = history[history.length - 1]
44
- setHistory(prev => prev.slice(0, -1))
45
- setPage(lastPage)
46
- window.location.hash = lastPage
47
- }
48
- }
49
-
50
- return { page, goto, goBack, history }
51
- }
52
-
53
4
  /**
54
5
  * PageLink - Navegación declarativa usando el sistema de hash
55
6
  *
@@ -50,5 +50,5 @@ export function useHashPage(defaultPage = "home") {
50
50
  }
51
51
  }
52
52
 
53
- return { page, goto, goBack, history }
53
+ return { page, goto, goBack, history, direction }
54
54
  }
package/src/site/site.js CHANGED
@@ -6,11 +6,9 @@ import { Tooltip } from '../html/tooltip'
6
6
  import { Page } from './page'
7
7
  import { SiteContext } from './siteContext'
8
8
  import { ReactNotifications, Store } from 'react-notifications-component'
9
- import { useHashPage } from './navigation'
10
9
  import 'react-notifications-component/dist/theme.css'
11
10
  import './site.css'
12
- import motion from "framer-motion/dist/framer-motion.cjs"
13
- const { AnimatePresence, motion: MotionDiv } = motion
11
+ import { useHashPage } from './navigation'
14
12
 
15
13
  /**
16
14
  * Site Provider
@@ -29,7 +27,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
29
27
  const [preview, setPreview] = useState()
30
28
  const [breadcrumb, setBreadcrumb] = useState()
31
29
 
32
- const { page, goto, goBack } = useHashPage()
30
+ const { page, goto, goBack, direction } = useHashPage()
33
31
 
34
32
  const value = {
35
33
 
@@ -65,6 +63,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
65
63
  page,
66
64
  goto,
67
65
  goBack,
66
+ direction,
68
67
 
69
68
  dialog,
70
69
  openDialog: (dialog) => { setDialog(dialog) },
@@ -255,7 +254,7 @@ const SiteMenu = ({ iconSrc, title, children, min }) => {
255
254
  */
256
255
  const SitePage = ({ children, init }) => {
257
256
  const context = useContext(SiteContext)
258
- const { page, direction } = context
257
+ const { page } = context
259
258
  useEffect(() => {
260
259
  if (init) {
261
260
  context.goto(init)
@@ -263,24 +262,9 @@ const SitePage = ({ children, init }) => {
263
262
  context.goto("EMPTY")
264
263
  }
265
264
  }, [])
266
-
267
- const currentPage = React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)
268
- const xOffset = direction === "left" ? 40 : -40
269
265
  return (
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>
266
+ <main>
267
+ {React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)}
284
268
  </main>
285
269
  )
286
270
  }