@samva/markup 0.7.0 → 0.8.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.
Files changed (73) hide show
  1. package/AGENTS.md +14 -0
  2. package/dist/brand-DcoVkh_S.d.ts +88 -0
  3. package/dist/{catalog-60eaYC7b.d.ts → catalog-CKuOooB8.d.ts} +13 -15
  4. package/dist/{checks-DBweSIPN.js → checks-D73Xizbw.js} +414 -2
  5. package/dist/checks.js +1 -1
  6. package/dist/classes.d.ts +2 -3
  7. package/dist/compiler.d.ts +62 -45
  8. package/dist/compiler.js +179 -857
  9. package/dist/{corpus-BjYMqOoY.d.ts → corpus-CPPfgAHN.d.ts} +14 -14
  10. package/dist/{css-COcFOT1y.d.ts → css-CS2jLID6.d.ts} +28 -2
  11. package/dist/email/assets.d.ts +40 -0
  12. package/dist/email/assets.js +63 -0
  13. package/dist/email/brand-footer.d.ts +34 -0
  14. package/dist/email/brand-footer.js +62 -0
  15. package/dist/email/brand.d.ts +2 -0
  16. package/dist/email/brand.js +148 -0
  17. package/dist/email/html.d.ts +2 -42
  18. package/dist/email/html.js +11 -0
  19. package/dist/email/render.d.ts +12 -5
  20. package/dist/email/render.js +2 -5
  21. package/dist/email/selection.d.ts +2 -91
  22. package/dist/email/stylesheets.d.ts +1 -1
  23. package/dist/email/stylesheets.js +3 -0
  24. package/dist/html-Bl9BAdqc.d.ts +42 -0
  25. package/dist/{ops-2aiiYO7m.js → ops-BvwqHl7V.js} +2 -2
  26. package/dist/ops.js +1 -1
  27. package/dist/registry-Dcp6QEK_.d.ts +73 -0
  28. package/dist/registry.d.ts +2 -42
  29. package/dist/{render-aaJBnsXK.js → render-vAv_4r9v.js} +174 -17
  30. package/dist/selection-CCArx9lU.d.ts +91 -0
  31. package/dist/{showcase-DGZAWn4Z.d.ts → showcase-egkusQBf.d.ts} +15 -56
  32. package/dist/{presets → starters}/category-mapping.d.ts +5 -5
  33. package/dist/{presets → starters}/category-mapping.js +5 -5
  34. package/dist/starters/corpus.d.ts +2 -0
  35. package/dist/{presets → starters}/corpus.js +15 -15
  36. package/dist/starters/library.d.ts +18 -0
  37. package/dist/starters/library.js +692 -0
  38. package/dist/{presets → starters}/public-gallery.d.ts +47 -47
  39. package/dist/{presets → starters}/public-gallery.js +92 -92
  40. package/dist/{presets → starters}/public-handoff.d.ts +14 -14
  41. package/dist/{presets → starters}/public-handoff.js +40 -40
  42. package/dist/{presets → starters}/public-preview-artifacts.d.ts +4 -4
  43. package/dist/{presets → starters}/public-preview-artifacts.js +15 -15
  44. package/dist/{presets → starters}/public-preview.d.ts +1 -1
  45. package/dist/{presets → starters}/public-preview.js +3 -3
  46. package/dist/starters/showcase.d.ts +2 -0
  47. package/dist/starters/showcase.js +335 -0
  48. package/dist/starters/sources.d.ts +45 -0
  49. package/dist/{presets → starters}/sources.js +1951 -272
  50. package/dist/starters/theme.d.ts +45 -0
  51. package/dist/starters/theme.js +77 -0
  52. package/dist/starters.d.ts +2 -0
  53. package/dist/{presets.js → starters.js} +4 -11
  54. package/dist/tailwind-BYq7Lo6u.js +727 -0
  55. package/dist/theme-css-hFqcPSar.js +587 -0
  56. package/dist/theme-css.d.ts +56 -15
  57. package/dist/theme-css.js +2 -509
  58. package/dist/tsx-tracer.js +1 -1
  59. package/dist/unsubscribe-link-CoesnQDU.js +26 -0
  60. package/package.json +53 -41
  61. package/samva-brand.d.ts +14 -0
  62. package/dist/footer.d.ts +0 -66
  63. package/dist/footer.js +0 -93
  64. package/dist/presets/corpus.d.ts +0 -2
  65. package/dist/presets/showcase.d.ts +0 -2
  66. package/dist/presets/showcase.js +0 -627
  67. package/dist/presets/sources.d.ts +0 -38
  68. package/dist/presets.d.ts +0 -2
  69. package/dist/theme-6ApjjiBo.d.ts +0 -116
  70. package/dist/theme.d.ts +0 -2
  71. package/dist/theme.js +0 -118
  72. package/dist/tokens.d.ts +0 -6
  73. package/dist/tokens.js +0 -417
@@ -0,0 +1,45 @@
1
+ import { BrandCss } from "../theme-css.js";
2
+ //#region starters/theme.d.ts
3
+ /**
4
+ * The theme variables every starter defines and a brand sets to restyle one.
5
+ * Each color also has a dark-mode counterpart named `<name>-dark`, which is
6
+ * what a brand's dark-mode `@theme` lowers to.
7
+ */
8
+ declare const STARTER_THEME_VARIABLES: {
9
+ readonly "--color-brand": "The primary color: buttons and the main call to action.";
10
+ readonly "--color-brand-foreground": "Text on the primary color.";
11
+ readonly "--color-accent": "The secondary color: eyebrows, labels, links and highlights.";
12
+ readonly "--color-surface": "The content card.";
13
+ readonly "--font-heading": "Headings.";
14
+ readonly "--font-body": "Body text.";
15
+ readonly "--radius-button": "Button corners.";
16
+ readonly "--radius-card": "The content card's corners.";
17
+ };
18
+ type StarterThemeVariable = keyof typeof STARTER_THEME_VARIABLES;
19
+ /** Every name a starter's `starter.css` defines: the vocabulary plus each color's `-dark` pair. */
20
+ declare const starterThemeVariableNames: ReadonlyArray<string>;
21
+ /**
22
+ * The `theme.css` a project created from a starter begins with: the starter's
23
+ * look, then the organization's default brand when the creator chose it, then
24
+ * an empty `@theme` for the project's own overrides.
25
+ */
26
+ declare const starterThemeCss: (options: {
27
+ readonly brand: boolean;
28
+ }) => string;
29
+ /**
30
+ * The brand a starter's brand preview is compiled against: one marker value
31
+ * per vocabulary name, dark colors in the dark-mode `@theme`.
32
+ */
33
+ declare const STARTER_PREVIEW_BRAND: {
34
+ readonly slug: "samva-starter-preview";
35
+ readonly css: string;
36
+ };
37
+ /**
38
+ * Re-brand a starter's preview, rendered against `STARTER_PREVIEW_BRAND`, with
39
+ * `brand`: each name takes the value the brand compiles to
40
+ * (`brandThemeVariables`), or the starter's own where the brand sets none. The brand's font faces join the document head.
41
+ */
42
+ declare const brandStarterPreview: (previewHtml: string, starterVariables: Readonly<Record<string, string>>, brand: BrandCss) => string;
43
+ //#endregion
44
+ export { STARTER_PREVIEW_BRAND, STARTER_THEME_VARIABLES, StarterThemeVariable, brandStarterPreview, starterThemeCss, starterThemeVariableNames };
45
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1,77 @@
1
+ import { escapeAttribute } from "../email/html.js";
2
+ import { a as brandThemeVariables, l as printBrandCss, s as darkVariableName } from "../theme-css-hFqcPSar.js";
3
+ //#region starters/theme.ts
4
+ /**
5
+ * The theme variables every starter defines and a brand sets to restyle one.
6
+ * Each color also has a dark-mode counterpart named `<name>-dark`, which is
7
+ * what a brand's dark-mode `@theme` lowers to.
8
+ */
9
+ const STARTER_THEME_VARIABLES = {
10
+ "--color-brand": "The primary color: buttons and the main call to action.",
11
+ "--color-brand-foreground": "Text on the primary color.",
12
+ "--color-accent": "The secondary color: eyebrows, labels, links and highlights.",
13
+ "--color-surface": "The content card.",
14
+ "--font-heading": "Headings.",
15
+ "--font-body": "Body text.",
16
+ "--radius-button": "Button corners.",
17
+ "--radius-card": "The content card's corners."
18
+ };
19
+ /** Every name a starter's `starter.css` defines: the vocabulary plus each color's `-dark` pair. */
20
+ const starterThemeVariableNames = Object.keys(STARTER_THEME_VARIABLES).flatMap((name) => name.startsWith("--color-") ? [name, darkVariableName(name)] : [name]);
21
+ /**
22
+ * The `theme.css` a project created from a starter begins with: the starter's
23
+ * look, then the organization's default brand when the creator chose it, then
24
+ * an empty `@theme` for the project's own overrides.
25
+ */
26
+ const starterThemeCss = (options) => [
27
+ "@import \"./starter.css\";",
28
+ ...options.brand ? ["@import \"samva:brand\";"] : [],
29
+ "@theme {}",
30
+ ""
31
+ ].join("\n");
32
+ const markerColor = (index) => `#5a${(57344 + index).toString(16)}`;
33
+ /** Each vocabulary name's marker value in the preview brand. */
34
+ const PREVIEW_MARKERS = Object.fromEntries(starterThemeVariableNames.map((name, index) => {
35
+ if (name.startsWith("--color-")) return [name, markerColor(index)];
36
+ if (name.startsWith("--font-")) return [name, `samva-preview${name.slice(1)}, sans-serif`];
37
+ return [name, `${(1731 + index) / 100}px`];
38
+ }));
39
+ const lightMarkers = () => Object.fromEntries(Object.entries(PREVIEW_MARKERS).filter(([name]) => !name.endsWith("-dark")));
40
+ /**
41
+ * The brand a starter's brand preview is compiled against: one marker value
42
+ * per vocabulary name, dark colors in the dark-mode `@theme`.
43
+ */
44
+ const STARTER_PREVIEW_BRAND = {
45
+ slug: "samva-starter-preview",
46
+ css: printBrandCss({
47
+ variables: lightMarkers(),
48
+ dark: Object.fromEntries(Object.entries(lightMarkers()).filter(([name]) => name.startsWith("--color-")).map(([name]) => [name, PREVIEW_MARKERS[darkVariableName(name)]])),
49
+ fontFaces: []
50
+ })
51
+ };
52
+ const replaceOutsideStyles = (html, replace) => html.split(/(<style[^>]*>[\s\S]*?<\/style>)/).map((segment) => segment.startsWith("<style") ? replace(segment, (value) => value) : replace(segment, escapeAttribute)).join("");
53
+ /**
54
+ * Re-brand a starter's preview, rendered against `STARTER_PREVIEW_BRAND`, with
55
+ * `brand`: each name takes the value the brand compiles to
56
+ * (`brandThemeVariables`), or the starter's own where the brand sets none. The brand's font faces join the document head.
57
+ */
58
+ const brandStarterPreview = (previewHtml, starterVariables, brand) => {
59
+ const brandVariables = brandThemeVariables(brand);
60
+ const values = Object.entries(PREVIEW_MARKERS).map(([name, marker]) => {
61
+ const value = brandVariables[name] ?? starterVariables[name];
62
+ if (value === void 0) throw new TypeError(`The starter defines no ${name}.`);
63
+ return [marker, value];
64
+ });
65
+ const rebranded = replaceOutsideStyles(previewHtml, (segment, escape) => values.reduce((text, [marker, value]) => text.replaceAll(escape(marker), escape(value)), segment));
66
+ if (brand.fontFaces.length === 0) return rebranded;
67
+ const faces = printBrandCss({
68
+ variables: {},
69
+ dark: {},
70
+ fontFaces: brand.fontFaces
71
+ });
72
+ return rebranded.replace("</head>", `<style>${faces}</style></head>`);
73
+ };
74
+ //#endregion
75
+ export { STARTER_PREVIEW_BRAND, STARTER_THEME_VARIABLES, brandStarterPreview, starterThemeCss, starterThemeVariableNames };
76
+
77
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1,2 @@
1
+ import { a as StarterMeta, i as StarterId, n as EmailStarterVariable, o as StarterVariable, r as StarterCategory, s as starterCatalog, t as EmailStarterId } from "./catalog-CKuOooB8.js";
2
+ export { EmailStarterId, EmailStarterVariable, StarterCategory, StarterId, StarterMeta, StarterVariable, starterCatalog };
@@ -1,12 +1,5 @@
1
- //#region presets/catalog.ts
2
- const RECOMMENDED_THEME = {
3
- colors: {
4
- brand: "#4f46e5",
5
- "brand-foreground": "#ffffff"
6
- },
7
- radiusPx: { brand: 8 }
8
- };
9
- const presetCatalog = [
1
+ //#region starters/catalog.ts
2
+ const starterCatalog = [
10
3
  {
11
4
  id: "linear-login-code",
12
5
  channel: "email",
@@ -876,6 +869,6 @@ const presetCatalog = [
876
869
  }
877
870
  ];
878
871
  //#endregion
879
- export { RECOMMENDED_THEME, presetCatalog };
872
+ export { starterCatalog };
880
873
 
881
- //# sourceMappingURL=presets.js.map
874
+ //# sourceMappingURL=starters.js.map