Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(utils): move extract-theme to a separate package #1051

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/component-tests/src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ThemeModes,
ThemePrimaryColors,
ThemeStyles,
} from '@qwik-ui/utils';
} from '@qwik-ui/extract-theme';

export default component$(() => {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { component$, useSignal } from '@builder.io/qwik';
import { Modal } from '@qwik-ui/headless';
import { Button } from '~/components/ui';
import { extractThemeCSS } from '@qwik-ui/utils';
import { extractThemeCSS } from '@qwik-ui/extract-theme';
import { LuX } from '@qwikest/icons/lucide';
import { useTheme } from '@qwik-ui/themes';
import globalCSS from '~/global.css?raw';
Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/components/make-it-yours/make-it-yours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
ThemeModes,
ThemePrimaryColors,
ThemeStyles,
cn,
} from '@qwik-ui/utils';
} from '@qwik-ui/extract-theme';
import { cn } from '@qwik-ui/utils';
import { LuSlidersHorizontal, LuX } from '@qwikest/icons/lucide';
import { useTheme } from '@qwik-ui/themes';

Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ThemeModes,
ThemePrimaryColors,
ThemeStyles,
} from '@qwik-ui/utils';
} from '@qwik-ui/extract-theme';
import { ModulePreload } from './components/module-preload/module-preload';

export default component$(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ThemePrimaryColors,
ThemeStyle,
ThemeStyles,
} from '@qwik-ui/utils';
} from '@qwik-ui/extract-theme';
import { bgRgb, bold, cyan, green, red } from 'ansis';
import { execSync } from 'child_process';
import { existsSync, readFileSync, writeFileSync } from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/generators/setup-tailwind/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ThemeConfig } from '@qwik-ui/utils';
import type { ThemeConfig } from '@qwik-ui/extract-theme';

export interface SetupTailwindGeneratorSchema extends ThemeConfig {
projectRoot?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { ThemeBorderRadiuses, ThemePrimaryColors, ThemeStyles } from '@qwik-ui/utils';
import {
ThemeBorderRadiuses,
ThemePrimaryColors,
ThemeStyles,
} from '@qwik-ui/extract-theme';
import { SetupTailwindGeneratorSchema } from './schema';
import { setupTailwindGenerator } from './setup-tailwind-generator';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
extractBetweenComments,
extractThemeCSS,
type ThemeConfig,
} from '@qwik-ui/utils';
} from '@qwik-ui/extract-theme';
import { readFileSync } from 'fs';
import { join } from 'path';
import { getKitRoot } from '../../_shared/get-kit-root';
Expand Down
18 changes: 18 additions & 0 deletions packages/extract-theme/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
42 changes: 42 additions & 0 deletions packages/extract-theme/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Changelog

## 0.3.1

### Patch Changes

- ✨ new inline component utilities (by [@thejackshelton](https://github.com/thejackshelton) in [#937](https://github.com/qwikifiers/qwik-ui/pull/937))

## 0.3.0

### Minor Changes

- Changed enums to const maps in utils (by [@shairez](https://github.com/shairez) in [#914](https://github.com/qwikifiers/qwik-ui/pull/914))

## 0.2.1

### Patch Changes

- ✨ added `extractThemeCSS` (by [@shairez](https://github.com/shairez) in [#604](https://github.com/qwikifiers/qwik-ui/pull/604))

## 0.2.0

### Minor Changes

- Removed `useOrdinal` (by [@shairez](https://github.com/shairez) in [`4043d29`](https://github.com/qwikifiers/qwik-ui/commit/4043d29dcc39b03f16c79d659da592af3fbeafeb))

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [0.1.1](https://github.com/qwikifiers/qwik-ui/compare/utils-0.1.0...utils-0.1.1) (2024-01-09)

# [0.1.0](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.3...utils-0.1.0) (2023-12-16)

### Bug Fixes

- **docs:** add install / related docs / merge with main ([bb1b62c](https://github.com/qwikifiers/qwik-ui/commit/bb1b62cd87d376858fd706e9b5344603be87127c))
- **everything:** fix 1.3 craziness ([0b20d97](https://github.com/qwikifiers/qwik-ui/commit/0b20d97af41f75bc7e1215391fd1c202ee8a9366))

## [0.0.3](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.2...utils-0.0.3) (2023-12-01)

## [0.0.2](https://github.com/qwikifiers/qwik-ui/compare/utils-0.0.1...utils-0.0.2) (2023-12-01)

## 0.0.1 (2023-11-30)
21 changes: 21 additions & 0 deletions packages/extract-theme/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 HiRez.io, Qwikifiers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions packages/extract-theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Qwik UI extract-theme

## `stringifyClassList`

A function that takes a Qwik class list and returns a string.
Good for cases you are working with other libraries that require a string as an input.

## `cva`

This is a version of the original code from [cva](https://cva.style/) but optimized for Qwik apps.

Thanks to [Joe Bell](https://twitter.com/joebell_) for creating the original library.

## `tcva`

CVA with Tailwind merge built in.

# License

MIT
34 changes: 34 additions & 0 deletions packages/extract-theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@qwik-ui/extract-theme",
"version": "0.3.1",
"description": "Qwik UI extract-theme",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/qwikifiers/qwik-ui",
"directory": "packages/extract-theme"
},
"main": "./index.qwik.cjs",
"qwik": "./index.qwik.mjs",
"module": "./index.qwik.mjs",
"types": "./index.d.ts",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.qwik.mjs",
"require": "./index.qwik.cjs"
}
},
"engines": {
"node": ">=16.0.0"
},
"private": false,
"dependencies": {
"tailwind-merge": "^1.14.0",
"clsx": "^2.0.0",
"qwik-themes": "^0.2.0"
}
}
61 changes: 61 additions & 0 deletions packages/extract-theme/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "extract-theme",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/extract-theme/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/packages/extract-theme",
"configFile": "packages/extract-theme/vite.config.ts",
"mode": "lib"
},
"configurations": {
"development": {},
"production": {}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/extract-theme/**/*.{ts,tsx,js,jsx}"]
}
},
"e2e": {
"executor": "@nx/playwright:playwright",
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
"options": {
"config": "packages/extract-theme/playwright.config.ts",
"project": ["logic"]
}
},
"setup-chrome-108": {
"executor": "nx:run-script",
"options": {
"script": "setup.chrome.108"
}
},
"e2e-chrome-108": {
"executor": "@nx/playwright:playwright",
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
"dependsOn": ["setup-chrome-108"],
"options": {
"config": "packages/extract-theme/playwright.config.ts",
"project": ["popover-chrome-108"]
}
},
"visual-test": {
"executor": "@nx/playwright:playwright",
"outputs": ["{workspaceRoot}/dist/.playwright/packages/extract-theme"],
"options": {
"config": "packages/extract-theme/playwright.config.ts",
"project": ["visual"]
}
}
},
"tags": []
}
9 changes: 9 additions & 0 deletions packages/extract-theme/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export { extractBetweenComments } from './extract-between-comments';
export { extractThemeCSS } from './extract-theme-css';
export { ThemeBaseColors, type ThemeBaseColor } from './theme-base-colors';
export { ThemeBorderRadiuses, type ThemeBorderRadius } from './theme-border-radiuses';
export { type ThemeConfig } from './theme-config.type';
export { ThemeFonts, type ThemeFont } from './theme-fonts';
export { ThemeModes, type ThemeMode } from './theme-modes';
export { ThemePrimaryColors, type ThemePrimaryColor } from './theme-primary-colors';
export { ThemeStyles, type ThemeStyle } from './theme-styles';
4 changes: 4 additions & 0 deletions packages/extract-theme/src/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-empty-function
export default () => {};

// THIS FILE IS ONLY HERE TO SATISFY QWIK BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemeBaseColors = {
SLATE: 'base-slate',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemeBorderRadiuses = {
'BORDER-RADIUS-0': 'border-radius-0',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemeFonts = {
MONO: 'font-mono',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemeModes = {
LIGHT: 'light',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemePrimaryColors = {
SLATE100: 'primary-slate-100',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ObjectValues } from '../type-utils';
import { ObjectValues } from './type-utils';

export const ThemeStyles = {
SIMPLE: 'simple',
Expand Down
1 change: 1 addition & 0 deletions packages/extract-theme/src/type-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type ObjectValues<T> = T[keyof T];
25 changes: 25 additions & 0 deletions packages/extract-theme/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "ES2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"types": ["vitest"]
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions packages/extract-theme/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
19 changes: 19 additions & 0 deletions packages/extract-theme/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"]
},
"include": [
"vite.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
Loading
Loading