@inkdropapp/theme-dev-helpers 0.1.0 → 0.2.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 +4 -7
- package/package.json +1 -1
- package/src/generate-palette.ts +4 -6
package/README.md
CHANGED
|
@@ -24,18 +24,15 @@ generate-palette [options] <theme-name>
|
|
|
24
24
|
|
|
25
25
|
### Parameters
|
|
26
26
|
|
|
27
|
-
You can specify
|
|
27
|
+
You can specify the following options:
|
|
28
28
|
|
|
29
|
-
- `<theme-name>`: The name of the theme package to extract variables from. Required. (e.g.,: `default-light-ui`).
|
|
30
29
|
- `-a, --appearance <light/dark>`: Force the UI appearance ("light" or "dark")
|
|
31
30
|
- `-o, --output`: The file path where the extracted variables will be saved (default: `./palette.json`).
|
|
32
31
|
|
|
33
|
-
###
|
|
32
|
+
### Example
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
generate-palette default-light-ui
|
|
37
|
-
```
|
|
34
|
+
If your theme package name doesn't include 'dark' but it is a dark mode:
|
|
38
35
|
|
|
39
36
|
```sh
|
|
40
|
-
generate-palette
|
|
37
|
+
generate-palette -a dark
|
|
41
38
|
```
|
package/package.json
CHANGED
package/src/generate-palette.ts
CHANGED
|
@@ -12,19 +12,18 @@ program
|
|
|
12
12
|
.name('generate-palette')
|
|
13
13
|
.description('CLI tool for extracting CSS variables from a theme package for Inkdrop')
|
|
14
14
|
.version(packageJson.version)
|
|
15
|
-
.argument('<theme-name>', 'Theme package name (e.g., default-light-ui)')
|
|
16
15
|
.option('-a, --appearance <light/dark>', 'Force the UI appearance ("light" or "dark")')
|
|
17
16
|
.option('-o, --output <path>', 'Output file path (default: ./palette.json)', './palette.json')
|
|
18
17
|
.parse(process.argv);
|
|
19
18
|
|
|
20
19
|
// Parse options
|
|
21
|
-
const themePackageName = program.args[0] as string;
|
|
22
20
|
const options = program.opts();
|
|
23
21
|
const outputPath = options.output as string;
|
|
24
22
|
const appearance = options.appearance as 'light' | 'dark' | undefined;
|
|
25
23
|
|
|
26
24
|
// Function to extract theme CSS variables
|
|
27
|
-
async function extractPalette(
|
|
25
|
+
async function extractPalette(outputPath: string) {
|
|
26
|
+
const themePackageJson = (await import(path.join(process.cwd(), 'package.json')))
|
|
28
27
|
const themeVariableNames = (await import(`@inkdropapp/base-ui-theme/lib/variable-names.json`)).default;
|
|
29
28
|
|
|
30
29
|
const browser = await puppeteer.launch();
|
|
@@ -46,13 +45,12 @@ async function extractPalette(themePackageName: string, outputPath: string) {
|
|
|
46
45
|
<link rel="stylesheet" href="node_modules/@inkdropapp/base-ui-theme/styles/theme.css" />
|
|
47
46
|
<link rel="stylesheet" href="styles/theme.css" />
|
|
48
47
|
</head>
|
|
49
|
-
<body class="${
|
|
48
|
+
<body class="${themePackageJson.name} ${typeof appearance !== 'undefined' ? appearance + '-mode' : ''}">
|
|
50
49
|
<h1>Hello</h1>
|
|
51
50
|
</body>
|
|
52
51
|
</html>
|
|
53
52
|
`;
|
|
54
53
|
|
|
55
|
-
console.log(content)
|
|
56
54
|
await page.goto(baseUrl);
|
|
57
55
|
await page.setContent(content);
|
|
58
56
|
|
|
@@ -80,6 +78,6 @@ async function extractPalette(themePackageName: string, outputPath: string) {
|
|
|
80
78
|
await browser.close();
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
extractPalette(
|
|
81
|
+
extractPalette(outputPath)
|
|
84
82
|
.then(() => console.log('Palette extraction complete!'))
|
|
85
83
|
.catch(err => console.error('Error extracting palette:', err));
|