@startupjs/docs 0.38.1 → 0.38.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
2
|
-
import { observer, useModel,
|
|
1
|
+
import React, { useCallback, useEffect, useMemo } from 'react'
|
|
2
|
+
import { observer, useModel, useLocal } from 'startupjs'
|
|
3
3
|
import { pathFor } from 'startupjs/app'
|
|
4
4
|
import { useMedia, Menu, Collapse } from '@startupjs/ui'
|
|
5
5
|
import { faAngleRight } from '@fortawesome/free-solid-svg-icons'
|
|
@@ -7,33 +7,63 @@ import { getTitle, useLang } from '../../../../../clientHelpers'
|
|
|
7
7
|
import { useDocsContext } from '../../../../../../docsContext'
|
|
8
8
|
import './index.styl'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const MenuItem = observer(function MenuItemComponent ({
|
|
11
|
+
active,
|
|
12
|
+
doc,
|
|
13
|
+
docName,
|
|
14
|
+
docPath,
|
|
15
|
+
nestingLevel,
|
|
16
|
+
superPath
|
|
17
|
+
}) {
|
|
12
18
|
const [lang] = useLang()
|
|
13
|
-
const
|
|
19
|
+
const { desktop } = useMedia()
|
|
20
|
+
const $mainSidebar = useModel('_session.Sidebar.mainSidebar')
|
|
21
|
+
const $openedCollapses = useModel('_session.SidebarCollapses')
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const menuItemStyle = useMemo(() => ({ paddingLeft: nestingLevel * 24 }), [nestingLevel])
|
|
24
|
+
const title = useMemo(() => getTitle(doc, lang), [doc, lang])
|
|
25
|
+
const rootPath = useMemo(() => pathFor('docs:doc', { lang, path: docPath }), [lang, docPath])
|
|
26
|
+
|
|
27
|
+
if (doc.type === 'collapse') {
|
|
28
|
+
return pug`
|
|
29
|
+
Collapse(
|
|
30
|
+
variant='pure'
|
|
31
|
+
$open=$openedCollapses.at(docPath)
|
|
32
|
+
)
|
|
33
|
+
Collapse.Header.header(
|
|
34
|
+
iconPosition='right'
|
|
35
|
+
icon=faAngleRight
|
|
36
|
+
iconStyleName='collapse-icon'
|
|
37
|
+
)
|
|
38
|
+
Menu.Item.item(
|
|
39
|
+
style=menuItemStyle
|
|
40
|
+
active=active
|
|
41
|
+
to=doc.component ? rootPath : null
|
|
42
|
+
bold
|
|
43
|
+
icon=doc.icon
|
|
44
|
+
)= title
|
|
45
|
+
Collapse.Content
|
|
46
|
+
Docs(
|
|
47
|
+
docs=doc.items
|
|
48
|
+
superPath=docPath
|
|
49
|
+
nestingLevel=nestingLevel + 1
|
|
50
|
+
)
|
|
51
|
+
`
|
|
52
|
+
}
|
|
21
53
|
|
|
22
54
|
return pug`
|
|
23
|
-
|
|
55
|
+
Menu.Item.item(
|
|
56
|
+
style=menuItemStyle
|
|
57
|
+
active=active
|
|
58
|
+
to=rootPath
|
|
59
|
+
onPress=desktop ? undefined : () => $mainSidebar.set(false)
|
|
60
|
+
)= title
|
|
24
61
|
`
|
|
25
62
|
})
|
|
26
63
|
|
|
27
|
-
const Docs = observer(function DocsComponent ({
|
|
28
|
-
docs,
|
|
29
|
-
lang,
|
|
30
|
-
superPath,
|
|
31
|
-
nestingLevel = 1
|
|
32
|
-
}) {
|
|
64
|
+
const Docs = observer(function DocsComponent ({ docs, superPath, nestingLevel = 1 }) {
|
|
33
65
|
const [path] = useLocal('$render.params.path')
|
|
34
|
-
const
|
|
35
|
-
const [, $openedCollapses] = useSession('SidebarCollapses')
|
|
36
|
-
const $mainSidebar = useModel('_session.Sidebar.mainSidebar')
|
|
66
|
+
const $openedCollapses = useModel('_session.SidebarCollapses')
|
|
37
67
|
|
|
38
68
|
// HACK: open parent collapse on initial render
|
|
39
69
|
useEffect(() => {
|
|
@@ -42,47 +72,47 @@ const Docs = observer(function DocsComponent ({
|
|
|
42
72
|
}
|
|
43
73
|
}, [])
|
|
44
74
|
|
|
45
|
-
const
|
|
75
|
+
const getDocPath = useCallback(
|
|
76
|
+
docName => {
|
|
77
|
+
return superPath ? superPath + '/' + docName : docName
|
|
78
|
+
},
|
|
79
|
+
[superPath]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const getActive = useCallback(
|
|
83
|
+
docName => {
|
|
84
|
+
return getDocPath(docName) === path
|
|
85
|
+
},
|
|
86
|
+
[path]
|
|
87
|
+
)
|
|
46
88
|
|
|
47
89
|
return pug`
|
|
48
90
|
Menu
|
|
49
|
-
each
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
active=isActive
|
|
76
|
-
to=doc.component ? rootPath : null
|
|
77
|
-
bold
|
|
78
|
-
icon=doc.icon
|
|
79
|
-
)= title
|
|
80
|
-
Collapse.Content
|
|
81
|
-
Docs(
|
|
82
|
-
docs=doc.items
|
|
83
|
-
superPath=docPath
|
|
84
|
-
lang=lang
|
|
85
|
-
nestingLevel=nestingLevel + 1
|
|
86
|
-
)
|
|
91
|
+
each docName in Object.keys(docs)
|
|
92
|
+
MenuItem(
|
|
93
|
+
key=docName
|
|
94
|
+
active=getActive(docName)
|
|
95
|
+
doc=docs[docName]
|
|
96
|
+
docName=docName
|
|
97
|
+
docPath=getDocPath(docName)
|
|
98
|
+
nestingLevel=nestingLevel
|
|
99
|
+
superPath=superPath
|
|
100
|
+
)
|
|
101
|
+
`
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
export default observer(function DocsRoot () {
|
|
105
|
+
const docs = useDocsContext()
|
|
106
|
+
const [path] = useLocal('$render.params.path')
|
|
107
|
+
|
|
108
|
+
// NOTE
|
|
109
|
+
// since layout renders before page loads
|
|
110
|
+
// and $render is created when page loads
|
|
111
|
+
// we need to wait for the 'path' to appear
|
|
112
|
+
// in the params
|
|
113
|
+
if (!path) return null
|
|
114
|
+
|
|
115
|
+
return pug`
|
|
116
|
+
Docs(docs=docs)
|
|
87
117
|
`
|
|
88
118
|
})
|
|
@@ -15,7 +15,7 @@ const IconSelect = observer(function ({ $value, value }) {
|
|
|
15
15
|
() =>
|
|
16
16
|
keys(omit(icons, ['fas', 'prefix'])).map(key => ({
|
|
17
17
|
label: key,
|
|
18
|
-
value:
|
|
18
|
+
value: icons[key]
|
|
19
19
|
})),
|
|
20
20
|
[]
|
|
21
21
|
)
|
|
@@ -25,8 +25,8 @@ const IconSelect = observer(function ({ $value, value }) {
|
|
|
25
25
|
options=_icons
|
|
26
26
|
size='s'
|
|
27
27
|
type='select'
|
|
28
|
-
value=
|
|
29
|
-
onChange=value => $value.set(
|
|
28
|
+
value=value
|
|
29
|
+
onChange=value => $value.set(value)
|
|
30
30
|
)
|
|
31
31
|
`
|
|
32
32
|
})
|
|
@@ -78,13 +78,13 @@ const JSONInput = observer(function ({ $value, type }) {
|
|
|
78
78
|
`
|
|
79
79
|
})
|
|
80
80
|
|
|
81
|
-
const PropInput = observer(function ({ $value, extraParams, options, type, value }) {
|
|
81
|
+
const PropInput = observer(function ({ $value, extraParams = {}, options, type, value }) {
|
|
82
82
|
switch (type) {
|
|
83
83
|
case 'array':
|
|
84
84
|
case 'object':
|
|
85
85
|
// custom Select for icon objects instead of JSONInput
|
|
86
86
|
// when extraParams.showIconSelect is true
|
|
87
|
-
if (extraParams
|
|
87
|
+
if (extraParams.showIconSelect) {
|
|
88
88
|
return pug`
|
|
89
89
|
IconSelect($value=$value value=value)
|
|
90
90
|
`
|
|
@@ -103,6 +103,7 @@ const PropInput = observer(function ({ $value, extraParams, options, type, value
|
|
|
103
103
|
type='text'
|
|
104
104
|
value=value
|
|
105
105
|
onChangeText=value => $value.set(value)
|
|
106
|
+
...extraParams
|
|
106
107
|
)
|
|
107
108
|
`
|
|
108
109
|
case 'number':
|
|
@@ -112,6 +113,7 @@ const PropInput = observer(function ({ $value, extraParams, options, type, value
|
|
|
112
113
|
type='number'
|
|
113
114
|
value=value
|
|
114
115
|
onChangeNumber=value => $value.set(value)
|
|
116
|
+
...extraParams
|
|
115
117
|
)
|
|
116
118
|
`
|
|
117
119
|
case 'bool':
|
|
@@ -125,12 +127,13 @@ const PropInput = observer(function ({ $value, extraParams, options, type, value
|
|
|
125
127
|
case 'oneOf':
|
|
126
128
|
return pug`
|
|
127
129
|
Input(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
options=options
|
|
131
|
+
size='s'
|
|
132
|
+
type='select'
|
|
133
|
+
value=value
|
|
134
|
+
onChange=value => $value.set(value)
|
|
135
|
+
...extraParams
|
|
136
|
+
)
|
|
134
137
|
`
|
|
135
138
|
default:
|
|
136
139
|
return null
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"description": "MDX documentation generator",
|
|
7
|
-
"version": "0.38.
|
|
7
|
+
"version": "0.38.5",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@fortawesome/free-solid-svg-icons": "^5.12.0",
|
|
12
|
-
"@startupjs/mdx": "^0.38.
|
|
13
|
-
"@startupjs/scrollable-anchors": "^0.38.
|
|
14
|
-
"@startupjs/ui": "^0.38.
|
|
12
|
+
"@startupjs/mdx": "^0.38.5",
|
|
13
|
+
"@startupjs/scrollable-anchors": "^0.38.5",
|
|
14
|
+
"@startupjs/ui": "^0.38.5",
|
|
15
15
|
"parse-prop-types": "^0.3.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"react-native": ">= 0.61.4 < 0.64.0",
|
|
20
20
|
"startupjs": ">= 0.33.0"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "3b435b1413049770136e08bf380f34d198d15826"
|
|
23
23
|
}
|