@slotjs/hooks 0.0.2 → 0.0.3

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,8 +1,14 @@
1
1
  # @slotjs/hooks
2
2
 
3
- ```ts
3
+ ```bash
4
+ npm i @slotjs/hooks
5
+ ```
6
+
7
+ ```tsx
8
+ import { useResponsive } from "@slotjs/hooks";
9
+
4
10
  const Index: React.FC = () => {
5
- const isReady = useRootFontSize();
11
+ const isReady = useResponsive();
6
12
 
7
13
  return isReady ? (
8
14
  <ContentContainer>content</ContentContainer>
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A React hook to set the root font size based on the viewport width.
3
+ * It scales the font size up to a maximum of 2x the base font size.
4
+ * This is useful for responsive designs where the font size needs to adapt to different screen sizes.
5
+ * It listens for window resize events to adjust the font size dynamically.
6
+ *
7
+ * @param baseWidth
8
+ * @param baseFontSize
9
+ * @example
10
+ * ```ts
11
+ * const isReady = useResponsive(1920, 16);
12
+ * ```
13
+ * // This will set the root font size based on a base width of 1920px
14
+ * // and a base font size of 16px.
15
+ * // The hook returns true once the font size has been set, allowing components to render correctly
16
+ * // with the appropriate font size.
17
+ * @returns
18
+ */
19
+ export declare function useResponsive(baseWidth?: number, baseFontSize?: number): boolean;
20
+
21
+ export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slotjs/hooks",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "description": "@slotjs/hooks for react",
7
7
  "homepage": "https://github.com/slotjs/hooks.git#readme",
@@ -16,6 +16,7 @@
16
16
  "author": "iamwjun",
17
17
  "scripts": {
18
18
  "dev": "vite",
19
+ "types": "tsc -p tsconfig.build.json",
19
20
  "build": "tsc -b && vite build",
20
21
  "lint": "eslint .",
21
22
  "preview": "vite preview",
@@ -30,6 +31,7 @@
30
31
  "@eslint/js": "^9.32.0",
31
32
  "@testing-library/jest-dom": "^6.6.4",
32
33
  "@testing-library/react": "^16.3.0",
34
+ "@types/node": "^24.3.0",
33
35
  "@types/react": "^19.1.9",
34
36
  "@types/react-dom": "^19.1.7",
35
37
  "@vitejs/plugin-react": "^4.7.0",
@@ -41,9 +43,21 @@
41
43
  "typescript": "~5.8.3",
42
44
  "typescript-eslint": "^8.39.0",
43
45
  "vite": "^7.1.0",
46
+ "vite-plugin-dts": "^4.5.4",
44
47
  "vitest": "^3.2.4"
45
48
  },
46
49
  "files": [
47
- "dist"
48
- ]
50
+ "dist",
51
+ "README.md"
52
+ ],
53
+ "main": "dist/index.umd.js",
54
+ "module": "dist/index.es.js",
55
+ "types": "dist/types/index.d.ts",
56
+ "exports": {
57
+ ".": {
58
+ "import": "./dist/index.es.js",
59
+ "require": "./dist/index.umd.js",
60
+ "types": "./dist/types/index.d.ts"
61
+ }
62
+ }
49
63
  }
package/dist/README.md DELETED
@@ -1,13 +0,0 @@
1
- # @slotjs/hooks
2
-
3
- ```ts
4
- const Index: React.FC = () => {
5
- const isReady = useRootFontSize();
6
-
7
- return isReady ? (
8
- <ContentContainer>content</ContentContainer>
9
- ) : (
10
- <FullScreenWrapper>loading</FullScreenWrapper>
11
- );
12
- };
13
- ```
File without changes
File without changes