{#each rows as row, ri}
- {#each row as group, gi}
- {#each group as img, i}
- {#if img.caption}
-
- {@html marked(img.caption)}
-
- {/if}
- {/each}
+ {#each row as img, i}
+ {#if img.caption}
+
+ {@html marked(img.caption)}
+
+ {/if}
{/each}
{/each}
@@ -163,51 +134,33 @@
div.photopack-row {
display: flex;
justify-content: space-between;
- &.break {
- display: block;
- div.photopack-group {
- display: flex;
- justify-content: space-between;
- &.break {
- display: block;
- figure {
- display: block;
- max-height: unset;
- margin-bottom: var(--gap);
- }
- }
- }
- }
- div.photopack-group {
- display: contents;
- }
- }
-
- figure {
- flex: 1;
- margin: 0;
- padding: 0;
- img {
+ figure {
+ flex: 1;
margin: 0;
- width: 100%;
- height: 100%;
- object-fit: cover;
+ padding: 0;
+ img {
+ margin: 0;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
}
}
}
div.captions-container {
div.caption {
- margin: 0 0 0.5rem;
+ margin: 0 0 0.6rem;
&:last-of-type {
margin-bottom: 0;
}
:global(p) {
font-size: 0.85rem;
- line-height: 1.15rem;
+ line-height: 1.10rem;
font-family: var(--theme-font-family-note, $font-family-display);
color: var(--theme-colour-text-secondary, $tr-medium-grey);
margin: 0;
+ font-weight: 300;
}
}
}
diff --git a/src/components/PhotoPack/docProps.ts b/src/components/PhotoPack/docProps.ts
new file mode 100644
index 00000000..df843d13
--- /dev/null
+++ b/src/components/PhotoPack/docProps.ts
@@ -0,0 +1,44 @@
+import urlJoin from 'proper-url-join';
+
+interface BlockImage {
+ Src: string;
+ AltText: string;
+ Caption?: string;
+ MaxHeight?: string;
+}
+
+interface BlockLayout {
+ Breakpoint: string;
+ Rows: string;
+}
+
+interface Block {
+ Type: string;
+ ID?: string;
+ Class?: string;
+ Width: string;
+ CaptionWidth?: string;
+ Gap?: string;
+ Images: BlockImage[],
+ Layouts: BlockLayout[],
+}
+
+export const getPhotoPackPropsFromDoc = (docBlock: Block, assetsPath: string = '') => {
+ return {
+ id: docBlock.ID,
+ cls: docBlock.Class,
+ width: docBlock.Width,
+ captionWidth: docBlock.CaptionWidth,
+ gap: docBlock.Gap && isNaN(docBlock.Gap as any) ? null : parseInt(docBlock.Gap),
+ images: docBlock.Images.map((img) => ({
+ src: /^https?:\/\/|^\/\//i.test(img.Src) ? img.Src : urlJoin(assetsPath, img.Src),
+ altText: img.AltText,
+ caption: img.Caption,
+ maxHeight: img.MaxHeight && isNaN(img.MaxHeight as any) ? null : parseFloat(img.MaxHeight),
+ })),
+ layouts: docBlock.Layouts.map((layout) => ({
+ breakpoint: isNaN(layout.Breakpoint as any) ? null : parseFloat(layout.Breakpoint),
+ rows: layout.Rows.split(',').map(r => parseInt(r.trim())),
+ })),
+ };
+};
diff --git a/src/components/PhotoPack/stories/docs/component.md b/src/components/PhotoPack/stories/docs/component.md
index e3c8f315..2a34e327 100644
--- a/src/components/PhotoPack/stories/docs/component.md
+++ b/src/components/PhotoPack/stories/docs/component.md
@@ -1,11 +1,30 @@
-> **Coming soon!**
-
----
+The `PhotoPack` component makes simple photo grids with custom layouts at whatever breakpoint you need.
```svelte
-