scavold 0.2.0-rc.11 → 0.2.0-rc.12

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/CHANGELOG.md CHANGED
@@ -9,6 +9,15 @@ changes may occur in any release.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.2.0-rc.12] — 2026-10-03
13
+
14
+ ### Added
15
+
16
+ - `:::cover` takes `tone=light` or `tone=dark` for content on top that is meant to be
17
+ light or dark, depending on the picture. It only marks the cover with
18
+ `scavold-cover--light` or `scavold-cover--dark`; the colours are the theme's. The
19
+ editor offers it as a choice.
20
+
12
21
  ## [0.2.0-rc.11] — 2026-10-01
13
22
 
14
23
  ### Added
@@ -334,7 +343,8 @@ First published release. Version `0.1.0` existed in-tree only.
334
343
  - Only images are processed out of `media_folder`; other file types (video, documents)
335
344
  are never copied into the build output and have to live in the static folder.
336
345
 
337
- [Unreleased]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.11...main
346
+ [Unreleased]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.12...main
347
+ [0.2.0-rc.12]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.11...v0.2.0-rc.12
338
348
  [0.2.0-rc.11]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.10...v0.2.0-rc.11
339
349
  [0.2.0-rc.10]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.9...v0.2.0-rc.10
340
350
  [0.2.0-rc.9]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.8...v0.2.0-rc.9
package/COMPONENTS.md CHANGED
@@ -451,12 +451,13 @@ the window, cropped to fit — a cover, or hero, at the top of a page. Written a
451
451
  | `poster` | `media-file` | — | Only for a video: still image shown until it plays, and instead of playing for visitors who asked for reduced motion. |
452
452
  | `focus` | `string` | `50% 50%` | Part of the picture kept visible when the window crops it, as a CSS `object-position` — `center top`, `30% 60%`. |
453
453
  | `label` | `string` | — | Alternative text of an image, accessible label of a video. Left out, the picture is treated as decoration. |
454
+ | `tone` | `"light" \| "dark"` | — | Whether the content on top is meant to be light (over a dark picture) or dark (over a bright one). Only marks the cover with `scavold-cover--light` or `scavold-cover--dark`; what that looks like is the theme's. Left out, or with any other value, the cover carries neither class. |
454
455
 
455
456
  #### Rendered markup
456
457
 
457
458
  ```html
458
- <!-- image -->
459
- <div class="scavold-cover" style="--scavold-cover-focus: center top">
459
+ <!-- image, tone=light -->
460
+ <div class="scavold-cover scavold-cover--light" style="--scavold-cover-focus: center top">
460
461
  <picture class="scavold-cover__media">
461
462
  <source type="image/webp" srcset="..." sizes="(min-aspect-ratio: 2400/1350) 100vw, 177.78vh" />
462
463
  <source srcset="..." sizes="..." />
@@ -504,6 +505,15 @@ html { overflow-x: clip; }
504
505
  The overlay is an empty grid cell over the picture; position its content, add a scrim
505
506
  for legibility and restyle `.scavold-cover__toggle` as the design asks.
506
507
 
508
+ The `tone` an author picked is the theme's to honour. Scavold sets no colour for it;
509
+ a theme gives each tone the colours of its design, including headings and links its
510
+ prose styles colour on their own:
511
+
512
+ ```css
513
+ .scavold-cover--light .scavold-cover__overlay { color: #fff; }
514
+ .scavold-cover--dark .scavold-cover__overlay { color: #000; }
515
+ ```
516
+
507
517
  #### A cover opening the page
508
518
 
509
519
  Where the theme's own parts go around a cover is the theme's choice; Scavold places
@@ -926,12 +936,13 @@ renders the same picture the way its design asks:
926
936
 
927
937
  ```js
928
938
  const props = defineProps( { ...coverProps } );
929
- const { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label } = useCover( props );
939
+ const { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label, tone } = useCover( props );
930
940
  ```
931
941
 
932
942
  `srcset`, `webpSrcset` and `sizes` are filled for an image only; the build provides
933
- the variants and the dimensions `sizes` is derived from. `isVideoUrl( url )` and
934
- `coverSizes( width, height )` are exported as well.
943
+ the variants and the dimensions `sizes` is derived from. `tone` is `"light"`, `"dark"`
944
+ or empty, one of `COVER_TONES`. `isVideoUrl( url )` and `coverSizes( width, height )`
945
+ are exported as well.
935
946
 
936
947
  ---
937
948
 
@@ -7,7 +7,7 @@ import ScavoldImage from "./ScavoldImage.vue";
7
7
 
8
8
  const props = defineProps( coverProps );
9
9
 
10
- const { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label } = useCover( props );
10
+ const { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label, tone } = useCover( props );
11
11
 
12
12
  const { t } = useScavoldI18n();
13
13
  const playLabel = t( "cover.play" );
@@ -46,7 +46,7 @@ function toggle() {
46
46
  <div
47
47
  v-if="src"
48
48
  class="scavold-cover"
49
- :class="{ 'scavold-cover--video': isVideo }"
49
+ :class="[ { 'scavold-cover--video': isVideo }, tone && `scavold-cover--${tone}` ]"
50
50
  :style="style"
51
51
  >
52
52
  <video
@@ -39,8 +39,17 @@ export const coverProps = {
39
39
 
40
40
  /** Alternative text of an image, accessible label of a video. */
41
41
  dataLabel: { type: String, default: "" },
42
+
43
+ /** Whether the content on top is meant to be light or dark, see COVER_TONES. */
44
+ dataTone: { type: String, default: "" },
42
45
  };
43
46
 
47
+ /**
48
+ * Tones an author may ask the content on top of a cover to take. The cover only
49
+ * marks its choice; the theme decides what light or dark content looks like.
50
+ */
51
+ export const COVER_TONES = [ "light", "dark" ];
52
+
44
53
  /**
45
54
  * Tells whether a URL names a video by its file extension.
46
55
  *
@@ -91,9 +100,10 @@ export function coverSizes( width, height ) {
91
100
  * - `poster` — still image of a video, or empty string
92
101
  * - `focus` — CSS `object-position` value, or empty string
93
102
  * - `label` — alternative text or accessible label, or empty string
103
+ * - `tone` — `"light"` or `"dark"` for the content on top, or empty string
94
104
  *
95
105
  * @param {object} props reactive props from defineProps
96
- * @returns {{ src, isVideo, srcset, webpSrcset, sizes, poster, focus, label }}
106
+ * @returns {{ src, isVideo, srcset, webpSrcset, sizes, poster, focus, label, tone }}
97
107
  */
98
108
  export function useCover( props ) {
99
109
  const src = computed( () => props.dataSrc ?? "" );
@@ -107,5 +117,12 @@ export function useCover( props ) {
107
117
  const focus = computed( () => props.dataFocus ?? "" );
108
118
  const label = computed( () => props.dataLabel ?? "" );
109
119
 
110
- return { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label };
120
+ // Anything but a known tone leaves the choice to the theme.
121
+ const tone = computed( () => {
122
+ const value = String( props.dataTone ?? "" ).trim().toLowerCase();
123
+
124
+ return COVER_TONES.includes( value ) ? value : "";
125
+ } );
126
+
127
+ return { src, isVideo, srcset, webpSrcset, sizes, poster, focus, label, tone };
111
128
  }
@@ -88,6 +88,12 @@ export const BUILTIN_SECTIONS = {
88
88
  label: "Description",
89
89
  hint: "Alternative text of the image, or what the video shows. Leave empty when it is decoration only.",
90
90
  },
91
+ tone: {
92
+ type: "enum",
93
+ label: "Content on top",
94
+ values: [ "light", "dark" ],
95
+ hint: "\"light\" over a dark picture, \"dark\" over a bright one. Left unset, the site's design decides.",
96
+ },
91
97
  },
92
98
  },
93
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scavold",
3
- "version": "0.2.0-rc.11",
3
+ "version": "0.2.0-rc.12",
4
4
  "type": "module",
5
5
  "description": "VitePress theme framework — a scaffold for building custom VitePress themes with Vue at the core",
6
6
  "keywords": [
@@ -297,7 +297,7 @@ const covers = cover.split( /<div class="scavold-cover[ "]/ ).slice( 1 );
297
297
  const [ coverImage = "", coverVideo = "" ] = covers;
298
298
 
299
299
  expect( covers.length === 2, "renders both covers of the page", `found ${covers.length}` );
300
- expect( /<div class="scavold-cover"[^>]*\sdata-leading[\s=>]/.test( cover ) && cover.match( /\sdata-leading[\s=>]/g )?.length === 1,
300
+ expect( /<div class="scavold-cover[ "][^>]*\sdata-leading[\s=>]/.test( cover ) && cover.match( /\sdata-leading[\s=>]/g )?.length === 1,
301
301
  "marks the cover opening the page, and only that one" );
302
302
  expect( cover.includes( '<main data-leading-container="cover">' ),
303
303
  "tells the layout before the content renders that the page opens with a cover" );
@@ -321,6 +321,9 @@ expect( /class="scavold-cover__overlay"[^>]*>\s*(?:<!--\[-->)?\s*<h1[^>]*>Over t
321
321
  const coverVideoTag = tags( coverVideo, "video" )[0] ?? "";
322
322
 
323
323
  expect( coverVideo.startsWith( "scavold-cover--video" ), "tells a video cover by its file type" );
324
+ // A mark for the theme to style, nothing more.
325
+ expect( /^scavold-cover--light"/.test( coverImage ), "marks the tone asked for the content on top" );
326
+ expect( !/scavold-cover--(light|dark)/.test( coverVideo ), "marks no tone where none is asked for" );
324
327
  expect( !cover.includes( "data-poster-srcset" ), "keeps the variants of a still image out of the markup" );
325
328
  expect( /src="\/media\/clip\.mp4"/.test( coverVideoTag ) && /poster="\/media\/wide--\d+w-[0-9a-f]+\.jpg"/.test( coverVideoTag ),
326
329
  "resolves a cover video and its still image to their published URLs" );