@the-portland-company/shell 0.3.4 → 0.4.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/dist/index.d.cts CHANGED
@@ -154,8 +154,15 @@ interface ShellModeValue {
154
154
  modes: ShellModeConfig[];
155
155
  /** Switch to a different mode. App owns side effects. */
156
156
  switchMode: (modeId: string) => void;
157
- /** Returns the config for the current mode (convenience). */
158
- getModeConfig: () => ShellModeConfig;
157
+ /**
158
+ * Optional convenience accessor for the current mode's config. If
159
+ * omitted, shell auto-derives it via `modes.find(m => m.id === currentMode)`.
160
+ * Avoid object-method syntax (`getModeConfig() { return this.modes[0] }`) —
161
+ * the function is destructured by shell internals and `this` will not be
162
+ * bound. Use a closure (`getModeConfig: () => modes[0]`) or just leave it
163
+ * unset and let shell resolve.
164
+ */
165
+ getModeConfig?: () => ShellModeConfig;
159
166
  }
160
167
  /** ---------------- Nav items ---------------- */
161
168
  /**
package/dist/index.d.ts CHANGED
@@ -154,8 +154,15 @@ interface ShellModeValue {
154
154
  modes: ShellModeConfig[];
155
155
  /** Switch to a different mode. App owns side effects. */
156
156
  switchMode: (modeId: string) => void;
157
- /** Returns the config for the current mode (convenience). */
158
- getModeConfig: () => ShellModeConfig;
157
+ /**
158
+ * Optional convenience accessor for the current mode's config. If
159
+ * omitted, shell auto-derives it via `modes.find(m => m.id === currentMode)`.
160
+ * Avoid object-method syntax (`getModeConfig() { return this.modes[0] }`) —
161
+ * the function is destructured by shell internals and `this` will not be
162
+ * bound. Use a closure (`getModeConfig: () => modes[0]`) or just leave it
163
+ * unset and let shell resolve.
164
+ */
165
+ getModeConfig?: () => ShellModeConfig;
159
166
  }
160
167
  /** ---------------- Nav items ---------------- */
161
168
  /**
package/dist/index.js CHANGED
@@ -8,22 +8,13 @@ import { keyframes } from '@emotion/react';
8
8
 
9
9
  // src/theme/index.ts
10
10
 
11
+ // src/theme/tokens.generated.ts
12
+ var brandRamp = { 50: "#FFF5F0", 100: "#FFE8DC", 200: "#FFD0B8", 300: "#FFB088", 400: "#FF8C5A", 500: "#E86A3A", 600: "#CC5429", 700: "#A6421F", 800: "#803317", 900: "#5C2410" };
13
+
11
14
  // src/theme/colors.ts
12
15
  var colors = {
13
- // Primary brand color - Politogy Red/Orange (Energy & Action)
14
- brand: {
15
- 50: "#fff5f0",
16
- 100: "#ffe8dc",
17
- 200: "#ffd0b8",
18
- 300: "#ffb088",
19
- 400: "#ff8c5a",
20
- 500: "#e86a3a",
21
- // Primary brand color - burnt orange/red
22
- 600: "#cc5429",
23
- 700: "#a6421f",
24
- 800: "#803317",
25
- 900: "#5c2410"
26
- },
16
+ // Primary brand color - Politogy burnt-orange (Energy & Action). From Specs.
17
+ brand: { ...brandRamp },
27
18
  // Politogy Brand Colors
28
19
  politogy: {
29
20
  // Legacy Blue - kept for reference
@@ -39,19 +30,8 @@ var colors = {
39
30
  800: "#2a4365",
40
31
  900: "#1a365d"
41
32
  },
42
- // Primary Red/Orange - Energy & Action (main brand color)
43
- red: {
44
- 50: "#fff5f0",
45
- 100: "#ffe8dc",
46
- 200: "#ffd0b8",
47
- 300: "#ffb088",
48
- 400: "#ff8c5a",
49
- 500: "#e86a3a",
50
- 600: "#cc5429",
51
- 700: "#a6421f",
52
- 800: "#803317",
53
- 900: "#5c2410"
54
- },
33
+ // Primary Red/Orange - Energy & Action (main brand color). From Specs.
34
+ red: { ...brandRamp },
55
35
  // Navy - Professional & Authoritative
56
36
  navy: {
57
37
  50: "#e8eef6",
@@ -1269,6 +1249,20 @@ function getUserDisplayName(user) {
1269
1249
  if (!user) return "User";
1270
1250
  return user.profile?.full_name || user.profile?.name || user.user_metadata?.full_name || user.user_metadata?.name || (typeof user.email === "string" ? user.email.split("@")[0] : "") || user.email || "User";
1271
1251
  }
1252
+
1253
+ // src/lib/resolveModeConfig.ts
1254
+ function resolveModeConfig(mode) {
1255
+ if (!mode) return null;
1256
+ const modes = mode.modes ?? [];
1257
+ if (typeof mode.getModeConfig === "function") {
1258
+ try {
1259
+ const result = mode.getModeConfig();
1260
+ if (result) return result;
1261
+ } catch {
1262
+ }
1263
+ }
1264
+ return modes.find((m) => m.id === mode.currentMode) ?? modes[0] ?? null;
1265
+ }
1272
1266
  function avatarUrlFromUser(user) {
1273
1267
  if (!user) return void 0;
1274
1268
  const meta = user.raw.user_metadata;
@@ -1293,7 +1287,7 @@ function UserMenu() {
1293
1287
  if (status !== "authenticated" || !user) return null;
1294
1288
  const displayName = getUserDisplayName(user.raw);
1295
1289
  const avatarUrl = userAvatarUrl ?? avatarUrlFromUser(user);
1296
- const modeConfig = mode?.getModeConfig() ?? null;
1290
+ const modeConfig = resolveModeConfig(mode);
1297
1291
  const currentOrg = org?.currentOrg ?? null;
1298
1292
  const linkedAccounts = linked?.linkedAccounts ?? [];
1299
1293
  const activeRoleConfig = role?.activeRoleConfig ?? null;
@@ -1581,10 +1575,10 @@ function NavItem({
1581
1575
  const navigate = useNavigate();
1582
1576
  const mode = useShellMode();
1583
1577
  const currentMode = mode?.currentMode ?? null;
1584
- const modeConfig = mode?.getModeConfig() ?? null;
1578
+ const modeConfig = resolveModeConfig(mode);
1585
1579
  const navPref = useShellNavigationPreference();
1586
1580
  const showSubMenu = navPref?.showSubMenu ?? true;
1587
- const navHoverGradient = currentMode === MODE_CAMPAIGN ? "linear-gradient(90deg, #F2C94C 0%, #E63946 100%)" : currentMode === MODE_PETITION ? "linear-gradient(90deg, #F2C94C 0%, #007BFF 100%)" : "linear-gradient(90deg, #007BFF 0%, #E63946 100%)";
1581
+ const navHoverGradient = currentMode === MODE_CAMPAIGN ? "linear-gradient(90deg, #F2C94C 0%, #E63946 100%)" : currentMode === MODE_PETITION ? "linear-gradient(90deg, #F2C94C 0%, #007BFF 100%)" : "linear-gradient(90deg, #ea6a3a 0%, #E63946 100%)";
1588
1582
  const gradientSweepBefore = {
1589
1583
  content: '""',
1590
1584
  position: "absolute",
@@ -2128,8 +2122,8 @@ var OrgPill_default = OrgPill;
2128
2122
  function ModePill() {
2129
2123
  const mode = useShellMode();
2130
2124
  if (!mode) return null;
2131
- const { currentMode, modes, switchMode, getModeConfig } = mode;
2132
- const modeConfig = getModeConfig();
2125
+ const { currentMode, modes, switchMode } = mode;
2126
+ const modeConfig = resolveModeConfig(mode);
2133
2127
  if (!modeConfig) return null;
2134
2128
  const hasMultipleModes = modes.length > 1;
2135
2129
  const isDisabled = !hasMultipleModes;