@dfosco/storyboard-react-primer 1.24.0 → 2.0.0-beta.1
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 +2 -2
- package/src/DevTools/DevTools.jsx +8 -8
- package/src/SceneDebug.jsx +11 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfosco/storyboard-react-primer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"src"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@dfosco/storyboard-react": "
|
|
15
|
+
"@dfosco/storyboard-react": "2.0.0-beta.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@primer/react": ">=37",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { loadFlow, getFlagKeys } from '@dfosco/storyboard-core'
|
|
3
3
|
import { BeakerIcon, InfoIcon, SyncIcon, XIcon, ScreenFullIcon, ZapIcon } from '@primer/octicons-react'
|
|
4
4
|
import styles from './DevTools.module.css'
|
|
5
5
|
import FeatureFlagsPanel from './FeatureFlagsPanel.jsx'
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function getFlowName() {
|
|
8
8
|
return new URLSearchParams(window.location.search).get('scene') || 'default'
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -56,12 +56,12 @@ export default function DevTools() {
|
|
|
56
56
|
setMenuOpen((v) => !v)
|
|
57
57
|
}, [])
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const handleShowFlowInfo = useCallback(() => {
|
|
60
60
|
setMenuOpen(false)
|
|
61
61
|
setPanelOpen(true)
|
|
62
62
|
setSceneError(null)
|
|
63
63
|
try {
|
|
64
|
-
setSceneData(
|
|
64
|
+
setSceneData(loadFlow(getFlowName()))
|
|
65
65
|
} catch (err) {
|
|
66
66
|
setSceneError(err.message)
|
|
67
67
|
}
|
|
@@ -88,13 +88,13 @@ export default function DevTools() {
|
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
90
|
<>
|
|
91
|
-
{/*
|
|
91
|
+
{/* Flow info overlay panel */}
|
|
92
92
|
{panelOpen && (
|
|
93
93
|
<div className={styles.overlay}>
|
|
94
94
|
<div className={styles.overlayBackdrop} onClick={() => setPanelOpen(false)} />
|
|
95
95
|
<div className={styles.panel}>
|
|
96
96
|
<div className={styles.panelHeader}>
|
|
97
|
-
<span className={styles.panelTitle}>
|
|
97
|
+
<span className={styles.panelTitle}>Flow: {getFlowName()}</span>
|
|
98
98
|
<button className={styles.panelClose} onClick={() => setPanelOpen(false)} aria-label="Close panel">
|
|
99
99
|
<XIcon size={16} />
|
|
100
100
|
</button>
|
|
@@ -117,8 +117,8 @@ export default function DevTools() {
|
|
|
117
117
|
<button className={styles.menuItem} onClick={handleViewfinder}>
|
|
118
118
|
<ScreenFullIcon size={16} /> See viewfinder
|
|
119
119
|
</button>
|
|
120
|
-
<button className={styles.menuItem} onClick={
|
|
121
|
-
<InfoIcon size={16} /> Show
|
|
120
|
+
<button className={styles.menuItem} onClick={handleShowFlowInfo}>
|
|
121
|
+
<InfoIcon size={16} /> Show flow info
|
|
122
122
|
</button>
|
|
123
123
|
<button className={styles.menuItem} onClick={handleResetParams}>
|
|
124
124
|
<SyncIcon size={16} /> Reset all params
|
package/src/SceneDebug.jsx
CHANGED
|
@@ -2,31 +2,31 @@ import { useMemo } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { useSearchParams } from 'react-router-dom'
|
|
4
4
|
import { Text } from '@primer/react'
|
|
5
|
-
import {
|
|
5
|
+
import { loadFlow } from '@dfosco/storyboard-core'
|
|
6
6
|
import styles from './SceneDebug.module.css'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Debug component that displays loaded
|
|
9
|
+
* Debug component that displays loaded flow data as formatted JSON.
|
|
10
10
|
* Used to verify the loader is working correctly.
|
|
11
|
-
* Reads
|
|
11
|
+
* Reads flow name from URL param (?scene=name) or uses prop/default.
|
|
12
12
|
*/
|
|
13
|
-
export default function SceneDebug({ sceneName } = {}) {
|
|
13
|
+
export default function SceneDebug({ flowName, sceneName } = {}) {
|
|
14
14
|
const [searchParams] = useSearchParams()
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const flowFromUrl = searchParams.get('scene')
|
|
16
|
+
const activeFlowName = flowName || sceneName || flowFromUrl || 'default'
|
|
17
17
|
|
|
18
18
|
const { data, error } = useMemo(() => {
|
|
19
19
|
try {
|
|
20
|
-
return { data:
|
|
20
|
+
return { data: loadFlow(activeFlowName), error: null }
|
|
21
21
|
} catch (err) {
|
|
22
22
|
return { data: null, error: err.message }
|
|
23
23
|
}
|
|
24
|
-
}, [
|
|
24
|
+
}, [activeFlowName])
|
|
25
25
|
|
|
26
26
|
if (error) {
|
|
27
27
|
return (
|
|
28
28
|
<div className={styles.error}>
|
|
29
|
-
<Text className={styles.errorTitle}>Error loading
|
|
29
|
+
<Text className={styles.errorTitle}>Error loading flow</Text>
|
|
30
30
|
<p className={styles.errorMessage}>{error}</p>
|
|
31
31
|
</div>
|
|
32
32
|
)
|
|
@@ -34,7 +34,7 @@ export default function SceneDebug({ sceneName } = {}) {
|
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<div className={styles.container}>
|
|
37
|
-
<h2 className={styles.title}>
|
|
37
|
+
<h2 className={styles.title}>Flow: {activeFlowName}</h2>
|
|
38
38
|
<pre className={styles.codeBlock}>
|
|
39
39
|
{JSON.stringify(data, null, 2)}
|
|
40
40
|
</pre>
|
|
@@ -43,5 +43,6 @@ export default function SceneDebug({ sceneName } = {}) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
SceneDebug.propTypes = {
|
|
46
|
+
flowName: PropTypes.string,
|
|
46
47
|
sceneName: PropTypes.string,
|
|
47
48
|
}
|