@bridge-ds/toolbar 0.0.0-stage → 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 +17 -0
- package/README.md +50 -2
- package/dist/BridgeToolbar.d.ts +25 -0
- package/dist/ChangeOutlines.d.ts +21 -0
- package/dist/Toolbar-B-p9ZCvk.js +1490 -0
- package/dist/Toolbar-B-p9ZCvk.js.map +1 -0
- package/dist/Toolbar.d.ts +3 -0
- package/dist/config.d.ts +15 -0
- package/dist/diff.d.ts +61 -0
- package/dist/github.d.ts +32 -0
- package/dist/index-yvFRSnsp.js +97 -0
- package/dist/index-yvFRSnsp.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/outline.d.ts +41 -0
- package/dist/pin.d.ts +6 -0
- package/dist/scope.d.ts +20 -0
- package/dist/session-CzlIsFDY.js +325 -0
- package/dist/session-CzlIsFDY.js.map +1 -0
- package/dist/session.d.ts +226 -0
- package/dist/together.d.ts +45 -0
- package/dist/together.js +57 -0
- package/dist/together.js.map +1 -0
- package/dist/useChangedElements.d.ts +2 -0
- package/dist/useTogether.d.ts +24 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Florian Gouloubi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
7
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
8
|
+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
|
11
|
+
the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
|
14
|
+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
16
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
17
|
+
IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bridge-ds/toolbar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Bridge toolbar for a product built with the Bridge design system. Bridge Studio opens the product with
|
|
4
|
+
`?bridge=<change>` ("Try it in the product"); the toolbar then lets anyone browse the real product and flip between
|
|
5
|
+
**Live product** (before) and **This change** (after), with **Show what changed** for token changes.
|
|
6
|
+
|
|
7
|
+
- **Code changes** (an exploration in the product's repository, a feature branch): Before is the product in
|
|
8
|
+
production, After is the branch's preview. Flipping keeps the screen and the scroll position.
|
|
9
|
+
- **Token changes** of the design system: the live tokens swap in without a reload, and Show what changed outlines
|
|
10
|
+
every surface that differs.
|
|
11
|
+
|
|
12
|
+
Without `?bridge=` (or the session that remembers it) it renders nothing and loads nothing: the toolbar and its styles
|
|
13
|
+
are one lazy chunk.
|
|
14
|
+
|
|
15
|
+
## Mount it
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i @bridge-ds/toolbar
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
One line at the root of the app, inside the design system's `ThemeProvider`:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { BridgeToolbar } from '@bridge-ds/toolbar';
|
|
25
|
+
|
|
26
|
+
<BridgeToolbar ds="acme/design-system" product="checkout" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`ds` is the design system repository and `product` the product's key in its `bridge.config.json` `products[]`. When
|
|
30
|
+
Studio opens the page, the toolbar reads that config from GitHub once per session: the product's repository (where its
|
|
31
|
+
explorations are pull requests), `production` (Before of a code change), `preview` (the branch preview template, the
|
|
32
|
+
only hosts allowed to hand over to production) and production Studio (`previews.production.docs`, the way back and the
|
|
33
|
+
live tokens). `bridge connect` prints this line with your values.
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{ "key": "checkout", "name": "Checkout", "repo": "acme/checkout", "framework": "react",
|
|
37
|
+
"preview": "https://checkout-git-{branch}-acme.vercel.app", "production": "https://checkout.acme.com" }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
| Prop | What it does |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `studio`, `production`, `preview` | Override what the config says (for example a staging URL as Before). |
|
|
45
|
+
| `deployEnv` | `"production"` or `"preview"` when your build knows it (Vercel: `VERCEL_ENV`). |
|
|
46
|
+
| `build` | Every fact at once, read at build time: no config read at run time. |
|
|
47
|
+
| `scope` | A hook returning `{ theme, brand, density, shop, set }` when your app keeps theme and shop in state. Default: the `data-theme`, `data-brand` and `data-density` attributes `ThemeProvider asRoot` puts on `<html>`. |
|
|
48
|
+
| `shops` | `{ id, name, brand }[]` of a multi-brand product, for the screens list and "Switch to <shop>". |
|
|
49
|
+
| `together` | A loader of the latest library's token files (`togetherBase` from `@bridge-ds/toolbar/together`), so Studio's "Try them together" runs on your production. |
|
|
50
|
+
|
|
51
|
+
Reads are anonymous (public repositories): at most a few GitHub API reads per change and session.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type BridgeBuild } from './session';
|
|
2
|
+
import type { ToolbarScope, ToolbarShop } from './scope';
|
|
3
|
+
import type { TogetherBase } from './together';
|
|
4
|
+
export interface BridgeToolbarProps {
|
|
5
|
+
/** The design system repository, "owner/name". The toolbar reads its bridge.config.json when Studio opens the page. */
|
|
6
|
+
ds?: string;
|
|
7
|
+
/** This product's key in the design system's bridge.config.json products[] ("checkout"). */
|
|
8
|
+
product?: string;
|
|
9
|
+
/** Overrides of what the config says: production Studio, this product in production, its preview template. */
|
|
10
|
+
studio?: string | null;
|
|
11
|
+
production?: string | null;
|
|
12
|
+
preview?: string | null;
|
|
13
|
+
/** The deploy environment ("production", "preview"), when the host tells it at build time (VERCEL_ENV). */
|
|
14
|
+
deployEnv?: string | null;
|
|
15
|
+
/** Every fact at once, read at build time: no config read at run time (the Admin demo passes it). */
|
|
16
|
+
build?: BridgeBuild;
|
|
17
|
+
/** A hook that says where the page is and moves it (theme, shop). Default: the attributes ThemeProvider sets on <html>. */
|
|
18
|
+
scope?: () => ToolbarScope;
|
|
19
|
+
/** The shops of a multi-brand product, for the screens list and "Switch to <shop>". */
|
|
20
|
+
shops?: ToolbarShop[];
|
|
21
|
+
/** The latest library's token files as a combination base: lets Studio's "Try them together" run here. */
|
|
22
|
+
together?: () => Promise<TogetherBase>;
|
|
23
|
+
}
|
|
24
|
+
/** Mounted once at the app root. Without a change from Studio it renders nothing and loads nothing. */
|
|
25
|
+
export declare function BridgeToolbar(props: BridgeToolbarProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Theme } from '@bridge-ds/react';
|
|
3
|
+
import { type ChangedElement } from './outline';
|
|
4
|
+
import type { Rect } from './session';
|
|
5
|
+
export interface Shown {
|
|
6
|
+
/** Visible surfaces, in order. */
|
|
7
|
+
count: number;
|
|
8
|
+
/** Boxes of the visible surfaces that are not page-sized: the toolbar keeps clear of them. */
|
|
9
|
+
obstacles: Rect[];
|
|
10
|
+
}
|
|
11
|
+
export declare function ChangeOutlines({ surfaces, theme, tip, onShown, emphasis, flash, }: {
|
|
12
|
+
surfaces: ChangedElement[];
|
|
13
|
+
theme: Theme;
|
|
14
|
+
/** The surface whose list row is hovered, focused or activated: chip and stronger outline. */
|
|
15
|
+
emphasis: number | null;
|
|
16
|
+
/** Show every chip (the moment outlines turn on). */
|
|
17
|
+
flash: boolean;
|
|
18
|
+
/** Tooltip content for a surface: its role, token and before and after. */
|
|
19
|
+
tip: (s: ChangedElement) => ReactNode;
|
|
20
|
+
onShown: (shown: Shown) => void;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|