@gramps-connect/story 0.1.3 → 0.3.0
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/README.md +51 -2
- package/dist/editor.js +3910 -0
- package/dist/editor.js.map +7 -0
- package/dist/embed.js +10 -10
- package/dist/player.js +80 -8
- package/dist/player.js.map +2 -2
- package/dist/types/editor/DateField.d.ts +12 -0
- package/dist/types/editor/PhotosField.d.ts +16 -0
- package/dist/types/editor/SlideList.d.ts +12 -0
- package/dist/types/editor/StoryEditor.d.ts +33 -0
- package/dist/types/editor/StoryTextField.d.ts +9 -0
- package/dist/types/editor/dates.d.ts +6 -0
- package/dist/types/editor/index.d.ts +8 -0
- package/dist/types/editor/model.d.ts +80 -0
- package/dist/types/editor/strings.d.ts +52 -0
- package/dist/types/player/StoryPlayer.d.ts +4 -1
- package/dist/types/player/strings.d.ts +2 -0
- package/package.json +21 -5
- package/src/editor/DateField.tsx +95 -0
- package/src/editor/PhotosField.tsx +134 -0
- package/src/editor/SlideList.tsx +54 -0
- package/src/editor/StoryEditor.tsx +423 -0
- package/src/editor/StoryTextField.tsx +61 -0
- package/src/editor/dates.ts +21 -0
- package/src/editor/index.ts +12 -0
- package/src/editor/model.ts +229 -0
- package/src/editor/strings.ts +106 -0
- package/src/player/StoryPlayer.tsx +71 -6
- package/src/player/strings.ts +7 -0
package/dist/player.js
CHANGED
|
@@ -459,7 +459,8 @@ var ENGLISH = {
|
|
|
459
459
|
historical: "Historical",
|
|
460
460
|
historicalMapYear: (year) => `Historical map, ${year}`,
|
|
461
461
|
noDateStandardMap: "No date here \u2014 standard map",
|
|
462
|
-
historicalYear: "Historical map year"
|
|
462
|
+
historicalYear: "Historical map year",
|
|
463
|
+
photoOf: (n, total) => `Photo ${n} of ${total}`
|
|
463
464
|
};
|
|
464
465
|
var TABLE = {
|
|
465
466
|
en: ENGLISH,
|
|
@@ -473,7 +474,8 @@ var TABLE = {
|
|
|
473
474
|
historical: "Historisch",
|
|
474
475
|
historicalMapYear: (year) => `Historische Karte, ${year}`,
|
|
475
476
|
noDateStandardMap: "Kein Datum hier \u2014 Standardkarte",
|
|
476
|
-
historicalYear: "Jahr der historischen Karte"
|
|
477
|
+
historicalYear: "Jahr der historischen Karte",
|
|
478
|
+
photoOf: (n, total) => `Foto ${n} von ${total}`
|
|
477
479
|
},
|
|
478
480
|
es: {
|
|
479
481
|
previous: "Anterior",
|
|
@@ -485,7 +487,8 @@ var TABLE = {
|
|
|
485
487
|
historical: "Hist\xF3rico",
|
|
486
488
|
historicalMapYear: (year) => `Mapa hist\xF3rico, ${year}`,
|
|
487
489
|
noDateStandardMap: "Sin fecha aqu\xED \u2014 mapa est\xE1ndar",
|
|
488
|
-
historicalYear: "A\xF1o del mapa hist\xF3rico"
|
|
490
|
+
historicalYear: "A\xF1o del mapa hist\xF3rico",
|
|
491
|
+
photoOf: (n, total) => `Foto ${n} de ${total}`
|
|
489
492
|
},
|
|
490
493
|
fr: {
|
|
491
494
|
previous: "Pr\xE9c\xE9dent",
|
|
@@ -497,7 +500,8 @@ var TABLE = {
|
|
|
497
500
|
historical: "Historique",
|
|
498
501
|
historicalMapYear: (year) => `Carte historique, ${year}`,
|
|
499
502
|
noDateStandardMap: "Pas de date ici \u2014 carte standard",
|
|
500
|
-
historicalYear: "Ann\xE9e de la carte historique"
|
|
503
|
+
historicalYear: "Ann\xE9e de la carte historique",
|
|
504
|
+
photoOf: (n, total) => `Photo ${n} sur ${total}`
|
|
501
505
|
},
|
|
502
506
|
nl: {
|
|
503
507
|
previous: "Vorige",
|
|
@@ -509,7 +513,8 @@ var TABLE = {
|
|
|
509
513
|
historical: "Historisch",
|
|
510
514
|
historicalMapYear: (year) => `Historische kaart, ${year}`,
|
|
511
515
|
noDateStandardMap: "Geen datum hier \u2014 standaardkaart",
|
|
512
|
-
historicalYear: "Jaar van de historische kaart"
|
|
516
|
+
historicalYear: "Jaar van de historische kaart",
|
|
517
|
+
photoOf: (n, total) => `Foto ${n} van ${total}`
|
|
513
518
|
}
|
|
514
519
|
};
|
|
515
520
|
function stringsFor(...languages) {
|
|
@@ -676,8 +681,45 @@ function SlidePhoto({ mediaKey, item, caption, credit, resolveMedia, colors }) {
|
|
|
676
681
|
(caption || credit) && /* @__PURE__ */ jsx4("figcaption", { style: { fontSize: 13, color: colors.muted }, children: [caption, credit && `\xA9 ${credit}`].filter(Boolean).join(" \xB7 ") })
|
|
677
682
|
] });
|
|
678
683
|
}
|
|
679
|
-
function
|
|
680
|
-
const
|
|
684
|
+
function PhotoThumb({ mediaKey, item, label, selected, onSelect, resolveMedia, colors }) {
|
|
685
|
+
const [src, setSrc] = useState3(null);
|
|
686
|
+
useEffect3(() => {
|
|
687
|
+
let cancelled = false;
|
|
688
|
+
resolveMedia(mediaKey, item).then((url) => {
|
|
689
|
+
if (!cancelled) setSrc(url);
|
|
690
|
+
}, () => {
|
|
691
|
+
});
|
|
692
|
+
return () => {
|
|
693
|
+
cancelled = true;
|
|
694
|
+
};
|
|
695
|
+
}, [mediaKey, item, resolveMedia]);
|
|
696
|
+
return /* @__PURE__ */ jsx4(
|
|
697
|
+
"button",
|
|
698
|
+
{
|
|
699
|
+
type: "button",
|
|
700
|
+
"aria-label": label,
|
|
701
|
+
title: label,
|
|
702
|
+
"aria-pressed": selected,
|
|
703
|
+
onClick: onSelect,
|
|
704
|
+
style: {
|
|
705
|
+
width: 44,
|
|
706
|
+
height: 44,
|
|
707
|
+
padding: 0,
|
|
708
|
+
borderRadius: 4,
|
|
709
|
+
overflow: "hidden",
|
|
710
|
+
cursor: "pointer",
|
|
711
|
+
border: `2px solid ${selected ? colors.mark : "transparent"}`,
|
|
712
|
+
background: colors.border,
|
|
713
|
+
opacity: selected ? 1 : 0.7
|
|
714
|
+
},
|
|
715
|
+
children: src && /* @__PURE__ */ jsx4("img", { src, alt: "", style: { width: "100%", height: "100%", objectFit: "cover", display: "block" } })
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
function SlideContent({ slide, story, resolveMedia, colors, strings }) {
|
|
720
|
+
const photos = (slide?.media ?? []).filter((m) => Object.prototype.hasOwnProperty.call(story.media, m.ref));
|
|
721
|
+
const [shown, setShown] = useState3(0);
|
|
722
|
+
const photo = photos[Math.min(shown, photos.length - 1)];
|
|
681
723
|
const eyebrow = [slide?.date?.text, slide?.place?.name].filter(Boolean).join(" \xB7 ");
|
|
682
724
|
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
683
725
|
photo && /* @__PURE__ */ jsx4(
|
|
@@ -691,6 +733,19 @@ function SlideContent({ slide, story, resolveMedia, colors }) {
|
|
|
691
733
|
colors
|
|
692
734
|
}
|
|
693
735
|
),
|
|
736
|
+
photos.length > 1 && /* @__PURE__ */ jsx4("div", { style: { display: "flex", gap: 6, flexWrap: "wrap", justifyContent: "center" }, children: photos.map((m, i) => /* @__PURE__ */ jsx4(
|
|
737
|
+
PhotoThumb,
|
|
738
|
+
{
|
|
739
|
+
mediaKey: m.ref,
|
|
740
|
+
item: story.media[m.ref],
|
|
741
|
+
label: strings.photoOf(i + 1, photos.length),
|
|
742
|
+
selected: photo === m,
|
|
743
|
+
onSelect: () => setShown(i),
|
|
744
|
+
resolveMedia,
|
|
745
|
+
colors
|
|
746
|
+
},
|
|
747
|
+
`${i}:${m.ref}`
|
|
748
|
+
)) }),
|
|
694
749
|
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: 4, alignItems: "center", maxWidth: 640, textAlign: "center" }, children: [
|
|
695
750
|
eyebrow && /* @__PURE__ */ jsx4("div", { dir: "auto", style: { fontSize: 14, color: colors.muted }, children: eyebrow }),
|
|
696
751
|
slide?.title && /* @__PURE__ */ jsx4("div", { dir: "auto", style: { fontSize: 20, fontWeight: 700, color: colors.text }, children: slide.title }),
|
|
@@ -757,6 +812,7 @@ function StoryPlayer({
|
|
|
757
812
|
onSlideChange,
|
|
758
813
|
renderMapModeControl,
|
|
759
814
|
brand,
|
|
815
|
+
actions,
|
|
760
816
|
initialSlide = 0
|
|
761
817
|
}) {
|
|
762
818
|
const colors = useMemo(() => ({ ...defaultColors(dark), ...colorOverrides }), [dark, colorOverrides]);
|
|
@@ -867,7 +923,7 @@ function StoryPlayer({
|
|
|
867
923
|
const item = Object.prototype.hasOwnProperty.call(story.media, key) ? story.media[key] : void 0;
|
|
868
924
|
return item ? resolveMedia(key, item) : Promise.resolve(null);
|
|
869
925
|
}, [story, resolveMedia]);
|
|
870
|
-
const content = /* @__PURE__ */ jsx4(SlideContent, { slide, story, resolveMedia, colors });
|
|
926
|
+
const content = /* @__PURE__ */ jsx4(SlideContent, { slide, story, resolveMedia, colors, strings }, slide?.id ?? index);
|
|
871
927
|
const timeline = showTimeline && /* @__PURE__ */ jsx4(TimelineStrip, { points: datedSlides, currentIndex: index, onSelect: setIndex, colors });
|
|
872
928
|
return /* @__PURE__ */ jsxs3(
|
|
873
929
|
"div",
|
|
@@ -938,6 +994,22 @@ function StoryPlayer({
|
|
|
938
994
|
children: /* @__PURE__ */ jsx4("div", { style: { pointerEvents: "auto" }, children: renderMapModeControl ? renderMapModeControl(modeControlProps) : /* @__PURE__ */ jsx4(MapModeControl, { ...modeControlProps, strings, colors }) })
|
|
939
995
|
}
|
|
940
996
|
),
|
|
997
|
+
actions && /* @__PURE__ */ jsx4(
|
|
998
|
+
"div",
|
|
999
|
+
{
|
|
1000
|
+
style: {
|
|
1001
|
+
position: "absolute",
|
|
1002
|
+
top: 0,
|
|
1003
|
+
right: onClose ? 60 : 12,
|
|
1004
|
+
height: BAR_HEIGHT,
|
|
1005
|
+
zIndex: 3,
|
|
1006
|
+
display: "flex",
|
|
1007
|
+
alignItems: "center",
|
|
1008
|
+
gap: 8
|
|
1009
|
+
},
|
|
1010
|
+
children: actions
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
941
1013
|
onClose && /* @__PURE__ */ jsx4(
|
|
942
1014
|
RoundButton,
|
|
943
1015
|
{
|