@gregogun/radial-menu 0.1.0-alpha.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 Greg Ogun
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,123 @@
1
+ # @gregogun/radial-menu
2
+
3
+ A radial (pie) context menu for React, built on [Base UI](https://base-ui.com).
4
+ Right-click / long-press or open it programmatically. Angle-from-centre pointer
5
+ routing, nested submenus, and CSS-variable theming with light/dark defaults.
6
+
7
+ > **Alpha.** The API is settling but may still change before `1.0`.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm i @gregogun/radial-menu @base-ui/react motion
13
+ ```
14
+
15
+ `react`, `react-dom`, `@base-ui/react`, and `motion` are **peer dependencies** —
16
+ nothing is bundled. Base UI must be a single copy (it shares React context with
17
+ the rest of your app), and keeping `motion` external preserves the lazy-loaded
18
+ animation features.
19
+
20
+ ## Usage
21
+
22
+ ```tsx
23
+ import { RadialMenu } from "@gregogun/radial-menu";
24
+ import "@gregogun/radial-menu/styles.css";
25
+
26
+ const items = [
27
+ { icon: <CopyIcon />, label: "Copy", onSelect: () => copy() },
28
+ { icon: <ReloadIcon />, label: "Reload", onSelect: () => reload() },
29
+ {
30
+ icon: <DownloadIcon />,
31
+ label: "Download",
32
+ submenu: [
33
+ { icon: <PdfIcon />, label: "Save as PDF", onSelect: () => savePdf() },
34
+ { icon: <ImgIcon />, label: "Save as image", onSelect: () => saveImg() },
35
+ ],
36
+ },
37
+ ];
38
+
39
+ function Editor() {
40
+ return (
41
+ <RadialMenu.Root items={items}>
42
+ <RadialMenu.Trigger
43
+ render={(props) => <div {...props}>Right-click me</div>}
44
+ />
45
+ </RadialMenu.Root>
46
+ );
47
+ }
48
+ ```
49
+
50
+ Item order **is** placement: item 0 is the top wedge, the rest fan clockwise. A
51
+ parent item carries a `submenu`; a leaf carries `onSelect`.
52
+
53
+ ## Programmatic / controlled open
54
+
55
+ For games or external events (a network message, an NPC interaction, a keybind)
56
+ you can open the menu with no pointer — and omit the `Trigger` entirely:
57
+
58
+ ```tsx
59
+ import { useRef } from "react";
60
+ import { RadialMenu, RadialMenuActions } from "@gregogun/radial-menu";
61
+
62
+ function Game() {
63
+ const menu = useRef<RadialMenuActions>(null);
64
+
65
+ // later: menu.current?.open(clientX, clientY)
66
+ return <RadialMenu.Root items={items} actionsRef={menu} />;
67
+ }
68
+ ```
69
+
70
+ `actionsRef` exposes `{ open(x, y), openAtElement(el), close() }`. You can also
71
+ drive visibility with the controlled `open` / `onOpenChange` props.
72
+
73
+ ## Props (`RadialMenu.Root`)
74
+
75
+ | Prop | Type | Default | Description |
76
+ | ------------------ | --------------------------------- | ----------- | -------------------------------------------------------------- |
77
+ | `items` | `MenuItem[]` | — | The ordered radial items (order is placement). |
78
+ | `size` | `number` | `250` | Diameter of the root ring, in px. |
79
+ | `layout` | `"halved" \| "full"` | `"halved"` | Submenu band layout (half a wedge per child, or a full wedge). |
80
+ | `direction` | `"cw" \| "ccw"` | `"cw"` | Submenu fan direction. |
81
+ | `submenuThickness` | `number` | `0.3` | Submenu band thickness as a fraction of `size`. |
82
+ | `ringGap` | `number` | `8` | Gap between the root rim and the submenu band, in px. |
83
+ | `openDelay` | `number` | `280` | Dwell (ms) before a hovered submenu-parent opens. |
84
+ | `open` | `boolean` | — | Controlled open state (pair with `onOpenChange`). |
85
+ | `defaultOpen` | `boolean` | — | Uncontrolled initial open state. |
86
+ | `onOpenChange` | `(open: boolean) => void` | — | Fired when the menu opens or closes. |
87
+ | `actionsRef` | `Ref<RadialMenuActions>` | — | Imperative handle: `open` / `openAtElement` / `close`. |
88
+ | `children` | `ReactNode` | — | A `RadialMenu.Trigger`. Optional for programmatic-only menus. |
89
+
90
+ ### `MenuItem`
91
+
92
+ | Field | Type | Description |
93
+ | --------------- | --------------- | --------------------------------------------------------------- |
94
+ | `icon` | `ReactNode` | Wedge icon. |
95
+ | `label` | `string` | Accessible label for the wedge. |
96
+ | `submenu` | `MenuItem[]` | Children. Parents open their submenu instead of selecting. |
97
+ | `onSelect` | `() => void` | Fired when a leaf is chosen. |
98
+ | `closeOnSelect` | `boolean` | Keep the menu open after selecting (default: close). |
99
+
100
+ ## Theming
101
+
102
+ The skin reads namespaced CSS variables (Radix slate values baked in as
103
+ defaults). Override any of them to retheme:
104
+
105
+ ```css
106
+ :root {
107
+ --radial-1: #fcfcfd; /* app / popup background */
108
+ --radial-2: #f9f9fb; /* wedge fill */
109
+ --radial-3: #f0f0f3; /* selected / border */
110
+ --radial-4: #e8e8ec; /* ring stroke */
111
+ --radial-11: #60646c; /* icon */
112
+ --radial-12: #1c2024; /* active icon */
113
+ }
114
+ ```
115
+
116
+ **Dark mode** ships out of the box: dark values apply under both
117
+ `@media (prefers-color-scheme: dark)` and a `.dark` / `[data-theme="dark"]`
118
+ selector, so it follows the system or an explicit class. Animations respect
119
+ `prefers-reduced-motion`.
120
+
121
+ ## License
122
+
123
+ MIT © Greg Ogun
@@ -0,0 +1,3 @@
1
+ export { RadialMenu, RadialMenuRoot, RadialMenuTrigger, } from './modules/radialMenu/RadialMenu';
2
+ export type { RadialMenuRootProps, RadialMenuTriggerProps, RadialMenuActions, } from './modules/radialMenu/RadialMenu';
3
+ export type { MenuItem, SubmenuLayout, SubsectionDirection, } from './types';