@clickhouse/click-ui 0.0.234-sc-deprecation.3 → 0.0.234-sc-deprecation.5
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 +178 -15
- package/bin/click-ui.js +57 -0
- package/bin/commands/init.js +151 -0
- package/dist/click-ui.bundled.es.js +787 -773
- package/dist/click-ui.bundled.umd.js +2 -2
- package/dist/click-ui.es.js +787 -773
- package/dist/click-ui.umd.js +2 -2
- package/dist/theme/types.d.ts +4 -3
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -6,35 +6,198 @@ The home of the ClickHouse design system and component library. Click UI is in v
|
|
|
6
6
|
|
|
7
7
|
Click UI has been tested in NextJS, Gatsby, and Vite. If you run into problems using it in your app, please create an issue and our team will try to answer.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
### Quick Start
|
|
10
|
+
|
|
11
|
+
1. **Install Click UI**
|
|
12
|
+
```bash
|
|
13
|
+
npm install @clickhouse/click-ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Wrap your app with ClickUIProvider**
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { ClickUIProvider, Text, Title } from '@clickhouse/click-ui'
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<ClickUIProvider>
|
|
24
|
+
<Title type='h1'>Click UI Example</Title>
|
|
25
|
+
<Text>Welcome to Click UI!</Text>
|
|
26
|
+
</ClickUIProvider>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default App
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Customizing Your Theme
|
|
34
|
+
|
|
35
|
+
To customize the theme with your own colors, spacing, and styles:
|
|
36
|
+
|
|
37
|
+
1. **Initialize configuration**
|
|
38
|
+
```bash
|
|
39
|
+
npx @clickhouse/click-ui init
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This creates a `click-ui.config.ts` file in your project root.
|
|
43
|
+
|
|
44
|
+
2. **Setup Vite alias** to enable auto-discovery
|
|
45
|
+
|
|
46
|
+
In your `vite.config.ts`:
|
|
47
|
+
```ts
|
|
48
|
+
import { defineConfig } from 'vite';
|
|
49
|
+
import path from 'path';
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
resolve: {
|
|
53
|
+
alias: {
|
|
54
|
+
'click-ui-config': path.resolve(__dirname, './click-ui.config.ts'),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
3. **Customize the generated config file**
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
64
|
+
|
|
65
|
+
const config: ThemeConfig = {
|
|
66
|
+
theme: {
|
|
67
|
+
global: {
|
|
68
|
+
color: {
|
|
69
|
+
brand: '#FFCC00',
|
|
70
|
+
background: {
|
|
71
|
+
default: '#FFFFFF'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
button: {
|
|
76
|
+
primary: {
|
|
77
|
+
background: {
|
|
78
|
+
default: '#FFCC00',
|
|
79
|
+
hover: '#FFD700'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default config;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
4. **That's it!** Your custom theme will be automatically loaded by ClickUIProvider.
|
|
90
|
+
|
|
91
|
+
#### CLI Options
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Create TypeScript config (default)
|
|
95
|
+
npx @clickhouse/click-ui init
|
|
96
|
+
|
|
97
|
+
# Create JavaScript config
|
|
98
|
+
npx @clickhouse/click-ui init -f js
|
|
99
|
+
|
|
100
|
+
# Overwrite existing config
|
|
101
|
+
npx @clickhouse/click-ui init --force
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Advanced Configuration Options
|
|
105
|
+
|
|
106
|
+
The generated config file supports extensive customization:
|
|
107
|
+
|
|
108
|
+
#### System Mode Overrides
|
|
109
|
+
|
|
110
|
+
Define different styles for light and dark modes:
|
|
14
111
|
|
|
15
112
|
```typescript
|
|
16
|
-
|
|
113
|
+
const config: ThemeConfig = {
|
|
114
|
+
systemModeOverrides: {
|
|
115
|
+
light: {
|
|
116
|
+
global: {
|
|
117
|
+
color: {
|
|
118
|
+
background: { default: '#FFFFFF' }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
dark: {
|
|
123
|
+
global: {
|
|
124
|
+
color: {
|
|
125
|
+
background: { default: '#0D1117' },
|
|
126
|
+
text: { default: '#F0F6FC' }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
```
|
|
17
133
|
|
|
18
|
-
|
|
19
|
-
|
|
134
|
+
#### Component-Specific Styling
|
|
135
|
+
|
|
136
|
+
Customize individual components:
|
|
20
137
|
|
|
21
|
-
|
|
22
|
-
|
|
138
|
+
```typescript
|
|
139
|
+
const config: ThemeConfig = {
|
|
140
|
+
theme: {
|
|
141
|
+
button: {
|
|
142
|
+
space: { x: '1rem', y: '0.5rem' },
|
|
143
|
+
radii: { all: '0.375rem' },
|
|
144
|
+
primary: {
|
|
145
|
+
background: {
|
|
146
|
+
default: '#FFCC00',
|
|
147
|
+
hover: '#FFD700'
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
23
151
|
}
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Manual Theme Control
|
|
156
|
+
|
|
157
|
+
You can manually control the theme at runtime:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { ClickUIProvider, useCUITheme, Switch } from '@clickhouse/click-ui'
|
|
161
|
+
|
|
162
|
+
function ThemeToggle() {
|
|
163
|
+
const { themeName, toggleTheme } = useCUITheme();
|
|
24
164
|
|
|
25
165
|
return (
|
|
26
|
-
<
|
|
27
|
-
|
|
166
|
+
<Switch
|
|
167
|
+
checked={themeName === 'dark'}
|
|
168
|
+
onClick={toggleTheme}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
28
172
|
|
|
173
|
+
function App() {
|
|
174
|
+
return (
|
|
175
|
+
<ClickUIProvider theme="dark">
|
|
176
|
+
<ThemeToggle />
|
|
29
177
|
<Title type='h1'>Click UI Example</Title>
|
|
30
|
-
<Text>Welcome to Click UI. Get started here.</Text>
|
|
31
178
|
</ClickUIProvider>
|
|
32
179
|
)
|
|
33
180
|
}
|
|
34
|
-
|
|
35
|
-
export default App
|
|
36
181
|
```
|
|
37
182
|
|
|
183
|
+
### How It Works
|
|
184
|
+
|
|
185
|
+
1. **Config File**: Create `click-ui.config.ts` in your project root
|
|
186
|
+
2. **Vite Alias**: The alias makes the config discoverable via `'click-ui-config'` import
|
|
187
|
+
3. **Auto-Load**: `ClickUIProvider` automatically imports and applies your config
|
|
188
|
+
4. **Runtime Override**: Props passed to `ClickUIProvider` can override the config
|
|
189
|
+
|
|
190
|
+
### Troubleshooting
|
|
191
|
+
|
|
192
|
+
**Config not loading?**
|
|
193
|
+
- Verify the Vite alias is correctly set up in `vite.config.ts`
|
|
194
|
+
- Ensure `click-ui.config.ts` is in your project root
|
|
195
|
+
- Restart your dev server after adding the alias
|
|
196
|
+
|
|
197
|
+
**TypeScript errors?**
|
|
198
|
+
- Import types from: `import type { ThemeConfig } from '@clickhouse/click-ui/theme';`
|
|
199
|
+
- Your IDE will provide autocomplete for all config options
|
|
200
|
+
|
|
38
201
|
## To develop this library locally 🚀
|
|
39
202
|
|
|
40
203
|
1. Clone this repo, cd into the `click-ui` directory
|
package/bin/click-ui.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { initCommand } from './commands/init.js';
|
|
4
|
+
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const command = args[0];
|
|
7
|
+
|
|
8
|
+
if (command === 'init') {
|
|
9
|
+
const options = {
|
|
10
|
+
format: 'ts',
|
|
11
|
+
force: false
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Parse options
|
|
15
|
+
for (let i = 1; i < args.length; i++) {
|
|
16
|
+
if (args[i] === '-f' || args[i] === '--format') {
|
|
17
|
+
options.format = args[i + 1];
|
|
18
|
+
i++;
|
|
19
|
+
} else if (args[i] === '--force') {
|
|
20
|
+
options.force = true;
|
|
21
|
+
} else if (args[i] === '-h' || args[i] === '--help') {
|
|
22
|
+
console.log(`
|
|
23
|
+
Usage: @clickhouse/click-ui init [options]
|
|
24
|
+
|
|
25
|
+
Initialize Click UI configuration file
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
-f, --format <format> Config format (js or ts) (default: "ts")
|
|
29
|
+
--force Overwrite existing config file
|
|
30
|
+
-h, --help Display help for command
|
|
31
|
+
`);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
initCommand(options);
|
|
37
|
+
} else if (command === '--version' || command === '-V') {
|
|
38
|
+
console.log('0.0.234');
|
|
39
|
+
} else if (command === '--help' || command === '-h' || !command) {
|
|
40
|
+
console.log(`
|
|
41
|
+
Usage: @clickhouse/click-ui [options] [command]
|
|
42
|
+
|
|
43
|
+
CLI for ClickHouse Click UI
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
-V, --version Output the version number
|
|
47
|
+
-h, --help Display help for command
|
|
48
|
+
|
|
49
|
+
Commands:
|
|
50
|
+
init [options] Initialize Click UI configuration file
|
|
51
|
+
help [command] Display help for command
|
|
52
|
+
`);
|
|
53
|
+
} else {
|
|
54
|
+
console.error(`Unknown command: ${command}`);
|
|
55
|
+
console.log('Run "@clickhouse/click-ui --help" for usage information.');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const CONFIG_TEMPLATES = {
|
|
11
|
+
ts: `import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
12
|
+
|
|
13
|
+
const config: ThemeConfig = {
|
|
14
|
+
cssPrefix: '--click',
|
|
15
|
+
storageKey: 'click-ui-theme',
|
|
16
|
+
|
|
17
|
+
theme: {
|
|
18
|
+
global: {
|
|
19
|
+
color: {
|
|
20
|
+
brand: '#FFCC00',
|
|
21
|
+
background: {
|
|
22
|
+
default: '#FFFFFF'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
button: {
|
|
27
|
+
space: {
|
|
28
|
+
x: '1rem',
|
|
29
|
+
y: '0.5rem'
|
|
30
|
+
},
|
|
31
|
+
radii: {
|
|
32
|
+
all: '0.375rem'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
systemModeOverrides: {
|
|
38
|
+
light: {
|
|
39
|
+
global: {
|
|
40
|
+
color: {
|
|
41
|
+
background: {
|
|
42
|
+
default: '#FFFFFF'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
dark: {
|
|
48
|
+
global: {
|
|
49
|
+
color: {
|
|
50
|
+
background: {
|
|
51
|
+
default: '#0D1117'
|
|
52
|
+
},
|
|
53
|
+
text: {
|
|
54
|
+
default: '#F0F6FC'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default config;
|
|
63
|
+
`,
|
|
64
|
+
js: `/** @type {import('@clickhouse/click-ui/theme').ThemeConfig} */
|
|
65
|
+
const config = {
|
|
66
|
+
cssPrefix: '--click',
|
|
67
|
+
storageKey: 'click-ui-theme',
|
|
68
|
+
|
|
69
|
+
theme: {
|
|
70
|
+
global: {
|
|
71
|
+
color: {
|
|
72
|
+
brand: '#FFCC00',
|
|
73
|
+
background: {
|
|
74
|
+
default: '#FFFFFF'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
button: {
|
|
79
|
+
space: {
|
|
80
|
+
x: '1rem',
|
|
81
|
+
y: '0.5rem'
|
|
82
|
+
},
|
|
83
|
+
radii: {
|
|
84
|
+
all: '0.375rem'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
systemModeOverrides: {
|
|
90
|
+
light: {
|
|
91
|
+
global: {
|
|
92
|
+
color: {
|
|
93
|
+
background: {
|
|
94
|
+
default: '#FFFFFF'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
dark: {
|
|
100
|
+
global: {
|
|
101
|
+
color: {
|
|
102
|
+
background: {
|
|
103
|
+
default: '#0D1117'
|
|
104
|
+
},
|
|
105
|
+
text: {
|
|
106
|
+
default: '#F0F6FC'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default config;
|
|
115
|
+
`
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const initCommand = (options) => {
|
|
119
|
+
const format = options.format === 'js' ? 'js' : 'ts';
|
|
120
|
+
const filename = `click-ui.config.${format}`;
|
|
121
|
+
const targetPath = path.join(process.cwd(), filename);
|
|
122
|
+
|
|
123
|
+
// Check if config already exists
|
|
124
|
+
if (fs.existsSync(targetPath) && !options.force) {
|
|
125
|
+
console.error(`❌ ${filename} already exists. Use --force to overwrite.`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Write config file
|
|
130
|
+
try {
|
|
131
|
+
fs.writeFileSync(targetPath, CONFIG_TEMPLATES[format], 'utf-8');
|
|
132
|
+
console.log(`✅ Created ${filename}`);
|
|
133
|
+
console.log(`\n📝 Next steps:`);
|
|
134
|
+
console.log(` 1. Customize your theme in ${filename}`);
|
|
135
|
+
console.log(` 2. Add Vite alias to make config discoverable (vite.config.ts):`);
|
|
136
|
+
console.log(`\n resolve: {`);
|
|
137
|
+
console.log(` alias: {`);
|
|
138
|
+
console.log(` 'click-ui-config': path.resolve(__dirname, './${filename}'),`);
|
|
139
|
+
console.log(` },`);
|
|
140
|
+
console.log(` },`);
|
|
141
|
+
console.log(`\n 3. Use ClickUIProvider (config loads automatically):`);
|
|
142
|
+
console.log(`\n import { ClickUIProvider } from '@clickhouse/click-ui';`);
|
|
143
|
+
console.log(`\n <ClickUIProvider>`);
|
|
144
|
+
console.log(` {/* Your app */}`);
|
|
145
|
+
console.log(` </ClickUIProvider>`);
|
|
146
|
+
console.log(`\n The config will be automatically discovered and applied! 🎨`);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error(`❌ Failed to create config file: ${error.message}`);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
};
|