@@ -2,6 +2,8 @@ import React, {useEffect, useState} from "react"
2
2
import ReactDOM from "react-dom/client" ;
3
3
import { useContentLevel , useCurrentPageId , useSidebarMenuElements } from "../../../services/hooks" ;
4
4
import Spinner from 'react-bootstrap/Spinner' ;
5
+ import { getDataAttribute , getDataAttributeFromContainer , renderComponent } from "../../../services/util" ;
6
+ import { TutorialTrigger } from "../tutorial/TutorialTrigger" ;
5
7
6
8
const PageNavigation = ( ) => {
7
9
@@ -44,27 +46,34 @@ const PageNavigation = () => {
44
46
return link . href
45
47
}
46
48
49
+ const composeButton = previous => {
50
+ const title = getDataAttributeFromContainer ( previous , "title" )
51
+
52
+ const button = < div className = "card my-1" >
53
+ < div className = "card-body py-2" >
54
+ { title }
55
+ </ div >
56
+ </ div >
57
+
58
+ if ( getDataAttributeFromContainer ( previous , "category" ) === "tutorial" ) {
59
+ const id = getDataAttributeFromContainer ( previous , "id" )
60
+ const content = document . getElementById ( "content-curriculum-tutorial-trigger-" + id ) . innerHTML
61
+
62
+ return < a href = "#" > < TutorialTrigger title = { title } content = { content } button = { button } /> </ a >
63
+ }
64
+
65
+ return < a href = { getHref ( previous ) } >
66
+ { button }
67
+ </ a >
68
+ }
69
+
47
70
return < >
48
71
{ ( previous === null && next === null ) && < Spinner animation = "border" role = "status" /> }
49
72
{ ( previous !== null || next !== null ) && < div className = "docs-navigation d-flex justify-content-between" >
50
- { previous !== null && < a href = { getHref ( previous ) } >
51
- < div className = "card my-1" >
52
- < div className = "card-body py-2" >
53
- { previous . textContent }
54
- </ div >
55
- </ div >
56
- </ a > }
57
- { next !== null && < a className = "ms-auto" href = { getHref ( next ) } >
58
- < div className = "card my-1" >
59
- < div className = "card-body py-2" >
60
- { next . textContent }
61
- </ div >
62
- </ div >
63
- </ a > }
73
+ { previous !== null && composeButton ( previous ) }
74
+ { next !== null && composeButton ( next ) }
64
75
</ div > }
65
76
</ >
66
77
}
67
78
68
- const container = document . getElementById ( 'page-navigation' ) ;
69
- const root = ReactDOM . createRoot ( container ) ;
70
- root . render ( < PageNavigation /> )
79
+ renderComponent ( < PageNavigation /> , "page-navigation" )
0 commit comments