@gramps-connect/story 0.1.0 → 0.1.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.
@@ -42,6 +42,8 @@ export interface StoryPlayerProps {
42
42
  /** Replaces the built-in map-mode control, e.g. with one from the host's
43
43
  * own UI kit. */
44
44
  renderMapModeControl?: (props: MapModeControlProps) => ReactNode;
45
+ /** Shown before the title, e.g. ViewerBrand on a standalone page. */
46
+ brand?: ReactNode;
45
47
  initialSlide?: number;
46
48
  }
47
49
 
@@ -199,7 +201,7 @@ function NavArrows({ index, total, onPrev, onNext, variant, strings, colors }: {
199
201
 
200
202
  export function StoryPlayer({
201
203
  story, resolveMedia, dark = false, colors: colorOverrides, strings: stringOverrides, onClose,
202
- keyboard = true, onSlideChange, renderMapModeControl, initialSlide = 0,
204
+ keyboard = true, onSlideChange, renderMapModeControl, brand, initialSlide = 0,
203
205
  }: StoryPlayerProps) {
204
206
  const colors = useMemo(() => ({ ...defaultColors(dark), ...colorOverrides }), [dark, colorOverrides]);
205
207
  const strings = useMemo(
@@ -341,9 +343,10 @@ export function StoryPlayer({
341
343
  dir="auto"
342
344
  style={{
343
345
  position: "absolute", top: 0, left: 20, height: BAR_HEIGHT, maxWidth: "26%", zIndex: 3,
344
- display: "flex", alignItems: "center", fontWeight: 600,
346
+ display: "flex", alignItems: "center", gap: 10, fontWeight: 600,
345
347
  }}
346
348
  >
349
+ {brand && <span style={{ flex: "none", display: "flex" }}>{brand}</span>}
347
350
  <span style={{ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{story.title}</span>
348
351
  </div>
349
352
  {/* Centered on the whole bar, as a toolbar for the presentation; the
@@ -0,0 +1,51 @@
1
+ // The Gramps Connect Story Viewer's mark, linking to the viewer: for
2
+ // StoryPlayer's `brand` slot on standalone pages (the viewer site, a page
3
+ // a program writes around a story), so whoever is watching can find where
4
+ // it came from.
5
+ import type { CSSProperties } from "react";
6
+
7
+ export const VIEWER_NAME = "Gramps Connect Story Viewer";
8
+ export const VIEWER_URL = "https://dsblank.github.io/gramps-connect-stories/";
9
+
10
+ /** The Gramps Connect icon (app/public/favicon.svg): a three-box pedigree
11
+ * on a blue tile, which holds up on light and dark headers alike. */
12
+ export function ViewerIcon({ size = 24 }: { size?: number }) {
13
+ return (
14
+ <svg viewBox="0 0 64 64" width={size} height={size} aria-hidden="true" focusable="false">
15
+ <rect width="64" height="64" rx="15" fill="#1866ba" />
16
+ <g transform="translate(9.6 9.6) scale(0.7)">
17
+ <path d="M25 32h7M32 15v34M32 15h7M32 49h7" fill="none" stroke="#fff" strokeWidth="5" strokeLinecap="round" />
18
+ <g fill="#fff">
19
+ <rect x="1" y="24" width="24" height="16" rx="4" />
20
+ <rect x="39" y="7" width="24" height="16" rx="4" />
21
+ <rect x="39" y="41" width="24" height="16" rx="4" />
22
+ </g>
23
+ </g>
24
+ </svg>
25
+ );
26
+ }
27
+
28
+ export interface ViewerBrandProps {
29
+ /** Where the link goes; the viewer site by default. */
30
+ href?: string;
31
+ /** "_blank" (the default) opens it beside the story, not in its place. */
32
+ target?: string;
33
+ size?: number;
34
+ }
35
+
36
+ /** The icon, as a link to the viewer. */
37
+ export function ViewerBrand({ href = VIEWER_URL, target = "_blank", size = 24 }: ViewerBrandProps) {
38
+ const style: CSSProperties = { display: "flex", lineHeight: 0, borderRadius: 6 };
39
+ return (
40
+ <a
41
+ href={href}
42
+ target={target}
43
+ rel={target === "_blank" ? "noopener" : undefined}
44
+ title={VIEWER_NAME}
45
+ aria-label={VIEWER_NAME}
46
+ style={style}
47
+ >
48
+ <ViewerIcon size={size} />
49
+ </a>
50
+ );
51
+ }
@@ -1,4 +1,5 @@
1
1
  export { StoryPlayer, type StoryPlayerProps } from "./StoryPlayer";
2
+ export { VIEWER_NAME, VIEWER_URL, ViewerBrand, ViewerIcon, type ViewerBrandProps } from "./brand";
2
3
  export { MapModeControl, type MapMode, type MapModeControlProps } from "./MapModeControl";
3
4
  export { defaultColors, PIN_PATH_D, type PlayerColors } from "./theme";
4
5
  export { ENGLISH, PLAYER_LANGUAGES, stringsFor, type PlayerStrings } from "./strings";