diff --git a/samples/js/photos/src/main.js b/samples/js/photos/src/main.js index 2a62bc818f..7a5405130f 100644 --- a/samples/js/photos/src/main.js +++ b/samples/js/photos/src/main.js @@ -37,7 +37,7 @@ async function getRenderElement(nav: Nav): Promise> { const indexStr = params.get('index'); if (!indexStr) { - return
Must provide an ?index= param.
; + return
Must provide the {notice('?index=')} parameter.
; } let index = indexMap.get(indexStr); @@ -46,12 +46,21 @@ async function getRenderElement(nav: Nav): Promise> { try { indexSpec = PathSpec.parse(indexStr); } catch (e) { - return
{indexStr} is not a valid path. {e.message}.
; + return
{notice(indexStr)} is not a valid path: {notice(e.message)}.
; } const [, indexValue] = await indexSpec.value(); if (!(indexValue instanceof Struct)) { - return
{indexStr} is not a valid index.
; + return
{notice(indexStr)} not found.
; + } + + if (!indexValue.byDate || !indexValue.byFace || !indexValue.byTag || + !indexValue.facesByCount || !indexValue.tagsByCount) { + if (indexStr.endsWith('.value')) { + return {notice(indexStr)} is not a photo index.; + } + return {notice(indexStr)} doesn't look like a photo index, did you leave out  + {notice('.value')}? Try me.; } // $FlowIssue: can't check instanceof PhotoIndex because it's only a type. @@ -77,4 +86,10 @@ async function getRenderElement(nav: Nav): Promise> { />; } +function notice(text: string) { + return {text}; +} + main(); diff --git a/samples/js/photos/src/nav.js b/samples/js/photos/src/nav.js index 33e13da2e4..be6c38f4d3 100644 --- a/samples/js/photos/src/nav.js +++ b/samples/js/photos/src/nav.js @@ -71,6 +71,6 @@ export default class Nav { } e.preventDefault(); - this.push(anchor.pathname); + this.push(anchor.pathname + anchor.search); } } diff --git a/samples/js/photos/styles.css b/samples/js/photos/styles.css index 2a1474c86f..645b43bff6 100644 --- a/samples/js/photos/styles.css +++ b/samples/js/photos/styles.css @@ -10,10 +10,6 @@ body { overflow-y: scroll; } -b { - font-weight: 600; -} - @keyframes fadeIn { 0% { opacity: 0;