codepen-demokit 0.0.0-stage → 1.0.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.
- package/README.md +229 -2
- package/bin/cli.mjs +154 -0
- package/lib/build-json.mjs +439 -0
- package/lib/build-site.mjs +193 -0
- package/lib/config.mjs +245 -0
- package/lib/init.mjs +651 -0
- package/lib/serve.mjs +369 -0
- package/lib/sync-codepen.mjs +1326 -0
- package/package.json +35 -4
- package/shell/index.html +48 -0
- package/shell/scripts.js +201 -0
- package/shell/styles.css +299 -0
- package/templates/AGENTS.md +76 -0
- package/templates/README.md +62 -0
- package/templates/config.json.example +10 -0
- package/templates/gitignore +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codepen-demokit",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A zero-config framework for organizing, previewing, deploying, and syncing self-contained web demos with CodePen 2.0.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codepen-demokit": "./bin/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
"./build-json": "./lib/build-json.mjs",
|
|
11
|
+
"./build-site": "./lib/build-site.mjs",
|
|
12
|
+
"./config": "./lib/config.mjs",
|
|
13
|
+
"./init": "./lib/init.mjs",
|
|
14
|
+
"./serve": "./lib/serve.mjs",
|
|
15
|
+
"./sync-codepen": "./lib/sync-codepen.mjs"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/",
|
|
19
|
+
"lib/",
|
|
20
|
+
"shell/",
|
|
21
|
+
"templates/",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"codepen",
|
|
26
|
+
"codepen-commander",
|
|
27
|
+
"demos",
|
|
28
|
+
"web-demos",
|
|
29
|
+
"static-site"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"codepen-commander": "^1.3.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/shell/index.html
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title>{{SITE_TITLE}}</title>
|
|
8
|
+
<link rel="stylesheet" href="./styles.css">
|
|
9
|
+
<script type="module" src="./scripts.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<header class="site-header">
|
|
13
|
+
<h1>{{SITE_TITLE}}</h1>
|
|
14
|
+
<p class="subtitle">{{SITE_SUBTITLE}}</p>
|
|
15
|
+
</header>
|
|
16
|
+
|
|
17
|
+
<main class="demo-directory" id="demo-directory">
|
|
18
|
+
<p class="directory-status">Loading demos…</p>
|
|
19
|
+
<noscript>
|
|
20
|
+
<section class="empty-state">
|
|
21
|
+
<h2>JavaScript required</h2>
|
|
22
|
+
<p>Enable JavaScript to load the list of demos from <code>demos.json</code>.</p>
|
|
23
|
+
</section>
|
|
24
|
+
</noscript>
|
|
25
|
+
</main>
|
|
26
|
+
|
|
27
|
+
<footer class="site-footer">
|
|
28
|
+
<p>{{SITE_FOOTER}}</p>
|
|
29
|
+
</footer>
|
|
30
|
+
|
|
31
|
+
<template id="demo-card-template">
|
|
32
|
+
<li class="demo-card">
|
|
33
|
+
<p class="demo-description"></p>
|
|
34
|
+
<div class="demo-meta">
|
|
35
|
+
<code class="demo-path"></code>
|
|
36
|
+
<a class="demo-codepen" target="_blank" rel="noopener noreferrer">CodePen</a>
|
|
37
|
+
</div>
|
|
38
|
+
</li>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<template id="empty-state-template">
|
|
42
|
+
<section class="empty-state">
|
|
43
|
+
<h2>No demos yet</h2>
|
|
44
|
+
<p>Create a self-contained demo folder inside <code>src/</code> (e.g., <code>src/my-demo/</code> or <code>src/my-group/my-demo/</code>) with an <code>index.html</code> and any assets it needs. Refresh this page and it will appear automatically.</p>
|
|
45
|
+
</section>
|
|
46
|
+
</template>
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
package/shell/scripts.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const directoryEl = document.getElementById('demo-directory');
|
|
2
|
+
const cardTemplate = document.getElementById('demo-card-template');
|
|
3
|
+
const emptyStateTemplate = document.getElementById('empty-state-template');
|
|
4
|
+
|
|
5
|
+
function toSafeLocalHref(rawHref) {
|
|
6
|
+
if (typeof rawHref !== 'string' || !rawHref.startsWith('./')) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const resolved = new URL(rawHref, window.location.href);
|
|
11
|
+
if (
|
|
12
|
+
resolved.origin !== window.location.origin ||
|
|
13
|
+
(resolved.protocol !== 'http:' && resolved.protocol !== 'https:')
|
|
14
|
+
) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return rawHref;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function toSafeCodePenUrl(rawUrl) {
|
|
24
|
+
if (typeof rawUrl !== 'string') {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const parsed = new URL(rawUrl);
|
|
29
|
+
if (parsed.protocol !== 'https:') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (parsed.hostname !== 'codepen.io' && !parsed.hostname.endsWith('.codepen.io')) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return parsed.href;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function createHeading(level, className) {
|
|
42
|
+
const clamped = Math.min(Math.max(level, 2), 6);
|
|
43
|
+
const heading = document.createElement(`h${clamped}`);
|
|
44
|
+
heading.className = className;
|
|
45
|
+
return heading;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function createDemoCard(demo, headingLevel) {
|
|
49
|
+
const safeHref = toSafeLocalHref(demo?.href);
|
|
50
|
+
if (!safeHref) return null;
|
|
51
|
+
|
|
52
|
+
const title = typeof demo?.title === 'string' && demo.title.trim() ? demo.title.trim() : demo.path;
|
|
53
|
+
const fragment = cardTemplate.content.cloneNode(true);
|
|
54
|
+
const cardEl = fragment.querySelector('.demo-card');
|
|
55
|
+
|
|
56
|
+
const headingEl = createHeading(headingLevel, 'demo-card-title');
|
|
57
|
+
const linkEl = document.createElement('a');
|
|
58
|
+
linkEl.className = 'demo-link';
|
|
59
|
+
linkEl.setAttribute('href', safeHref);
|
|
60
|
+
linkEl.textContent = title;
|
|
61
|
+
headingEl.append(linkEl);
|
|
62
|
+
cardEl.prepend(headingEl);
|
|
63
|
+
|
|
64
|
+
const descriptionEl = fragment.querySelector('.demo-description');
|
|
65
|
+
if (typeof demo?.description === 'string' && demo.description.trim()) {
|
|
66
|
+
descriptionEl.textContent = demo.description.trim();
|
|
67
|
+
} else {
|
|
68
|
+
descriptionEl.remove();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const pathEl = fragment.querySelector('.demo-path');
|
|
72
|
+
pathEl.textContent = typeof demo?.path === 'string' ? demo.path : safeHref.replace(/^\.\//, '');
|
|
73
|
+
|
|
74
|
+
const codepenEl = fragment.querySelector('.demo-codepen');
|
|
75
|
+
const safeCodePenUrl = toSafeCodePenUrl(demo?.codepenUrl);
|
|
76
|
+
if (safeCodePenUrl) {
|
|
77
|
+
codepenEl.setAttribute('href', safeCodePenUrl);
|
|
78
|
+
codepenEl.setAttribute('aria-label', `CodePen for ${title}`);
|
|
79
|
+
} else {
|
|
80
|
+
codepenEl.remove();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return fragment;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function createGroupSection(headingText, demos, subgroups = [], headingLevel = 2) {
|
|
87
|
+
const cards = (Array.isArray(demos) ? demos : [])
|
|
88
|
+
.map((demo) => createDemoCard(demo, headingLevel + 1))
|
|
89
|
+
.filter(Boolean);
|
|
90
|
+
|
|
91
|
+
const childSections = (Array.isArray(subgroups) ? subgroups : [])
|
|
92
|
+
.map((subgroup) => {
|
|
93
|
+
const subHeading =
|
|
94
|
+
typeof subgroup?.title === 'string' && subgroup.title.trim()
|
|
95
|
+
? subgroup.title.trim()
|
|
96
|
+
: String(subgroup?.id ?? 'Demos');
|
|
97
|
+
return createGroupSection(subHeading, subgroup?.demos, subgroup?.groups, headingLevel + 1);
|
|
98
|
+
})
|
|
99
|
+
.filter(Boolean);
|
|
100
|
+
|
|
101
|
+
if (cards.length === 0 && childSections.length === 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const section = document.createElement('section');
|
|
106
|
+
section.className = 'demo-group';
|
|
107
|
+
|
|
108
|
+
const headingEl = createHeading(headingLevel, 'demo-group-title');
|
|
109
|
+
headingEl.textContent = headingText;
|
|
110
|
+
section.append(headingEl);
|
|
111
|
+
|
|
112
|
+
if (cards.length > 0) {
|
|
113
|
+
const gridEl = document.createElement('ul');
|
|
114
|
+
gridEl.className = 'demo-grid';
|
|
115
|
+
gridEl.setAttribute('role', 'list');
|
|
116
|
+
gridEl.replaceChildren(...cards);
|
|
117
|
+
section.append(gridEl);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (childSections.length > 0) {
|
|
121
|
+
const subgroupsEl = document.createElement('div');
|
|
122
|
+
subgroupsEl.className = 'demo-subgroups';
|
|
123
|
+
subgroupsEl.replaceChildren(...childSections);
|
|
124
|
+
section.append(subgroupsEl);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return section;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function createCode(text) {
|
|
131
|
+
const code = document.createElement('code');
|
|
132
|
+
code.textContent = text;
|
|
133
|
+
return code;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function createErrorState() {
|
|
137
|
+
const section = document.createElement('section');
|
|
138
|
+
section.className = 'empty-state';
|
|
139
|
+
|
|
140
|
+
const heading = document.createElement('h2');
|
|
141
|
+
heading.textContent = 'Unable to load demos';
|
|
142
|
+
|
|
143
|
+
const paragraph = document.createElement('p');
|
|
144
|
+
paragraph.append(
|
|
145
|
+
'Run ',
|
|
146
|
+
createCode('npm run build'),
|
|
147
|
+
' to generate ',
|
|
148
|
+
createCode('dist/demos.json'),
|
|
149
|
+
', or start the dev server with ',
|
|
150
|
+
createCode('npm start'),
|
|
151
|
+
' to build and watch it automatically.',
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
section.append(heading, paragraph);
|
|
155
|
+
return section;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function loadDemos() {
|
|
159
|
+
try {
|
|
160
|
+
const response = await fetch('./demos.json', {
|
|
161
|
+
cache: 'no-store',
|
|
162
|
+
signal: AbortSignal.timeout(5_000),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
throw new Error(`HTTP ${response.status}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const data = await response.json();
|
|
170
|
+
const groups = Array.isArray(data?.groups) ? data.groups : [];
|
|
171
|
+
const standalone = Array.isArray(data?.standalone) ? data.standalone : [];
|
|
172
|
+
|
|
173
|
+
const sections = [];
|
|
174
|
+
|
|
175
|
+
for (const group of groups) {
|
|
176
|
+
const heading =
|
|
177
|
+
typeof group?.title === 'string' && group.title.trim()
|
|
178
|
+
? group.title.trim()
|
|
179
|
+
: String(group?.id ?? 'Demos');
|
|
180
|
+
const section = createGroupSection(heading, group?.demos, group?.groups, 2);
|
|
181
|
+
if (section) sections.push(section);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (standalone.length > 0) {
|
|
185
|
+
const standaloneHeading = sections.length > 0 ? 'Standalone Demos' : 'Demos';
|
|
186
|
+
const section = createGroupSection(standaloneHeading, standalone, [], 2);
|
|
187
|
+
if (section) sections.push(section);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (sections.length === 0) {
|
|
191
|
+
directoryEl.replaceChildren(emptyStateTemplate.content.cloneNode(true));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
directoryEl.replaceChildren(...sections);
|
|
196
|
+
} catch {
|
|
197
|
+
directoryEl.replaceChildren(createErrorState());
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
loadDemos();
|
package/shell/styles.css
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
@layer reset, base, components;
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
color-scheme: light dark;
|
|
5
|
+
|
|
6
|
+
/* Tier 1: Raw color values */
|
|
7
|
+
--surface-page-light: oklch(98.5% 0.004 250);
|
|
8
|
+
--surface-page-dark: oklch(15% 0.012 260);
|
|
9
|
+
--surface-card-light: oklch(100% 0 0);
|
|
10
|
+
--surface-card-dark: oklch(20% 0.014 260);
|
|
11
|
+
--surface-code-light: oklch(94.5% 0.008 255);
|
|
12
|
+
--surface-code-dark: oklch(25% 0.016 260);
|
|
13
|
+
|
|
14
|
+
--text-primary-light: oklch(20% 0.015 260);
|
|
15
|
+
--text-primary-dark: oklch(94% 0.008 250);
|
|
16
|
+
--text-muted-light: oklch(46% 0.016 260);
|
|
17
|
+
--text-muted-dark: oklch(72% 0.014 255);
|
|
18
|
+
|
|
19
|
+
--border-subtle-light: oklch(88% 0.01 255);
|
|
20
|
+
--border-subtle-dark: oklch(30% 0.018 260);
|
|
21
|
+
|
|
22
|
+
--accent-light: oklch(48% 0.2 260);
|
|
23
|
+
--accent-dark: oklch(75% 0.15 250);
|
|
24
|
+
|
|
25
|
+
/* Tier 2: Semantic tokens */
|
|
26
|
+
--surface-page: light-dark(var(--surface-page-light), var(--surface-page-dark));
|
|
27
|
+
--surface-card: light-dark(var(--surface-card-light), var(--surface-card-dark));
|
|
28
|
+
--surface-code: light-dark(var(--surface-code-light), var(--surface-code-dark));
|
|
29
|
+
|
|
30
|
+
--text-primary: light-dark(var(--text-primary-light), var(--text-primary-dark));
|
|
31
|
+
--text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
|
|
32
|
+
|
|
33
|
+
--border-subtle: light-dark(var(--border-subtle-light), var(--border-subtle-dark));
|
|
34
|
+
--accent: light-dark(var(--accent-light), var(--accent-dark));
|
|
35
|
+
|
|
36
|
+
--radius-card: 0.875rem;
|
|
37
|
+
--radius-code: 0.375rem;
|
|
38
|
+
--space-page-inline: clamp(1.25rem, 4vw, 3rem);
|
|
39
|
+
--content-max-inline: 68rem;
|
|
40
|
+
|
|
41
|
+
accent-color: var(--accent);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@layer reset {
|
|
45
|
+
html,
|
|
46
|
+
body,
|
|
47
|
+
header,
|
|
48
|
+
main,
|
|
49
|
+
section,
|
|
50
|
+
article,
|
|
51
|
+
footer,
|
|
52
|
+
div,
|
|
53
|
+
ul,
|
|
54
|
+
li {
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
body,
|
|
59
|
+
h1,
|
|
60
|
+
h2,
|
|
61
|
+
h3,
|
|
62
|
+
h4,
|
|
63
|
+
h5,
|
|
64
|
+
h6,
|
|
65
|
+
p {
|
|
66
|
+
margin: 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@layer base {
|
|
71
|
+
body {
|
|
72
|
+
min-block-size: 100dvb;
|
|
73
|
+
display: grid;
|
|
74
|
+
grid-template-rows: auto 1fr auto;
|
|
75
|
+
gap: 2.5rem;
|
|
76
|
+
padding-block: clamp(2rem, 5vw, 3.5rem) 2rem;
|
|
77
|
+
padding-inline: var(--space-page-inline);
|
|
78
|
+
background-color: var(--surface-page);
|
|
79
|
+
color: var(--text-primary);
|
|
80
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
81
|
+
line-height: 1.55;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
h1,
|
|
85
|
+
h2,
|
|
86
|
+
h3,
|
|
87
|
+
h4,
|
|
88
|
+
h5,
|
|
89
|
+
h6 {
|
|
90
|
+
line-height: 1.25;
|
|
91
|
+
text-wrap: balance;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
p {
|
|
95
|
+
text-wrap: pretty;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
a {
|
|
99
|
+
color: var(--accent);
|
|
100
|
+
text-underline-offset: 0.2em;
|
|
101
|
+
|
|
102
|
+
&:focus-visible {
|
|
103
|
+
outline: 2px solid var(--accent);
|
|
104
|
+
outline-offset: 3px;
|
|
105
|
+
border-radius: 0.2rem;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
code {
|
|
110
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
111
|
+
font-size: 0.875em;
|
|
112
|
+
padding-block: 0.125em;
|
|
113
|
+
padding-inline: 0.4em;
|
|
114
|
+
border-radius: var(--radius-code);
|
|
115
|
+
background-color: var(--surface-code);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@layer components {
|
|
120
|
+
.site-header,
|
|
121
|
+
.demo-directory,
|
|
122
|
+
.site-footer {
|
|
123
|
+
inline-size: min(100%, var(--content-max-inline));
|
|
124
|
+
margin-inline: auto;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.site-header {
|
|
128
|
+
display: grid;
|
|
129
|
+
gap: 0.5rem;
|
|
130
|
+
padding-block-end: 1.5rem;
|
|
131
|
+
border-block-end: 1px solid var(--border-subtle);
|
|
132
|
+
|
|
133
|
+
& h1 {
|
|
134
|
+
font-size: clamp(1.75rem, 3.5vw, 2.5rem);
|
|
135
|
+
letter-spacing: -0.02em;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.subtitle {
|
|
140
|
+
color: var(--text-muted);
|
|
141
|
+
max-inline-size: 62ch;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.demo-directory {
|
|
145
|
+
display: grid;
|
|
146
|
+
align-content: start;
|
|
147
|
+
gap: 2.5rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.demo-group {
|
|
151
|
+
display: grid;
|
|
152
|
+
gap: 1rem;
|
|
153
|
+
|
|
154
|
+
& > .demo-group-title {
|
|
155
|
+
font-size: 1.35rem;
|
|
156
|
+
letter-spacing: -0.01em;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
& .demo-group {
|
|
160
|
+
gap: 0.75rem;
|
|
161
|
+
|
|
162
|
+
& > .demo-group-title {
|
|
163
|
+
font-size: 1.0625rem;
|
|
164
|
+
font-weight: 600;
|
|
165
|
+
color: var(--text-muted);
|
|
166
|
+
letter-spacing: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.demo-subgroups {
|
|
172
|
+
display: grid;
|
|
173
|
+
gap: 1.5rem;
|
|
174
|
+
padding-inline-start: 1rem;
|
|
175
|
+
border-inline-start: 2px solid var(--border-subtle);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.directory-status {
|
|
179
|
+
color: var(--text-muted);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.demo-grid {
|
|
183
|
+
display: grid;
|
|
184
|
+
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
|
185
|
+
gap: 1rem;
|
|
186
|
+
list-style: none;
|
|
187
|
+
margin: 0;
|
|
188
|
+
padding: 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.demo-card {
|
|
192
|
+
position: relative;
|
|
193
|
+
grid-row: span 3;
|
|
194
|
+
display: grid;
|
|
195
|
+
/* Same-cascade fallback when subgrid is unsupported */
|
|
196
|
+
grid-template-rows: auto 1fr auto;
|
|
197
|
+
grid-template-rows: subgrid;
|
|
198
|
+
row-gap: 0.5rem;
|
|
199
|
+
padding: 1.25rem;
|
|
200
|
+
background-color: var(--surface-card);
|
|
201
|
+
border: 1px solid var(--border-subtle);
|
|
202
|
+
border-radius: var(--radius-card);
|
|
203
|
+
corner-shape: squircle;
|
|
204
|
+
transition: border-color 150ms ease, translate 150ms ease;
|
|
205
|
+
|
|
206
|
+
&:hover {
|
|
207
|
+
border-color: var(--accent);
|
|
208
|
+
translate: 0 -2px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
& .demo-card-title {
|
|
212
|
+
grid-row: 1;
|
|
213
|
+
font-size: 1.05rem;
|
|
214
|
+
|
|
215
|
+
& a {
|
|
216
|
+
text-decoration: none;
|
|
217
|
+
|
|
218
|
+
&::after {
|
|
219
|
+
content: "";
|
|
220
|
+
position: absolute;
|
|
221
|
+
inset: 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
& p {
|
|
227
|
+
grid-row: 2;
|
|
228
|
+
color: var(--text-muted);
|
|
229
|
+
font-size: 0.9375rem;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.demo-meta {
|
|
234
|
+
grid-row: 3;
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-wrap: wrap;
|
|
237
|
+
align-items: start;
|
|
238
|
+
justify-content: space-between;
|
|
239
|
+
gap: 0.5rem;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.demo-description + .demo-meta {
|
|
243
|
+
margin-block-start: 0.25rem;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.demo-path {
|
|
247
|
+
min-inline-size: 0;
|
|
248
|
+
overflow-wrap: anywhere;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.demo-codepen {
|
|
252
|
+
position: relative;
|
|
253
|
+
z-index: 1;
|
|
254
|
+
flex-shrink: 0;
|
|
255
|
+
font-size: 0.8125rem;
|
|
256
|
+
font-weight: 500;
|
|
257
|
+
text-decoration: none;
|
|
258
|
+
|
|
259
|
+
&:hover {
|
|
260
|
+
text-decoration: underline;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.empty-state {
|
|
265
|
+
display: grid;
|
|
266
|
+
gap: 0.75rem;
|
|
267
|
+
padding: clamp(1.5rem, 4vw, 2.5rem);
|
|
268
|
+
background-color: var(--surface-card);
|
|
269
|
+
border: 1px dashed var(--border-subtle);
|
|
270
|
+
border-radius: var(--radius-card);
|
|
271
|
+
corner-shape: squircle;
|
|
272
|
+
|
|
273
|
+
& h2 {
|
|
274
|
+
font-size: 1.15rem;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
& p {
|
|
278
|
+
color: var(--text-muted);
|
|
279
|
+
max-inline-size: 65ch;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.site-footer {
|
|
284
|
+
padding-block-start: 1.25rem;
|
|
285
|
+
border-block-start: 1px solid var(--border-subtle);
|
|
286
|
+
color: var(--text-muted);
|
|
287
|
+
font-size: 0.875rem;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@media (prefers-reduced-motion: reduce) {
|
|
291
|
+
.demo-card {
|
|
292
|
+
transition: none;
|
|
293
|
+
|
|
294
|
+
&:hover {
|
|
295
|
+
translate: none;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
This repository is a collection of self-contained web demos powered by [`codepen-demokit`](https://www.npmjs.com/package/codepen-demokit) and synced with CodePen 2.0 via [CodePen Commander](https://www.npmjs.com/package/codepen-commander). Every agent working in this repository MUST follow the rules below.
|
|
4
|
+
|
|
5
|
+
## 1. Folder Structure & Naming
|
|
6
|
+
|
|
7
|
+
All demos live inside `src/`. Use clear, descriptive `kebab-case` names for all demo and group folders.
|
|
8
|
+
|
|
9
|
+
- **Index page**: Provided automatically by `codepen-demokit` (configured via `site` in `config.json`). You only need to place `index.html`, `styles.css`, or `scripts.js` at `src/` root if you intentionally want to override the default index UI.
|
|
10
|
+
- **Standalone demo** (directly inside `src/`):
|
|
11
|
+
```text
|
|
12
|
+
src/<demo-name>/
|
|
13
|
+
├── index.html
|
|
14
|
+
├── styles.css # optional
|
|
15
|
+
├── scripts.js # optional
|
|
16
|
+
├── .cdpn.json # CodePen sync metadata (when synced via CodePen Commander)
|
|
17
|
+
└── .codepen/ # optional CodePen 2.0 config (e.g. pen.config.json)
|
|
18
|
+
```
|
|
19
|
+
- **Grouped or nested demos** (related demos sharing topic folders inside `src/`):
|
|
20
|
+
```text
|
|
21
|
+
src/<group-name>/
|
|
22
|
+
├── <demo-one>/
|
|
23
|
+
│ ├── index.html
|
|
24
|
+
│ ├── styles.css # optional
|
|
25
|
+
│ ├── scripts.js # optional
|
|
26
|
+
│ └── .cdpn.json # when synced
|
|
27
|
+
└── <subgroup-name>/
|
|
28
|
+
└── <demo-two>/
|
|
29
|
+
├── index.html
|
|
30
|
+
└── styles.css
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Reuse an existing `src/<group-name>/` directory whenever a new demo clearly belongs to that topic.
|
|
34
|
+
- Create a new `src/<group-name>/` directory when building a series of related demos around the same feature or topic.
|
|
35
|
+
|
|
36
|
+
## 2. Self-Contained Demo Rules
|
|
37
|
+
|
|
38
|
+
Every demo folder MUST be self-contained and portable so it can be opened, served, or copied independently without breaking—and so it syncs cleanly as a standalone CodePen 2.0 Pen:
|
|
39
|
+
|
|
40
|
+
1. **Entry point**:
|
|
41
|
+
- Include an `index.html` entry point so `codepen-demokit` discovers the demo and renders it cleanly in the browser.
|
|
42
|
+
- For Pens cloned or forked from CodePen via `cdpn`, preserve their existing file layout unless the user explicitly asks to reorganize them.
|
|
43
|
+
2. **Local assets stay inside the demo folder**:
|
|
44
|
+
- Store local files (stylesheets, scripts, images, SVGs, fonts, media, data files) inside that demo's folder and reference them with relative paths (`./...`).
|
|
45
|
+
3. **No cross-demo coupling**:
|
|
46
|
+
- Never import or reference files from `src/` root, the repository root, or sibling demos (e.g., `../other-demo/...`).
|
|
47
|
+
|
|
48
|
+
## 3. CodePen Sync (`cdpn:*` & CodePen Commander)
|
|
49
|
+
|
|
50
|
+
This repository uses `codepen-demokit` (powered by CodePen Commander / `cdpn` under the hood) to keep demos in `src/` synced with CodePen 2.0:
|
|
51
|
+
|
|
52
|
+
- Bulk sync commands (configured via `codepen.user` and `codepen.defaultVisibility` in `config.json`):
|
|
53
|
+
- `npm run cdpn:sync` — two-way sync across `src/`
|
|
54
|
+
- `npm run cdpn:push` — push local edits and create Pens for unlinked demos
|
|
55
|
+
- `npm run cdpn:pull` — pull remote updates (supports `-- --force`)
|
|
56
|
+
- `npm run cdpn:delete` — delete linked Pens on CodePen while keeping Pen metadata (`--keep-info`) in `.cdpn.json`
|
|
57
|
+
- All bulk commands support optional folder scoping (e.g., `npm run cdpn:push -- scroll-driven-animations`) and `-- --dry-run`.
|
|
58
|
+
- Cloning a Pen into `src/`:
|
|
59
|
+
- `npm run cdpn:clone -- [options] <url> [folder]` — passes arguments through to `cdpn clone` inside `src/` using `codepen.user` from `config.json` (e.g., `npm run cdpn:clone -- https://codepen.io/user/pen/slug group/my-demo`).
|
|
60
|
+
- Other single-Pen commands via `npx cdpn`:
|
|
61
|
+
- Pass `--json` and explicit flags when running non-interactively (e.g., `-t "<title>"`, `--access <Public|Private|Protected|Collaborators>`, `-m "<label>"`, `--yes`).
|
|
62
|
+
- Sync metadata files:
|
|
63
|
+
- Commit `.cdpn.json` (contains no secrets) and `.codepen/` inside each synced demo folder so sync state persists across machines.
|
|
64
|
+
- Never commit API keys or `.cdpn` files.
|
|
65
|
+
- Do not manually edit `.cdpn.json`; let `cdpn` manage it.
|
|
66
|
+
|
|
67
|
+
## 4. Keeping the Demo Index Up to Date
|
|
68
|
+
|
|
69
|
+
- The web index page and `dist/demos.json` are **automatically built** by `codepen-demokit` from `src/` subfolders (reading each demo's `<title>`, optional `<meta name="description">`, and optional `.cdpn.json` URL). Never manually edit `dist/`.
|
|
70
|
+
- Whenever you add, clone, fork, scaffold, push to CodePen for the first time, rename, move, or remove a demo, update the `## Demos` section in `README.md`.
|
|
71
|
+
|
|
72
|
+
## 5. Local Verification
|
|
73
|
+
|
|
74
|
+
- Give each demo's `index.html` a descriptive `<title>` and an optional `<meta name="description" content="...">` (displayed automatically on the index card).
|
|
75
|
+
- Preview locally with `npm start` (serves at `http://127.0.0.1:3000`), or `npm start "group/demo"` to serve a single demo directly as the root.
|
|
76
|
+
- Verify static production builds with `npm run build` (outputs deployable static site to `dist/`).
|