@jsonresume/core 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonresume/core",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Framework-agnostic resume component core - design tokens, primitives, and validators",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -103,6 +103,26 @@ describe('renderResumeDocument', () => {
103
103
  expect(out).toContain('<body class="theme-foo">');
104
104
  });
105
105
 
106
+ it('places head before, and headAfterStyles after, the styled-components tags', () => {
107
+ const out = renderResumeDocument(<Box>Hi</Box>, {
108
+ head: '<style id="before">:root{--x:1}</style>',
109
+ headAfterStyles: '<style id="after">@page{margin:1cm}</style>',
110
+ });
111
+ const before = out.indexOf('id="before"');
112
+ const styled = out.indexOf('data-styled');
113
+ const after = out.indexOf('id="after"');
114
+ expect(before).toBeGreaterThan(-1);
115
+ expect(after).toBeGreaterThan(-1);
116
+ // cascade order: head -> styled-components -> headAfterStyles
117
+ expect(before).toBeLessThan(styled);
118
+ expect(styled).toBeLessThan(after);
119
+ });
120
+
121
+ it('omits headAfterStyles when not provided', () => {
122
+ const out = renderResumeDocument(<Box>Hi</Box>);
123
+ expect(out).not.toContain('id="after"');
124
+ });
125
+
106
126
  it('always seals the sheet — styles do not leak across calls', () => {
107
127
  // Two different styled components rendered in separate calls. If the sheet
108
128
  // were not sealed, the second document would carry the first's rules.
package/src/ssr/index.js CHANGED
@@ -96,7 +96,13 @@ export function googleFontsLinks(families) {
96
96
  * @param {string} [options.lang='en'] <html lang> attribute.
97
97
  * @param {string} [options.dir='ltr'] <html dir> attribute.
98
98
  * @param {boolean} [options.reset=false] Include the minimal CSS reset.
99
- * @param {string} [options.head=''] Extra raw HTML for the <head>.
99
+ * @param {string} [options.head=''] Raw HTML inserted in <head> BEFORE the
100
+ * styled-components tags (base styles a theme's components then override — e.g. a
101
+ * `:root` design-token block or a CSS reset).
102
+ * @param {string} [options.headAfterStyles=''] Raw HTML inserted in <head> AFTER the
103
+ * styled-components tags (styles that must OVERRIDE component styles — e.g. a global
104
+ * reset, body background, or `@media print`/`@page` rules). Composes with `head`:
105
+ * a theme can pass both to reproduce an inline-style block on each side.
100
106
  * @param {boolean} [options.includeTokensCss=true] Link @jsonresume/core tokens.
101
107
  * @param {string} [options.bodyClass] class attribute on <body>.
102
108
  * @returns {string} Full `<!DOCTYPE html>...` document.
@@ -109,6 +115,7 @@ export function renderResumeDocument(element, options = {}) {
109
115
  dir = 'ltr',
110
116
  reset = false,
111
117
  head = '',
118
+ headAfterStyles = '',
112
119
  includeTokensCss = true,
113
120
  bodyClass,
114
121
  } = options;
@@ -142,6 +149,7 @@ export function renderResumeDocument(element, options = {}) {
142
149
  resetTag +
143
150
  head +
144
151
  styleTags +
152
+ headAfterStyles +
145
153
  titleTag +
146
154
  '</head>' +
147
155
  `<body${bodyAttr}>${html}</body>` +