@oyerinde/caliper 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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/index.cjs +4999 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.global.js +4995 -0
- package/dist/index.js +4994 -0
- package/dist/index.server.cjs +29 -0
- package/dist/index.server.js +24 -0
- package/dist/version.json +4 -0
- package/package.json +104 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-01-10
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Core Measurement System**: High-precision boundary detection and distance calculation between DOM elements.
|
|
10
|
+
- **Interactive Overlay**: Real-time measurement lines and labels with smooth animations.
|
|
11
|
+
- **Selection System**: Ability to focus and lock elements for side-by-side comparison.
|
|
12
|
+
- **Viewport Rulers**: Draggable horizontal and vertical guidelines for design layout audits.
|
|
13
|
+
- **Projection Visualizer**: Automatic edge projection for checking alignment across the entire viewport.
|
|
14
|
+
- **Integrated Calculator**: Precise spatial math and side-to-side distance calculations.
|
|
15
|
+
- **Configurable Commands**: Custom keyboard shortcuts for all major features (Alt, Shift + R, etc.).
|
|
16
|
+
- **Theme Support**: Custom primary colors and UI styling via CSS variables.
|
|
17
|
+
- **Two-Entry Distribution**: Separate `index.js` for module-based usage and `index.global.js` for self-mounting script tags.
|
|
18
|
+
- **Next.js Integration**: Support for Next.js Script component with data-attribute configuration.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Oyerinde
|
|
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,149 @@
|
|
|
1
|
+
<img src="https://raw.githubusercontent.com/oyerindedaniel/caliper/main/apps/web/public/caliper_logo.svg" width="144" alt="Caliper Logo" style="margin-bottom: 24px;" />
|
|
2
|
+
|
|
3
|
+
[](https://bundlephobia.com/package/@oyerinde/caliper)
|
|
4
|
+
[](https://www.npmjs.com/package/@oyerinde/caliper)
|
|
5
|
+
|
|
6
|
+
**Essential tooling for detail-obsessed design engineers.**
|
|
7
|
+
|
|
8
|
+
Caliper is a high-precision, framework-agnostic measurement tool that lives in your browser during development. It helps you catch "pixel-drift" and alignment issues before they reach production.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features 🚀
|
|
13
|
+
|
|
14
|
+
- **Core Measurement**: High-precision boundary detection and distance calculation between DOM elements.
|
|
15
|
+
- **Interactive Overlay**: Real-time measurement lines and labels with smooth, high-fidelity animations.
|
|
16
|
+
- **Selection System**: Lock elements for side-by-side comparison (Cmd/Ctrl + Click).
|
|
17
|
+
- **Edge Projections**: Check alignment across the entire viewport using relative projections (W/A/S/D).
|
|
18
|
+
- **Viewport Rulers**: Draggable guidelines with magnetic snapping and chained distance measurements (Shift + R).
|
|
19
|
+
- **Integrated Calculator**: Precise spatial math for complex component spacing (T/R/B/L/G).
|
|
20
|
+
- **Full Customization**: Fully configurable shortcuts and theme colors.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation 📦
|
|
25
|
+
|
|
26
|
+
Caliper is designed to be side-effect-free in production and easy to integrate into any modern stack.
|
|
27
|
+
|
|
28
|
+
### Method 1: NPM (Recommended)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm install @oyerinde/caliper
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Next.js (App Router)**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
// app/layout.tsx
|
|
38
|
+
import Script from "next/script";
|
|
39
|
+
|
|
40
|
+
export default function RootLayout({ children }) {
|
|
41
|
+
return (
|
|
42
|
+
<html lang="en">
|
|
43
|
+
<body>
|
|
44
|
+
{process.env.NODE_ENV === "development" && (
|
|
45
|
+
<Script
|
|
46
|
+
src="https://unpkg.com/@oyerinde/caliper/dist/index.global.js"
|
|
47
|
+
data-config={JSON.stringify({ theme: { primary: "#18A0FB" } })}
|
|
48
|
+
strategy="afterInteractive"
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
{children}
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Method 2: Script Tag (Zero Config)
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<!-- Automatically mounts in development -->
|
|
62
|
+
<script
|
|
63
|
+
src="https://unpkg.com/@oyerinde/caliper/dist/index.global.js"
|
|
64
|
+
data-config='{"theme": {"primary": "#18A0FB"}}'
|
|
65
|
+
></script>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Configuration 🛠️
|
|
71
|
+
|
|
72
|
+
Caliper can be customized to fit your specific design system and workflow. `init()` automatically mounts the overlay in the browser.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { init } from "@oyerinde/caliper";
|
|
76
|
+
|
|
77
|
+
init({
|
|
78
|
+
theme: {
|
|
79
|
+
primary: "#18A0FB", // Main brand color
|
|
80
|
+
ruler: "#AC2323", // Guideline color
|
|
81
|
+
calcBg: "rgba(0,0,0,0.9)",
|
|
82
|
+
},
|
|
83
|
+
commands: {
|
|
84
|
+
activate: "Alt", // Key to show overlay
|
|
85
|
+
freeze: " ", // Key to lock lines
|
|
86
|
+
ruler: "r", // Key for guideline (Shift+r)
|
|
87
|
+
selectionHoldDuration: 250, // Hold duration to select
|
|
88
|
+
},
|
|
89
|
+
animation: {
|
|
90
|
+
lerpFactor: 0.2, // Smoothness (0-1)
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Excluding Elements
|
|
96
|
+
|
|
97
|
+
To prevent Caliper from measuring specific elements (like sidebars, floating buttons, or decorative overlays), add the `data-caliper-ignore` attribute:
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<div data-caliper-ignore>
|
|
101
|
+
<!-- This element and its children will be ignored by Caliper -->
|
|
102
|
+
</div>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Interaction Guide ⌨️
|
|
108
|
+
|
|
109
|
+
### Measurements
|
|
110
|
+
|
|
111
|
+
- **Cmd/Ctrl + Hold + Click** (250ms) — Select an element.
|
|
112
|
+
- **Hover** — View relative distances to target.
|
|
113
|
+
- **Option/Alt** — Hold to reveal the overlay.
|
|
114
|
+
- **Space** — Freeze the current state.
|
|
115
|
+
|
|
116
|
+
### Analysis tools
|
|
117
|
+
|
|
118
|
+
- **W / A / S / D** — Trigger edge projections.
|
|
119
|
+
- **Shift + R** — Create a pair of vertical and horizontal guidelines at the cursor.
|
|
120
|
+
- **Numeric Keypad** — Type numbers while projecting to set specific edge distances.
|
|
121
|
+
- **Escape** — Clear all active measurements, rulers, and projections.
|
|
122
|
+
|
|
123
|
+
### Ruler Precision
|
|
124
|
+
|
|
125
|
+
- **Arrow Keys** — Nudge selected ruler lines by 1px.
|
|
126
|
+
- **Shift + Arrows** — Nudge by 10px.
|
|
127
|
+
- **Option/Alt + Arrows** — Nudge by 0.1px for sub-pixel auditing.
|
|
128
|
+
- **Magnetic Snap** — Rulers automatically snap to active projection lines.
|
|
129
|
+
- **Chained Measurement** — Link multiple parallel rulers with **Shift + Click** to reveal gaps.
|
|
130
|
+
- **Auto-Focus** — Typing operators (**+ - \* / .**) instantly switches focus to the calculator.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## License ⚖️
|
|
135
|
+
|
|
136
|
+
This project is licensed under the **MIT License**.
|
|
137
|
+
|
|
138
|
+
- **Allowed**: Personal and commercial use, modification, and distribution.
|
|
139
|
+
- **Open**: Completely permissive with no restrictions on derivative works or competition.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Author & Acknowledgement 👤
|
|
144
|
+
|
|
145
|
+
**Caliper** is built and maintained with precision by **[Daniel Oyerinde](https://danieloyerinde.com)**.
|
|
146
|
+
|
|
147
|
+
If you find this tool helpful in your design-to-code workflow, consider giving it a star on **[GitHub](https://github.com/oyerindedaniel/caliper)**.
|
|
148
|
+
|
|
149
|
+
Copyright © 2026 Daniel Oyerinde.
|