@andrewcyuan/focusgrid 0.2.0 → 0.3.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/README.md CHANGED
@@ -7,24 +7,20 @@ You can put any react component in the panes using the `renderPane` prop and sup
7
7
  The react bindings are also dependent on [shortcut-engine](https://www.npmjs.com/package/@andrewcyuan/shortcut-engine) for out-of-the-box keyboard support.
8
8
 
9
9
  **Example usage**
10
+
10
11
  ```tsx
11
- import { useState } from "react";
12
- import { FocusGridDomController } from "@andrewcyuan/focusgrid/dom";
13
- import {
14
- FocusGrid, FocusgridController, useFocusGridController,
15
- } from "@andrewcyuan/focusgrid/react";
12
+ import { FocusGrid, FocusgridController, useFocusGridController } from "@andrewcyuan/focusgrid/react";
16
13
  import "@andrewcyuan/focusgrid/react/styles.css";
17
14
 
18
15
  export function App() {
19
- const [domController] = useState(() => new FocusGridDomController());
20
- const controller = useFocusGridController(() => ({
16
+ const controllers = useFocusGridController(() => ({
21
17
  root: { kind: "pane", id: "root", paneId: "editor" },
22
18
  activePaneId: "editor",
23
19
  container: { width: 0, height: 0 },
24
- }), domController);
20
+ }));
25
21
 
26
22
  return (
27
- <FocusgridController.Provider value={{ controller, domController }}>
23
+ <FocusgridController.Provider value={controllers}>
28
24
  <div style={{ height: 500 }}>
29
25
  <FocusGrid renderPane={({ paneId }) => <textarea aria-label={paneId} />} />
30
26
  </div>
@@ -42,5 +38,35 @@ Focusgrid can be easily customized. It can be the surface in which you create yo
42
38
  - Read layout with `getLayout()`/`useControllerLayout(controller)` (React version). You can also directly mutate the layout, although using the API is probably easier and safer.
43
39
  - To write your own frontend framework binding, use `getPane`, `getContainerSize`, and `getSplitSizes` for specific queries, and `subscribe` for changes.
44
40
 
41
+ **Styling**
42
+
43
+ The optional `@andrewcyuan/focusgrid/react/styles.css` stylesheet uses zero-specificity `:where(...)` selectors. Ordinary class selectors override its defaults regardless of stylesheet order, including active, hover, and focus-visible states; no extra parent selector or `!important` is needed.
44
+
45
+ Set these inherited variables on your grid or an ancestor to customize the default colors:
46
+
47
+ | Variable | Default | Applies to |
48
+ | ------------------------------- | ----------------------- | -------------------------------------- |
49
+ | `--focusgrid-focus-color` | `#4d8dff` | Active pane outline |
50
+ | `--focusgrid-handle-idle-color` | `transparent` | Idle resize handle |
51
+ | `--focusgrid-handle-color` | `rgb(77 141 255 / 35%)` | Hovered or focus-visible resize handle |
52
+
53
+ ```css
54
+ .myGrid {
55
+ --focusgrid-handle-idle-color: #555;
56
+ --focusgrid-handle-color: #aaa;
57
+ }
58
+
59
+ .FocusgridPaneView {
60
+ outline: none;
61
+ }
62
+ .FocusgridResizeHandle {
63
+ background: #555;
64
+ }
65
+ .FocusgridResizeHandle:hover {
66
+ background: #aaa;
67
+ }
68
+ ```
69
+
70
+ Pane and handle positions and dimensions still come from inline styles computed by the layout controller; the zero-specificity defaults do not change that geometry.
45
71
 
46
72
  Made by [Andrew Yuan](https://andrewcyuan.com)