@vikejs/license-components 0.0.9 → 0.0.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LicenseSnippet.d.ts","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"LicenseSnippet.d.ts","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAmB3C,iBAAS,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,2CA4C3D"}
|
package/dist/LicenseSnippet.js
CHANGED
|
@@ -7,10 +7,17 @@ import { renderTokens } from './renderTokens.js';
|
|
|
7
7
|
// and license-components' `FreeTrialForm`, so the two surfaces are byte-identical (symlinked into
|
|
8
8
|
// `packages/license-components/src/` alongside snippet.ts / wire.ts / renderTokens.tsx).
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
10
|
+
// Rendered with plain <div>s, NOT <pre><code>, on purpose: vike.dev's docpress force-styles the
|
|
11
|
+
// `pre` and `code` *elements* through cascade layers that un-layered `!important` can't beat — `code`
|
|
12
|
+
// gets display:block + 16px padding on every side, and `pre` gets a 13px font-size. That capped the
|
|
13
|
+
// scrollable width at the viewport (clipping the diff highlight ~32px short of `code`'s edge) and
|
|
14
|
+
// pinned the font so it wouldn't inherit. Generic <div>s the host's selectors don't target dodge all
|
|
15
|
+
// of it: we own the padding (so every `.line`'s green spans the full SCROLL width) and the font-size
|
|
16
|
+
// (so it inherits the host prose) — identically on the dashboard and on vike.dev. CSS is injected as
|
|
17
|
+
// a scoped <style> (everything under `.license-snippet`) rather than a CSS import, because
|
|
18
|
+
// license-components is compiled by `tsc` (no CSS-import support); Vite (the dashboard) is fine with
|
|
19
|
+
// it too. `// pages/+config.js` + a blank line lead the block (context lines: `license: false`, not
|
|
20
|
+
// diff-highlighted, excluded from Copy) — mirrors vike.dev/license.
|
|
14
21
|
function LicenseSnippet({ license }) {
|
|
15
22
|
const [copied, setCopied] = useState(false);
|
|
16
23
|
const lines = [
|
|
@@ -33,7 +40,7 @@ function LicenseSnippet({ license }) {
|
|
|
33
40
|
// clipboard can reject (denied permission / insecure context) — leave the button unchanged.
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
|
-
return (_jsxs("div", { style: snippetWrapStyle, children: [_jsx("style", { children: SNIPPET_CSS }), _jsx("
|
|
43
|
+
return (_jsxs("div", { style: snippetWrapStyle, children: [_jsx("style", { children: SNIPPET_CSS }), _jsx("div", { className: "license-snippet", children: _jsx("div", { className: "license-snippet-code", children: lines.map((line, i) => (_jsx("div", { className: `line${line.license ? ' add' : ''}${line.text.startsWith('//') ? ' comment' : ''}`, children: line.text === '' ? ' ' : renderTokens(line.text) }, i))) }) }), _jsx("button", { type: "button", onClick: copy, style: copyButtonStyle, children: copied ? 'Copied' : 'Copy' })] }));
|
|
37
44
|
}
|
|
38
45
|
const snippetWrapStyle = { position: 'relative', margin: '8px 0' };
|
|
39
46
|
const copyButtonStyle = {
|
|
@@ -50,14 +57,14 @@ const copyButtonStyle = {
|
|
|
50
57
|
};
|
|
51
58
|
// github-light look (docpress's Shiki theme) without the dependency. `background:#f4f4f4` is solid
|
|
52
59
|
// (not docpress's rgba-on-white) so the block reads as a light code surface — dark text on light —
|
|
53
|
-
// on any host box tint or theme.
|
|
54
|
-
// to the widest line so every
|
|
55
|
-
//
|
|
56
|
-
//
|
|
60
|
+
// on any host box tint or theme. `.license-snippet` is the scroll viewport; the inner
|
|
61
|
+
// `.license-snippet-code` (`inline-block; min-width:100%`) shrink-wraps to the widest line so every
|
|
62
|
+
// `.line` (a block child) is exactly as wide, and its diff background spans the full SCROLL width
|
|
63
|
+
// (no ~32px right-edge gap, which a host-padded `<code>` produced). font-size inherits the host's
|
|
64
|
+
// prose — possible only because these are <div>s, not docpress-styled `pre`/`code`.
|
|
57
65
|
const SNIPPET_CSS = `
|
|
58
66
|
.license-snippet { margin: 0; border-radius: 6px; overflow-x: auto; background: #f4f4f4; font-size: inherit; line-height: 1.6; }
|
|
59
|
-
.license-snippet code {
|
|
60
|
-
.license-snippet .lines { display: inline-block; min-width: 100%; }
|
|
67
|
+
.license-snippet .license-snippet-code { display: inline-block; min-width: 100%; box-sizing: border-box; padding: 16px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; color: #24292e; }
|
|
61
68
|
.license-snippet .line { display: block; position: relative; padding: 0 16px; white-space: pre; }
|
|
62
69
|
.license-snippet .line.add { background: #d7ecdf; }
|
|
63
70
|
.license-snippet .line.add::before { content: '+'; position: absolute; top: -1px; left: 4px; color: #89d189; font-size: 1.2em; font-weight: 500; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LicenseSnippet.js","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,qGAAqG;AACrG,kGAAkG;AAClG,yFAAyF;AACzF,EAAE;AACF,gGAAgG;AAChG,
|
|
1
|
+
{"version":3,"file":"LicenseSnippet.js","sourceRoot":"","sources":["../src/LicenseSnippet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM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