@leancodepl/styled-tools 8.4.0 → 8.5.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 CHANGED
@@ -1,7 +1,58 @@
1
- # styled-tools
1
+ # @leancodepl/styled-tools
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ TypeScript utilities for styled-components with type-safe theme access.
4
4
 
5
- ## Running unit tests
5
+ ## Installation
6
6
 
7
- Run `nx test styled-tools` to execute the unit tests via [Jest](https://jestjs.io).
7
+ ```bash
8
+ npm install @leancodepl/styled-tools
9
+ # or
10
+ yarn add @leancodepl/styled-tools
11
+ ```
12
+
13
+ ## API
14
+
15
+ ### `mkTheme()`
16
+
17
+ Creates type-safe theme utilities for styled-components with full TypeScript support.
18
+
19
+ **Returns:** Object containing `theme` proxy and `useTheme` hook
20
+
21
+ ## Usage Examples
22
+
23
+ ### Basic Setup
24
+
25
+ ```typescript
26
+ // theme.ts
27
+ import { mkTheme } from '@leancodepl/styled-tools';
28
+ import styled from 'styled-components';
29
+
30
+ interface AppTheme {
31
+ colors: { primary: string; secondary: string };
32
+ spacing: { small: string; large: string };
33
+ }
34
+
35
+ export const { theme, useTheme } = mkTheme<AppTheme>();
36
+
37
+ const Button = styled.button`
38
+ color: ${theme.colors.primary};
39
+ padding: ${theme.spacing.small};
40
+ `;
41
+ ```
42
+
43
+ ### React Hook Usage
44
+
45
+ ```typescript
46
+ import React from 'react';
47
+ import { useTheme } from './theme';
48
+
49
+ function ThemedComponent() {
50
+ const theme = useTheme();
51
+
52
+ return (
53
+ <div style={{ backgroundColor: theme.colors.primary }}>
54
+ <h1>Themed Component</h1>
55
+ </div>
56
+ );
57
+ }
58
+ ```
package/index.cjs.js CHANGED
@@ -23,7 +23,26 @@ function guard(value) {
23
23
  return typeof value === "object";
24
24
  }
25
25
 
26
- function mkTheme() {
26
+ /**
27
+ * Creates type-safe theme utilities for styled-components with full TypeScript support.
28
+ *
29
+ * @template TTheme - The theme object type extending Value
30
+ * @returns Object containing theme proxy and useTheme hook
31
+ * @example
32
+ * ```typescript
33
+ * interface AppTheme {
34
+ * colors: { primary: string; secondary: string };
35
+ * spacing: { small: string; large: string };
36
+ * }
37
+ *
38
+ * const { theme, useTheme } = mkTheme<AppTheme>();
39
+ *
40
+ * const Button = styled.button`
41
+ * color: ${theme.colors.primary};
42
+ * padding: ${theme.spacing.small};
43
+ * `;
44
+ * ```
45
+ */ function mkTheme() {
27
46
  return {
28
47
  theme: mkProxy(function(ctx) {
29
48
  return ctx.theme;
package/index.esm.js CHANGED
@@ -21,7 +21,26 @@ function guard(value) {
21
21
  return typeof value === "object";
22
22
  }
23
23
 
24
- function mkTheme() {
24
+ /**
25
+ * Creates type-safe theme utilities for styled-components with full TypeScript support.
26
+ *
27
+ * @template TTheme - The theme object type extending Value
28
+ * @returns Object containing theme proxy and useTheme hook
29
+ * @example
30
+ * ```typescript
31
+ * interface AppTheme {
32
+ * colors: { primary: string; secondary: string };
33
+ * spacing: { small: string; large: string };
34
+ * }
35
+ *
36
+ * const { theme, useTheme } = mkTheme<AppTheme>();
37
+ *
38
+ * const Button = styled.button`
39
+ * color: ${theme.colors.primary};
40
+ * padding: ${theme.spacing.small};
41
+ * `;
42
+ * ```
43
+ */ function mkTheme() {
25
44
  return {
26
45
  theme: mkProxy(function(ctx) {
27
46
  return ctx.theme;
package/package.json CHANGED
@@ -1,19 +1,50 @@
1
1
  {
2
2
  "name": "@leancodepl/styled-tools",
3
- "version": "8.4.0",
3
+ "version": "8.5.1",
4
4
  "peerDependencies": {
5
5
  "styled-components": ">=6.0.0"
6
6
  },
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org/"
10
+ },
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/leancodepl/js_corelibrary.git",
17
+ "directory": "packages/styled-tools"
18
+ },
19
+ "homepage": "https://github.com/leancodepl/js_corelibrary",
20
+ "bugs": {
21
+ "url": "https://github.com/leancodepl/js_corelibrary/issues"
22
+ },
23
+ "description": "Utilities for styled-components",
24
+ "keywords": [
25
+ "styled-components",
26
+ "theme",
27
+ "css-in-js",
28
+ "react",
29
+ "typescript",
30
+ "javascript",
31
+ "leancode"
32
+ ],
33
+ "author": {
34
+ "name": "LeanCode",
35
+ "url": "https://leancode.co"
36
+ },
37
+ "sideEffects": false,
7
38
  "exports": {
8
39
  "./package.json": "./package.json",
9
40
  ".": {
10
41
  "module": "./index.esm.js",
11
- "types": "./index.esm.d.ts",
42
+ "types": "./index.d.ts",
12
43
  "import": "./index.cjs.mjs",
13
44
  "default": "./index.cjs.js"
14
45
  }
15
46
  },
16
47
  "module": "./index.esm.js",
17
48
  "main": "./index.cjs.js",
18
- "types": "./index.esm.d.ts"
49
+ "types": "./index.d.ts"
19
50
  }
@@ -1,5 +1,25 @@
1
1
  import { type ExecutionContext, type RuleSet } from "styled-components";
2
2
  import { Value } from "./mkProxy";
3
+ /**
4
+ * Creates type-safe theme utilities for styled-components with full TypeScript support.
5
+ *
6
+ * @template TTheme - The theme object type extending Value
7
+ * @returns Object containing theme proxy and useTheme hook
8
+ * @example
9
+ * ```typescript
10
+ * interface AppTheme {
11
+ * colors: { primary: string; secondary: string };
12
+ * spacing: { small: string; large: string };
13
+ * }
14
+ *
15
+ * const { theme, useTheme } = mkTheme<AppTheme>();
16
+ *
17
+ * const Button = styled.button`
18
+ * color: ${theme.colors.primary};
19
+ * padding: ${theme.spacing.small};
20
+ * `;
21
+ * ```
22
+ */
3
23
  export declare function mkTheme<TTheme extends Value>(): {
4
24
  theme: TransformDeep<TTheme>;
5
25
  useTheme: () => TTheme;
package/index.esm.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
File without changes