@clickhouse/click-ui 0.0.234-sc-deprecation.9 → 0.0.234-sc-deprecation.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,106 +1,84 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
3
+ import fs from "fs";
4
+ import path from "path";
6
5
 
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
6
+ const CONFIG_BODY = ` // Optional: Customize the storage key for theme persistence
7
+ // storageKey: 'click-ui-theme',
8
+
9
+ // Optional: Customize light mode theme
10
+ // theme: {
11
+ // global: {
12
+ // color: {
13
+ // brand: '#FFCC00',
14
+ // background: {
15
+ // default: '#FFFFFF'
16
+ // }
17
+ // }
18
+ // },
19
+ // button: {
20
+ // space: {
21
+ // x: '1rem',
22
+ // y: '0.5rem'
23
+ // },
24
+ // radii: {
25
+ // all: '0.375rem'
26
+ // }
27
+ // }
28
+ // },
29
+
30
+ // Optional: Dark mode overrides
31
+ // If not defined, theme values are used for dark mode too
32
+ // dark: {
33
+ // global: {
34
+ // color: {
35
+ // background: {
36
+ // default: '#0D1117'
37
+ // },
38
+ // text: {
39
+ // default: '#F0F6FC'
40
+ // }
41
+ // }
42
+ // }
43
+ // },
44
+
45
+ // Optional: Tooltip configuration
46
+ // tooltipConfig: {
47
+ // delayDuration: 100,
48
+ // skipDelayDuration: 300,
49
+ // disableHoverableContent: false,
50
+ // },
51
+
52
+ // Optional: Toast configuration
53
+ // toastConfig: {
54
+ // duration: 4000,
55
+ // swipeDirection: 'right',
56
+ // swipeThreshold: 50,
57
+ // },`;
9
58
 
10
59
  const CONFIG_TEMPLATES = {
11
60
  ts: `import type { ThemeConfig } from '@clickhouse/click-ui/theme';
12
61
 
13
62
  const config: ThemeConfig = {
14
- cssPrefix: '--click',
15
- storageKey: 'click-ui-theme',
16
-
17
- // Light mode theme (default)
18
- theme: {
19
- global: {
20
- color: {
21
- brand: '#FFCC00',
22
- background: {
23
- default: '#FFFFFF'
24
- }
25
- }
26
- },
27
- button: {
28
- space: {
29
- x: '1rem',
30
- y: '0.5rem'
31
- },
32
- radii: {
33
- all: '0.375rem'
34
- }
35
- }
36
- },
37
-
38
- // Dark mode overrides - if not defined, theme values are used for dark mode too
39
- dark: {
40
- global: {
41
- color: {
42
- background: {
43
- default: '#0D1117'
44
- },
45
- text: {
46
- default: '#F0F6FC'
47
- }
48
- }
49
- }
50
- }
63
+ ${CONFIG_BODY}
51
64
  };
52
65
 
53
66
  export default config;
54
67
  `,
55
68
  js: `/** @type {import('@clickhouse/click-ui/theme').ThemeConfig} */
56
69
  const config = {
57
- cssPrefix: '--click',
58
- storageKey: 'click-ui-theme',
59
-
60
- // Light mode theme (default)
61
- theme: {
62
- global: {
63
- color: {
64
- brand: '#FFCC00',
65
- background: {
66
- default: '#FFFFFF'
67
- }
68
- }
69
- },
70
- button: {
71
- space: {
72
- x: '1rem',
73
- y: '0.5rem'
74
- },
75
- radii: {
76
- all: '0.375rem'
77
- }
78
- }
79
- },
80
-
81
- // Dark mode overrides - if not defined, theme values are used for dark mode too
82
- dark: {
83
- global: {
84
- color: {
85
- background: {
86
- default: '#0D1117'
87
- },
88
- text: {
89
- default: '#F0F6FC'
90
- }
91
- }
92
- }
93
- }
70
+ ${CONFIG_BODY}
94
71
  };
95
72
 
96
73
  export default config;
97
74
  `
98
75
  };
99
76
 
100
- export const initCommand = (options) => {
101
- const format = options.format === 'js' ? 'js' : 'ts';
77
+ export const initCommand = options => {
78
+ const format = options.format === "js" ? "js" : "ts";
102
79
  const filename = `click-ui.config.${format}`;
103
80
  const targetPath = path.join(process.cwd(), filename);
81
+ const configExt = format === "ts" ? "ts" : "js";
104
82
 
105
83
  // Check if config already exists
106
84
  if (fs.existsSync(targetPath) && !options.force) {
@@ -110,22 +88,25 @@ export const initCommand = (options) => {
110
88
 
111
89
  // Write config file
112
90
  try {
113
- fs.writeFileSync(targetPath, CONFIG_TEMPLATES[format], 'utf-8');
114
- console.log(`✅ Created ${filename}`);
115
- console.log(`\n📝 Next steps:`);
116
- console.log(` 1. Customize your theme in ${filename}`);
117
- console.log(` 2. Add Vite alias to make config discoverable (vite.config.ts):`);
118
- console.log(`\n resolve: {`);
119
- console.log(` alias: {`);
120
- console.log(` 'click-ui-config': path.resolve(__dirname, './${filename}'),`);
121
- console.log(` },`);
122
- console.log(` },`);
123
- console.log(`\n 3. Use ClickUIProvider (config loads automatically):`);
124
- console.log(`\n import { ClickUIProvider } from '@clickhouse/click-ui';`);
125
- console.log(`\n <ClickUIProvider>`);
126
- console.log(` {/* Your app */}`);
127
- console.log(` </ClickUIProvider>`);
128
- console.log(`\n The config will be automatically discovered and applied! 🎨`);
91
+ fs.writeFileSync(targetPath, CONFIG_TEMPLATES[format], "utf-8");
92
+ console.log(`✅ Created ${filename}\n`);
93
+ console.log("📝 Next steps:\n");
94
+ console.log(` 1. Customize your theme in ${filename}\n`);
95
+ console.log(" 2. Add plugin to your bundler config:\n");
96
+ console.log(` // vite.config.${configExt}`);
97
+ console.log(" import { clickUIConfig } from '@clickhouse/click-ui/config';\n");
98
+ console.log(" export default defineConfig({");
99
+ console.log(" plugins: [");
100
+ console.log(" react(),");
101
+ console.log(` clickUIConfig(), // Loads ${filename}`);
102
+ console.log(" ],");
103
+ console.log(" });\n");
104
+ console.log(" 3. Use ClickUIProvider in your app:\n");
105
+ console.log(" import { ClickUIProvider } from '@clickhouse/click-ui';\n");
106
+ console.log(" <ClickUIProvider>");
107
+ console.log(" {/* Your app */}");
108
+ console.log(" </ClickUIProvider>\n");
109
+ console.log(" 🎨 Your custom theme will be applied!");
129
110
  } catch (error) {
130
111
  console.error(`❌ Failed to create config file: ${error.message}`);
131
112
  process.exit(1);