@the-portland-company/shell 0.30.0 → 0.32.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/CHANGELOG.md CHANGED
@@ -1,3 +1,55 @@
1
+ ## 0.32.0 — 2026-07-23
2
+
3
+ ### Added — mode-aware navigation (Campaign Mode) with zero new chrome config
4
+
5
+ `standardPolitogyNav` now builds a per-Mode tree. `mode: 'relationship'` (the
6
+ default) is **byte-for-byte** what it produced before — no consumer changes,
7
+ no regression. `mode: 'campaign'` produces the Campaign tree — Dashboard, Voter
8
+ Contact (both core-hosted under `app.politogyvrm.com/campaign/*`), then A2P,
9
+ Phone Banking, Field Canvassing, Sign Mapping (standalone apps), Tribes (the
10
+ Contacts app's `/tribes`) and Polling Engine (the polls app). `mode: 'petition'`
11
+ is a minimal tree pointing at the Petition Mode app.
12
+
13
+ Which tree an app renders is **derived, not passed**: it comes from the app's
14
+ own `mode` in the `POLITOGY_APPS` registry. New rows were added for the four
15
+ Campaign apps — `a2p`, `phonebank`, `canvass`, `signs` — each `mode: 'campaign'`,
16
+ so they render the Campaign tree and a **static Campaign pill** (never a
17
+ Relationship pill). Unscoped apps (forms / surveys / polls / contacts / vrm)
18
+ have no `mode` and render Relationship exactly as before. The zero-drift
19
+ contract holds: an app still passes nothing about its chrome.
20
+
21
+ ### Added — `CAMPAIGN_FEATURE_AVAILABILITY` (staged feature rollout)
22
+
23
+ Campaign features ship incrementally. A disabled feature is **omitted** from the
24
+ nav (not rendered as a dead row); its flag flips to `true` in a later patch
25
+ release as the app launches. Defaults at this version: Polling Engine and Tribes
26
+ on; A2P, Phone Banking, Field Canvassing and Sign Mapping off.
27
+
28
+ ### Changed — Mode switcher targets, and cross-app links carry the active org
29
+
30
+ The Campaign/Petition trees carry the active org on every cross-app link as
31
+ `?org=<last6>` — the same convention the Mode switcher and My Account menu use —
32
+ so the destination app opens on the same org. The Mode switcher's Petition
33
+ destination is corrected to `petition-mode.politogyvrm.com` (the petitions app's
34
+ real production subdomain), and a mode-scoped app can pass `pinnedModeId` to
35
+ `useChromeMode` so its pill shows its own mode while a multi-mode org still gets
36
+ the switcher to leave.
37
+
38
+ ## 0.31.0 — 2026-07-23
39
+
40
+ ### Fixed — Surveys sub-menu now shows all three items (matches the tab strip)
41
+
42
+ 0.25.0 collapsed the Surveys group to a single "Surveys" child to kill an
43
+ all-active bug, which left the sidebar sub-menu showing 1 item while the tab
44
+ strip showed 3 (Surveys / Canvas / Results). Restored to three, with distinct
45
+ `?view=` hrefs so active-detection still singles out exactly one.
46
+
47
+ ### Changed — Beta banner reads as a warning (amber)
48
+
49
+ The `--beta-banner-*` tokens were never emitted, so the banner had no reliable
50
+ colour. It now falls back to amber-100 fill, amber-500 border and amber-900
51
+ text — a clear warning treatment with a darker text/border shade.
52
+
1
53
  ## 0.30.0 — 2026-07-23
2
54
 
3
55
  ### Added — `TopBarPopover` is public (enables the VRM widget port)
package/README.md CHANGED
@@ -179,6 +179,32 @@ import '@the-portland-company/shell/css' // view-transitions CSS for
179
179
 
180
180
  ---
181
181
 
182
+ ## Mode-aware navigation (Campaign Mode)
183
+
184
+ `PolitogyAppFrame` and `standardPolitogyNav` render a different left-nav tree per
185
+ operating **Mode** — and an app passes nothing to select it. Which tree an app
186
+ renders is derived from the app's own `mode` in the `POLITOGY_APPS` registry:
187
+
188
+ - **Unscoped apps** (no `mode` — forms / surveys / polls / contacts / vrm) render
189
+ the **Relationship** tree, byte-for-byte as before, with an entitlement-driven
190
+ Mode pill.
191
+ - **Campaign apps** (`a2p`, `phonebank`, `canvass`, `signs`, all `mode: 'campaign'`)
192
+ render the **Campaign** tree (Dashboard, Voter Contact, then the launched
193
+ feature apps) and a **static Campaign pill**.
194
+ - **Petitions** (`mode: 'petition'`) renders a minimal Petition tree.
195
+
196
+ Campaign features ship incrementally. `CAMPAIGN_FEATURE_AVAILABILITY` (exported
197
+ from `@the-portland-company/shell/native`) gates each feature: a disabled one is
198
+ omitted from the nav, and its flag flips to `true` in a patch release as the app
199
+ launches. Defaults: Polling Engine and Tribes on; A2P, Phone Banking, Field
200
+ Canvassing, Sign Mapping off.
201
+
202
+ Cross-app links in the Campaign/Petition trees carry the active org as
203
+ `?org=<last6>` — the same convention the Mode switcher and My Account menu use —
204
+ so the destination app opens on the same org. When the chrome API grants more
205
+ than one Mode (`scope.modes`), the pill becomes a switcher whose selection
206
+ navigates to that Mode's home carrying the active org.
207
+
182
208
  ## Multi-SPA routing on `app.politogy.com`
183
209
 
184
210
  Multiple politogy apps live behind one domain via a Cloudflare Worker edge router (in `packages/edge-router` of the monorepo).
@@ -820,6 +820,21 @@ function useThemePreference() {
820
820
  }
821
821
 
822
822
  // src/native/standardNav.ts
823
+ var CAMPAIGN_FEATURE_AVAILABILITY = {
824
+ a2p: false,
825
+ phonebank: false,
826
+ canvass: false,
827
+ signs: false,
828
+ tribes: true,
829
+ polling: true
830
+ };
831
+ var A2P_ORIGIN = "https://a2p.politogyvrm.com/";
832
+ var PHONEBANK_ORIGIN = "https://phonebank.politogyvrm.com/";
833
+ var CANVASS_ORIGIN = "https://canvass.politogyvrm.com/";
834
+ var SIGNS_ORIGIN = "https://signs.politogyvrm.com/";
835
+ var POLLS_ORIGIN = "https://polls.politogyvrm.com/";
836
+ var CONTACTS_TRIBES = "https://contacts.politogyvrm.com/tribes";
837
+ var PETITION_MODE_ORIGIN = "https://petition-mode.politogyvrm.com/";
823
838
  var CONTACTS_DEFAULT_CHILDREN = [
824
839
  { label: "Dashboard", icon: "grid", path: "/relationship/contacts/dashboard" },
825
840
  { label: "All Contacts", icon: "list", path: "/relationship/contacts/all" },
@@ -870,7 +885,9 @@ var APP_FORMS_CHILDREN = [
870
885
  { label: "Submissions", icon: "fileText", href: "https://forms.politogyvrm.com/?tab=submissions" }
871
886
  ];
872
887
  var APP_SURVEYS_CHILDREN = [
873
- { label: "Surveys", icon: "list", href: "https://surveys.politogyvrm.com/surveys" }
888
+ { label: "Surveys", icon: "list", href: "https://surveys.politogyvrm.com/surveys" },
889
+ { label: "Canvas", icon: "edit", href: "https://surveys.politogyvrm.com/surveys?view=canvas" },
890
+ { label: "Results", icon: "barChart", href: "https://surveys.politogyvrm.com/surveys?view=results" }
874
891
  ];
875
892
  var APP_POLLS_CHILDREN = [
876
893
  { label: "Command Center", icon: "grid", href: "https://polls.politogyvrm.com/" },
@@ -887,59 +904,85 @@ function standardPolitogyNav(opts) {
887
904
  href: abs(c.path),
888
905
  children: c.children ? leaves(c.children) : void 0
889
906
  }));
890
- const contacts = opts.contactsItem ? {
891
- label: "Contacts",
892
- icon: icon("users"),
893
- href: opts.contactsItem.href,
894
- children: opts.contactsItem.children
895
- } : {
896
- label: "Contacts",
897
- icon: icon("users"),
898
- href: abs("/relationship/contacts/dashboard"),
899
- children: leaves(CONTACTS_DEFAULT_CHILDREN)
907
+ const orgParam = opts.activeOrgId ? `org=${opts.activeOrgId.slice(-6)}` : "";
908
+ const withOrg = (url) => orgParam ? `${url}${url.includes("?") ? "&" : "?"}${orgParam}` : url;
909
+ const buildRelationship = () => {
910
+ const contacts = opts.contactsItem ? {
911
+ label: "Contacts",
912
+ icon: icon("users"),
913
+ href: opts.contactsItem.href,
914
+ children: opts.contactsItem.children
915
+ } : {
916
+ label: "Contacts",
917
+ icon: icon("users"),
918
+ href: abs("/relationship/contacts/dashboard"),
919
+ children: leaves(CONTACTS_DEFAULT_CHILDREN)
920
+ };
921
+ return [
922
+ { label: "Dashboard", icon: icon("home"), href: abs("/relationship/dashboard") },
923
+ contacts,
924
+ {
925
+ label: "Email Broadcast",
926
+ icon: icon("mail"),
927
+ href: abs("/relationship/email/dashboard"),
928
+ children: leaves(EMAIL_CHILDREN)
929
+ },
930
+ {
931
+ label: "SMS/MMS Blast",
932
+ icon: icon("messageSquare"),
933
+ href: abs("/relationship/sms-mms-blast/dashboard"),
934
+ children: leaves(SMS_CHILDREN)
935
+ },
936
+ // These two carry no top-level href in VRM core (parent row only toggles).
937
+ { label: "Calls to Action", icon: icon("layout"), children: leaves(CTA_CHILDREN) },
938
+ {
939
+ label: "Forms",
940
+ icon: icon("activity"),
941
+ href: "https://forms.politogyvrm.com/",
942
+ children: APP_FORMS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
943
+ },
944
+ {
945
+ label: "Surveys",
946
+ icon: icon("fileText"),
947
+ href: "https://surveys.politogyvrm.com/surveys",
948
+ children: APP_SURVEYS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
949
+ },
950
+ {
951
+ label: "Polls",
952
+ icon: icon("barChart"),
953
+ href: "https://polls.politogyvrm.com/",
954
+ children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
955
+ },
956
+ {
957
+ label: "Organization Settings",
958
+ icon: icon("briefcase"),
959
+ href: abs("/organization-settings"),
960
+ children: branches(ORG_SETTINGS_CHILDREN)
961
+ }
962
+ ];
900
963
  };
901
- const items = [
902
- { label: "Dashboard", icon: icon("home"), href: abs("/relationship/dashboard") },
903
- contacts,
904
- {
905
- label: "Email Broadcast",
906
- icon: icon("mail"),
907
- href: abs("/relationship/email/dashboard"),
908
- children: leaves(EMAIL_CHILDREN)
909
- },
910
- {
911
- label: "SMS/MMS Blast",
912
- icon: icon("messageSquare"),
913
- href: abs("/relationship/sms-mms-blast/dashboard"),
914
- children: leaves(SMS_CHILDREN)
915
- },
916
- // These two carry no top-level href in VRM core (parent row only toggles).
917
- { label: "Calls to Action", icon: icon("layout"), children: leaves(CTA_CHILDREN) },
918
- {
919
- label: "Forms",
920
- icon: icon("activity"),
921
- href: "https://forms.politogyvrm.com/",
922
- children: APP_FORMS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
923
- },
924
- {
925
- label: "Surveys",
926
- icon: icon("fileText"),
927
- href: "https://surveys.politogyvrm.com/surveys",
928
- children: APP_SURVEYS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
929
- },
930
- {
931
- label: "Polls",
932
- icon: icon("barChart"),
933
- href: "https://polls.politogyvrm.com/",
934
- children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: c.href }))
935
- },
936
- {
937
- label: "Organization Settings",
938
- icon: icon("briefcase"),
939
- href: abs("/organization-settings"),
940
- children: branches(ORG_SETTINGS_CHILDREN)
941
- }
964
+ const buildCampaign = () => {
965
+ const avail = {
966
+ ...CAMPAIGN_FEATURE_AVAILABILITY,
967
+ ...opts.campaignAvailability
968
+ };
969
+ const rows = [
970
+ { label: "Dashboard", icon: icon("home"), href: withOrg(abs("/campaign/dashboard")) },
971
+ { label: "Voter Contact", icon: icon("target"), href: withOrg(abs("/campaign/campaigns")) },
972
+ { label: "A2P", icon: icon("messageSquare"), href: withOrg(A2P_ORIGIN), flag: "a2p" },
973
+ { label: "Phone Banking", icon: icon("phone"), href: withOrg(PHONEBANK_ORIGIN), flag: "phonebank" },
974
+ { label: "Field Canvassing", icon: icon("map"), href: withOrg(CANVASS_ORIGIN), flag: "canvass" },
975
+ { label: "Sign Mapping", icon: icon("mapPin"), href: withOrg(SIGNS_ORIGIN), flag: "signs" },
976
+ { label: "Tribes", icon: icon("users"), href: withOrg(CONTACTS_TRIBES), flag: "tribes" },
977
+ { label: "Polling Engine", icon: icon("barChart"), href: withOrg(POLLS_ORIGIN), flag: "polling" }
978
+ ];
979
+ return rows.filter((r) => !r.flag || avail[r.flag]).map(({ flag: _flag, ...item }) => item);
980
+ };
981
+ const buildPetition = () => [
982
+ { label: "Dashboard", icon: icon("home"), href: withOrg(PETITION_MODE_ORIGIN) }
942
983
  ];
984
+ const mode = opts.mode ?? "relationship";
985
+ const items = mode === "campaign" ? buildCampaign() : mode === "petition" ? buildPetition() : buildRelationship();
943
986
  if (opts.supportItem) {
944
987
  items.push({
945
988
  label: "Support",
@@ -1840,9 +1883,12 @@ function NavBetaBanner({ text, linkLabel, href }) {
1840
1883
  role: "note",
1841
1884
  className: "w-full border-y px-4 py-2 text-center text-sm",
1842
1885
  style: {
1843
- background: "var(--beta-banner-bg)",
1844
- borderColor: "var(--beta-banner-border)",
1845
- color: "var(--beta-banner-text)"
1886
+ // Warning amber with a darker border + text (HITL 2026-07-23). The
1887
+ // --beta-banner-* tokens were never emitted, so the fallbacks are the
1888
+ // real values: amber-100 fill, amber-500 border, amber-900 text.
1889
+ background: "var(--beta-banner-bg, #FEF3C7)",
1890
+ borderColor: "var(--beta-banner-border, #F59E0B)",
1891
+ color: "var(--beta-banner-text, #78350F)"
1846
1892
  },
1847
1893
  children: [
1848
1894
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: body }),
@@ -1853,7 +1899,7 @@ function NavBetaBanner({ text, linkLabel, href }) {
1853
1899
  target: "_blank",
1854
1900
  rel: "noreferrer",
1855
1901
  className: "font-bold underline",
1856
- style: { color: "var(--beta-banner-text)" },
1902
+ style: { color: "var(--beta-banner-text, #78350F)" },
1857
1903
  children: label
1858
1904
  }
1859
1905
  )
@@ -1973,7 +2019,19 @@ var POLITOGY_APPS = {
1973
2019
  forms: { title: "Forms", origin: "https://forms.politogyvrm.com", storagePrefix: "forms" },
1974
2020
  surveys: { title: "Surveys", origin: "https://surveys.politogyvrm.com", storagePrefix: "surveys" },
1975
2021
  polls: { title: "Polls", origin: "https://polls.politogyvrm.com", storagePrefix: "polls" },
1976
- petitions: { title: "Petitions", origin: "https://petitions.politogyvrm.com", storagePrefix: "petitions" }
2022
+ petitions: {
2023
+ title: "Petitions",
2024
+ origin: "https://petition-mode.politogyvrm.com",
2025
+ storagePrefix: "petitions",
2026
+ mode: "petition"
2027
+ },
2028
+ // Campaign Mode apps — each scoped to Campaign, so they render the Campaign
2029
+ // tree and a static Campaign pill. Not yet deployed; hidden from the Campaign
2030
+ // nav by CAMPAIGN_FEATURE_AVAILABILITY until their launch flips the flag.
2031
+ a2p: { title: "A2P Messaging", origin: "https://a2p.politogyvrm.com", storagePrefix: "a2p", mode: "campaign" },
2032
+ phonebank: { title: "Phone Banking", origin: "https://phonebank.politogyvrm.com", storagePrefix: "phonebank", mode: "campaign" },
2033
+ canvass: { title: "Field Canvassing", origin: "https://canvass.politogyvrm.com", storagePrefix: "canvass", mode: "campaign" },
2034
+ signs: { title: "Sign Mapping", origin: "https://signs.politogyvrm.com", storagePrefix: "signs", mode: "campaign" }
1977
2035
  };
1978
2036
  function PolitogyAppFrame({
1979
2037
  app,
@@ -2037,19 +2095,24 @@ function FrameBody({
2037
2095
  email: identity.email
2038
2096
  });
2039
2097
  const footer = useChromeFooter(buildMeta ?? {});
2040
- const mode = useChromeMode();
2098
+ const appMode = meta.mode;
2099
+ const mode = useChromeMode(appMode ? { pinnedModeId: appMode } : void 0);
2041
2100
  const coreOrgs = chrome?.orgs ?? [];
2042
2101
  const activeCoreOrg = coreOrgs.find((o) => o.id === chrome?.orgId) ?? null;
2043
2102
  const navDisplay = chrome?.navDisplay ?? "both";
2103
+ const navMode = appMode ?? "relationship";
2104
+ const activeOrgId = chrome?.orgId ?? null;
2044
2105
  const navItems = react.useMemo(
2045
2106
  () => standardPolitogyNav({
2046
2107
  coreBaseUrl: POLITOGY_APPS.vrm.origin,
2047
2108
  icons: standardNavIcons,
2048
2109
  // An app that OWNS a standard nav entry (Contacts) nests its own routes
2049
2110
  // under it. This is routing data, not chrome configuration.
2050
- contactsItem: data?.contactsItem
2111
+ contactsItem: data?.contactsItem,
2112
+ mode: navMode,
2113
+ activeOrgId
2051
2114
  }),
2052
- [data?.contactsItem]
2115
+ [data?.contactsItem, navMode, activeOrgId]
2053
2116
  );
2054
2117
  const breadcrumbs = react.useMemo(
2055
2118
  () => deriveBreadcrumbs(navItems, pathname, { search, origin: meta.origin }),
@@ -2122,7 +2185,13 @@ var standardNavIcons = {
2122
2185
  settings: fi.FiSettings,
2123
2186
  creditCard: fi.FiCreditCard,
2124
2187
  dollarSign: fi.FiDollarSign,
2125
- share: fi.FiShare2
2188
+ share: fi.FiShare2,
2189
+ // Campaign / Petition mode slots.
2190
+ phone: fi.FiPhone,
2191
+ map: fi.FiMap,
2192
+ mapPin: fi.FiMapPin,
2193
+ target: fi.FiTarget,
2194
+ flag: fi.FiFlag
2126
2195
  };
2127
2196
  var ORG_STORAGE_KEY = "vrm.activeOrg";
2128
2197
  var MODE_STORAGE_KEY = "vrm.activeMode";
@@ -2375,15 +2444,17 @@ var MODE_DEFS = [
2375
2444
  orgQuery: true
2376
2445
  },
2377
2446
  {
2378
- // Petition Mode lives in its own standalone app (HITL 2026-07-23).
2447
+ // Petition Mode lives in its own standalone app on its own subdomain — the
2448
+ // petitions repo deploys production to petition-mode.politogyvrm.com.
2379
2449
  id: "petition",
2380
2450
  label: "Petition Mode",
2381
2451
  icon: fi.FiFlag,
2382
- href: "https://petitions.politogyvrm.com/",
2452
+ href: "https://petition-mode.politogyvrm.com/",
2383
2453
  orgQuery: true
2384
2454
  }
2385
2455
  ];
2386
- function useChromeMode(fallbackModeId = "relationship") {
2456
+ function useChromeMode(arg = {}) {
2457
+ const { fallbackModeId = "relationship", pinnedModeId } = typeof arg === "string" ? { fallbackModeId: arg, pinnedModeId: void 0 } : arg;
2387
2458
  const ctx = react.useContext(ChromeStateContext);
2388
2459
  const nav = useNavChromeFetcher();
2389
2460
  const orgId = ctx?.orgId ?? null;
@@ -2410,8 +2481,9 @@ function useChromeMode(fallbackModeId = "relationship") {
2410
2481
  };
2411
2482
  }, [nav, orgId]);
2412
2483
  const options = MODE_DEFS.filter((m) => entitled?.[m.id]);
2484
+ const pinned = pinnedModeId ? MODE_DEFS.find((m) => m.id === pinnedModeId) ?? null : null;
2413
2485
  const selected = selectedModeId ? options.find((m) => m.id === selectedModeId) ?? null : null;
2414
- const current = selected ?? options[0] ?? MODE_DEFS.find((m) => m.id === fallbackModeId) ?? MODE_DEFS[0];
2486
+ const current = pinned ?? selected ?? options[0] ?? MODE_DEFS.find((m) => m.id === fallbackModeId) ?? MODE_DEFS[0];
2415
2487
  const suffix = orgId ? `?org=${orgId.slice(-6)}` : "";
2416
2488
  return {
2417
2489
  label: current.label,