@brdgapp/ui 0.1.0 → 0.1.2

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
@@ -1,12 +1,8 @@
1
1
  # @brdgapp/ui
2
2
 
3
- Shows how many people you know at a specific domain, and who they are, from the signed-in user’s Bridge network.
4
-
5
- Use it on any screen that is about one company or firm. Pass that domain. The package looks up the signed-in user’s contacts whose email domain matches, then renders a floating widget: “You know 6 people at Brdg”, with avatars. Opening it lists those people (name, role, company, email) so the user can make an intro, copy an intro link, or open a Bridge profile. Apps can add their own row actions, such as adding the person as a team member.
3
+ Shared UI components for Bridge apps. Each component lives in its own folder under `src/` with its own README. Apps install one package and import the components they need.
6
4
 
7
- Nothing appears when the user is signed out, or when they know nobody at that domain.
8
-
9
- It publishes to the `brdgapp` npm team as `@brdgapp/ui`. Installing it does not need an `.npmrc` or a registry token. Vercel installs it like any other dependency.
5
+ It publishes to the `brdgapp` npm team. Installing it does not need an `.npmrc` or a registry token. Vercel installs it like any other dependency.
10
6
 
11
7
  Source lives in the private GitLab repo `intropath/packages/ui`. The published tarball is what apps install.
12
8
 
@@ -30,7 +26,7 @@ const nextConfig = {
30
26
  }
31
27
  ```
32
28
 
33
- Import the stylesheet once from the root layout (`app/layout.tsx`). Next.js does not pick up the package’s CSS import on its own.
29
+ Import the stylesheet once from the root layout (`app/layout.tsx`). That file pulls in every component stylesheet. Next.js does not pick up the package’s CSS import on its own.
34
30
 
35
31
  ```tsx
36
32
  import "@brdgapp/ui/styles.css"
@@ -40,14 +36,14 @@ import "@brdgapp/ui/styles.css"
40
36
 
41
37
  Add the package to `optimizeDeps.exclude` only if the dev server fails to compile its TypeScript. The package entry imports `styles.css`, so a normal Vite app gets the CSS from the JS import. If styles are missing, import `@brdgapp/ui/styles.css` once from the app entry.
42
38
 
43
- ## Wire it up
39
+ ## Provider
44
40
 
45
- Render `BridgeUIProvider` once around the tree that contains the helper. It supplies the Bridge API base and the signed-in user’s access token. The helper then calls the contacts API itself.
41
+ Wrap the tree once with `BridgeUIProvider`. It supplies the Bridge API base and the signed-in user’s access token. Components that talk to the Bridge API use this provider. They do not take their own token prop.
46
42
 
47
43
  ```tsx
48
44
  "use client"
49
45
 
50
- import { BridgeUIProvider, NetworkPeopleHelper } from "@brdgapp/ui"
46
+ import { BridgeUIProvider } from "@brdgapp/ui"
51
47
 
52
48
  export function AppProviders({ children }: { children: React.ReactNode }) {
53
49
  return (
@@ -60,7 +56,7 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
60
56
 
61
57
  `apiBaseUrl` defaults to production: `https://api.brdg.app/api/v4`. Pass it only for staging or a local backend, using the same value the app already uses for `NEXT_PUBLIC_API_BASE_URL`. Include the `/api/v4` prefix and leave off the trailing slash.
62
58
 
63
- `getAccessToken` returns the bearer token for the signed-in user, or `null` when nobody is signed in. It may be async. A Next.js server action that reads the `authToken` cookie is a valid implementation, because the helper calls it from the browser:
59
+ `getAccessToken` returns the bearer token for the signed-in user, or `null` when nobody is signed in. It may be async. A Next.js server action that reads the `authToken` cookie is a valid implementation, because components call it from the browser:
64
60
 
65
61
  ```tsx
66
62
  "use server"
@@ -75,9 +71,24 @@ export async function getAuthToken(): Promise<string | null> {
75
71
 
76
72
  Pass that function as `getAccessToken`. Do not put the token, or any other secret, in this package.
77
73
 
78
- If `getAccessToken` returns `null`, or the user knows nobody at the domain, the helper stays hidden.
74
+ `introInboxUrl` and `profileUrlForUsername` override the URLs used by built-in intro and profile actions. Defaults are `https://intros.brdg.app/inbox` and `https://os.brdg.app/to/<username>`.
75
+
76
+ ## Components
77
+
78
+ Import from `@brdgapp/ui`, not from a deep path. The app must already wrap the tree in `BridgeUIProvider`.
79
+
80
+ - [Network people helper](#network-people-helper)
81
+
82
+ <details id="network-people-helper">
83
+ <summary><strong>Network people helper</strong> — people you know at a domain</summary>
84
+
85
+ Shows how many people you know at a specific domain, and who they are, from the signed-in user’s Bridge network.
86
+
87
+ Use it on any screen that is about one company or firm. Pass that domain. The component looks up the signed-in user’s contacts whose email domain matches, then renders a floating widget: “You know 6 people at Brdg”, with avatars. Opening it lists those people (name, role, company, email) so the user can make an intro, copy an intro link, or open a Bridge profile. Apps can add their own row actions, such as adding the person as a team member.
88
+
89
+ Nothing appears when the user is signed out, or when they know nobody at that domain.
79
90
 
80
- ## Network people helper
91
+ ### Floating widget
81
92
 
82
93
  ```tsx
83
94
  import { NetworkPeopleHelper } from "@brdgapp/ui"
@@ -96,20 +107,18 @@ import { NetworkPeopleHelper } from "@brdgapp/ui"
96
107
  />
97
108
  ```
98
109
 
99
- `domain` is required. The package cleans it (strips protocol, `www.`, path, and query) and sends it as `domain_override`.
110
+ `domain` is required. The component cleans it (strips protocol, `www.`, path, and query) and sends it as `domain_override`.
100
111
 
101
- ### What the package does
102
-
103
- After about 3 seconds on the page it requests:
112
+ After `checkDelayMs` (default 3000) it requests:
104
113
 
105
114
  - `GET {apiBaseUrl}/search/owned_full_network_contacts/count?domain_override=`
106
115
  - `GET {apiBaseUrl}/search/owned_full_network_contacts?domain_override=&limit=&offset=`
107
116
 
108
- Requests send `Authorization: Bearer <token>` from `getAccessToken`.
117
+ Requests send `Authorization: Bearer <token>` from the provider’s `getAccessToken`. Pass `0` to skip the wait.
109
118
 
110
119
  When the count is greater than zero, the widget appears: icon, then the “You know N people at …” note, then a searchable list with infinite scroll. “Do not show again” hides it for the rest of the browser session (`sessionStorage` key `bridge-network-helper-dismissed:<domain>`).
111
120
 
112
- ### Props
121
+ #### Props
113
122
 
114
123
  | Prop | Required | Default | Purpose |
115
124
  | --- | --- | --- | --- |
@@ -122,7 +131,7 @@ When the count is greater than zero, the widget appears: icon, then the “You k
122
131
  | `style` | no | — | Extra inline style on the fixed root. |
123
132
  | `customActions` | no | `[]` | Extra rows in each person’s menu. |
124
133
 
125
- `placement` is one of `"bottom-end"`, `"bottom-start"`, `"top-end"`, `"top-start"`. `"bottom-end"` matches the portfolio widget: fixed, bottom-right, with a slightly larger offset from 640px up.
134
+ `placement` is one of `"bottom-end"`, `"bottom-start"`, `"top-end"`, `"top-start"`. `"bottom-end"` is fixed, bottom-right, with a slightly larger offset from 640px up.
126
135
 
127
136
  Override that position in the app’s CSS. These variables win over the preset:
128
137
 
@@ -138,7 +147,7 @@ The full set is `--bridge-helper-top`, `--bridge-helper-right`, `--bridge-helper
138
147
 
139
148
  Colors follow the host app’s `--foreground`, `--background`, `--muted`, `--muted-foreground`, and `--border` when those exist. Otherwise the widget uses its own defaults. The Bridge blue accent is `#0038ff`.
140
149
 
141
- ### Person menu
150
+ #### Person menu
142
151
 
143
152
  Built-in actions, shown only when the contact has the field they need:
144
153
 
@@ -146,15 +155,7 @@ Built-in actions, shown only when the contact has the field they need:
146
155
  - **Copy intro link** copies `shareLink`.
147
156
  - **View Bridge profile** opens `https://os.brdg.app/to/<username>` when `username` is set.
148
157
 
149
- Change those URLs on the provider:
150
-
151
- ```tsx
152
- <BridgeUIProvider
153
- getAccessToken={getAuthToken}
154
- introInboxUrl="https://intros.brdg.app/inbox"
155
- profileUrlForUsername={(username) => `https://os.brdg.app/to/${username}`}
156
- >
157
- ```
158
+ Change those URLs with `introInboxUrl` and `profileUrlForUsername` on `BridgeUIProvider`.
158
159
 
159
160
  Custom actions are not built in. “Add as team member” and “Add as founder” belong to the app. Pass them only on the screens where they apply. `onSelect` receives the row’s contact:
160
161
 
@@ -180,9 +181,9 @@ type NetworkPersonAction = {
180
181
  }
181
182
  ```
182
183
 
183
- Custom actions render above the built-in ones. The package does not check edit permission. If the user must not see an action, omit it from `customActions`.
184
+ Custom actions render above the built-in ones. The component does not check edit permission. If the user must not see an action, omit it from `customActions`.
184
185
 
185
- ## Inline nudge
186
+ ### Inline nudge
186
187
 
187
188
  `NetworkPeopleNudge` is the same note, inline in a team or founders section. It uses the same request as the floating helper. Clicking it opens the helper’s people list on this page.
188
189
 
@@ -192,10 +193,20 @@ import { NetworkPeopleNudge } from "@brdgapp/ui"
192
193
  <NetworkPeopleNudge domain={domain} organizationLabel={displayName} />
193
194
  ```
194
195
 
195
- Pass `onOpen` when the click should do something else. `organizationLabel`, `enabled`, and `className` match the helper.
196
+ Pass `onOpen` when the click should do something else. `organizationLabel`, `enabled`, and `className` match the helper. The nudge’s check delay is fixed at 3 seconds.
196
197
 
197
198
  `openNetworkPeopleHelper(domain)` opens the floating helper from any other button. It clears the session dismiss for that domain.
198
199
 
200
+ </details>
201
+
202
+ ## Adding a component
203
+
204
+ 1. Add `src/<component-name>/` with the component source and a `README.md` that says what it is for, its props, and a usage example. Add a `<details id="...">` section for that component under Components in this README, with the same usage, and link the component name to that id. npm renders this file only, and the GitLab repo is private.
205
+ 2. Export the public components and types from `src/<component-name>/index.ts`.
206
+ 3. Re-export those names from `src/index.ts` so apps keep importing `@brdgapp/ui`.
207
+ 4. If the component has CSS, put it in `src/<component-name>/styles.css` and add `@import "./<component-name>/styles.css";` to `src/styles.css`.
208
+ 5. If it calls the Bridge API, use `useBridgeUI()` from `src/provider.tsx`. Do not read tokens inside the component.
209
+
199
210
  ## Publish
200
211
 
201
212
  From this repo, after the version in `package.json` is the one you want to release:
@@ -216,8 +227,5 @@ To release a change, bump `version`, commit, push, then run `pnpm publish` again
216
227
  1. Run `pnpm add @brdgapp/ui`.
217
228
  2. Next.js: set `transpilePackages: ["@brdgapp/ui"]`.
218
229
  3. Import `@brdgapp/ui/styles.css` once in the root layout.
219
- 4. Wrap the app in `BridgeUIProvider` with a `getAccessToken` that returns the signed-in user’s bearer token. The API base defaults to `https://api.brdg.app/api/v4`. Pass `apiBaseUrl` only for staging or local.
220
- 5. Render `NetworkPeopleHelper` with `domain`.
221
- 6. Pass `organizationLabel` only when the screen already has a display name.
222
- 7. Pass `customActions` only for actions this screen owns. `onSelect` gets the `NetworkContact`.
223
- 8. Leave Make intro, Copy intro link, and View Bridge profile to the package.
230
+ 4. Wrap the app in `BridgeUIProvider` with a `getAccessToken` that returns the signed-in user’s bearer token.
231
+ 5. Open the component’s section under Components in this README and follow that.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "0.1.0",
4
- "description": "Shows how many people you know at a domain, and who they are, from the signed-in user's Bridge network.",
3
+ "version": "0.1.2",
4
+ "description": "Shared Bridge UI components for Bridge apps.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "sideEffects": [
package/src/index.ts CHANGED
@@ -4,9 +4,15 @@ import "./styles.css"
4
4
 
5
5
  export { BridgeUIProvider, DEFAULT_API_BASE_URL } from "./provider"
6
6
  export type { BridgeUIProviderProps } from "./provider"
7
- export { NetworkPeopleHelper } from "./network-people-helper"
8
- export type { NetworkPeopleHelperProps } from "./network-people-helper"
9
- export { NetworkPeopleNudge } from "./network-people-nudge"
10
- export type { NetworkPeopleNudgeProps } from "./network-people-nudge"
11
- export { openNetworkPeopleHelper } from "./open-helper"
12
- export type { NetworkContact, NetworkPersonAction, HelperPlacement } from "./types"
7
+ export {
8
+ NetworkPeopleHelper,
9
+ NetworkPeopleNudge,
10
+ openNetworkPeopleHelper,
11
+ } from "./network-people-helper"
12
+ export type {
13
+ NetworkPeopleHelperProps,
14
+ NetworkPeopleNudgeProps,
15
+ NetworkContact,
16
+ NetworkPersonAction,
17
+ HelperPlacement,
18
+ } from "./network-people-helper"
@@ -0,0 +1,130 @@
1
+ # Network people helper
2
+
3
+ Shows how many people you know at a specific domain, and who they are, from the signed-in user’s Bridge network.
4
+
5
+ Use it on any screen that is about one company or firm. Pass that domain. The component looks up the signed-in user’s contacts whose email domain matches, then renders a floating widget: “You know 6 people at Brdg”, with avatars. Opening it lists those people (name, role, company, email) so the user can make an intro, copy an intro link, or open a Bridge profile. Apps can add their own row actions, such as adding the person as a team member.
6
+
7
+ Nothing appears when the user is signed out, or when they know nobody at that domain.
8
+
9
+ The app must already wrap the tree in `BridgeUIProvider`. See the [package README](../../README.md).
10
+
11
+ ## Floating widget
12
+
13
+ ```tsx
14
+ import { NetworkPeopleHelper } from "@brdgapp/ui"
15
+
16
+ <NetworkPeopleHelper
17
+ domain={domain}
18
+ placement="bottom-end"
19
+ customActions={[
20
+ {
21
+ id: "add-team-member",
22
+ label: "Add as team member",
23
+ description: "Save them on this firm's team so they show up with the rest of the roster.",
24
+ onSelect: (contact) => addTeamMember(contact),
25
+ },
26
+ ]}
27
+ />
28
+ ```
29
+
30
+ `domain` is required. The component cleans it (strips protocol, `www.`, path, and query) and sends it as `domain_override`.
31
+
32
+ ### What it requests
33
+
34
+ After about 3 seconds on the page it requests:
35
+
36
+ - `GET {apiBaseUrl}/search/owned_full_network_contacts/count?domain_override=`
37
+ - `GET {apiBaseUrl}/search/owned_full_network_contacts?domain_override=&limit=&offset=`
38
+
39
+ Requests send `Authorization: Bearer <token>` from the provider’s `getAccessToken`.
40
+
41
+ When the count is greater than zero, the widget appears: icon, then the “You know N people at …” note, then a searchable list with infinite scroll. “Do not show again” hides it for the rest of the browser session (`sessionStorage` key `bridge-network-helper-dismissed:<domain>`).
42
+
43
+ ### Props
44
+
45
+ | Prop | Required | Default | Purpose |
46
+ | --- | --- | --- | --- |
47
+ | `domain` | yes | — | Company or firm domain to match contacts against. |
48
+ | `organizationLabel` | no | cleaned domain | Text after “at”. Pass a display name such as `"Brdg"` when the screen already has one. The contacts API does not return an organization name. |
49
+ | `enabled` | no | `true` | Set `false` to skip the request and render nothing. |
50
+ | `checkDelayMs` | no | `3000` | Wait after the page visit before the first request. |
51
+ | `placement` | no | `"bottom-end"` | Fixed corner. See below. |
52
+ | `className` | no | — | Extra class on the fixed root. |
53
+ | `style` | no | — | Extra inline style on the fixed root. |
54
+ | `customActions` | no | `[]` | Extra rows in each person’s menu. |
55
+
56
+ `placement` is one of `"bottom-end"`, `"bottom-start"`, `"top-end"`, `"top-start"`. `"bottom-end"` is fixed, bottom-right, with a slightly larger offset from 640px up.
57
+
58
+ Override that position in the app’s CSS. These variables win over the preset:
59
+
60
+ ```css
61
+ .my-helper {
62
+ --bridge-helper-bottom: 5rem;
63
+ --bridge-helper-right: 2rem;
64
+ --bridge-helper-z: 50;
65
+ }
66
+ ```
67
+
68
+ The full set is `--bridge-helper-top`, `--bridge-helper-right`, `--bridge-helper-bottom`, `--bridge-helper-left`, and `--bridge-helper-z`.
69
+
70
+ Colors follow the host app’s `--foreground`, `--background`, `--muted`, `--muted-foreground`, and `--border` when those exist. Otherwise the widget uses its own defaults. The Bridge blue accent is `#0038ff`.
71
+
72
+ ### Person menu
73
+
74
+ Built-in actions, shown only when the contact has the field they need:
75
+
76
+ - **Make intro** opens `https://intros.brdg.app/inbox?action=make-intro&n1=<email>` when `email` is set.
77
+ - **Copy intro link** copies `shareLink`.
78
+ - **View Bridge profile** opens `https://os.brdg.app/to/<username>` when `username` is set.
79
+
80
+ Change those URLs with `introInboxUrl` and `profileUrlForUsername` on `BridgeUIProvider`.
81
+
82
+ Custom actions are not built in. “Add as team member” and “Add as founder” belong to the app. Pass them only on the screens where they apply. `onSelect` receives the row’s contact:
83
+
84
+ ```ts
85
+ type NetworkContact = {
86
+ id: string
87
+ name: string
88
+ email: string | null
89
+ shareLink: string | null
90
+ profilePicUrl: string | null
91
+ position: string | null
92
+ company: string | null
93
+ username: string | null
94
+ isMember: boolean
95
+ }
96
+
97
+ type NetworkPersonAction = {
98
+ id: string
99
+ label: string
100
+ description?: string
101
+ icon?: React.ReactNode
102
+ onSelect: (contact: NetworkContact) => void
103
+ }
104
+ ```
105
+
106
+ Custom actions render above the built-in ones. The component does not check edit permission. If the user must not see an action, omit it from `customActions`.
107
+
108
+ ## Inline nudge
109
+
110
+ `NetworkPeopleNudge` is the same note, inline in a team or founders section. It uses the same request as the floating helper. Clicking it opens the helper’s people list on this page.
111
+
112
+ ```tsx
113
+ import { NetworkPeopleNudge } from "@brdgapp/ui"
114
+
115
+ <NetworkPeopleNudge domain={domain} organizationLabel={displayName} />
116
+ ```
117
+
118
+ Pass `onOpen` when the click should do something else. `organizationLabel`, `enabled`, and `className` match the helper.
119
+
120
+ `openNetworkPeopleHelper(domain)` opens the floating helper from any other button. It clears the session dismiss for that domain.
121
+
122
+ ## Files
123
+
124
+ | File | Role |
125
+ | --- | --- |
126
+ | `network-people-helper.tsx` | Floating widget. |
127
+ | `network-people-nudge.tsx` | Inline note that opens the widget. |
128
+ | `api.ts` | Count, preview, and paged contact requests. |
129
+ | `styles.css` | Widget styles. Imported by the package stylesheet. |
130
+ | `index.ts` | Public exports for this component. |
@@ -1,5 +1,6 @@
1
1
  import { cleanDomain } from "./domain"
2
- import type { BridgeClientConfig, NetworkContact } from "./types"
2
+ import type { BridgeClientConfig } from "../provider"
3
+ import type { NetworkContact } from "./types"
3
4
 
4
5
  export const PREVIEW_LIMIT = 3
5
6
  export const PAGE_SIZE = 20
@@ -0,0 +1,6 @@
1
+ export { NetworkPeopleHelper } from "./network-people-helper"
2
+ export type { NetworkPeopleHelperProps } from "./network-people-helper"
3
+ export { NetworkPeopleNudge } from "./network-people-nudge"
4
+ export type { NetworkPeopleNudgeProps } from "./network-people-nudge"
5
+ export { openNetworkPeopleHelper } from "./open-helper"
6
+ export type { NetworkContact, NetworkPersonAction, HelperPlacement } from "./types"
@@ -16,7 +16,7 @@ import {
16
16
  type NetworkPeopleHelperOpenDetail,
17
17
  } from "./open-helper"
18
18
  import { PersonMenu, ShareLinkCopyControl } from "./person-menu"
19
- import { useBridgeUI } from "./provider"
19
+ import { useBridgeUI } from "../provider"
20
20
  import type { HelperPlacement, NetworkPersonAction } from "./types"
21
21
  import { useNetworkPeopleList } from "./use-network-people-list"
22
22
  import { useNetworkPreview } from "./use-network-preview"
@@ -5,7 +5,7 @@ import { ContactAvatar } from "./contact-avatar"
5
5
  import { cleanDomain, organizationLabelFromDomain } from "./domain"
6
6
  import { BridgeHelperIcon, ChevronUpIcon } from "./icons"
7
7
  import { openNetworkPeopleHelper } from "./open-helper"
8
- import { useBridgeUI } from "./provider"
8
+ import { useBridgeUI } from "../provider"
9
9
  import { useNetworkPreview } from "./use-network-preview"
10
10
 
11
11
  const DEFAULT_CHECK_DELAY_MS = 3000
@@ -3,7 +3,8 @@
3
3
  import { useEffect, useLayoutEffect, useRef, useState } from "react"
4
4
  import { createPortal } from "react-dom"
5
5
  import { CheckIcon, CopyIcon, LinkIcon, MoreIcon, UserIcon, UserPlusIcon } from "./icons"
6
- import type { BridgeClientConfig, NetworkContact, NetworkPersonAction } from "./types"
6
+ import type { BridgeClientConfig } from "../provider"
7
+ import type { NetworkContact, NetworkPersonAction } from "./types"
7
8
 
8
9
  function introUrl(inboxUrl: string, email: string): string {
9
10
  const url = new URL(inboxUrl)