@@ -13,7 +13,8 @@ import { |
13 | 13 | MIN_PANEL_ANIMATION_DURATION_MS, |
14 | 14 | } from "@t3tools/contracts/settings"; |
15 | 15 | import { |
16 | | - resolveEnvironmentIdentificationPillLabel, |
| 16 | + resolveSidebarStageBackdropVariant, |
| 17 | + type SidebarStageBackdropVariant, |
17 | 18 | useEnvironmentStageLabel, |
18 | 19 | } from "../SidebarStageBackdrop"; |
19 | 20 | import { useCustomThemes } from "../../hooks/useCustomThemes"; |
@@ -35,10 +36,40 @@ import { TypographySection } from "./TypographySettings"; |
35 | 36 |
|
36 | 37 | const ENVIRONMENT_IDENTIFICATION_LABELS: Record<EnvironmentIdentificationMode, string> = { |
37 | 38 | artwork: "Artwork", |
| 39 | + "nightly-artwork": "Nightly artwork", |
| 40 | + "dev-artwork": "Dev artwork", |
38 | 41 | pill: "Version pill", |
39 | 42 | none: "None", |
40 | 43 | }; |
41 | 44 |
|
| 45 | +// The default "artwork" follows the running channel, so it is labeled as that channel's art, |
| 46 | +// or as "None" on Latest. The other channel's art is offered as a fixed choice. |
| 47 | +function environmentIdentificationOptions( |
| 48 | + stageVariant: SidebarStageBackdropVariant | null, |
| 49 | +): ReadonlyArray<readonly [EnvironmentIdentificationMode, string]> { |
| 50 | + if (stageVariant === "dev") { |
| 51 | + return [ |
| 52 | + ["artwork", "Dev artwork"], |
| 53 | + ["nightly-artwork", "Nightly artwork"], |
| 54 | + ["pill", "Version pill"], |
| 55 | + ["none", "None"], |
| 56 | + ]; |
| 57 | + } |
| 58 | + if (stageVariant === "nightly") { |
| 59 | + return [ |
| 60 | + ["artwork", "Nightly artwork"], |
| 61 | + ["dev-artwork", "Dev artwork"], |
| 62 | + ["pill", "Version pill"], |
| 63 | + ["none", "None"], |
| 64 | + ]; |
| 65 | + } |
| 66 | + return [ |
| 67 | + ["artwork", "None"], |
| 68 | + ["nightly-artwork", "Nightly artwork"], |
| 69 | + ["dev-artwork", "Dev artwork"], |
| 70 | + ]; |
| 71 | +} |
| 72 | + |
42 | 73 | const CHAT_WIDTH_LABELS: Record<ChatWidth, string> = { |
43 | 74 | comfortable: "Comfortable", |
44 | 75 | wide: "Wide", |
@@ -61,8 +92,13 @@ export function AppearanceSettingsPanel() { |
61 | 92 | const settings = useScopedSettings(); |
62 | 93 | const updateSettings = useUpdateScopedSettings(); |
63 | 94 | const environmentStageLabel = useEnvironmentStageLabel(); |
64 | | - const showEnvironmentIdentification = |
65 | | - resolveEnvironmentIdentificationPillLabel(environmentStageLabel) !== null; |
| 95 | + const environmentStageVariant = resolveSidebarStageBackdropVariant(environmentStageLabel); |
| 96 | + const environmentIdentificationOptionList = |
| 97 | + environmentIdentificationOptions(environmentStageVariant); |
| 98 | + const environmentIdentificationLabel = |
| 99 | + environmentIdentificationOptionList.find( |
| 100 | + ([value]) => value === settings.environmentIdentificationMode, |
| 101 | + )?.[1] ?? ENVIRONMENT_IDENTIFICATION_LABELS[settings.environmentIdentificationMode]; |
66 | 102 | const glassOpacityRatio = |
67 | 103 | (settings.glassOpacity - MIN_GLASS_OPACITY) / (MAX_GLASS_OPACITY - MIN_GLASS_OPACITY); |
68 | 104 | const glassOpacitySliderStyle = { |
@@ -316,52 +352,52 @@ export function AppearanceSettingsPanel() { |
316 | 352 | ) : null |
317 | 353 | } |
318 | 354 | /> |
319 | | - {showEnvironmentIdentification ? ( |
320 | | - <SettingsRow |
321 | | - {...searchableSetting("environment-identification")} |
322 | | - description="Choose how Dev and Nightly environments are identified." |
323 | | - resetAction={ |
324 | | - settings.environmentIdentificationMode !== |
325 | | - DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE ? ( |
326 | | - <SettingResetButton |
327 | | - label="environment identification" |
328 | | - onClick={() => |
329 | | - updateSettings({ |
330 | | - environmentIdentificationMode: DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE, |
331 | | - }) |
332 | | - } |
333 | | - /> |
334 | | - ) : null |
335 | | - } |
336 | | - control={ |
337 | | - <Select |
338 | | - value={settings.environmentIdentificationMode} |
339 | | - onValueChange={(value) => { |
340 | | - if (value === "artwork" || value === "pill" || value === "none") { |
341 | | - updateSettings({ environmentIdentificationMode: value }); |
342 | | - } |
343 | | - }} |
| 355 | + <SettingsRow |
| 356 | + {...searchableSetting("environment-identification")} |
| 357 | + description={ |
| 358 | + environmentStageVariant |
| 359 | + ? "Choose how Dev and Nightly environments are identified." |
| 360 | + : "Show Dev or Nightly artwork in the sidebar header." |
| 361 | + } |
| 362 | + resetAction={ |
| 363 | + settings.environmentIdentificationMode !== DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE ? ( |
| 364 | + <SettingResetButton |
| 365 | + label="environment identification" |
| 366 | + onClick={() => |
| 367 | + updateSettings({ |
| 368 | + environmentIdentificationMode: DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE, |
| 369 | + }) |
| 370 | + } |
| 371 | + /> |
| 372 | + ) : null |
| 373 | + } |
| 374 | + control={ |
| 375 | + <Select |
| 376 | + value={settings.environmentIdentificationMode} |
| 377 | + onValueChange={(value) => { |
| 378 | + const option = environmentIdentificationOptionList.find( |
| 379 | + ([optionValue]) => optionValue === value, |
| 380 | + ); |
| 381 | + if (option) updateSettings({ environmentIdentificationMode: option[0] }); |
| 382 | + }} |
| 383 | + > |
| 384 | + <SelectTrigger |
| 385 | + size="sm" |
| 386 | + className="w-full sm:w-40" |
| 387 | + aria-label="Environment identification" |
344 | 388 | > |
345 | | - <SelectTrigger |
346 | | - size="sm" |
347 | | - className="w-full sm:w-40" |
348 | | - aria-label="Environment identification" |
349 | | - > |
350 | | - <SelectValue> |
351 | | - {ENVIRONMENT_IDENTIFICATION_LABELS[settings.environmentIdentificationMode]} |
352 | | - </SelectValue> |
353 | | - </SelectTrigger> |
354 | | - <SelectPopup align="end" alignItemWithTrigger={false}> |
355 | | - {Object.entries(ENVIRONMENT_IDENTIFICATION_LABELS).map(([value, label]) => ( |
356 | | - <SelectItem hideIndicator key={value} value={value}> |
357 | | - {label} |
358 | | - </SelectItem> |
359 | | - ))} |
360 | | - </SelectPopup> |
361 | | - </Select> |
362 | | - } |
363 | | - /> |
364 | | - ) : null} |
| 389 | + <SelectValue>{environmentIdentificationLabel}</SelectValue> |
| 390 | + </SelectTrigger> |
| 391 | + <SelectPopup align="end" alignItemWithTrigger={false}> |
| 392 | + {environmentIdentificationOptionList.map(([value, label]) => ( |
| 393 | + <SelectItem hideIndicator key={value} value={value}> |
| 394 | + {label} |
| 395 | + </SelectItem> |
| 396 | + ))} |
| 397 | + </SelectPopup> |
| 398 | + </Select> |
| 399 | + } |
| 400 | + /> |
365 | 401 | <SettingsRow |
366 | 402 | {...searchableSetting("composer-context")} |
367 | 403 | description="Keep branch and worktree controls below the composer after a thread starts." |
|