@commonpub/layer 0.21.17 → 0.21.19

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.
@@ -4,22 +4,53 @@ const props = defineProps<{ content: Record<string, unknown> }>();
4
4
  const src = computed(() => (props.content.src as string) || (props.content.url as string) || '');
5
5
  const alt = computed(() => (props.content.alt as string) || '');
6
6
  const caption = computed(() => (props.content.caption as string) || '');
7
+
8
+ /**
9
+ * Rendered-width preset. New uploads (editor ≥ 0.7.11) carry `size` on
10
+ * the BlockTuple content; pre-picker content (no `size` field) falls
11
+ * back to `l` to preserve its pre-0.21.19 visual width — that's the
12
+ * 760px cap from layer 0.21.18.
13
+ */
14
+ type ImageSize = 's' | 'm' | 'l' | 'full';
15
+ const size = computed<ImageSize>(() => {
16
+ const v = props.content.size;
17
+ return v === 's' || v === 'm' || v === 'l' || v === 'full' ? v : 'l';
18
+ });
7
19
  </script>
8
20
 
9
21
  <template>
10
- <figure v-if="src" class="cpub-block-image">
22
+ <figure v-if="src" class="cpub-block-image" :class="`cpub-image-size-${size}`">
11
23
  <img :src="src" :alt="alt" class="cpub-image-img" loading="lazy" />
12
24
  <figcaption v-if="caption" class="cpub-image-caption">{{ caption }}</figcaption>
13
25
  </figure>
14
26
  </template>
15
27
 
16
28
  <style scoped>
29
+ /**
30
+ * Width preset is applied via a class on the <figure> wrapper. The image
31
+ * itself is `width: 100%` of the wrapper, so capping the wrapper's
32
+ * max-width caps the image. `margin-inline: auto` centers when narrower
33
+ * than the available column. The caption sits underneath at the wrapper's
34
+ * width so it never extends past the image.
35
+ *
36
+ * Aspect ratio is preserved via the image's intrinsic ratio + `height:
37
+ * auto`. The .cpub-prose :deep(img) cap in ProjectView.vue still applies
38
+ * but at 760px — these per-block presets stay within that envelope (the
39
+ * 760-cap in ProjectView is the fallback when no per-block size is set).
40
+ */
17
41
  .cpub-block-image {
18
- margin: 24px 0;
42
+ margin: 24px auto;
43
+ display: block;
19
44
  }
20
45
 
46
+ .cpub-image-size-s { max-width: 320px; }
47
+ .cpub-image-size-m { max-width: 540px; }
48
+ .cpub-image-size-l { max-width: 760px; }
49
+ .cpub-image-size-full { max-width: 100%; }
50
+
21
51
  .cpub-image-img {
22
52
  width: 100%;
53
+ height: auto;
23
54
  display: block;
24
55
  border: var(--border-width-default) solid var(--border);
25
56
  }
@@ -713,7 +713,10 @@ async function handleBuild(): Promise<void> {
713
713
  .cpub-page-outer {
714
714
  max-width: 1160px;
715
715
  margin: 0 auto;
716
- padding: 0 clamp(12px, 3vw, 32px);
716
+ /* A smidge more breathing room at all widths: min 20 (was 12),
717
+ max 40 (was 32). Keeps content from hugging the viewport edge
718
+ on mid-size screens. */
719
+ padding: 0 clamp(20px, 3.5vw, 40px);
717
720
  }
718
721
 
719
722
  /* ── BREADCRUMB ── */
@@ -989,9 +992,16 @@ async function handleBuild(): Promise<void> {
989
992
  overflow-wrap: break-word;
990
993
  }
991
994
 
992
- /* ── COVER PHOTO (in-body) ── */
995
+ /* ── COVER PHOTO (in-body) ──
996
+ * The in-body featured image. Lives OUTSIDE .cpub-prose, so the
997
+ * `.cpub-prose img` cap doesn't reach it. Cap here at 880px (a touch
998
+ * wider than the 'l' preset for body images, since this is the hero
999
+ * featured image) and center. Pre-0.21.19 this was unbounded `width:
1000
+ * 100%` and grew to whatever the content column was — too big on wide
1001
+ * layouts. */
993
1002
  .cpub-cover-photo {
994
- margin-bottom: 24px;
1003
+ margin: 0 auto 24px;
1004
+ max-width: 880px;
995
1005
  }
996
1006
 
997
1007
  .cpub-cover-photo-img {
@@ -1010,13 +1020,30 @@ async function handleBuild(): Promise<void> {
1010
1020
  word-break: break-word;
1011
1021
  }
1012
1022
 
1013
- /* Prevent images and media from overflowing prose */
1023
+ /* Prevent images and media from overflowing prose, AND cap them at a
1024
+ reading-friendly size in wide content columns. Without this cap, body
1025
+ images blew up to 900px+ once the right sidebar was made optional in
1026
+ 0.21.16 (the content column got wider when no BOM/community). 760px
1027
+ for images matches what photographers + technical-writing layouts
1028
+ converge on; videos/iframes get a touch more (880px) for visibility.
1029
+ Cover photo lives OUTSIDE .cpub-prose so it still goes full-width. */
1014
1030
  .cpub-prose :deep(img),
1015
1031
  .cpub-prose :deep(video),
1016
1032
  .cpub-prose :deep(iframe) {
1017
1033
  max-width: 100%;
1018
1034
  height: auto;
1019
1035
  }
1036
+ .cpub-prose :deep(img) {
1037
+ max-width: min(100%, 760px);
1038
+ margin-inline: auto;
1039
+ display: block;
1040
+ }
1041
+ .cpub-prose :deep(video),
1042
+ .cpub-prose :deep(iframe) {
1043
+ max-width: min(100%, 880px);
1044
+ margin-inline: auto;
1045
+ display: block;
1046
+ }
1020
1047
 
1021
1048
  /* Code blocks scroll horizontally instead of overflowing */
1022
1049
  .cpub-prose :deep(pre) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonpub/layer",
3
- "version": "0.21.17",
3
+ "version": "0.21.19",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "files": [
@@ -50,16 +50,16 @@
50
50
  "vue": "^3.4.0",
51
51
  "vue-router": "^4.3.0",
52
52
  "zod": "^4.3.6",
53
- "@commonpub/auth": "0.6.0",
54
- "@commonpub/learning": "0.5.2",
55
53
  "@commonpub/config": "0.13.0",
56
- "@commonpub/explainer": "0.7.15",
57
54
  "@commonpub/docs": "0.6.3",
58
- "@commonpub/editor": "0.7.10",
55
+ "@commonpub/editor": "0.7.11",
56
+ "@commonpub/protocol": "0.12.0",
59
57
  "@commonpub/schema": "0.16.0",
60
58
  "@commonpub/server": "2.55.0",
61
- "@commonpub/protocol": "0.12.0",
62
- "@commonpub/ui": "0.8.5"
59
+ "@commonpub/ui": "0.8.5",
60
+ "@commonpub/auth": "0.6.0",
61
+ "@commonpub/learning": "0.5.2",
62
+ "@commonpub/explainer": "0.7.15"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@testing-library/jest-dom": "^6.9.1",