twiddle-panel 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ravi
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 CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # Panel by Twiddle
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A design-system tweak panel you drop into any prototype. Designers expose a few
4
+ intentional knobs (type, colour, shape, density, depth); anyone reviewing the
5
+ prototype can explore them live and share the exact version as a link.
6
+
7
+ **Step-by-step guide with copy-ready snippets and agent prompts: [panel.twiddle.in](https://panel.twiddle.in)**
8
+
9
+ ## Install
10
+
11
+ Panel is a design tool: load it in development or in shared prototype links, not in a production site.
12
+
13
+ Panel used to be published as `@theoldpixel/twiddle`; that package is deprecated in favour of `twiddle-panel`.
14
+
15
+ **Projects with a build tool (Vite, Next.js…)**
16
+
17
+ ```bash
18
+ npm install -D twiddle-panel
19
+ ```
20
+
21
+ ```js
22
+ // in your app's entry file
23
+ import 'twiddle-panel';
24
+ ```
25
+
26
+ That's all: the panel adds the token defaults itself (first in `<head>`, so
27
+ your own CSS still wins). To load the panel only while developing, keep the
28
+ tokens in every build and import the panel in development:
29
+
30
+ ```js
31
+ import 'twiddle-panel/tokens.css';
32
+ if (import.meta.env.DEV) import('twiddle-panel');
33
+ ```
34
+
35
+ **Plain HTML prototypes** (no install needed)
36
+
37
+ ```html
38
+ <script src="https://cdn.jsdelivr.net/npm/twiddle-panel@0.6.0/dist/twiddle.js" defer></script>
39
+ ```
40
+
41
+ The prototype's CSS must use the `--twd-*` token variables
42
+ (for example `border-radius: var(--twd-radius-control)`). Hard-coded values
43
+ won't respond to the panel.
44
+
45
+ Optional layout roles (token contract v0.2) name what a space is for:
46
+ `--twd-page-pad`, `--twd-section-gap`, `--twd-card-pad`, `--twd-card-gap` and
47
+ `--twd-control-gap`. Each points at a spacing step by default, so prototypes
48
+ that use them can be re-pointed in **Edit every token › Spacing › Roles**.
49
+
50
+ ## Using the panel
51
+
52
+ - The **Simple** page tweaks the whole page with broad knobs: the **Character** pad (drag up/down for spacing, left/right for shadow strength), then Fonts, Brand, Neutral, Mode and Corners (buttons and cards together). **Edit every token** opens a page per area (Fonts, Type scale, Colours, Spacing, Corners, Borders, Shadows): the area's knobs, then each of its tokens as a row you can set to a fixed value. An edited token shows **Custom** and its own reset, and stays put when you change the broad knobs. **Spacing › Roles** points each layout role (page padding, section gap, card padding, card gap, control gap, control padding) at another spacing step or a fixed value. **Copy link** shares the exact version (`?twd=…`).
53
+ - **Pick** (crosshair) selects one element. The panel then shows only the sections that element uses. Choose **This element** or **All `.class` (n)** to set where the tweaks go. Add `data-twd="name"` to an element to control what counts as "all like this".
54
+ - **Compare** (half circle): hold it, or press Alt+C, to see the original page.
55
+ - **Undo / Redo** in the footer, or ⌘Z / ⇧⌘Z while the panel has focus. Reset can be undone too.
56
+ - **Changes** lists every tweak with the token values before and after. Use × to remove one.
57
+ - **Copy prompt** turns the tweaks into a Markdown prompt for a coding agent, so they become permanent in the source. Use the arrow next to it to choose between *Preview before copying* and *Copy without preview*.
58
+ - Colour pairs that fall below WCAG AA show a warning in Colour, in Changes and in the prompt.
59
+
60
+ ## Licence
61
+
62
+ MIT
@@ -0,0 +1,71 @@
1
+ /* ==========================================================
2
+ Panel token contract — v0.2
3
+ Default values for every role token. Prototypes use ONLY
4
+ these variables; the panel overrides them live.
5
+ ========================================================== */
6
+
7
+ :root {
8
+ /* ---------- Typography ---------- */
9
+ --twd-font-heading: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
10
+ --twd-font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
11
+
12
+ /* Balanced scale (1.2) from a 16px base */
13
+ --twd-text-xs: 0.694rem;
14
+ --twd-text-sm: 0.833rem;
15
+ --twd-text-base: 1rem;
16
+ --twd-text-lg: 1.2rem;
17
+ --twd-text-xl: 1.44rem;
18
+ --twd-text-2xl: 1.728rem;
19
+ --twd-text-3xl: 2.074rem;
20
+
21
+ --twd-leading-tight: 1.2;
22
+ --twd-leading-normal: 1.5;
23
+
24
+ /* ---------- Colour (roles) ---------- */
25
+ --twd-bg: #fafafa;
26
+ --twd-surface: #ffffff;
27
+ --twd-surface-raised: #ffffff;
28
+ --twd-text: #18181b;
29
+ --twd-text-muted: #71717a;
30
+ --twd-border: #e4e4e7;
31
+ --twd-primary: #4f46e5;
32
+ --twd-primary-hover: #4338ca;
33
+ --twd-on-primary: #ffffff;
34
+ --twd-focus: #6366f1;
35
+ --twd-success: #16a34a;
36
+ --twd-warning: #d97706;
37
+ --twd-danger: #dc2626;
38
+
39
+ /* ---------- Shape ---------- */
40
+ --twd-radius-control: 8px;
41
+ --twd-radius-container: 12px;
42
+
43
+ /* ---------- Density ---------- */
44
+ --twd-space-1: 4px;
45
+ --twd-space-2: 8px;
46
+ --twd-space-3: 12px;
47
+ --twd-space-4: 16px;
48
+ --twd-space-5: 24px;
49
+ --twd-space-6: 32px;
50
+ --twd-space-7: 48px;
51
+ --twd-space-8: 64px;
52
+ --twd-control-height: 40px;
53
+ --twd-control-pad-x: 16px;
54
+
55
+ /* ---------- Layout roles (v0.2) ----------
56
+ Optional. Each points at a spacing step, so Density still scales it,
57
+ and the panel's Edit › Spacing › Roles can point it at another step
58
+ or a fixed value. Use them where they fit; space-1…8 still work. */
59
+ --twd-page-pad: var(--twd-space-5); /* side padding of the page */
60
+ --twd-section-gap: var(--twd-space-6); /* between page sections */
61
+ --twd-card-pad: var(--twd-space-5); /* inside cards, menus, modals */
62
+ --twd-card-gap: var(--twd-space-2); /* between items in a card */
63
+ --twd-control-gap: var(--twd-space-3); /* between buttons, chips, inputs in a row */
64
+
65
+ /* ---------- Depth ---------- */
66
+ --twd-border-width: 1px;
67
+ --twd-border-width-container: var(--twd-border-width); /* cards, menus */
68
+ --twd-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
69
+ --twd-shadow-md: 0 4px 12px rgb(0 0 0 / 0.08);
70
+ --twd-shadow-lg: 0 12px 32px rgb(0 0 0 / 0.12);
71
+ }
@@ -0,0 +1,34 @@
1
+ /* Types for twiddle-panel. Importing the package mounts the panel (and adds the token defaults if the page doesn't load them). */
2
+
3
+ /** Global settings per section, plus local tweaks per CSS selector under `scopes`. */
4
+ export type TwiddleState = Record<string, unknown> & {
5
+ scopes?: Record<string, Record<string, Record<string, unknown>>>;
6
+ };
7
+
8
+ export interface TwiddleAPI {
9
+ /** Show the panel. */
10
+ open(): void;
11
+ /** Hide the panel. */
12
+ close(): void;
13
+ /** Show or hide the panel (also Alt/Option + T). */
14
+ toggle(): void;
15
+ /** Clear every setting and go back to the page's own defaults. */
16
+ reset(): void;
17
+ /** Undo / redo the last settings change. */
18
+ undo(): void;
19
+ redo(): void;
20
+ /** Start picking an element on the page to tweak on its own. */
21
+ pick(): void;
22
+ /** The Copy prompt text for the current tweaks (empty string if nothing changed). */
23
+ prompt(): string;
24
+ /** A copy of the current settings (what the ?twd= link carries). */
25
+ getState(): TwiddleState;
26
+ }
27
+
28
+ export declare const Twiddle: TwiddleAPI;
29
+
30
+ declare global {
31
+ interface Window {
32
+ Twiddle: TwiddleAPI;
33
+ }
34
+ }