@layout-lib/react 0.1.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.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +2 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amézir Messaoud
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @layout-lib/react
|
|
2
|
+
|
|
3
|
+
A responsive design grid overlay for development, for React, Next and Vite.
|
|
4
|
+
|
|
5
|
+
The config is versioned in your repo, the overlay follows your real breakpoints, and it leaves your production bundle untouched.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @layout-lib/react
|
|
9
|
+
# or: pnpm add -D @layout-lib/react
|
|
10
|
+
# or: yarn add -D @layout-lib/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { LayoutGrid } from "@layout-lib/react";
|
|
15
|
+
|
|
16
|
+
export function App() {
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<LayoutGrid />
|
|
20
|
+
{/* your app */}
|
|
21
|
+
</>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd> shows or hides the grid.
|
|
27
|
+
<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> folds the settings panel.
|
|
28
|
+
|
|
29
|
+
## Next.js (App Router)
|
|
30
|
+
|
|
31
|
+
The package already carries the `"use client"` directive, so a server component renders it as is.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
// app/layout.tsx
|
|
35
|
+
import { LayoutGrid } from "@layout-lib/react";
|
|
36
|
+
|
|
37
|
+
export default function RootLayout({ children }) {
|
|
38
|
+
return (
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<body>
|
|
41
|
+
<LayoutGrid />
|
|
42
|
+
{children}
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Driving it from your code
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { useLayoutOverlay } from "@layout-lib/react";
|
|
53
|
+
|
|
54
|
+
const overlay = useLayoutOverlay({ panel: false });
|
|
55
|
+
|
|
56
|
+
overlay?.toggle();
|
|
57
|
+
overlay?.updateActiveGrid({ columns: 6 }); // only the current breakpoint
|
|
58
|
+
overlay?.exportConfig(); // the TypeScript file, as a string
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## In production
|
|
62
|
+
|
|
63
|
+
The component only runs in development, and the core is pulled in through a dynamic import: the main chunk of a production build contains not a line of the overlay. Pass `enabled` to force the behaviour either way.
|
|
64
|
+
|
|
65
|
+
Options, breakpoint config and the full API are documented at the root of the repo: https://github.com/amezir/layout-lib
|
|
66
|
+
|
|
67
|
+
MIT.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";"use client";var c=Object.create;var a=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},s=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!L.call(e,o)&&o!==r&&a(e,o,{get:()=>t[o],enumerable:!(l=v(t,o))||l.enumerable});return e};var P=(e,t,r)=>(r=e!=null?c(d(e)):{},s(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e)),x=e=>s(a({},"__esModule",{value:!0}),e);var N={};m(N,{LayoutGrid:()=>b,useLayoutOverlay:()=>p});module.exports=x(N);var n=require("react"),G=()=>{try{return process.env.NODE_ENV!=="production"}catch{return!1}};function p({enabled:e=G(),container:t,...r}={}){let[l,o]=(0,n.useState)(null),y=JSON.stringify(r);return(0,n.useEffect)(()=>{if(!e)return;let u=null,i=!1;return import("@layout-lib/core").then(({createOverlay:O})=>{i||(u=O({...JSON.parse(y),container:t}),o(u))}),()=>{i=!0,u?.destroy(),o(null)}},[e,y,t]),l}function b(e){return p(e),null}0&&(module.exports={LayoutGrid,useLayoutOverlay});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OverlayOptions, LayoutOverlay } from '@layout-lib/core';
|
|
2
|
+
export { Breakpoint, GridConfig, LayoutOverlay, OverlayOptions, OverlayState, PanelPalette, PanelTheme } from '@layout-lib/core';
|
|
3
|
+
|
|
4
|
+
interface LayoutGridProps extends OverlayOptions {
|
|
5
|
+
/** Defaults to `true` in development and `false` in production builds. */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Mounts the overlay while the component is rendered, and returns its handle. */
|
|
9
|
+
declare function useLayoutOverlay({ enabled, container, ...options }?: LayoutGridProps): LayoutOverlay | null;
|
|
10
|
+
/** Drop-in overlay. Renders nothing; the grid lives in its own shadow root. */
|
|
11
|
+
declare function LayoutGrid(props: LayoutGridProps): null;
|
|
12
|
+
|
|
13
|
+
export { LayoutGrid, type LayoutGridProps, useLayoutOverlay };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OverlayOptions, LayoutOverlay } from '@layout-lib/core';
|
|
2
|
+
export { Breakpoint, GridConfig, LayoutOverlay, OverlayOptions, OverlayState, PanelPalette, PanelTheme } from '@layout-lib/core';
|
|
3
|
+
|
|
4
|
+
interface LayoutGridProps extends OverlayOptions {
|
|
5
|
+
/** Defaults to `true` in development and `false` in production builds. */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Mounts the overlay while the component is rendered, and returns its handle. */
|
|
9
|
+
declare function useLayoutOverlay({ enabled, container, ...options }?: LayoutGridProps): LayoutOverlay | null;
|
|
10
|
+
/** Drop-in overlay. Renders nothing; the grid lives in its own shadow root. */
|
|
11
|
+
declare function LayoutGrid(props: LayoutGridProps): null;
|
|
12
|
+
|
|
13
|
+
export { LayoutGrid, type LayoutGridProps, useLayoutOverlay };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{useEffect as i,useState as s}from"react";var p=()=>{try{return process.env.NODE_ENV!=="production"}catch{return!1}};function O({enabled:e=p(),container:r,...n}={}){let[u,o]=s(null),l=JSON.stringify(n);return i(()=>{if(!e)return;let t=null,a=!1;return import("@layout-lib/core").then(({createOverlay:y})=>{a||(t=y({...JSON.parse(l),container:r}),o(t))}),()=>{a=!0,t?.destroy(),o(null)}},[e,l,r]),u}function v(e){return O(e),null}export{v as LayoutGrid,O as useLayoutOverlay};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layout-lib/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Responsive layout grid overlay for React, Next.js and Vite.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@layout-lib/core": "0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^19.0.1",
|
|
28
|
+
"react": "^19.0.0"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"react",
|
|
32
|
+
"nextjs",
|
|
33
|
+
"grid",
|
|
34
|
+
"overlay",
|
|
35
|
+
"layout",
|
|
36
|
+
"responsive"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"author": "Amézir Messaoud (https://github.com/amezir)",
|
|
40
|
+
"homepage": "https://github.com/amezir/layout-lib#readme",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/amezir/layout-lib/issues"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/amezir/layout-lib.git",
|
|
47
|
+
"directory": "packages/react"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"typecheck": "tsc --noEmit"
|
|
56
|
+
}
|
|
57
|
+
}
|