@texturehq/edges 0.0.18 → 0.0.20

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.
@@ -0,0 +1,170 @@
1
+ // scripts/setup-cursor-rules.js
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const setupCursorRules = () => {
6
+ const cwd = process.env.INIT_CWD || process.cwd();
7
+
8
+ // Don't run inside the edges package itself
9
+ try {
10
+ const pkgJsonPath = path.join(cwd, "package.json");
11
+ if (fs.existsSync(pkgJsonPath)) {
12
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
13
+ if (pkg.name === "@texturehq/edges") return;
14
+ }
15
+ } catch {
16
+ // ignore
17
+ }
18
+
19
+ const cursorTemplatesDir = path.join(path.dirname(new URL(import.meta.url).pathname), '../templates/cursor-rules');
20
+ const claudeTemplatesDir = path.join(path.dirname(new URL(import.meta.url).pathname), '../templates/claude-rules');
21
+ const cursorDir = path.join(cwd, '.cursor');
22
+ const rulesDir = path.join(cursorDir, 'rules');
23
+
24
+ // Create directories recursively
25
+ fs.mkdirSync(cursorDir, { recursive: true });
26
+ fs.mkdirSync(rulesDir, { recursive: true });
27
+
28
+ // Setup Cursor rules
29
+ if (fs.existsSync(cursorTemplatesDir)) {
30
+ const templateFiles = fs.readdirSync(cursorTemplatesDir).filter(file => file.endsWith('.mdc'));
31
+
32
+ if (templateFiles.length > 0) {
33
+ let copiedCount = 0;
34
+
35
+ templateFiles.forEach(file => {
36
+ const templatePath = path.join(cursorTemplatesDir, file);
37
+ const targetPath = path.join(rulesDir, file);
38
+
39
+ // Backup existing rule before overwriting
40
+ if (fs.existsSync(targetPath)) {
41
+ const backupsDir = path.join(rulesDir, "_backups");
42
+ fs.mkdirSync(backupsDir, { recursive: true });
43
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
44
+ fs.copyFileSync(targetPath, path.join(backupsDir, `${file}.${ts}.bak`));
45
+ }
46
+ // Always copy to ensure latest version
47
+ fs.copyFileSync(templatePath, targetPath);
48
+ copiedCount++;
49
+ console.log(`✅ Updated .cursor/rules/${file}`);
50
+ });
51
+
52
+ if (copiedCount > 0) {
53
+ console.log(`🎨 Added ${copiedCount} cursor rule(s) for @texturehq/edges design system`);
54
+ }
55
+ }
56
+ }
57
+
58
+ // Setup Claude rules
59
+ if (fs.existsSync(claudeTemplatesDir)) {
60
+ const claudeTemplateFiles = fs.readdirSync(claudeTemplatesDir).filter(file => file.endsWith('.md') || file === '.claude');
61
+
62
+ if (claudeTemplateFiles.length > 0) {
63
+ let claudeCopiedCount = 0;
64
+
65
+ claudeTemplateFiles.forEach(file => {
66
+ const templatePath = path.join(claudeTemplatesDir, file);
67
+ const targetPath = path.join(cwd, file);
68
+
69
+ // Backup existing file before overwriting
70
+ if (fs.existsSync(targetPath)) {
71
+ const backupPath = `${targetPath}.${new Date().toISOString().replace(/[:.]/g, "-")}.bak`;
72
+ fs.copyFileSync(targetPath, backupPath);
73
+ console.log(`📋 Backed up existing ${file} to ${backupPath}`);
74
+ }
75
+
76
+ // Always copy to ensure latest version
77
+ fs.copyFileSync(templatePath, targetPath);
78
+ claudeCopiedCount++;
79
+ console.log(`✅ Updated ${file} for Claude`);
80
+ });
81
+
82
+ if (claudeCopiedCount > 0) {
83
+ console.log(`🤖 Added ${claudeCopiedCount} Claude rule(s) for @texturehq/edges design system`);
84
+ }
85
+ }
86
+ }
87
+
88
+ // Also render edges-components.mdc from manifest when present
89
+ const manifestPath = [
90
+ path.join(cwd, 'node_modules/@texturehq/edges/dist/components.manifest.json')
91
+ ].find(p => fs.existsSync(p));
92
+
93
+ if (manifestPath) {
94
+ try {
95
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
96
+
97
+ // Generate Cursor components list
98
+ const cursorLines = [
99
+ '---',
100
+ 'alwaysApply: true',
101
+ '---',
102
+ '',
103
+ `## @texturehq/edges Components (v${manifest.version || 'unknown'})`,
104
+ ''
105
+ ];
106
+ for (const c of manifest.components || []) {
107
+ cursorLines.push(`- ${c.name}`);
108
+ if (c.importRoot) cursorLines.push(` - Import: \`import { ${c.name} } from "${c.importRoot}"\``);
109
+ if (c.importPath) cursorLines.push(` - Subpath: \`import { ${c.name} } from "${c.importPath}"\``);
110
+ if (c.props && c.props.length) {
111
+ const propNames = c.props.slice(0, 8).map(p => p.name).join(', ');
112
+ cursorLines.push(` - Props: ${propNames}${c.props.length > 8 ? ', …' : ''}`);
113
+ }
114
+ }
115
+ const cursorOutPath = path.join(rulesDir, 'edges-components.mdc');
116
+ // Backup existing components manifest before overwriting
117
+ if (fs.existsSync(cursorOutPath)) {
118
+ const backupsDir = path.join(rulesDir, "_backups");
119
+ fs.mkdirSync(backupsDir, { recursive: true });
120
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
121
+ fs.copyFileSync(cursorOutPath, path.join(backupsDir, `edges-components.mdc.${ts}.bak`));
122
+ }
123
+ fs.writeFileSync(cursorOutPath, cursorLines.join('\n'), "utf8");
124
+ console.log(`✅ Wrote .cursor/rules/edges-components.mdc from manifest (${manifest.components?.length || 0} components)`);
125
+
126
+ // Generate Claude components list
127
+ const claudeLines = [];
128
+ for (const c of manifest.components || []) {
129
+ claudeLines.push(`- **${c.name}**`);
130
+ if (c.description) claudeLines.push(` - ${c.description}`);
131
+ if (c.importPath) claudeLines.push(` - Import: \`import { ${c.name} } from "${c.importPath}"\``);
132
+ if (c.props && c.props.length) {
133
+ const propNames = c.props.slice(0, 6).map(p => p.name).join(', ');
134
+ claudeLines.push(` - Props: ${propNames}${c.props.length > 6 ? ', …' : ''}`);
135
+ }
136
+ claudeLines.push('');
137
+ }
138
+
139
+ // Update Claude templates with components list
140
+ const claudeTemplates = ['claude.md', '.claude'];
141
+
142
+ claudeTemplates.forEach(templateName => {
143
+ const claudeTemplatePath = path.join(claudeTemplatesDir, templateName);
144
+ if (fs.existsSync(claudeTemplatePath)) {
145
+ let claudeContent = fs.readFileSync(claudeTemplatePath, 'utf8');
146
+ claudeContent = claudeContent.split("{{COMPONENTS_LIST}}").join(claudeLines.join("\n"));
147
+ const claudeOutPath = path.join(cwd, templateName);
148
+ // Backup existing file before overwriting
149
+ if (fs.existsSync(claudeOutPath)) {
150
+ const backupPath = `${claudeOutPath}.${new Date().toISOString().replace(/[:.]/g, "-")}.bak`;
151
+ fs.copyFileSync(claudeOutPath, backupPath);
152
+ console.log(`📋 Backed up existing ${templateName} to ${backupPath}`);
153
+ }
154
+ fs.writeFileSync(claudeOutPath, claudeContent, "utf8");
155
+ console.log(`✅ Wrote ${templateName} with components list (${manifest.components?.length || 0} components)`);
156
+ }
157
+ });
158
+ } catch (err) {
159
+ console.log('⚠️ Failed to read components.manifest.json:', err.message);
160
+ }
161
+ }
162
+ };
163
+
164
+ try {
165
+ setupCursorRules();
166
+ } catch (err) {
167
+ console.warn("setup-cursor-rules error:", err);
168
+ }
169
+
170
+
@@ -0,0 +1,95 @@
1
+ // scripts/setup-cursor-rules.js
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const setupCursorRules = () => {
6
+ const cwd = process.cwd();
7
+
8
+ // Don't run in the package itself
9
+ if (cwd.includes('mono/packages/edges')) {
10
+ return;
11
+ }
12
+
13
+ const templatesDir = path.join(__dirname, '../templates/cursor-rules');
14
+ const cursorDir = path.join(cwd, '.cursor');
15
+ const rulesDir = path.join(cursorDir, 'rules');
16
+
17
+ // Create directories if they don't exist
18
+ if (!fs.existsSync(cursorDir)) {
19
+ fs.mkdirSync(cursorDir);
20
+ }
21
+ if (!fs.existsSync(rulesDir)) {
22
+ fs.mkdirSync(rulesDir);
23
+ }
24
+
25
+ // Check if templates directory exists
26
+ if (!fs.existsSync(templatesDir)) {
27
+ console.log('⚠️ No cursor rules templates found');
28
+ return;
29
+ }
30
+
31
+ // Copy all .mdc files from templates to the project's cursor rules
32
+ const templateFiles = fs.readdirSync(templatesDir).filter(file => file.endsWith('.mdc'));
33
+
34
+ if (templateFiles.length === 0) {
35
+ console.log('⚠️ No .mdc files found in templates directory');
36
+ return;
37
+ }
38
+
39
+ let copiedCount = 0;
40
+
41
+ templateFiles.forEach(file => {
42
+ const templatePath = path.join(templatesDir, file);
43
+ const targetPath = path.join(rulesDir, file);
44
+
45
+ // Only copy if the target doesn't already exist
46
+ if (!fs.existsSync(targetPath)) {
47
+ fs.copyFileSync(templatePath, targetPath);
48
+ copiedCount++;
49
+ console.log(`✅ Added .cursor/rules/${file}`);
50
+ } else {
51
+ console.log(`⏭️ Skipped .cursor/rules/${file} (already exists)`);
52
+ }
53
+ });
54
+
55
+ if (copiedCount > 0) {
56
+ console.log(`🎨 Added ${copiedCount} cursor rule(s) for @texturehq/edges design system`);
57
+ } else {
58
+ console.log('ℹ️ All cursor rules already exist');
59
+ }
60
+
61
+ // Also render edges-components.mdc from manifest when present
62
+ const manifestPath = [
63
+ path.join(cwd, 'node_modules/@texturehq/edges/dist/components.manifest.json')
64
+ ].find(p => fs.existsSync(p));
65
+
66
+ if (manifestPath) {
67
+ try {
68
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
69
+ const lines = [
70
+ '---',
71
+ 'alwaysApply: true',
72
+ '---',
73
+ '',
74
+ `## @texturehq/edges Components (v${manifest.version || 'unknown'})`,
75
+ ''
76
+ ];
77
+ for (const c of manifest.components || []) {
78
+ lines.push(`- ${c.name}`);
79
+ if (c.importRoot) lines.push(` - Import: \`import { ${c.name} } from "${c.importRoot}"\``);
80
+ if (c.importPath) lines.push(` - Subpath: \`import { ${c.name} } from "${c.importPath}"\``);
81
+ if (c.props && c.props.length) {
82
+ const propNames = c.props.slice(0, 8).map(p => p.name).join(', ');
83
+ lines.push(` - Props: ${propNames}${c.props.length > 8 ? ', …' : ''}`);
84
+ }
85
+ }
86
+ const outPath = path.join(rulesDir, 'edges-components.mdc');
87
+ fs.writeFileSync(outPath, lines.join('\n'));
88
+ console.log(`✅ Wrote .cursor/rules/edges-components.mdc from manifest (${manifest.components?.length || 0} components)`);
89
+ } catch (err) {
90
+ console.log('⚠️ Failed to read components.manifest.json:', err.message);
91
+ }
92
+ }
93
+ };
94
+
95
+ setupCursorRules();
@@ -0,0 +1,85 @@
1
+ # @texturehq/edges Design System
2
+
3
+ This project uses the @texturehq/edges design system with Tailwind 4. The theme CSS file contains all design system variables that automatically become available as Tailwind classes.
4
+
5
+ ## Setup
6
+
7
+ The theme is imported via CSS:
8
+ ```css
9
+ @import "@texturehq/edges/theme.css";
10
+ ```
11
+
12
+ ## How It Works
13
+
14
+ - CSS variables in the theme file automatically become Tailwind classes
15
+ - `--color-brand-primary` becomes available as `bg-brand-primary`, `text-brand-primary`, `border-brand-primary`, etc.
16
+ - `--spacing-md` becomes available as `p-md`, `m-md`, `gap-md`, etc.
17
+ - `--text-lg` becomes available as `text-lg`
18
+ - `--radius-lg` becomes available as `rounded-lg`
19
+
20
+ ## Usage Guidelines
21
+
22
+ - **Use semantic classes over arbitrary values**
23
+ - Prefer: `bg-brand-primary`, `text-text-body`, `p-md`, `rounded-lg`
24
+ - Avoid: `bg-[#444ae1]`, `text-[#333333]`, `p-[1rem]`, `rounded-[0.5rem]`
25
+
26
+ ## Naming Conventions
27
+
28
+ - Brand colors: `brand-primary`, `brand-light`, `brand-dark`
29
+ - Text colors: `text-body`, `text-heading`, `text-muted`, `text-caption`
30
+ - Background colors: `background-body`, `background-surface`, `background-muted`
31
+ - Border colors: `border-default`, `border-focus`, `border-muted`
32
+ - Action colors: `action-primary`, `action-secondary`, `action-destructive`
33
+ - Feedback colors: `feedback-success`, `feedback-error`, `feedback-warning`, `feedback-info`
34
+ - Spacing: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
35
+ - Typography: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
36
+ - Border radius: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
37
+
38
+ ## Examples
39
+
40
+ ```html
41
+ <!-- ✅ Good - Uses semantic classes -->
42
+ <div class="bg-brand-primary text-text-on-primary p-md rounded-lg shadow-md">
43
+ <h2 class="text-text-heading text-lg font-medium">Title</h2>
44
+ <p class="text-text-body text-base">Content</p>
45
+ </div>
46
+
47
+ <!-- ❌ Avoid - Uses arbitrary values -->
48
+ <div class="bg-[#444ae1] text-[#ffffff] p-[1rem] rounded-[0.5rem]">
49
+ <h2 class="text-[#111827] text-[1.125rem] font-[500]">Title</h2>
50
+ <p class="text-[#333333] text-[1rem]">Content</p>
51
+ </div>
52
+ ```
53
+
54
+ ## Dark Mode
55
+
56
+ All colors automatically adapt to dark mode when `.dark` class is present.
57
+
58
+ ## Available Variables
59
+
60
+ All CSS variables from the theme file are automatically available. The theme includes:
61
+ - Complete color system (brand, text, background, border, action, feedback, device states, data visualization)
62
+ - Spacing scale
63
+ - Typography scale
64
+ - Border radius scale
65
+ - Shadow system
66
+ - Animation definitions
67
+ - Form control specifications
68
+
69
+ ## Available Components
70
+
71
+ The following components are available from @texturehq/edges:
72
+
73
+ {{COMPONENTS_LIST}}
74
+
75
+ ## Import Examples
76
+
77
+ ```typescript
78
+ // Import from package root
79
+ import { Button, TextField, Card } from "@texturehq/edges";
80
+
81
+ // Import individual components for tree-shaking
82
+ import { Button } from "@texturehq/edges/components/Button";
83
+ import { TextField } from "@texturehq/edges/components/TextField";
84
+ import { Card } from "@texturehq/edges/components/Card";
85
+ ```
@@ -0,0 +1,85 @@
1
+ # @texturehq/edges Design System
2
+
3
+ This project uses the @texturehq/edges design system with Tailwind 4. The theme CSS file contains all design system variables that automatically become available as Tailwind classes.
4
+
5
+ ## Setup
6
+
7
+ The theme is imported via CSS:
8
+ ```css
9
+ @import "@texturehq/edges/theme.css";
10
+ ```
11
+
12
+ ## How It Works
13
+
14
+ - CSS variables in the theme file automatically become Tailwind classes
15
+ - `--color-brand-primary` becomes available as `bg-brand-primary`, `text-brand-primary`, `border-brand-primary`, etc.
16
+ - `--spacing-md` becomes available as `p-md`, `m-md`, `gap-md`, etc.
17
+ - `--text-lg` becomes available as `text-lg`
18
+ - `--radius-lg` becomes available as `rounded-lg`
19
+
20
+ ## Usage Guidelines
21
+
22
+ - **Use semantic classes over arbitrary values**
23
+ - Prefer: `bg-brand-primary`, `text-text-body`, `p-md`, `rounded-lg`
24
+ - Avoid: `bg-[#444ae1]`, `text-[#333333]`, `p-[1rem]`, `rounded-[0.5rem]`
25
+
26
+ ## Naming Conventions
27
+
28
+ - Brand colors: `brand-primary`, `brand-light`, `brand-dark`
29
+ - Text colors: `text-body`, `text-heading`, `text-muted`, `text-caption`
30
+ - Background colors: `background-body`, `background-surface`, `background-muted`
31
+ - Border colors: `border-default`, `border-focus`, `border-muted`
32
+ - Action colors: `action-primary`, `action-secondary`, `action-destructive`
33
+ - Feedback colors: `feedback-success`, `feedback-error`, `feedback-warning`, `feedback-info`
34
+ - Spacing: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
35
+ - Typography: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
36
+ - Border radius: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
37
+
38
+ ## Examples
39
+
40
+ ```html
41
+ <!-- ✅ Good - Uses semantic classes -->
42
+ <div class="bg-brand-primary text-text-on-primary p-md rounded-lg shadow-md">
43
+ <h2 class="text-text-heading text-lg font-medium">Title</h2>
44
+ <p class="text-text-body text-base">Content</p>
45
+ </div>
46
+
47
+ <!-- ❌ Avoid - Uses arbitrary values -->
48
+ <div class="bg-[#444ae1] text-[#ffffff] p-[1rem] rounded-[0.5rem]">
49
+ <h2 class="text-[#111827] text-[1.125rem] font-[500]">Title</h2>
50
+ <p class="text-[#333333] text-[1rem]">Content</p>
51
+ </div>
52
+ ```
53
+
54
+ ## Dark Mode
55
+
56
+ All colors automatically adapt to dark mode when `.dark` class is present.
57
+
58
+ ## Available Variables
59
+
60
+ All CSS variables from the theme file are automatically available. The theme includes:
61
+ - Complete color system (brand, text, background, border, action, feedback, device states, data visualization)
62
+ - Spacing scale
63
+ - Typography scale
64
+ - Border radius scale
65
+ - Shadow system
66
+ - Animation definitions
67
+ - Form control specifications
68
+
69
+ ## Available Components
70
+
71
+ The following components are available from @texturehq/edges:
72
+
73
+ {{COMPONENTS_LIST}}
74
+
75
+ ## Import Examples
76
+
77
+ ```typescript
78
+ // Import from package root
79
+ import { Button, TextField, Card } from "@texturehq/edges";
80
+
81
+ // Import individual components for tree-shaking
82
+ import { Button } from "@texturehq/edges/components/Button";
83
+ import { TextField } from "@texturehq/edges/components/TextField";
84
+ import { Card } from "@texturehq/edges/components/Card";
85
+ ```
@@ -0,0 +1,65 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ Usage Context for @texturehq/edges
6
+
7
+ ## Setup
8
+ This project uses @texturehq/edges design system with Tailwind 4. The theme CSS file contains all design system variables that automatically become available as Tailwind classes.
9
+
10
+ ## Theme Import
11
+ The theme is imported via CSS:
12
+ ```css
13
+ @import "@texturehq/edges/theme.css";
14
+ ```
15
+
16
+ ## How It Works
17
+ - CSS variables in the theme file automatically become Tailwind classes
18
+ - `--color-brand-primary` becomes available as `bg-brand-primary`, `text-brand-primary`, `border-brand-primary`, etc.
19
+ - `--spacing-md` becomes available as `p-md`, `m-md`, `gap-md`, etc.
20
+ - `--text-lg` becomes available as `text-lg`
21
+ - `--radius-lg` becomes available as `rounded-lg`
22
+
23
+ ## Usage Guidelines
24
+ - **Use semantic classes over arbitrary values**
25
+ - Prefer: `bg-brand-primary`, `text-text-body`, `p-md`, `rounded-lg`
26
+ - Avoid: `bg-[#444ae1]`, `text-[#333333]`, `p-[1rem]`, `rounded-[0.5rem]`
27
+
28
+ ## Naming Conventions
29
+ - Brand colors: `brand-primary`, `brand-light`, `brand-dark`
30
+ - Text colors: `text-body`, `text-heading`, `text-muted`, `text-caption`
31
+ - Background colors: `background-body`, `background-surface`, `background-muted`
32
+ - Border colors: `border-default`, `border-focus`, `border-muted`
33
+ - Action colors: `action-primary`, `action-secondary`, `action-destructive`
34
+ - Feedback colors: `feedback-success`, `feedback-error`, `feedback-warning`, `feedback-info`
35
+ - Spacing: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
36
+ - Typography: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
37
+ - Border radius: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`
38
+
39
+ ## Examples
40
+ ```html
41
+ <!-- ✅ Good - Uses semantic classes -->
42
+ <div class="bg-brand-primary text-text-on-primary p-md rounded-lg shadow-md">
43
+ <h2 class="text-text-heading text-lg font-medium">Title</h2>
44
+ <p class="text-text-body text-base">Content</p>
45
+ </div>
46
+
47
+ <!-- ❌ Avoid - Uses arbitrary values -->
48
+ <div class="bg-[#444ae1] text-[#ffffff] p-[1rem] rounded-[0.5rem]">
49
+ <h2 class="text-[#111827] text-[1.125rem] font-[500]">Title</h2>
50
+ <p class="text-[#333333] text-[1rem]">Content</p>
51
+ </div>
52
+ ```
53
+
54
+ ## Dark Mode
55
+ All colors automatically adapt to dark mode when `.dark` class is present.
56
+
57
+ ## Available Variables
58
+ All CSS variables from the theme file are automatically available. The theme includes:
59
+ - Complete color system (brand, text, background, border, action, feedback, device states, data visualization)
60
+ - Spacing scale
61
+ - Typography scale
62
+ - Border radius scale
63
+ - Shadow system
64
+ - Animation definitions
65
+ - Form control specifications