Skip to content

Commit bb23dc1

Browse files
committed
refactor(utils): move extract-theme to a separate package
1 parent 8c07955 commit bb23dc1

34 files changed

+384
-36
lines changed

apps/component-tests/src/root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ThemeModes,
1414
ThemePrimaryColors,
1515
ThemeStyles,
16-
} from '@qwik-ui/utils';
16+
} from '@qwik-ui/extract-theme';
1717

1818
export default component$(() => {
1919
/**

apps/website/src/components/copy-css-config/copy-css-config.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { component$, useSignal } from '@builder.io/qwik';
22
import { Modal } from '@qwik-ui/headless';
33
import { Button } from '~/components/ui';
4-
import { extractThemeCSS } from '@qwik-ui/utils';
4+
import { extractThemeCSS } from '@qwik-ui/extract-theme';
55
import { LuX } from '@qwikest/icons/lucide';
66
import { useTheme } from '@qwik-ui/themes';
77
import globalCSS from '~/global.css?raw';

apps/website/src/components/make-it-yours/make-it-yours.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
ThemeModes,
88
ThemePrimaryColors,
99
ThemeStyles,
10-
cn,
11-
} from '@qwik-ui/utils';
10+
} from '@qwik-ui/extract-theme';
11+
import { cn } from '@qwik-ui/utils';
1212
import { LuSlidersHorizontal, LuX } from '@qwikest/icons/lucide';
1313
import { useTheme } from '@qwik-ui/themes';
1414

apps/website/src/root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
ThemeModes,
1616
ThemePrimaryColors,
1717
ThemeStyles,
18-
} from '@qwik-ui/utils';
18+
} from '@qwik-ui/extract-theme';
1919
import { ModulePreload } from './components/module-preload/module-preload';
2020

2121
export default component$(() => {

packages/cli/bin/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
ThemePrimaryColors,
2828
ThemeStyle,
2929
ThemeStyles,
30-
} from '@qwik-ui/utils';
30+
} from '@qwik-ui/extract-theme';
3131
import { bgRgb, bold, cyan, green, red } from 'ansis';
3232
import { execSync } from 'child_process';
3333
import { existsSync, readFileSync, writeFileSync } from 'fs';

packages/cli/src/generators/setup-tailwind/schema.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ThemeConfig } from '@qwik-ui/utils';
1+
import type { ThemeConfig } from '@qwik-ui/extract-theme';
22

33
export interface SetupTailwindGeneratorSchema extends ThemeConfig {
44
projectRoot?: string;

packages/cli/src/generators/setup-tailwind/setup-tailwind-generator.spec.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2-
import { ThemeBorderRadiuses, ThemePrimaryColors, ThemeStyles } from '@qwik-ui/utils';
2+
import {
3+
ThemeBorderRadiuses,
4+
ThemePrimaryColors,
5+
ThemeStyles,
6+
} from '@qwik-ui/extract-theme';
37
import { SetupTailwindGeneratorSchema } from './schema';
48
import { setupTailwindGenerator } from './setup-tailwind-generator';
59

packages/cli/src/generators/setup-tailwind/setup-tailwind-generator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
extractBetweenComments,
88
extractThemeCSS,
99
type ThemeConfig,
10-
} from '@qwik-ui/utils';
10+
} from '@qwik-ui/extract-theme';
1111
import { readFileSync } from 'fs';
1212
import { join } from 'path';
1313
import { getKitRoot } from '../../_shared/get-kit-root';

packages/extract-theme/.eslintrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

packages/extract-theme/CHANGELOG.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Changelog
2+
3+
## 0.3.1
4+
5+
### Patch Changes
6+
7+
- ✨ new inline component utilities (by [@thejackshelton](https://github.com/thejackshelton) in [#937](https://github.com/qwikifiers/qwik-ui/pull/937))
8+
9+
## 0.3.0
10+
11+
### Minor Changes
12+
13+
- Changed enums to const maps in utils (by [@shairez](https://github.com/shairez) in [#914](https://github.com/qwikifiers/qwik-ui/pull/914))
14+
15+
## 0.2.1
16+
17+
### Patch Changes
18+
19+
- ✨ added `extractThemeCSS` (by [@shairez](https://github.com/shairez) in [#604](https://github.com/qwikifiers/qwik-ui/pull/604))
20+
21+
## 0.2.0
22+
23+
### Minor Changes
24+
25+
- Removed `useOrdinal` (by [@shairez](https://github.com/shairez) in [`4043d29`](https://github.com/qwikifiers/qwik-ui/commit/4043d29dcc39b03f16c79d659da592af3fbeafeb))
26+
27+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
28+
29+
## [0.1.1](https://github.com/qwikifiers/qwik-ui/compare/utils-0.1.0...utils-0.1.1) (2024-01-09)
30+
31+
# [0.1.0](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.3...utils-0.1.0) (2023-12-16)
32+
33+
### Bug Fixes
34+
35+
- **docs:** add install / related docs / merge with main ([bb1b62c](https://github.com/qwikifiers/qwik-ui/commit/bb1b62cd87d376858fd706e9b5344603be87127c))
36+
- **everything:** fix 1.3 craziness ([0b20d97](https://github.com/qwikifiers/qwik-ui/commit/0b20d97af41f75bc7e1215391fd1c202ee8a9366))
37+
38+
## [0.0.3](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.2...utils-0.0.3) (2023-12-01)
39+
40+
## [0.0.2](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.1...utils-0.0.2) (2023-12-01)
41+
42+
## 0.0.1 (2023-11-30)

packages/extract-theme/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 HiRez.io, Qwikifiers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/extract-theme/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Qwik UI extract-theme
2+
3+
## `stringifyClassList`
4+
5+
A function that takes a Qwik class list and returns a string.
6+
Good for cases you are working with other libraries that require a string as an input.
7+
8+
## `cva`
9+
10+
This is a version of the original code from [cva](https://cva.style/) but optimized for Qwik apps.
11+
12+
Thanks to [Joe Bell](https://twitter.com/joebell_) for creating the original library.
13+
14+
## `tcva`
15+
16+
CVA with Tailwind merge built in.
17+
18+
# License
19+
20+
MIT

packages/extract-theme/package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@qwik-ui/extract-theme",
3+
"version": "0.3.1",
4+
"description": "Qwik UI extract-theme",
5+
"publishConfig": {
6+
"access": "public"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/qwikifiers/qwik-ui",
11+
"directory": "packages/extract-theme"
12+
},
13+
"main": "./index.qwik.cjs",
14+
"qwik": "./index.qwik.mjs",
15+
"module": "./index.qwik.mjs",
16+
"types": "./index.d.ts",
17+
"type": "module",
18+
"exports": {
19+
".": {
20+
"types": "./index.d.ts",
21+
"import": "./index.qwik.mjs",
22+
"require": "./index.qwik.cjs"
23+
}
24+
},
25+
"engines": {
26+
"node": ">=16.0.0"
27+
},
28+
"private": false,
29+
"dependencies": {
30+
"tailwind-merge": "^1.14.0",
31+
"clsx": "^2.0.0",
32+
"qwik-themes": "^0.2.0"
33+
}
34+
}

packages/extract-theme/project.json

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "extract-theme",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/extract-theme/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/vite:build",
9+
"outputs": ["{options.outputPath}"],
10+
"defaultConfiguration": "production",
11+
"options": {
12+
"outputPath": "dist/packages/extract-theme",
13+
"configFile": "packages/extract-theme/vite.config.ts",
14+
"mode": "lib"
15+
},
16+
"configurations": {
17+
"development": {},
18+
"production": {}
19+
}
20+
},
21+
"lint": {
22+
"executor": "@nx/eslint:lint",
23+
"outputs": ["{options.outputFile}"],
24+
"options": {
25+
"lintFilePatterns": ["packages/extract-theme/**/*.{ts,tsx,js,jsx}"]
26+
}
27+
},
28+
"e2e": {
29+
"executor": "@nx/playwright:playwright",
30+
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
31+
"options": {
32+
"config": "packages/extract-theme/playwright.config.ts",
33+
"project": ["logic"]
34+
}
35+
},
36+
"setup-chrome-108": {
37+
"executor": "nx:run-script",
38+
"options": {
39+
"script": "setup.chrome.108"
40+
}
41+
},
42+
"e2e-chrome-108": {
43+
"executor": "@nx/playwright:playwright",
44+
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
45+
"dependsOn": ["setup-chrome-108"],
46+
"options": {
47+
"config": "packages/extract-theme/playwright.config.ts",
48+
"project": ["popover-chrome-108"]
49+
}
50+
},
51+
"visual-test": {
52+
"executor": "@nx/playwright:playwright",
53+
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
54+
"options": {
55+
"config": "packages/extract-theme/playwright.config.ts",
56+
"project": ["visual"]
57+
}
58+
}
59+
},
60+
"tags": []
61+
}

packages/extract-theme/src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export { extractBetweenComments } from './extract-between-comments';
2+
export { extractThemeCSS } from './extract-theme-css';
3+
export { ThemeBaseColors, type ThemeBaseColor } from './theme-base-colors';
4+
export { ThemeBorderRadiuses, type ThemeBorderRadius } from './theme-border-radiuses';
5+
export { type ThemeConfig } from './theme-config.type';
6+
export { ThemeFonts, type ThemeFont } from './theme-fonts';
7+
export { ThemeModes, type ThemeMode } from './theme-modes';
8+
export { ThemePrimaryColors, type ThemePrimaryColor } from './theme-primary-colors';
9+
export { ThemeStyles, type ThemeStyle } from './theme-styles';

packages/extract-theme/src/root.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/no-empty-function
2+
export default () => {};
3+
4+
// THIS FILE IS ONLY HERE TO SATISFY QWIK BUILD

packages/utils/src/theme/theme-base-colors.ts packages/extract-theme/src/theme-base-colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemeBaseColors = {
44
SLATE: 'base-slate',

packages/utils/src/theme/theme-border-radiuses.ts packages/extract-theme/src/theme-border-radiuses.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemeBorderRadiuses = {
44
'BORDER-RADIUS-0': 'border-radius-0',

packages/utils/src/theme/theme-fonts.ts packages/extract-theme/src/theme-fonts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemeFonts = {
44
MONO: 'font-mono',

packages/utils/src/theme/theme-modes.ts packages/extract-theme/src/theme-modes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemeModes = {
44
LIGHT: 'light',

packages/utils/src/theme/theme-primary-colors.ts packages/extract-theme/src/theme-primary-colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemePrimaryColors = {
44
SLATE100: 'primary-slate-100',

packages/utils/src/theme/theme-styles.ts packages/extract-theme/src/theme-styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectValues } from '../type-utils';
1+
import { ObjectValues } from './type-utils';
22

33
export const ThemeStyles = {
44
SIMPLE: 'simple',
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type ObjectValues<T> = T[keyof T];

packages/extract-theme/tsconfig.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "ES2022",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"resolveJsonModule": true,
12+
"esModuleInterop": true,
13+
"types": ["vitest"]
14+
},
15+
"files": [],
16+
"include": [],
17+
"references": [
18+
{
19+
"path": "./tsconfig.lib.json"
20+
},
21+
{
22+
"path": "./tsconfig.spec.json"
23+
}
24+
]
25+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"]
6+
},
7+
"include": [
8+
"vite.config.ts",
9+
"src/**/*.test.ts",
10+
"src/**/*.spec.ts",
11+
"src/**/*.test.tsx",
12+
"src/**/*.spec.tsx",
13+
"src/**/*.test.js",
14+
"src/**/*.spec.js",
15+
"src/**/*.test.jsx",
16+
"src/**/*.spec.jsx",
17+
"src/**/*.d.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)