@dfosco/storyboard-react 1.17.0 → 1.17.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Viewfinder.jsx +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfosco/storyboard-react",
3
- "version": "1.17.0",
3
+ "version": "1.17.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@dfosco/storyboard-core": "*",
@@ -3,6 +3,13 @@ import { useState, useEffect, useMemo } from 'react'
3
3
  import { hash, resolveSceneRoute, getSceneMeta } from '@dfosco/storyboard-core'
4
4
  import styles from './Viewfinder.module.css'
5
5
 
6
+ function formatSceneName(name) {
7
+ return name
8
+ .split('-')
9
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
10
+ .join(' ')
11
+ }
12
+
6
13
  function PlaceholderGraphic({ name }) {
7
14
  const seed = hash(name)
8
15
  const rects = []
@@ -92,11 +99,15 @@ function getCurrentBranch(basePath) {
92
99
  * @param {string} [props.title] - Header title (defaults to "Viewfinder")
93
100
  * @param {string} [props.subtitle] - Optional subtitle displayed below the title
94
101
  * @param {boolean} [props.showThumbnails] - Show thumbnail previews (defaults to false)
102
+ * @param {boolean} [props.hideDefaultScene] - Hide the "default" scene from the list (defaults to false)
95
103
  */
96
- export default function Viewfinder({ scenes = {}, pageModules = {}, basePath, title = 'Viewfinder', subtitle, showThumbnails = false }) {
104
+ export default function Viewfinder({ scenes = {}, pageModules = {}, basePath, title = 'Viewfinder', subtitle, showThumbnails = false, hideDefaultScene = false }) {
97
105
  const [branches, setBranches] = useState(null)
98
106
 
99
- const sceneNames = useMemo(() => Object.keys(scenes), [scenes])
107
+ const sceneNames = useMemo(() => {
108
+ const names = Object.keys(scenes)
109
+ return hideDefaultScene ? names.filter(n => n !== 'default') : names
110
+ }, [scenes, hideDefaultScene])
100
111
 
101
112
  const knownRoutes = useMemo(() =>
102
113
  Object.keys(pageModules)
@@ -176,6 +187,7 @@ export default function Viewfinder({ scenes = {}, pageModules = {}, basePath, ti
176
187
  <div className={showThumbnails ? styles.grid : styles.list}>
177
188
  {sceneNames.map((name) => {
178
189
  const meta = getSceneMeta(name)
190
+ const displayName = meta?.title || meta?.name || formatSceneName(name)
179
191
  return (
180
192
  <a key={name} href={resolveSceneRoute(name, knownRoutes)} className={showThumbnails ? styles.card : styles.listItem}>
181
193
  {showThumbnails && (
@@ -184,7 +196,7 @@ export default function Viewfinder({ scenes = {}, pageModules = {}, basePath, ti
184
196
  </div>
185
197
  )}
186
198
  <div className={styles.cardBody}>
187
- <p className={styles.sceneName}>{name}</p>
199
+ <p className={styles.sceneName}>{displayName}</p>
188
200
  {meta?.author && (() => {
189
201
  const authors = Array.isArray(meta.author) ? meta.author : [meta.author]
190
202
  return (