@clickhouse/click-ui 0.0.235 ā 0.0.237-sc-deprecation.1
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 +161 -20
- package/bin/README.md +178 -0
- package/bin/click-ui.config.example.ts +70 -0
- package/bin/click-ui.js +97 -0
- package/bin/commands/build-default-theme.ts +48 -0
- package/bin/commands/generate.js +117 -0
- package/bin/commands/init.js +110 -0
- package/bin/utils/config-loader.ts +61 -0
- package/bin/utils/css-generator.js +32 -0
- package/dist/click-ui.bundled.es.js +40740 -48756
- package/dist/click-ui.bundled.umd.js +79 -53070
- package/dist/click-ui.es.js +40747 -47595
- package/dist/click-ui.umd.js +79 -51901
- package/dist/components/Accordion/Accordion.d.ts +3 -3
- package/dist/components/AutoComplete/AutoComplete.d.ts +0 -1
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/BigStat/BigStat.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/components/CardHorizontal/CardHorizontal.d.ts +5 -1
- package/dist/components/CardPrimary/CardPrimaryTopBadge.d.ts +14 -3
- package/dist/components/CardPromotion/CardPromotion.d.ts +1 -1
- package/dist/components/CardSecondary/CardSecondary.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/CodeBlock/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock/useColorStyle.d.ts +1 -1
- package/dist/components/Collapsible/Collapsible.d.ts +3 -3
- package/dist/components/Container/Container.d.ts +5 -6
- package/dist/components/DatePicker/Common.d.ts +8 -3
- package/dist/components/Dialog/Dialog.d.ts +2 -2
- package/dist/components/EllipsisContent/EllipsisContent.d.ts +4 -6
- package/dist/components/FileTabs/FileTabs.d.ts +2 -2
- package/dist/components/Flyout/Flyout.d.ts +1 -1
- package/dist/components/GenericMenu.d.ts +22 -10
- package/dist/components/Grid/Cell.d.ts +2 -1
- package/dist/components/Grid/StyledCell.d.ts +5 -2
- package/dist/components/Grid/types.d.ts +1 -1
- package/dist/components/GridContainer/GridContainer.d.ts +4 -5
- package/dist/components/Icon/IconCommon.d.ts +4 -3
- package/dist/components/Icon/types.d.ts +3 -1
- package/dist/components/IconWrapper/IconWrapper.d.ts +2 -2
- package/dist/components/Input/InputWrapper.d.ts +25 -18
- package/dist/components/Link/Link.d.ts +4 -6
- package/dist/components/Link/linkStyles.d.ts +134 -0
- package/dist/components/Logos/AWSGlue.d.ts +4 -0
- package/dist/components/Logos/Logo.d.ts +1 -1
- package/dist/components/Logos/types.d.ts +1 -1
- package/dist/components/MultiAccordion/MultiAccordion.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/Select/common/SelectStyled.d.ts +24 -26
- package/dist/components/Separator/Separator.d.ts +4 -3
- package/dist/components/SidebarNavigationItem/SidebarNavigationItem.d.ts +5 -9
- package/dist/components/SidebarNavigationTitle/SidebarNavigationTitle.d.ts +5 -7
- package/dist/components/Spacer/Spacer.d.ts +2 -1
- package/dist/components/SplitButton/SplitButton.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +26 -24
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
- package/dist/components/Typography/Text/Text.d.ts +4 -5
- package/dist/components/VerticalStepper/VerticalStepper.d.ts +2 -2
- package/dist/components/commonElement.d.ts +21 -17
- package/dist/components/commonTypes.d.ts +1 -1
- package/dist/components/icons/DataLakes.d.ts +4 -0
- package/dist/components/icons/HorizontalLoading.d.ts +3 -1
- package/dist/components/icons/Loading.d.ts +1 -1
- package/dist/components/icons/LoadingAnimated.d.ts +3 -1
- package/dist/components/index.d.ts +6 -3
- package/dist/components/types.d.ts +51 -83
- package/dist/config/tokens/types.d.ts +15296 -0
- package/dist/config/tokens/types.d.ts.map +1 -0
- package/dist/config/tokens/types.js +2 -0
- package/dist/config/tokens/types.js.map +1 -0
- package/dist/config/types.d.ts +55 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/utils/css-builder.d.ts +38 -0
- package/dist/config/utils/css-builder.d.ts.map +1 -0
- package/dist/config/utils/css-builder.js +56 -0
- package/dist/config/utils/css-builder.js.map +1 -0
- package/dist/config/utils/css-generator.d.ts +25 -0
- package/dist/config/utils/css-generator.d.ts.map +1 -0
- package/dist/config/utils/css-generator.js +151 -0
- package/dist/config/utils/css-generator.js.map +1 -0
- package/dist/config/utils/find-config.d.ts +17 -0
- package/dist/config/utils/find-config.d.ts.map +1 -0
- package/dist/config/utils/find-config.js +28 -0
- package/dist/config/utils/find-config.js.map +1 -0
- package/dist/cui-components.css +1 -0
- package/dist/cui-default-theme.css +1809 -0
- package/dist/cui.css +3 -0
- package/dist/index.d.ts +77 -1
- package/dist/stories/ChartColorComponent.d.ts +1 -0
- package/dist/stories/chart-examples/ChartTooltip.d.ts +12 -0
- package/dist/stories/chart-examples/ColorSwatchesChart.d.ts +1 -0
- package/dist/stories/chart-examples/GroupedBarChart.d.ts +1 -0
- package/dist/stories/chart-examples/MultiLineChart.d.ts +1 -0
- package/dist/stories/chart-examples/StackedAreaChart.d.ts +1 -0
- package/dist/stories/chart-examples/StackedBarChartDemo.d.ts +1 -0
- package/dist/theme/ClickUIProvider/ClickUIProvider.d.ts +5 -0
- package/dist/theme/ClickUIProvider/ServerClickUIProvider.d.ts +23 -0
- package/dist/theme/ClickUIProvider/context.d.ts +24 -0
- package/dist/theme/ClickUIProvider/hooks.d.ts +4 -0
- package/dist/theme/ClickUIProvider/index.d.ts +6 -0
- package/dist/theme/ClickUIProvider/types.d.ts +39 -0
- package/dist/theme/config.d.ts +22 -0
- package/dist/theme/hooks/useSystemColorSchemePreference.d.ts +7 -0
- package/dist/theme/index.d.ts +6 -12
- package/dist/{styles ā theme/tokens}/types.d.ts +13 -6
- package/dist/{styles ā theme/tokens}/variables.dark.json.d.ts +118 -117
- package/dist/{styles ā theme/tokens}/variables.json.d.ts +20 -13
- package/dist/{styles ā theme/tokens}/variables.light.json.d.ts +146 -145
- package/dist/theme/types.d.ts +54 -0
- package/dist/theme/utils/css-builder.d.ts +37 -0
- package/dist/theme/utils/css-generator.d.ts +25 -0
- package/dist/theme/utils/find-config.d.ts +16 -0
- package/dist/theme/utils/theme-attribute.d.ts +13 -0
- package/dist/theme/utils.d.ts +29 -0
- package/dist/utils/capitalize.d.ts +12 -0
- package/dist/utils/polymorphic/index.d.ts +48 -0
- package/dist/utils/test-utils.d.ts +1 -3
- package/package.json +49 -24
- package/dist/click-ui.bundled.es.js.map +0 -1
- package/dist/click-ui.bundled.umd.js.map +0 -1
- package/dist/click-ui.es.js.map +0 -1
- package/dist/click-ui.umd.js.map +0 -1
- package/dist/components/ClickUIProvider/ClickUIProvider.d.ts +0 -15
- package/dist/components/Link/common.d.ts +0 -7
- package/dist/styles/variables.classic.json.d.ts +0 -993
- package/dist/theme/theme.d.ts +0 -7
package/README.md
CHANGED
|
@@ -6,35 +6,176 @@ 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
|
-
`npm i @clickhouse/click-ui`
|
|
11
|
-
or
|
|
12
|
-
`yarn add @clickhouse/click-ui`
|
|
13
|
-
2. Make sure to wrap your application in the Click UI `ClickUIProvider`, without doing this, you may run into issues with styled-components. Once thats done, you'll be able to import the individual components that you want to use on each page. Here's an example an `App.tsx` in NextJS.
|
|
9
|
+
### Quick Start
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
1. **Install Click UI**
|
|
12
|
+
```bash
|
|
13
|
+
npm install @clickhouse/click-ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Import the required styles**
|
|
17
|
+
|
|
18
|
+
Add these imports at the top of your main application file (before other styles):
|
|
19
|
+
|
|
20
|
+
**Option A: Simple (Recommended for most projects)**
|
|
21
|
+
```typescript
|
|
22
|
+
// All-in-one: Includes both component styles and default theme
|
|
23
|
+
import '@clickhouse/click-ui/cui.css';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Option B: Granular (For custom theming)**
|
|
27
|
+
```typescript
|
|
28
|
+
// Component styles only
|
|
29
|
+
import '@clickhouse/click-ui/cui-components.css';
|
|
30
|
+
|
|
31
|
+
// Default theme (light + dark with automatic switching)
|
|
32
|
+
import '@clickhouse/click-ui/cui-default-theme.css';
|
|
33
|
+
|
|
34
|
+
// OR import your custom theme instead:
|
|
35
|
+
// import './my-custom-theme.css';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Where to import:**
|
|
39
|
+
- **Next.js App Router**: Add to your root `layout.tsx`
|
|
40
|
+
- **Next.js Pages Router**: Add to `pages/_app.tsx`
|
|
41
|
+
- **Gatsby**: Add to `gatsby-browser.js`
|
|
42
|
+
- **Vite/React**: Add to `main.tsx` or `App.tsx`
|
|
43
|
+
|
|
44
|
+
3. **Wrap your app with ClickUIProvider**
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import '@clickhouse/click-ui/cui.css';
|
|
48
|
+
import { ClickUIProvider, Text, Title } from '@clickhouse/click-ui'
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
return (
|
|
52
|
+
<ClickUIProvider>
|
|
53
|
+
<Title type='h1'>Click UI Example</Title>
|
|
54
|
+
<Text>Welcome to Click UI!</Text>
|
|
55
|
+
</ClickUIProvider>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
17
58
|
|
|
18
|
-
|
|
19
|
-
|
|
59
|
+
export default App
|
|
60
|
+
```
|
|
20
61
|
|
|
21
|
-
|
|
22
|
-
theme === 'dark' ? setTheme('light') : setTheme('dark')
|
|
23
|
-
}
|
|
62
|
+
### Customizing Your Theme
|
|
24
63
|
|
|
25
|
-
|
|
26
|
-
<ClickUIProvider theme={theme} config={{tooltip:{ delayDuration: 0 }}}>
|
|
27
|
-
<Switch checked={theme === 'dark'} onClick={() => toggleTheme() } />
|
|
64
|
+
Click UI supports extensive theming through a CLI-based approach:
|
|
28
65
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
66
|
+
#### Step 1: Create a config file
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx click-ui init
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This creates a `click-ui.config.ts` file in your project root.
|
|
73
|
+
|
|
74
|
+
#### Step 2: Customize your theme
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// click-ui.config.ts
|
|
78
|
+
export default {
|
|
79
|
+
// Light mode theme tokens
|
|
80
|
+
theme: {
|
|
81
|
+
button: {
|
|
82
|
+
color: {
|
|
83
|
+
primary: {
|
|
84
|
+
'background-default': '#FF6B00',
|
|
85
|
+
'background-hover': '#FF8533',
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Dark mode overrides
|
|
92
|
+
dark: {
|
|
93
|
+
button: {
|
|
94
|
+
color: {
|
|
95
|
+
primary: {
|
|
96
|
+
'background-default': '#FF8533',
|
|
97
|
+
'background-hover': '#FFA366',
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// Runtime configuration (optional)
|
|
104
|
+
storageKey: 'my-app-theme',
|
|
105
|
+
tooltipConfig: { delayDuration: 200 }
|
|
33
106
|
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Step 3: Generate your custom theme CSS
|
|
34
110
|
|
|
35
|
-
|
|
111
|
+
```bash
|
|
112
|
+
npx click-ui generate
|
|
36
113
|
```
|
|
37
114
|
|
|
115
|
+
This creates `cui-custom-theme.css` in your `public/` folder.
|
|
116
|
+
|
|
117
|
+
#### Step 4: Import your custom theme instead of the default
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import '@clickhouse/click-ui/cui-components.css'; // Component styles only
|
|
121
|
+
import './public/cui-custom-theme.css'; // Your custom theme
|
|
122
|
+
import { ClickUIProvider } from '@clickhouse/click-ui'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Resources:**
|
|
126
|
+
- **[CLI Theme Generation](CLI_THEME_GENERATION.md)** - Complete CLI documentation
|
|
127
|
+
- **[Theme System](src/theme/index.md)** - Runtime theming, hooks, and theme switching
|
|
128
|
+
- **[Build-Time Configuration](BUILD_TIME_CONFIG_CLICK_UI.md)** - Theme config API reference
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## How It Works
|
|
133
|
+
|
|
134
|
+
Click UI uses a **pre-built CSS approach** for optimal performance:
|
|
135
|
+
|
|
136
|
+
1. **CSS Files Generated at Build Time**
|
|
137
|
+
- Default theme included in the library (~10 KB)
|
|
138
|
+
- Custom themes generated via CLI
|
|
139
|
+
- Uses CSS `light-dark()` function for automatic theme switching
|
|
140
|
+
|
|
141
|
+
2. **Minimal Runtime JavaScript**
|
|
142
|
+
- Provider only sets `data-theme` attribute (~600 bytes)
|
|
143
|
+
- Zero runtime CSS generation
|
|
144
|
+
- Instant theme switching via CSS attributes
|
|
145
|
+
|
|
146
|
+
3. **Perfect Tree-Shaking**
|
|
147
|
+
- Import only the components you use
|
|
148
|
+
- Unused CSS automatically eliminated by your bundler
|
|
149
|
+
- Optimal bundle size
|
|
150
|
+
|
|
151
|
+
### Theme Switching
|
|
152
|
+
|
|
153
|
+
Themes are controlled via HTML attributes and CSS custom properties:
|
|
154
|
+
|
|
155
|
+
```html
|
|
156
|
+
<!-- Light mode -->
|
|
157
|
+
<html data-theme="light">
|
|
158
|
+
|
|
159
|
+
<!-- Dark mode -->
|
|
160
|
+
<html data-theme="dark">
|
|
161
|
+
|
|
162
|
+
<!-- System preference mode (automatic) -->
|
|
163
|
+
<html data-theme="system">
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
All theme tokens are available as CSS variables with the `--click` prefix:
|
|
167
|
+
|
|
168
|
+
```css
|
|
169
|
+
.my-component {
|
|
170
|
+
background: var(--click-global-color-background-default);
|
|
171
|
+
color: var(--click-global-color-text-default);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The provider automatically sets the theme attribute based on user preference and system settings.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
38
179
|
## To develop this library locally š
|
|
39
180
|
|
|
40
181
|
1. Clone this repo, cd into the `click-ui` directory
|
package/bin/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Click UI CLI
|
|
2
|
+
|
|
3
|
+
This directory contains the Click UI command-line interface for theme customization.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Initialize a config file
|
|
9
|
+
npx click-ui init
|
|
10
|
+
|
|
11
|
+
# Generate custom theme CSS
|
|
12
|
+
npx click-ui generate
|
|
13
|
+
|
|
14
|
+
# Get help
|
|
15
|
+
npx click-ui --help
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
### `click-ui init`
|
|
21
|
+
|
|
22
|
+
Creates a `click-ui.config.ts` file in your project root with default configuration.
|
|
23
|
+
|
|
24
|
+
**Options:**
|
|
25
|
+
- `-f, --format <format>` - Config format: `js` or `ts` (default: `ts`)
|
|
26
|
+
- `--force` - Overwrite existing config file
|
|
27
|
+
- `-h, --help` - Display help
|
|
28
|
+
|
|
29
|
+
**Example:**
|
|
30
|
+
```bash
|
|
31
|
+
npx click-ui init
|
|
32
|
+
npx click-ui init --format js
|
|
33
|
+
npx click-ui init --force
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### `click-ui generate`
|
|
37
|
+
|
|
38
|
+
Generates custom theme CSS from your `click-ui.config.ts` file.
|
|
39
|
+
|
|
40
|
+
**Options:**
|
|
41
|
+
- `-o, --output <path>` - Output file path (default: `public/cui-custom-theme.css`)
|
|
42
|
+
- `-v, --verbose` - Show detailed output
|
|
43
|
+
- `-w, --watch` - Watch for config changes and regenerate
|
|
44
|
+
- `-h, --help` - Display help
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
```bash
|
|
48
|
+
npx click-ui generate
|
|
49
|
+
npx click-ui generate --output src/theme.css
|
|
50
|
+
npx click-ui generate --watch
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
See [click-ui.config.example.ts](./click-ui.config.example.ts) for a complete example configuration.
|
|
56
|
+
|
|
57
|
+
### Basic Structure
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
61
|
+
|
|
62
|
+
const config: ThemeConfig = {
|
|
63
|
+
// Light mode theme
|
|
64
|
+
theme: {
|
|
65
|
+
global: {
|
|
66
|
+
color: {
|
|
67
|
+
brand: '#FF6B6B',
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// Dark mode overrides
|
|
73
|
+
dark: {
|
|
74
|
+
global: {
|
|
75
|
+
color: {
|
|
76
|
+
brand: '#FF8A80',
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// Runtime configuration
|
|
82
|
+
storageKey: 'my-app-theme',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default config;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Workflow
|
|
89
|
+
|
|
90
|
+
1. **Create config:**
|
|
91
|
+
```bash
|
|
92
|
+
npx click-ui init
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
2. **Customize theme** in `click-ui.config.ts`:
|
|
96
|
+
```typescript
|
|
97
|
+
theme: {
|
|
98
|
+
button: {
|
|
99
|
+
primary: {
|
|
100
|
+
background: { default: '#FF6B6B' }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
3. **Generate CSS:**
|
|
107
|
+
```bash
|
|
108
|
+
npx click-ui generate
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
4. **Import in your app:**
|
|
112
|
+
```typescript
|
|
113
|
+
import '@clickhouse/click-ui/cui.css';
|
|
114
|
+
import './public/cui-custom-theme.css'; // Your custom theme
|
|
115
|
+
import { ClickUIProvider } from '@clickhouse/click-ui';
|
|
116
|
+
// OR for simple setup without custom theme:
|
|
117
|
+
// import '@clickhouse/click-ui/cui.css';
|
|
118
|
+
|
|
119
|
+
function App() {
|
|
120
|
+
return (
|
|
121
|
+
<ClickUIProvider>
|
|
122
|
+
{/* Your app */}
|
|
123
|
+
</ClickUIProvider>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## File Structure
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
bin/
|
|
132
|
+
āāā click-ui.js # CLI entry point
|
|
133
|
+
āāā click-ui.config.example.ts # Example configuration
|
|
134
|
+
āāā commands/
|
|
135
|
+
ā āāā init.js # Creates config file
|
|
136
|
+
ā āāā generate.js # Generates theme CSS
|
|
137
|
+
ā āāā build-default-theme.ts # Internal: builds library's default theme
|
|
138
|
+
āāā utils/
|
|
139
|
+
āāā css-generator.js # CSS generation utilities
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## TypeScript Support
|
|
143
|
+
|
|
144
|
+
Full TypeScript support with autocomplete for theme configuration:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import type { ThemeConfig } from '@clickhouse/click-ui/theme';
|
|
148
|
+
|
|
149
|
+
const config: ThemeConfig = {
|
|
150
|
+
theme: {
|
|
151
|
+
// TypeScript autocomplete works here! āØ
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## CSS Output
|
|
157
|
+
|
|
158
|
+
The CLI generates CSS using `light-dark()` functions for automatic theme switching:
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
:root {
|
|
162
|
+
color-scheme: light dark;
|
|
163
|
+
--click-button-color-primary-background-default: light-dark(#FF6B6B, #FF8A80);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This allows the browser to automatically switch between light and dark values based on the user's system preference or your theme setting.
|
|
168
|
+
|
|
169
|
+
## Documentation
|
|
170
|
+
|
|
171
|
+
For more information:
|
|
172
|
+
- [Main README](../README.md) - Getting started
|
|
173
|
+
- [Theme Documentation](../src/theme/index.md) - Theme configuration guide
|
|
174
|
+
- [GitHub Repository](https://github.com/ClickHouse/click-ui)
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
Apache-2.0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ThemeConfig } from "@clickhouse/click-ui/theme";
|
|
2
|
+
|
|
3
|
+
const config: ThemeConfig = {
|
|
4
|
+
storageKey: "click-ui-theme",
|
|
5
|
+
|
|
6
|
+
// Light mode theme (default)
|
|
7
|
+
theme: {
|
|
8
|
+
global: {
|
|
9
|
+
color: {
|
|
10
|
+
brand: "#FF6B6B",
|
|
11
|
+
background: {
|
|
12
|
+
default: "#FFFFFF",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
button: {
|
|
17
|
+
space: {
|
|
18
|
+
x: "1.5rem",
|
|
19
|
+
y: "0.75rem",
|
|
20
|
+
},
|
|
21
|
+
radii: {
|
|
22
|
+
all: "0.5rem",
|
|
23
|
+
},
|
|
24
|
+
primary: {
|
|
25
|
+
background: {
|
|
26
|
+
default: "#FF6B6B",
|
|
27
|
+
hover: "#FF5252",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// Dark mode overrides - if not defined, theme values are used for dark mode too
|
|
34
|
+
dark: {
|
|
35
|
+
global: {
|
|
36
|
+
color: {
|
|
37
|
+
background: {
|
|
38
|
+
default: "#0D1117",
|
|
39
|
+
},
|
|
40
|
+
text: {
|
|
41
|
+
default: "#F0F6FC",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
button: {
|
|
46
|
+
primary: {
|
|
47
|
+
background: {
|
|
48
|
+
default: "#FF8A80",
|
|
49
|
+
hover: "#FF7043",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// Tooltip configuration (optional)
|
|
56
|
+
// tooltipConfig: {
|
|
57
|
+
// delayDuration: 100,
|
|
58
|
+
// skipDelayDuration: 300,
|
|
59
|
+
// disableHoverableContent: false,
|
|
60
|
+
// },
|
|
61
|
+
|
|
62
|
+
// Toast configuration (optional)
|
|
63
|
+
// toastConfig: {
|
|
64
|
+
// duration: 4000,
|
|
65
|
+
// swipeDirection: "right",
|
|
66
|
+
// swipeThreshold: 50,
|
|
67
|
+
// },
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default config;
|
package/bin/click-ui.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { initCommand } from './commands/init.js';
|
|
4
|
+
import { generateCommand } from './commands/generate.js';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const command = args[0];
|
|
8
|
+
|
|
9
|
+
if (command === 'init') {
|
|
10
|
+
const options = {
|
|
11
|
+
format: 'ts',
|
|
12
|
+
force: false
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Parse options
|
|
16
|
+
for (let i = 1; i < args.length; i++) {
|
|
17
|
+
if (args[i] === '-f' || args[i] === '--format') {
|
|
18
|
+
options.format = args[i + 1];
|
|
19
|
+
i++;
|
|
20
|
+
} else if (args[i] === '--force') {
|
|
21
|
+
options.force = true;
|
|
22
|
+
} else if (args[i] === '-h' || args[i] === '--help') {
|
|
23
|
+
console.log(`
|
|
24
|
+
Usage: @clickhouse/click-ui init [options]
|
|
25
|
+
|
|
26
|
+
Initialize Click UI configuration file
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-f, --format <format> Config format (js or ts) (default: "ts")
|
|
30
|
+
--force Overwrite existing config file
|
|
31
|
+
-h, --help Display help for command
|
|
32
|
+
`);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
initCommand(options);
|
|
38
|
+
} else if (command === 'generate') {
|
|
39
|
+
const options = {
|
|
40
|
+
output: null,
|
|
41
|
+
verbose: false,
|
|
42
|
+
watch: false
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Parse options
|
|
46
|
+
for (let i = 1; i < args.length; i++) {
|
|
47
|
+
if (args[i] === '-o' || args[i] === '--output') {
|
|
48
|
+
options.output = args[i + 1];
|
|
49
|
+
i++;
|
|
50
|
+
} else if (args[i] === '-v' || args[i] === '--verbose') {
|
|
51
|
+
options.verbose = true;
|
|
52
|
+
} else if (args[i] === '-w' || args[i] === '--watch') {
|
|
53
|
+
options.watch = true;
|
|
54
|
+
} else if (args[i] === '-h' || args[i] === '--help') {
|
|
55
|
+
console.log(`
|
|
56
|
+
Usage: @clickhouse/click-ui generate [options]
|
|
57
|
+
|
|
58
|
+
Generate custom theme CSS from click-ui.config.ts/js
|
|
59
|
+
|
|
60
|
+
Options:
|
|
61
|
+
-o, --output <path> Output file path (default: "public/cui-custom-theme.css")
|
|
62
|
+
-v, --verbose Show detailed output
|
|
63
|
+
-w, --watch Watch for config changes and regenerate
|
|
64
|
+
-h, --help Display help for command
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
click-ui generate
|
|
68
|
+
click-ui generate --output src/theme.css
|
|
69
|
+
click-ui generate --watch
|
|
70
|
+
`);
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
generateCommand(options);
|
|
76
|
+
} else if (command === '--version' || command === '-V') {
|
|
77
|
+
console.log('0.0.234');
|
|
78
|
+
} else if (command === '--help' || command === '-h' || !command) {
|
|
79
|
+
console.log(`
|
|
80
|
+
Usage: @clickhouse/click-ui [options] [command]
|
|
81
|
+
|
|
82
|
+
CLI for ClickHouse Click UI
|
|
83
|
+
|
|
84
|
+
Options:
|
|
85
|
+
-V, --version Output the version number
|
|
86
|
+
-h, --help Display help for command
|
|
87
|
+
|
|
88
|
+
Commands:
|
|
89
|
+
init [options] Initialize Click UI configuration file
|
|
90
|
+
generate [options] Generate custom theme CSS from config
|
|
91
|
+
help [command] Display help for command
|
|
92
|
+
`);
|
|
93
|
+
} else {
|
|
94
|
+
console.error(`Unknown command: ${command}`);
|
|
95
|
+
console.log('Run "@clickhouse/click-ui --help" for usage information.');
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate theme-default.css with light-dark() functions
|
|
5
|
+
* This runs during library build to create pre-compiled CSS
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
import { getBaseTheme } from "../../src/theme/utils";
|
|
11
|
+
import { generateLightDarkVariables, generateThemeOverrides } from "../../src/theme/utils/css-generator";
|
|
12
|
+
import { buildCSSOutput } from "../../src/theme/utils/css-builder";
|
|
13
|
+
|
|
14
|
+
// Load light and dark base themes from tokens
|
|
15
|
+
const lightTheme = getBaseTheme("light");
|
|
16
|
+
const darkTheme = getBaseTheme("dark");
|
|
17
|
+
|
|
18
|
+
// Debug: Check if themes loaded correctly
|
|
19
|
+
console.log("\nš Debug Info:");
|
|
20
|
+
console.log(`Light theme loaded: ${Object.keys(lightTheme).length} keys`);
|
|
21
|
+
console.log(`Dark theme loaded: ${Object.keys(darkTheme).length} keys`);
|
|
22
|
+
console.log(`Light accordion color: ${lightTheme?.click?.accordion?.color?.default?.label?.default}`);
|
|
23
|
+
console.log(`Dark accordion color: ${darkTheme?.click?.accordion?.color?.default?.label?.default}`);
|
|
24
|
+
|
|
25
|
+
// Generate CSS using the same logic as injectThemeStyles()
|
|
26
|
+
const lightDarkVars = generateLightDarkVariables(lightTheme, darkTheme);
|
|
27
|
+
const themeOverrides = generateThemeOverrides(lightTheme, darkTheme);
|
|
28
|
+
|
|
29
|
+
// Build CSS using shared builder
|
|
30
|
+
const css = buildCSSOutput(lightDarkVars, themeOverrides, {
|
|
31
|
+
headerComment: '/* Click UI Default Theme */\n/* Generated during library build - DO NOT EDIT MANUALLY */\n/* Uses light-dark() CSS function for automatic theme switching */\n'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Ensure output directory exists
|
|
35
|
+
const outputDir = path.join(process.cwd(), "src", "styles");
|
|
36
|
+
if (!fs.existsSync(outputDir)) {
|
|
37
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Write the CSS file
|
|
41
|
+
const outputPath = path.join(outputDir, "cui-default-theme.css");
|
|
42
|
+
fs.writeFileSync(outputPath, css, "utf-8");
|
|
43
|
+
|
|
44
|
+
console.log(`ā
Generated cui-default-theme.css (${css.length} bytes)`);
|
|
45
|
+
console.log(` Location: ${outputPath}`);
|
|
46
|
+
console.log(` Light vars: ${Object.keys(lightDarkVars).length}`);
|
|
47
|
+
console.log(` Light overrides: ${Object.keys(themeOverrides.light).length}`);
|
|
48
|
+
console.log(` Dark overrides: ${Object.keys(themeOverrides.dark).length}`);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { pathToFileURL } from 'url';
|
|
7
|
+
import { findConfigFile } from '../../src/theme/utils/find-config.js';
|
|
8
|
+
import { loadConfig, validateConfig } from '../utils/config-loader.js';
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generate custom theme CSS from click-ui.config.ts/js
|
|
15
|
+
*/
|
|
16
|
+
export async function generateCommand(options = {}) {
|
|
17
|
+
const cwd = process.cwd();
|
|
18
|
+
const outputPath = options.output || path.join(cwd, 'public', 'cui-custom-theme.css');
|
|
19
|
+
const verbose = options.verbose || false;
|
|
20
|
+
|
|
21
|
+
console.log('šØ Click UI Theme Generator\n');
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
// Find config file
|
|
25
|
+
const configFile = findConfigFile(cwd);
|
|
26
|
+
|
|
27
|
+
if (!configFile) {
|
|
28
|
+
console.log('ā¹ļø No click-ui.config.ts/js found');
|
|
29
|
+
console.log(' Run "click-ui init" to create a config file');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (verbose) {
|
|
34
|
+
console.log(`š Found config: ${path.relative(cwd, configFile)}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Load config
|
|
38
|
+
const config = await loadConfig(configFile);
|
|
39
|
+
|
|
40
|
+
if (!validateConfig(config)) {
|
|
41
|
+
console.log('ā ļø Config file exists but has no theme configuration');
|
|
42
|
+
console.log(' Add "theme" or "dark" properties to customize your theme');
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Generate CSS
|
|
47
|
+
const css = await generateCSS(config);
|
|
48
|
+
|
|
49
|
+
// Ensure output directory exists
|
|
50
|
+
const outputDir = path.dirname(outputPath);
|
|
51
|
+
if (!fs.existsSync(outputDir)) {
|
|
52
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
53
|
+
if (verbose) {
|
|
54
|
+
console.log(`š Created directory: ${path.relative(cwd, outputDir)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Write CSS file
|
|
59
|
+
fs.writeFileSync(outputPath, css, 'utf-8');
|
|
60
|
+
|
|
61
|
+
console.log('ā
Generated custom theme CSS');
|
|
62
|
+
console.log(` Location: ${path.relative(cwd, outputPath)}`);
|
|
63
|
+
console.log(` Size: ${(css.length / 1024).toFixed(2)} KB\n`);
|
|
64
|
+
|
|
65
|
+
console.log('š Next steps:');
|
|
66
|
+
console.log(' 1. Import the CSS in your app:');
|
|
67
|
+
console.log(` import '${path.relative(cwd, outputPath).replace(/\\/g, '/')}';`);
|
|
68
|
+
console.log(' 2. Or add to your HTML:');
|
|
69
|
+
console.log(` <link rel="stylesheet" href="/${path.basename(outputPath)}">`);
|
|
70
|
+
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('ā Failed to generate theme CSS:', error.message);
|
|
73
|
+
if (verbose) {
|
|
74
|
+
console.error(error.stack);
|
|
75
|
+
}
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generate CSS from config
|
|
82
|
+
*/
|
|
83
|
+
async function generateCSS(config) {
|
|
84
|
+
// Import the CSS generation function from bin/utils
|
|
85
|
+
const cssGeneratorPath = path.join(__dirname, '../utils/css-generator.js');
|
|
86
|
+
|
|
87
|
+
if (!fs.existsSync(cssGeneratorPath)) {
|
|
88
|
+
throw new Error('CSS generator module not found at ' + cssGeneratorPath);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { generateThemeCSS } = await import(pathToFileURL(cssGeneratorPath).href);
|
|
92
|
+
|
|
93
|
+
// Get full config and generate CSS
|
|
94
|
+
const fullConfig = config.default || config;
|
|
95
|
+
const css = generateThemeCSS(fullConfig);
|
|
96
|
+
|
|
97
|
+
if (!css || css.length === 0) {
|
|
98
|
+
throw new Error('No CSS generated. Please check your theme configuration.');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return css;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Split config into build-time and runtime
|
|
106
|
+
*/
|
|
107
|
+
function splitConfig(fullConfig) {
|
|
108
|
+
const { theme, dark, ...runtimeConfig } = fullConfig;
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
buildTimeConfig: {
|
|
112
|
+
...(theme && { theme }),
|
|
113
|
+
...(dark && { dark }),
|
|
114
|
+
},
|
|
115
|
+
runtimeConfig,
|
|
116
|
+
};
|
|
117
|
+
}
|