@puzzle-ui/core 0.5.0 → 0.6.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.
Files changed (2) hide show
  1. package/README.md +44 -79
  2. package/package.json +6 -1
package/README.md CHANGED
@@ -1,98 +1,63 @@
1
- # Getting Started
1
+ # @puzzle-ui/core
2
2
 
3
- Install Puzzle in your React app, build your first interface, and customize the theme.
3
+ Framework-independent utilities shared by all Puzzle packages.
4
4
 
5
- > \[!WARNING\] **Puzzle is not ready for production use.**
6
- >
7
- > This project is under active development. APIs, component props,
8
- > package exports, styling, and internal implementation may change
9
- > without notice. Components may be incomplete, and testing,
10
- > accessibility, documentation, and framework compatibility are not yet
11
- > guaranteed. Use it for experimentation and evaluation only---not for
12
- > production applications.
5
+ **Documentation:** [https://puzzle-ui.com/docs/getting-started](https://puzzle-ui.com/docs/getting-started)
13
6
 
14
- Puzzle is a TypeScript and React UI component library built around reusable components and shared design tokens. Its components are composable and router-independent, with styling supplied by `"@puzzle-ui/theme`. The framework is setup to be compatible with `Next.js`, `Tanstack Start` and `react-router`.
7
+ See the [package documentation](https://puzzle-ui.com/docs/getting-started)
8
+ for API and compatibility details.
15
9
 
16
- **Puzzle is under active development and is not ready for production use.** APIs, props, exports, and styling may change without notice. Accessibility and framework compatibility are still being tested. Use the project for experimentation and evaluation.
10
+ `@puzzle-ui/core` contains the small, dependency-free helpers that
11
+ [`@puzzle-ui/ui`](https://puzzle-ui.com/docs/ui),
12
+ [`@puzzle-ui/theme`](https://puzzle-ui.com/docs/theme), and the other Puzzle
13
+ packages build on: class name composition, string casing, CSS value safety,
14
+ color parsing and conversion, responsive value resolution, and debouncing.
15
+ It has no React dependency and runs in browsers, Node.js, Bun, and edge
16
+ runtimes.
17
17
 
18
- ## Prerequisites
18
+ Use it directly when you build your own components on top of Puzzle and want
19
+ the same conventions, for example `cn` for class names and the shared
20
+ breakpoints for responsive props.
19
21
 
20
- - A package manager: npm, Bun, pnpm, or Yarn.
21
- - An existing React application with a bundler that supports CSS imports, such as Vite.
22
- - Familiarity with React and TypeScript. The UI and theme packages require React and React DOM 19 or later within the supported React 19 range.
23
-
24
- ## Set up a new project
25
-
26
- Simple run our @puzzle-ui/create project template to get started.
27
-
28
- npm:
29
-
30
- ```bash
31
- npx @puzzle-ui/create
32
- ```
33
-
34
- bun:
35
-
36
- ```bash
37
- bunx @puzzle-ui/create
38
- ```
39
-
40
- Puzzle can set up a new project for you with the following framework options:
41
-
42
- - Basic React app
43
- - Tanstack start
44
- - Next.js
45
-
46
- Furthermore you can choose to install tailwindcss or not.
47
- It directly installs all dependencies and sets up the project for you.
48
-
49
- ## Set up in an existing project:
50
-
51
- Install the UI library and theme package in your application's directory. Choose your package manager below:
52
-
53
- npm:
22
+ ## Install
54
23
 
55
24
  ```bash
56
- npm install @puzzle-ui/ui --save
25
+ npm install @puzzle-ui/core
26
+ # or
27
+ bun add @puzzle-ui/core
28
+ # or
29
+ pnpm add @puzzle-ui/core
30
+ # or
31
+ yarn add @puzzle-ui/core
57
32
  ```
58
33
 
59
- bun:
60
-
61
- ```bash
62
- bun add @puzzle-ui/create
63
- ```
34
+ ## Usage
64
35
 
65
- pnpm:
36
+ ```ts
37
+ import { cn, resolveResponsiveValue, stringWithCasing } from "@puzzle-ui/core";
66
38
 
67
- ```bash
68
- pnpm add @puzzle-ui/ui
69
- ```
39
+ cn("puzzle-button", isActive && "puzzle-button--active", className);
40
+ // "puzzle-button puzzle-button--active my-class"
70
41
 
71
- yarn:
42
+ stringWithCasing("hello world", "kebabcase");
43
+ // "hello-world"
72
44
 
73
- ```bash
74
- yarn add @puzzle-ui/ui
45
+ resolveResponsiveValue({ mobile: "col", desktop: "row" });
46
+ // { mobile: "col", tablet: "col", desktop: "row" }
75
47
  ```
76
48
 
77
- These commands install published packages; they do not clone the repository or build its workspaces. Puzzle does not require Bun in your application. React and React DOM are peer dependencies and should already be installed in your app.
78
-
79
- ## Your first interface
49
+ ## API
80
50
 
81
- Import components from `"@puzzle-ui/ui` and wrap your application in `Theme` from `"@puzzle-ui/theme`:
51
+ | Area | Exports |
52
+ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
53
+ | Strings | `cn`, `stringWithCasing`, `normalizeSearchString`, `withSafeCharacters`, `escapeCssString`, `assertSafeCssValue`, `nameToInitials` |
54
+ | Colors | `isColor`, `isHexColor`, `isCssVariable`, `isDarkColor`, `isColorDark`, `getColorType`, `parseColor`, `parseRgb`, `hexToRgb`, `hexToRgba`, `rgbToHex`, `hslToRgb`, `rgbToHsl`, `rgbToCss`, `hslToCss`, `getColorLuminance`, `clamp` |
55
+ | Responsive | `BREAKPOINTS`, `resolveResponsiveValue`, `resolveResponsiveValueForBreakpoint` |
56
+ | Timing | `debounce` (returns a debounced function with a `cancel()` method) |
57
+ | Types | `ClassnameArg`, `ColorType`, `RGBColor`, `HSLColor`, `Breakpoint`, `ResponsiveConfig`, `ResponsiveValue`, `DeepPartial` |
82
58
 
83
- ```tsx
84
- import { Theme } from "@puzzle-ui/theme";
85
- import { Button } from "@puzzle-ui/ui";
59
+ `stringWithCasing` supports `lowercase`, `uppercase`, `snakecase`,
60
+ `kebabcase`, `camelcase`, `pascalcase`, `sentencecase`, and `headercase`.
86
61
 
87
- export const App = () => (
88
- <Theme>
89
- <main>
90
- <h1>Hello, Puzzle</h1>
91
- <p>Build your interface with reusable components and shared tokens.</p>
92
- <Button onClick={() => window.alert("Welcome to Puzzle!")}>
93
- Get started
94
- </Button>
95
- </main>
96
- </Theme>
97
- );
98
- ```
62
+ Responsive values use the `mobile`, `tablet`, and `desktop` breakpoints;
63
+ smaller breakpoints cascade to larger ones when a value is omitted.
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@puzzle-ui/core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-independent utilities",
5
+ "homepage": "https://puzzle-ui.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/senorprogramador/puzzle.git"
9
+ },
5
10
  "license": "MIT",
6
11
  "publishConfig": {
7
12
  "access": "public",