@brdgapp/ui 0.1.1 → 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.
Files changed (2) hide show
  1. package/README.md +124 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -75,15 +75,133 @@ Pass that function as `getAccessToken`. Do not put the token, or any other secre
75
75
 
76
76
  ## Components
77
77
 
78
- | Component | Folder | What it is for |
79
- | --- | --- | --- |
80
- | Network people helper | [`src/network-people-helper`](./src/network-people-helper/README.md) | Shows how many people you know at a domain, and who they are, from the signed-in user’s Bridge network. |
78
+ Import from `@brdgapp/ui`, not from a deep path. The app must already wrap the tree in `BridgeUIProvider`.
81
79
 
82
- Read that component’s README before rendering it. Import from `@brdgapp/ui`, not from a deep path.
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.
90
+
91
+ ### Floating widget
92
+
93
+ ```tsx
94
+ import { NetworkPeopleHelper } from "@brdgapp/ui"
95
+
96
+ <NetworkPeopleHelper
97
+ domain={domain}
98
+ placement="bottom-end"
99
+ customActions={[
100
+ {
101
+ id: "add-team-member",
102
+ label: "Add as team member",
103
+ description: "Save them on this firm's team so they show up with the rest of the roster.",
104
+ onSelect: (contact) => addTeamMember(contact),
105
+ },
106
+ ]}
107
+ />
108
+ ```
109
+
110
+ `domain` is required. The component cleans it (strips protocol, `www.`, path, and query) and sends it as `domain_override`.
111
+
112
+ After `checkDelayMs` (default 3000) it requests:
113
+
114
+ - `GET {apiBaseUrl}/search/owned_full_network_contacts/count?domain_override=`
115
+ - `GET {apiBaseUrl}/search/owned_full_network_contacts?domain_override=&limit=&offset=`
116
+
117
+ Requests send `Authorization: Bearer <token>` from the provider’s `getAccessToken`. Pass `0` to skip the wait.
118
+
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>`).
120
+
121
+ #### Props
122
+
123
+ | Prop | Required | Default | Purpose |
124
+ | --- | --- | --- | --- |
125
+ | `domain` | yes | — | Company or firm domain to match contacts against. |
126
+ | `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. |
127
+ | `enabled` | no | `true` | Set `false` to skip the request and render nothing. |
128
+ | `checkDelayMs` | no | `3000` | Wait after the page visit before the first request. |
129
+ | `placement` | no | `"bottom-end"` | Fixed corner. See below. |
130
+ | `className` | no | — | Extra class on the fixed root. |
131
+ | `style` | no | — | Extra inline style on the fixed root. |
132
+ | `customActions` | no | `[]` | Extra rows in each person’s menu. |
133
+
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.
135
+
136
+ Override that position in the app’s CSS. These variables win over the preset:
137
+
138
+ ```css
139
+ .my-helper {
140
+ --bridge-helper-bottom: 5rem;
141
+ --bridge-helper-right: 2rem;
142
+ --bridge-helper-z: 50;
143
+ }
144
+ ```
145
+
146
+ The full set is `--bridge-helper-top`, `--bridge-helper-right`, `--bridge-helper-bottom`, `--bridge-helper-left`, and `--bridge-helper-z`.
147
+
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`.
149
+
150
+ #### Person menu
151
+
152
+ Built-in actions, shown only when the contact has the field they need:
153
+
154
+ - **Make intro** opens `https://intros.brdg.app/inbox?action=make-intro&n1=<email>` when `email` is set.
155
+ - **Copy intro link** copies `shareLink`.
156
+ - **View Bridge profile** opens `https://os.brdg.app/to/<username>` when `username` is set.
157
+
158
+ Change those URLs with `introInboxUrl` and `profileUrlForUsername` on `BridgeUIProvider`.
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:
161
+
162
+ ```ts
163
+ type NetworkContact = {
164
+ id: string
165
+ name: string
166
+ email: string | null
167
+ shareLink: string | null
168
+ profilePicUrl: string | null
169
+ position: string | null
170
+ company: string | null
171
+ username: string | null
172
+ isMember: boolean
173
+ }
174
+
175
+ type NetworkPersonAction = {
176
+ id: string
177
+ label: string
178
+ description?: string
179
+ icon?: React.ReactNode
180
+ onSelect: (contact: NetworkContact) => void
181
+ }
182
+ ```
183
+
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`.
185
+
186
+ ### Inline nudge
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.
189
+
190
+ ```tsx
191
+ import { NetworkPeopleNudge } from "@brdgapp/ui"
192
+
193
+ <NetworkPeopleNudge domain={domain} organizationLabel={displayName} />
194
+ ```
195
+
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.
197
+
198
+ `openNetworkPeopleHelper(domain)` opens the floating helper from any other button. It clears the session dismiss for that domain.
199
+
200
+ </details>
83
201
 
84
202
  ## Adding a component
85
203
 
86
- 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.
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.
87
205
  2. Export the public components and types from `src/<component-name>/index.ts`.
88
206
  3. Re-export those names from `src/index.ts` so apps keep importing `@brdgapp/ui`.
89
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`.
@@ -110,4 +228,4 @@ To release a change, bump `version`, commit, push, then run `pnpm publish` again
110
228
  2. Next.js: set `transpilePackages: ["@brdgapp/ui"]`.
111
229
  3. Import `@brdgapp/ui/styles.css` once in the root layout.
112
230
  4. Wrap the app in `BridgeUIProvider` with a `getAccessToken` that returns the signed-in user’s bearer token.
113
- 5. Open the README for the component you are adding and follow that.
231
+ 5. Open the component’s section under Components in this README and follow that.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brdgapp/ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Shared Bridge UI components for Bridge apps.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",