diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f787e..155e4e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [0.9.0] - 2026-11-10 + +### Changed + +- **After checkout, people land back in the app.** A completed checkout or a Free plan pick now returns to the subscription page with a "You're on Pro now" banner, with no separate confirmation step. Set `billing.successRoute` to land on any page of your app, and put `` there for the same banner, or read the `checkoutResult` signal for a message of your own. The old confirmation page at `/subscription/success` still works for apps that point to it. +- **A subscription page that fits your app.** Plan cards and the current-plan panel have their own surface built from your `--bridge-*` tokens, so they look right on any app background. Prices are shown large and formatted for their currency, buttons say "Upgrade to" or "Switch to", the current plan is marked in your primary colour, and its renewal date and card are shown. Two optional tokens, `--bridge-card-bg` and `--bridge-card-shadow`, tune the cards. Plan buttons no longer read "Select free plan" or "29 USD / month", so tests that match that text need updating. +- **Bridge pages follow your app's text.** Every text size on the sign-in and subscription pages now scales from your page's body text size, alongside the font family and text colour they already inherited. At the usual 16px nothing changes; set `--bridge-font-size` to size Bridge text differently. +- **Your CSS always wins.** Bridge's styles now live in a CSS cascade layer named `bridge`, so any normal CSS you write against a Bridge class or data attribute overrides it, whatever the load order or specificity, with no `!important`. CSS inside one of your own layers declared before `bridge`, including Tailwind utility classes on Bridge's elements, still ranks below it. + +### Added + +- **Weight and shadow settings.** `--bridge-font-weight-heading`, `--bridge-font-weight-button`, `--bridge-font-weight-label` and `--bridge-button-shadow` let an app with heavy type or hard drop shadows carry that look onto the Bridge pages. `--bridge-card-shadow` also styles the plan-change dialog. Every default is the previous look. +- **The same subscription page as the other Bridge packages.** The Angular pages now match bridge-svelte 0.9.3: the same layout, wording and settings. + ## [0.8.1] - 2026-11-04 ### Fixed diff --git a/bridge-angular/package.json b/bridge-angular/package.json index 5ff8244..3ad37cb 100644 --- a/bridge-angular/package.json +++ b/bridge-angular/package.json @@ -1,6 +1,6 @@ { "name": "@nebulr-group/bridge-angular", - "version": "0.8.1", + "version": "0.9.0", "description": "The Bridge for Angular: sign-in, workspaces and roles, feature flags, Stripe subscriptions and plan limits with providers and route helpers.", "author": "Iman Pouya", "license": "MIT", diff --git a/bridge-angular/src/lib/billing/checkout-result.spec.ts b/bridge-angular/src/lib/billing/checkout-result.spec.ts new file mode 100644 index 0000000..b8f0f0f --- /dev/null +++ b/bridge-angular/src/lib/billing/checkout-result.spec.ts @@ -0,0 +1,71 @@ +/** + * TBP-944 (svelte TBP-813) — the one-shot "a checkout just finished" signal the + * landing page reads. In memory only; whoever shows it clears it, so it shows once. + */ +import { effect, Injector, runInInjectionContext } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; +import { afterEach, describe, expect, it } from 'vitest'; +import { + checkoutResult, + clearCheckoutResult, + markCheckoutComplete, + takeCheckoutResult, +} from './checkout-result'; + +afterEach(() => clearCheckoutResult()); + +describe('checkoutResult (TBP-944)', () => { + it('starts empty', () => { + expect(checkoutResult()).toBeNull(); + expect(takeCheckoutResult()).toBeNull(); + }); + + it('markCheckoutComplete sets what the signal reads', () => { + markCheckoutComplete({ kind: 'checkout' }); + expect(checkoutResult()).toEqual({ kind: 'checkout' }); + }); + + it('carries the plan name of a Free pick', () => { + markCheckoutComplete({ kind: 'plan', planName: 'Free' }); + expect(checkoutResult()).toEqual({ kind: 'plan', planName: 'Free' }); + }); + + it('a later result replaces an earlier one', () => { + markCheckoutComplete({ kind: 'plan', planName: 'Free' }); + markCheckoutComplete({ kind: 'checkout' }); + expect(checkoutResult()).toEqual({ kind: 'checkout' }); + }); + + it('takeCheckoutResult returns the result once, then nothing', () => { + markCheckoutComplete({ kind: 'plan', planName: 'Pro' }); + expect(takeCheckoutResult()).toEqual({ kind: 'plan', planName: 'Pro' }); + expect(takeCheckoutResult()).toBeNull(); + expect(checkoutResult()).toBeNull(); + }); + + it('clearCheckoutResult forgets it without showing it', () => { + markCheckoutComplete({ kind: 'checkout' }); + clearCheckoutResult(); + expect(checkoutResult()).toBeNull(); + expect(takeCheckoutResult()).toBeNull(); + }); + + it('an effect reading it sees it set and then cleared', () => { + const seen: unknown[] = []; + const injector = TestBed.inject(Injector); + const ref = runInInjectionContext(injector, () => effect(() => seen.push(checkoutResult()))); + TestBed.flushEffects(); + markCheckoutComplete({ kind: 'checkout' }); + TestBed.flushEffects(); + takeCheckoutResult(); + TestBed.flushEffects(); + ref.destroy(); + expect(seen).toEqual([null, { kind: 'checkout' }, null]); + }); + + it('the exported signal is read-only: apps cannot set it', () => { + expect(typeof checkoutResult).toBe('function'); + expect((checkoutResult as unknown as { set?: unknown }).set).toBeUndefined(); + expect((checkoutResult as unknown as { update?: unknown }).update).toBeUndefined(); + }); +}); diff --git a/bridge-angular/src/lib/billing/checkout-result.ts b/bridge-angular/src/lib/billing/checkout-result.ts new file mode 100644 index 0000000..326ee17 --- /dev/null +++ b/bridge-angular/src/lib/billing/checkout-result.ts @@ -0,0 +1,50 @@ +/** + * TBP-944 (svelte TBP-813) — "a checkout just finished", for whichever page it + * lands on. + * + * A completed checkout used to stop on a confirmation page + * (`/subscription/success`) before going anywhere. It now lands on + * `billing.successRoute` (the subscription page by default), and this one-shot + * signal is how that page knows to say so: `` shows it + * as a banner, and an app that wants its own message reads `checkoutResult`. + * + * In memory only, never in the URL or storage: the checkout return navigates + * inside the running app, so the signal is still here when the landing page + * renders, and a reload (or a later visit) does not show it again. Whoever + * shows it clears it. + * + * Plain module-level signals rather than a service, so the OAuth-callback + * resolver and the plan picker can set it without an injection context, and an + * app can read it from a template, a `computed` or an `effect`. + */ +import { signal, type Signal } from '@angular/core'; + +/** What just completed. */ +export interface BridgeCheckoutResult { + /** `checkout`: a paid Stripe checkout returned. `plan`: a plan was set without one (a Free pick). */ + kind: 'checkout' | 'plan'; + /** The plan's name, when the page that set it knew it. Otherwise read the current plan. */ + planName?: string; +} + +const result = signal(null); + +/** The checkout that just completed, or `null`. Cleared once something shows it. Read-only. */ +export const checkoutResult: Signal = result.asReadonly(); + +/** Record a completed checkout or plan pick. Called by the plugin, not by apps. */ +export function markCheckoutComplete(value: BridgeCheckoutResult): void { + result.set(value); +} + +/** Read the result and clear it, so it is shown once. */ +export function takeCheckoutResult(): BridgeCheckoutResult | null { + const value = result(); + if (value) result.set(null); + return value; +} + +/** Forget the result without showing it. */ +export function clearCheckoutResult(): void { + result.set(null); +} diff --git a/bridge-angular/src/lib/components/login/login.component.ts b/bridge-angular/src/lib/components/login/login.component.ts index 74d8ab6..acff327 100644 --- a/bridge-angular/src/lib/components/login/login.component.ts +++ b/bridge-angular/src/lib/components/login/login.component.ts @@ -10,20 +10,23 @@ import { AuthService } from '../../shared/services/auth.service'; `, styles: [` - .login-button { - display: inline-block; - padding: 0.5rem 1rem; - background-color: #3b82f6; - color: white; - border-radius: 0.25rem; - border: none; - cursor: pointer; - font-size: 0.875rem; - transition: background-color 0.2s; - } + /* TBP-944 — in the \`bridge\` layer with the stylesheet, so any CSS of the app wins. */ + @layer bridge { + .login-button { + display: inline-block; + padding: 0.5rem 1rem; + background-color: #3b82f6; + color: white; + border-radius: 0.25rem; + border: none; + cursor: pointer; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + transition: background-color 0.2s; + } - .login-button:hover { - background-color: #2563eb; + .login-button:hover { + background-color: #2563eb; + } } `], }) diff --git a/bridge-angular/src/lib/components/routes/bridge-auth-page.component.ts b/bridge-angular/src/lib/components/routes/bridge-auth-page.component.ts index ac1c59f..c067206 100644 --- a/bridge-angular/src/lib/components/routes/bridge-auth-page.component.ts +++ b/bridge-angular/src/lib/components/routes/bridge-auth-page.component.ts @@ -18,6 +18,7 @@ import { type BridgePageOptions, } from '../../routing/bridge-routes'; import { resolveCallbackTarget } from '../../routing/callback'; +import { markCheckoutComplete } from '../../billing/checkout-result'; import { routeSegments } from '../../routing/route-path'; import { logger } from '../../shared/logger'; import { AuthService } from '../../shared/services/auth.service'; @@ -216,6 +217,9 @@ export class BridgeAuthPageComponent implements OnInit { handleCallback: (code) => this.auth.handleCallback(code), confirmStripeCheckout: (id) => this.auth.confirmStripeCheckout(id), refreshBilling: () => this.auth.loadSubscription(), + // TBP-944 — the landing page (the subscription page by default) says + // the checkout went through; no separate confirmation page. + completeCheckout: () => markCheckoutComplete({ kind: 'checkout' }), takeReturnTo, logError: (message, err) => logger.error(message, err), }, diff --git a/bridge-angular/src/lib/components/routes/bridge-billing-page.component.ts b/bridge-angular/src/lib/components/routes/bridge-billing-page.component.ts index 2f2ab56..a00bdff 100644 --- a/bridge-angular/src/lib/components/routes/bridge-billing-page.component.ts +++ b/bridge-angular/src/lib/components/routes/bridge-billing-page.component.ts @@ -1,16 +1,26 @@ /** * TBP-744 — the component every `bridgeBillingRoutes()` page renders. Angular * port of bridge-svelte's `` body: - * manage the current plan, "Manage billing" and the plan picker + * manage the current plan, "Manage billing" and the plan picker; a + * completed checkout lands here, with a banner * plan the paywall: where a plan-less workspace is sent - * success where a completed checkout (or a Free pick) lands + * success the old confirmation page, for `billing.successRoute` * error where a failed checkout confirmation lands * - * Not normally used directly — spread `bridgeBillingRoutes()` into the router. + * TBP-944 (svelte TBP-813) — a paid checkout and a Free pick land on + * `billing.successRoute`, by default these routes' own subscription page, which + * shows ``. The current plan sits in a panel with its + * renewal date and card, above the plan picker. + * + * Not normally used directly: spread `bridgeBillingRoutes()` into the router. */ -import { Component, OnInit, inject } from '@angular/core'; +import { Component, OnDestroy, OnInit, computed, inject } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import type { BridgeBillingPage } from '../../routing/billing-paths'; +import type { BillingSubscriptionSnapshot } from '@nebulr-group/bridge-auth-core'; +import { clearCheckoutResult } from '../../billing/checkout-result'; +import { BridgeConfigService } from '../../config/bridge-config.service'; +import { createSubscriptionSignal, type BillingSignal } from '../../core/billing-signals'; +import { resolveBillingPaths, type BridgeBillingPage } from '../../routing/billing-paths'; import { BRIDGE_BILLING_PAGE_DATA, BRIDGE_PAGE_OPTIONS_DATA, @@ -19,6 +29,8 @@ import { import { routeSegments } from '../../routing/route-path'; import { AuthService } from '../../shared/services/auth.service'; import { BillingPortalButtonComponent } from '../subscription/billing-portal-button.component'; +import { CheckoutNoticeComponent } from '../subscription/checkout-notice.component'; +import { subscriptionMeta } from '../subscription/plan-format'; import { PlanSelectorComponent } from '../subscription/plan-selector.component'; import { SubscriptionStatusComponent } from '../subscription/subscription-status.component'; @@ -32,22 +44,31 @@ const DEFAULT_HEADINGS: Record = { @Component({ selector: 'bridge-billing-page', standalone: true, - imports: [BillingPortalButtonComponent, PlanSelectorComponent, SubscriptionStatusComponent], + imports: [BillingPortalButtonComponent, CheckoutNoticeComponent, PlanSelectorComponent, SubscriptionStatusComponent], template: `
+ @if (page === 'manage' && options.checkoutNotice !== false) { + + }

{{ heading }}

@switch (page) { @case ('manage') { -
- Current plan - +

Your plan, what it includes, and billing.

+
+
+ Current plan + + @if (meta()) { + {{ meta() }} + } +
- + } @case ('plan') {

Pick a plan to start using the app.

- + } @case ('success') {

Your plan is active.

@@ -68,9 +89,10 @@ const DEFAULT_HEADINGS: Record = {
`, }) -export class BridgeBillingPageComponent implements OnInit { +export class BridgeBillingPageComponent implements OnInit, OnDestroy { private readonly route = inject(ActivatedRoute); private readonly auth = inject(AuthService); + private readonly config = inject(BridgeConfigService, { optional: true }); protected readonly page: BridgeBillingPage = this.route.snapshot.data[BRIDGE_BILLING_PAGE_DATA] ?? 'manage'; protected readonly options: BridgePageOptions = this.route.snapshot.data[BRIDGE_PAGE_OPTIONS_DATA] ?? { @@ -90,6 +112,30 @@ export class BridgeBillingPageComponent implements OnInit { return this.base === '/' ? `/${sub}` : `${this.base}/${sub}`; } + /** + * TBP-944 — where a checkout or a Free pick lands: `billing.successRoute`, by + * default this set's own subscription page, wherever the routes live. + */ + protected readonly successTarget = (() => { + let paths; + try { + paths = resolveBillingPaths(this.config?.getConfig().billing); + } catch { + paths = resolveBillingPaths(undefined); + } + return paths.successIsDefault ? this.base : paths.successRoute; + })(); + + /** The current plan's renewal date and card, for the line under its name. */ + private readonly billing: BillingSignal | null = (() => { + try { + return createSubscriptionSignal(); + } catch { + return null; // Bridge not initialised: no meta line + } + })(); + protected readonly meta = computed(() => subscriptionMeta(this.billing?.value().state)); + ngOnInit(): void { // The success page always re-reads: the checkout just changed the plan. // The others read unless something already loaded it. @@ -97,5 +143,11 @@ export class BridgeBillingPageComponent implements OnInit { if (this.page === 'success' || (!status && !loading)) { void this.auth.loadSubscription(); } + // The old confirmation page says it all; no banner on the next page too. + if (this.page === 'success') clearCheckoutResult(); + } + + ngOnDestroy(): void { + this.billing?.destroy(); } } diff --git a/bridge-angular/src/lib/components/subscription/billing-portal-button.component.spec.ts b/bridge-angular/src/lib/components/subscription/billing-portal-button.component.spec.ts index 29813cc..6c11484 100644 --- a/bridge-angular/src/lib/components/subscription/billing-portal-button.component.spec.ts +++ b/bridge-angular/src/lib/components/subscription/billing-portal-button.component.spec.ts @@ -188,7 +188,8 @@ describe('the subscription page bridgeBillingRoutes() serves (TBP-937)', () => { it('shows "Manage billing" next to the current plan, with no app code', async () => { const harness = await RouterTestingHarness.create('/subscription'); const el = harness.routeNativeElement as HTMLElement; - const button = el.querySelector('.bridge-billing-current [data-bridge-billing-portal]'); + // TBP-944 — the current plan sits in its summary panel, with the button beside it. + const button = el.querySelector('[data-bridge-billing-summary] [data-bridge-billing-portal]'); expect(button?.textContent?.trim()).toBe('Manage billing'); }); diff --git a/bridge-angular/src/lib/components/subscription/checkout-notice.component.spec.ts b/bridge-angular/src/lib/components/subscription/checkout-notice.component.spec.ts new file mode 100644 index 0000000..75c6c13 --- /dev/null +++ b/bridge-angular/src/lib/components/subscription/checkout-notice.component.spec.ts @@ -0,0 +1,272 @@ +import { Component, signal } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; +import { provideRouter, Router } from '@angular/router'; +import { RouterTestingHarness } from '@angular/router/testing'; +import { useBridge, type Plan } from '@nebulr-group/bridge-auth-core'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { checkoutResult, clearCheckoutResult, markCheckoutComplete } from '../../billing/checkout-result'; +import { BridgeConfigService } from '../../config/bridge-config.service'; +import { bridgeAuthRoutes, bridgeBillingRoutes } from '../../routing/bridge-routes'; +import { AuthService, type SubscriptionState } from '../../shared/services/auth.service'; +import { CheckoutNoticeComponent } from './checkout-notice.component'; + +/** + * TBP-944 (svelte TBP-813) — after a paid checkout or a Free pick the user lands + * on the subscription page with a one-time banner naming the plan, instead of a + * separate "You're all set" page. `` renders nothing + * until the one-shot result is set, shows it once, and can be dismissed. + */ + +const FREE: Plan = { key: 'free', name: 'Free', prices: [{ id: 'f', amount: 0, currency: 'usd', recurrenceInterval: 'month' }] }; +const PRO: Plan = { key: 'pro', name: 'Pro', prices: [{ id: 'p', amount: 29, currency: 'usd', recurrenceInterval: 'month' }] }; + +class StubAuthService { + readonly sub = signal({ + status: { plan: 'pro', paymentsEnabled: false } as unknown as SubscriptionState['status'], + plans: [FREE, PRO], + loading: false, + error: null, + }); + readonly subscription = this.sub.asReadonly(); + readonly isAuthenticated = signal(true).asReadonly(); + readonly bridgeAuth = { + selectFreePlan: vi.fn(async () => {}), + canManageBilling: () => false, + // No token keeps off the network. + getApiContext: () => ({ apiBaseUrl: 'https://api.example.test', accessToken: null, appId: 'app' }), + }; + getBridgeAuth() { + return this.bridgeAuth; + } + async loadSubscription(): Promise { + /* state is pre-seeded */ + } +} + +const text = (n: Element | null | undefined) => n?.textContent?.replace(/\s+/g, ' ').trim(); + +async function flush(fixture: { whenStable(): Promise; detectChanges(): void }) { + fixture.detectChanges(); + await Promise.resolve(); + await fixture.whenStable(); + fixture.detectChanges(); +} + +let auth: StubAuthService; + +beforeEach(() => { + clearCheckoutResult(); + useBridge().subscription.setError(null); + auth = new StubAuthService(); +}); + +afterEach(() => clearCheckoutResult()); + +describe(' (TBP-944)', () => { + @Component({ + standalone: true, + imports: [CheckoutNoticeComponent], + template: ` + {{ kind }}:{{ planName }} + + `, + }) + class Host { + dismissible = true; + custom = false; + } + + beforeEach(() => { + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ imports: [Host], providers: [{ provide: AuthService, useValue: auth }] }); + }); + + it('renders nothing until a checkout has just completed', async () => { + const fixture = TestBed.createComponent(Host); + await flush(fixture); + expect(fixture.nativeElement.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + }); + + it('names the plan of a Free pick and says the change is immediate', async () => { + markCheckoutComplete({ kind: 'plan', planName: 'Free' }); + const fixture = TestBed.createComponent(Host); + await flush(fixture); + const notice = fixture.nativeElement.querySelector('[data-bridge-checkout-notice]'); + expect(notice?.getAttribute('data-kind')).toBe('plan'); + expect(notice?.getAttribute('role')).toBe('status'); + expect(text(notice?.querySelector('.bridge-checkout-notice-title'))).toBe("You're on Free now"); + expect(text(notice?.querySelector('.bridge-checkout-notice-text'))).toBe('The change takes effect right away.'); + }); + + it('after a paid checkout, reads the plan name from the billing state', async () => { + useBridge().subscription.hydrate({ plan: { slug: 'pro', name: 'Pro' }, status: 'active' } as never); + markCheckoutComplete({ kind: 'checkout' }); + const fixture = TestBed.createComponent(Host); + await flush(fixture); + const notice = fixture.nativeElement.querySelector('[data-bridge-checkout-notice]'); + expect(text(notice?.querySelector('.bridge-checkout-notice-title'))).toBe("You're on Pro now"); + expect(text(notice?.querySelector('.bridge-checkout-notice-text'))).toBe( + 'Your payment went through and the new plan is active.', + ); + }); + + it('shows once: it takes the result, so the next page does not show it again', async () => { + markCheckoutComplete({ kind: 'checkout' }); + const first = TestBed.createComponent(Host); + await flush(first); + expect(first.nativeElement.querySelector('[data-bridge-checkout-notice]')).not.toBeNull(); + expect(checkoutResult()).toBeNull(); + + const second = TestBed.createComponent(Host); + await flush(second); + expect(second.nativeElement.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + // The first one keeps showing what it took. + expect(first.nativeElement.querySelector('[data-bridge-checkout-notice]')).not.toBeNull(); + }); + + it('the close button dismisses it; dismissible=false has none', async () => { + markCheckoutComplete({ kind: 'checkout' }); + const fixture = TestBed.createComponent(Host); + await flush(fixture); + (fixture.nativeElement.querySelector('.bridge-checkout-notice-close') as HTMLButtonElement).click(); + fixture.detectChanges(); + expect(fixture.nativeElement.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + + markCheckoutComplete({ kind: 'checkout' }); + const fixed = TestBed.createComponent(Host); + fixed.componentInstance.dismissible = false; + await flush(fixed); + expect(fixed.nativeElement.querySelector('[data-bridge-checkout-notice]')).not.toBeNull(); + expect(fixed.nativeElement.querySelector('.bridge-checkout-notice-close')).toBeNull(); + }); + + it('a contentTemplate replaces the text and gets the kind and plan name', async () => { + markCheckoutComplete({ kind: 'plan', planName: 'Free' }); + const fixture = TestBed.createComponent(Host); + fixture.componentInstance.custom = true; + await flush(fixture); + expect(text(fixture.nativeElement.querySelector('[data-mine]'))).toBe('plan:Free'); + expect(fixture.nativeElement.querySelector('.bridge-checkout-notice-title')).toBeNull(); + }); + + it('a notice already on screen picks up a result set later (a Free pick that lands on the same page)', async () => { + const fixture = TestBed.createComponent(Host); + await flush(fixture); + expect(fixture.nativeElement.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + markCheckoutComplete({ kind: 'plan', planName: 'Free' }); + await flush(fixture); + expect(fixture.nativeElement.querySelector('[data-bridge-checkout-notice]')).not.toBeNull(); + }); +}); + +describe('the subscription page from bridgeBillingRoutes() (TBP-944)', () => { + function setup(options: Parameters[0] = {}) { + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + providers: [provideRouter(bridgeBillingRoutes(options)), { provide: AuthService, useValue: auth }], + }); + } + + async function open(url: string) { + const harness = await RouterTestingHarness.create(); + await harness.navigateByUrl(url); + await flush(harness.fixture); + return harness; + } + + it('shows the banner after a checkout, once', async () => { + setup(); + markCheckoutComplete({ kind: 'checkout' }); + const harness = await open('/subscription'); + expect(harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]')).not.toBeNull(); + await harness.navigateByUrl('/subscription/plan'); + await harness.navigateByUrl('/subscription'); + await flush(harness.fixture); + expect(harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + }); + + it('a Free pick on the subscription page lands back on it with the banner', async () => { + setup(); + const harness = await open('/subscription'); + expect(harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + const free = [...(harness.routeNativeElement?.querySelectorAll('.bridge-plan-select-btn') ?? [])].find( + (b) => text(b) === 'Switch to Free', + )!; + free.click(); + await flush(harness.fixture); + await flush(harness.fixture); + expect(auth.bridgeAuth.selectFreePlan).toHaveBeenCalledWith('free'); + expect(TestBed.inject(Router).url).toBe('/subscription'); + const notice = harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]'); + expect(text(notice?.querySelector('.bridge-checkout-notice-title'))).toBe("You're on Free now"); + }); + + it('checkoutNotice: false hides it', async () => { + setup({ checkoutNotice: false }); + markCheckoutComplete({ kind: 'checkout' }); + const harness = await open('/subscription'); + expect(harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + }); + + it('the old confirmation page still works, and clears the result so the next page shows no banner', async () => { + setup(); + markCheckoutComplete({ kind: 'checkout' }); + const harness = await open('/subscription/success'); + expect(text(harness.routeNativeElement?.querySelector('.bridge-billing-heading'))).toBe("You're all set"); + expect(harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]')).toBeNull(); + expect(checkoutResult()).toBeNull(); + }); + + it('puts the current plan in a panel with its renewal date and card, above "Change plan"', async () => { + setup(); + useBridge().subscription.hydrate({ + plan: { slug: 'pro', name: 'Pro' }, + status: 'active', + renewsAt: '2026-12-10T12:00:00.000Z', + cardLast4: '4242', + } as never); + const harness = await open('/subscription'); + const page = harness.routeNativeElement!; + useBridge().subscription.setError(null); + await flush(harness.fixture); + expect(text(page.querySelector('.bridge-billing-text'))).toBe('Your plan, what it includes, and billing.'); + const summary = page.querySelector('[data-bridge-billing-summary]'); + expect(text(summary?.querySelector('.bridge-billing-label'))).toBe('Current plan'); + expect(text(summary?.querySelector('[data-bridge-billing-meta]'))).toMatch(/^Renews .*2026 · Card ending 4242$/); + expect(text(page.querySelector('[data-bridge-plan-head] .bridge-plan-heading'))).toBe('Change plan'); + }); +}); + +describe('the Stripe return on the OAuth callback page (TBP-944)', () => { + afterEach(() => window.history.replaceState(null, '', '/')); + + it('confirms the checkout, then lands on the subscription page with the banner', async () => { + const confirmStripeCheckout = vi.fn(async () => {}); + const callbackAuth = Object.assign(auth, { + confirmStripeCheckout, + handleCallback: vi.fn(async () => {}), + tokens: () => null, + ensureAppConfig: async () => null, + appConfig: () => null, + }); + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + providers: [ + provideRouter([...bridgeAuthRoutes(), ...bridgeBillingRoutes()]), + { provide: AuthService, useValue: callbackAuth }, + ], + }); + TestBed.inject(BridgeConfigService).initConfig({ appId: 'app', apiBaseUrl: 'http://localhost:3000' }); + const url = '/auth/oauth-callback?stripe_success=1&session_id=cs_1&redirect=%2Fsubscription'; + window.history.replaceState(null, '', url); + + const harness = await RouterTestingHarness.create(); + await harness.navigateByUrl(url); + for (let i = 0; i < 4; i++) await flush(harness.fixture); + + expect(confirmStripeCheckout).toHaveBeenCalledWith('cs_1'); + expect(TestBed.inject(Router).url).toBe('/subscription'); + const notice = harness.routeNativeElement?.querySelector('[data-bridge-checkout-notice]'); + expect(notice?.getAttribute('data-kind')).toBe('checkout'); + }); +}); diff --git a/bridge-angular/src/lib/components/subscription/checkout-notice.component.ts b/bridge-angular/src/lib/components/subscription/checkout-notice.component.ts new file mode 100644 index 0000000..6231124 --- /dev/null +++ b/bridge-angular/src/lib/components/subscription/checkout-notice.component.ts @@ -0,0 +1,144 @@ +/** + * TBP-944 — ``: the "You're on Pro now" banner after a + * checkout. Angular port of bridge-svelte's `` (TBP-813). + * + * A completed checkout (or a Free pick) lands on `billing.successRoute`, the + * subscription page by default, which shows this banner itself. To land + * somewhere else and still say so, put it on that page or in the app shell: + * + * + * + * It renders nothing until a checkout has just completed, shows once, and is + * gone after a reload. `contentTemplate` replaces the text and receives the + * result, with the plan name when known; for a message of your own anywhere + * else, read the `checkoutResult` signal. + * + * The host is `display: contents`, so an empty notice takes no room (and adds + * no gap) in a flex or grid layout. + */ +import { NgTemplateOutlet } from '@angular/common'; +import { + Component, + Input, + OnDestroy, + TemplateRef, + computed, + effect, + inject, + signal, + untracked, +} from '@angular/core'; +import type { BillingSubscriptionSnapshot, Plan } from '@nebulr-group/bridge-auth-core'; +import { + checkoutResult, + clearCheckoutResult, + type BridgeCheckoutResult, +} from '../../billing/checkout-result'; +import { createSubscriptionSignal, type BillingSignal } from '../../core/billing-signals'; +import { AuthService } from '../../shared/services/auth.service'; + +/** What a `contentTemplate` receives: the result, with the plan name when known. */ +export interface CheckoutNoticeTemplateContext { + $implicit: { kind: BridgeCheckoutResult['kind']; planName: string | null }; + kind: BridgeCheckoutResult['kind']; + planName: string | null; +} + +@Component({ + selector: 'bridge-checkout-notice', + standalone: true, + imports: [NgTemplateOutlet], + host: { style: 'display: contents' }, + template: ` + @if (shown(); as result) { +
+ +
+ @if (contentTemplate) { + + } @else { + + {{ planName() ? "You're on " + planName() + ' now' : 'Your new plan is active' }} + + + {{ + result.kind === 'checkout' + ? 'Your payment went through and the new plan is active.' + : 'The change takes effect right away.' + }} + + } +
+ @if (dismissible) { + + } +
+ } + `, +}) +export class CheckoutNoticeComponent implements OnDestroy { + /** Optional class on the banner. */ + @Input() className = ''; + /** Show a close button. @default true */ + @Input() dismissible = true; + /** Replaces the banner's text. Context: `{ kind, planName }` (also on `$implicit`). */ + @Input() contentTemplate?: TemplateRef; + + private readonly auth = inject(AuthService, { optional: true }); + + /** The result this banner took, so it stays after the shared signal is cleared. */ + protected readonly shown = signal(null); + + private readonly billing: BillingSignal | null = (() => { + try { + return createSubscriptionSignal(); + } catch { + return null; // Bridge not initialised: the banner goes without the plan name + } + })(); + + protected readonly planName = computed(() => { + const shown = this.shown(); + if (shown?.planName) return shown.planName; + const fromState = this.billing?.value().state?.plan?.name; + if (fromState) return fromState; + const plan = this.auth?.subscription().status?.plan as Plan | string | undefined; + return plan && typeof plan === 'object' ? (plan.name ?? null) : null; + }); + + protected readonly context = computed(() => { + const kind = this.shown()?.kind ?? 'checkout'; + const planName = this.planName(); + return { $implicit: { kind, planName }, kind, planName }; + }); + + constructor() { + // Take the result as soon as it is set, so it shows once, including on a + // page that is already open when a Free pick lands back on it. Cleared a + // microtask later so a second notice rendering in the same pass sees it too. + effect(() => { + const value = checkoutResult(); + if (!value) return; + untracked(() => this.shown.set(value)); + queueMicrotask(clearCheckoutResult); + }); + } + + protected dismiss(): void { + this.shown.set(null); + } + + ngOnDestroy(): void { + this.billing?.destroy(); + } +} diff --git a/bridge-angular/src/lib/components/subscription/paywall-page.component.ts b/bridge-angular/src/lib/components/subscription/paywall-page.component.ts index 5123a45..5182883 100644 --- a/bridge-angular/src/lib/components/subscription/paywall-page.component.ts +++ b/bridge-angular/src/lib/components/subscription/paywall-page.component.ts @@ -8,7 +8,8 @@ * * `bridgeBillingRoutes()` already serves a paywall at `/subscription/plan`; * this is only for an app that wants its own. A completed checkout lands on - * `/success`; a cancelled one comes back here. + * `billing.successRoute` (the subscription page, with a confirmation banner, by + * default); a cancelled one comes back here. */ import { Component, Input, OnInit, inject, isDevMode } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; @@ -33,7 +34,7 @@ import { PlanSelectorComponent } from './plan-selector.component'; export class BridgePaywallPageComponent implements OnInit { /** The page heading. */ @Input() heading = 'Choose a plan'; - /** Where a completed checkout lands. @default `/success` */ + /** Where a completed checkout lands. @default `billing.successRoute`, else the subscription page */ @Input() successRedirect?: string; /** Where a cancelled checkout lands. @default this page */ @Input() cancelRedirect?: string; diff --git a/bridge-angular/src/lib/components/subscription/plan-format.spec.ts b/bridge-angular/src/lib/components/subscription/plan-format.spec.ts new file mode 100644 index 0000000..3ecb6f9 --- /dev/null +++ b/bridge-angular/src/lib/components/subscription/plan-format.spec.ts @@ -0,0 +1,159 @@ +// TBP-944 (svelte TBP-813) — how the plan cards and the current-plan panel word things. +// Same cases as bridge-svelte's plan-format.test.ts. +// Pure functions; a fixed 'en-US' locale keeps the output deterministic. + +import { describe, expect, it } from 'vitest'; +import type { BillingSubscriptionState, Plan, PriceOfferSdk } from '@nebulr-group/bridge-auth-core'; +import { + formatAmount, + intervalSuffix, + minAmount, + pickKind, + pickLabel, + subscriptionMeta, +} from './plan-format'; + +const LOCALE = 'en-US'; + +const price = (amount: number, recurrenceInterval: PriceOfferSdk['recurrenceInterval'] = 'month') => + ({ id: `p-${amount}-${recurrenceInterval}`, amount, currency: 'usd', recurrenceInterval }) as PriceOfferSdk; + +const plan = (key: string, name: string, prices: PriceOfferSdk[]) => ({ key, name, prices }) as Plan; + +const FREE = plan('free', 'Free', [price(0)]); +const PRO = plan('pro', 'Pro', [price(29), price(290, 'year')]); +const TEAM = plan('team', 'Team', [price(99)]); +const NO_PRICE = plan('custom', 'Custom', []); + +const state = (s: Partial): BillingSubscriptionState => + ({ plan: { slug: 'pro', name: 'Pro' }, status: 'active', ...s }) as BillingSubscriptionState; + +describe('formatAmount (TBP-944)', () => { + it('whole amounts have no decimals; fractional ones have two', () => { + expect(formatAmount(29, 'usd', LOCALE)).toBe('$29'); + expect(formatAmount(9.5, 'usd', LOCALE)).toBe('$9.50'); + expect(formatAmount(0, 'usd', LOCALE)).toBe('$0'); + }); + + it('reads the currency code case-insensitively', () => { + expect(formatAmount(29, 'USD', LOCALE)).toBe(formatAmount(29, 'usd', LOCALE)); + expect(formatAmount(10, 'eur', LOCALE)).toBe('€10'); + }); + + it('a malformed currency code falls back to " " instead of throwing', () => { + expect(formatAmount(29, 'dollars', LOCALE)).toBe('29 DOLLARS'); + expect(formatAmount(9.5, 'us', LOCALE)).toBe('9.5 US'); + expect(formatAmount(29, '', LOCALE)).toBe('29 '); + }); +}); + +describe('minAmount (TBP-944)', () => { + it('is the cheapest price across every interval', () => { + expect(minAmount(PRO)).toBe(29); + expect(minAmount(FREE)).toBe(0); + }); + + it('a plan with no prices sorts last', () => { + expect(minAmount(NO_PRICE)).toBe(Number.POSITIVE_INFINITY); + expect(minAmount({ key: 'x', name: 'X' } as Plan)).toBe(Number.POSITIVE_INFINITY); + }); +}); + +describe('pickKind / pickLabel (TBP-944)', () => { + it('the current plan is "Current plan"', () => { + expect(pickKind(PRO, PRO)).toBe('current'); + expect(pickLabel('current', PRO)).toBe('Current plan'); + }); + + it('with no current plan every card is "Choose X"', () => { + for (const current of [null, undefined]) { + expect(pickKind(PRO, current)).toBe('choose'); + expect(pickKind(FREE, current)).toBe('choose'); + } + expect(pickLabel('choose', PRO)).toBe('Choose Pro'); + }); + + it('a pricier plan than the current one is an upgrade', () => { + expect(pickKind(TEAM, PRO)).toBe('upgrade'); + expect(pickKind(PRO, FREE)).toBe('upgrade'); + expect(pickLabel('upgrade', TEAM)).toBe('Upgrade to Team'); + }); + + it('a cheaper or same-priced plan is a switch', () => { + expect(pickKind(FREE, PRO)).toBe('switch'); + expect(pickKind(plan('pro2', 'Pro 2', [price(29)]), PRO)).toBe('switch'); + expect(pickLabel('switch', FREE)).toBe('Switch to Free'); + }); + + it('matching is by key, not by object identity', () => { + expect(pickKind(PRO, { ...PRO } as Plan)).toBe('current'); + }); +}); + +describe('intervalSuffix (TBP-944)', () => { + it('is "/ "', () => { + expect(intervalSuffix(price(29, 'month'))).toBe('/ month'); + expect(intervalSuffix(price(290, 'year'))).toBe('/ year'); + }); +}); + +describe('subscriptionMeta (TBP-944)', () => { + // Mid-day UTC so the date is the same in any time zone the suite runs in. + const RENEWS = '2026-11-14T12:00:00.000Z'; + const ENDS = '2026-12-01T12:00:00.000Z'; + + it('no billing state → empty', () => { + expect(subscriptionMeta(null, LOCALE)).toBe(''); + expect(subscriptionMeta(undefined, LOCALE)).toBe(''); + }); + + it('active: renewal date and the card on file', () => { + expect(subscriptionMeta(state({ status: 'active', renewsAt: RENEWS, cardLast4: '4242' }), LOCALE)).toBe( + 'Renews Nov 14, 2026 · Card ending 4242', + ); + }); + + it('active with only one of the two says only that one', () => { + expect(subscriptionMeta(state({ status: 'active', renewsAt: RENEWS }), LOCALE)).toBe('Renews Nov 14, 2026'); + expect(subscriptionMeta(state({ status: 'active', cardLast4: '4242' }), LOCALE)).toBe('Card ending 4242'); + }); + + it('active with nothing to say → empty', () => { + expect(subscriptionMeta(state({ status: 'active' }), LOCALE)).toBe(''); + }); + + it('trial: the end date wins over days left', () => { + expect(subscriptionMeta(state({ status: 'trial', endsAt: ENDS, daysLeft: 9 }), LOCALE)).toBe( + 'Trial ends Dec 1, 2026', + ); + }); + + it('trial without an end date falls back to days left, including 0', () => { + expect(subscriptionMeta(state({ status: 'trial', daysLeft: 9 }), LOCALE)).toBe('9 days left in trial'); + expect(subscriptionMeta(state({ status: 'trial', daysLeft: 0 }), LOCALE)).toBe('0 days left in trial'); + }); + + it('trial never says "Renews", even with a renewal date', () => { + expect(subscriptionMeta(state({ status: 'trial', renewsAt: RENEWS }), LOCALE)).toBe(''); + }); + + it('cancel_at_period_end and canceled: the end date, never a renewal', () => { + for (const status of ['cancel_at_period_end', 'canceled'] as const) { + expect( + subscriptionMeta(state({ status, endsAt: ENDS, renewsAt: RENEWS, cardLast4: '1881' }), LOCALE), + ).toBe('Ends Dec 1, 2026 · Card ending 1881'); + expect(subscriptionMeta(state({ status, renewsAt: RENEWS }), LOCALE)).toBe(''); + } + }); + + it('past_due reads like active: renewal date when there is one', () => { + expect(subscriptionMeta(state({ status: 'past_due', renewsAt: RENEWS }), LOCALE)).toBe('Renews Nov 14, 2026'); + }); + + it('an unparseable date is left out, not printed as "Invalid Date"', () => { + expect(subscriptionMeta(state({ status: 'active', renewsAt: 'not-a-date', cardLast4: '4242' }), LOCALE)).toBe( + 'Card ending 4242', + ); + expect(subscriptionMeta(state({ status: 'cancel_at_period_end', endsAt: 'garbage' }), LOCALE)).toBe(''); + }); +}); diff --git a/bridge-angular/src/lib/components/subscription/plan-format.ts b/bridge-angular/src/lib/components/subscription/plan-format.ts new file mode 100644 index 0000000..3d32a90 --- /dev/null +++ b/bridge-angular/src/lib/components/subscription/plan-format.ts @@ -0,0 +1,83 @@ +/** + * TBP-944 (svelte TBP-813) — how the plan cards and the current-plan panel word + * things, as pure functions. Prices are whole currency units (29 = 29 USD), as + * Bridge stores them. Same wording as bridge-svelte's `plan-format.ts`. + */ +import type { BillingSubscriptionState, Plan, PriceOfferSdk } from '@nebulr-group/bridge-auth-core'; + +/** `29` + `usd` → `$29`; `9.5` → `$9.50`. An unknown currency code falls back to `29 XYZ`. */ +export function formatAmount(amount: number, currency: string, locale?: string): string { + const code = currency.toUpperCase(); + try { + return new Intl.NumberFormat(locale, { + style: 'currency', + currency: code, + minimumFractionDigits: Number.isInteger(amount) ? 0 : 2, + maximumFractionDigits: 2, + }).format(amount); + } catch { + return `${amount} ${code}`; + } +} + +/** The cheapest price a plan has in any interval; plans with none sort last. */ +export function minAmount(plan: Plan): number { + const amounts = (plan.prices ?? []).map((p) => p.amount); + return amounts.length > 0 ? Math.min(...amounts) : Number.POSITIVE_INFINITY; +} + +/** What picking a plan does, relative to the current one. */ +export type PickKind = 'current' | 'choose' | 'upgrade' | 'switch'; + +export function pickKind(plan: Plan, current: Plan | null | undefined): PickKind { + if (current && current.key === plan.key) return 'current'; + if (!current) return 'choose'; + return minAmount(plan) > minAmount(current) ? 'upgrade' : 'switch'; +} + +/** The button text for a pick. */ +export function pickLabel(kind: PickKind, plan: Plan): string { + switch (kind) { + case 'current': + return 'Current plan'; + case 'upgrade': + return `Upgrade to ${plan.name}`; + case 'switch': + return `Switch to ${plan.name}`; + default: + return `Choose ${plan.name}`; + } +} + +/** `/ month`, after a price. */ +export function intervalSuffix(price: PriceOfferSdk): string { + return `/ ${price.recurrenceInterval}`; +} + +function formatDate(iso: string | undefined, locale?: string): string | null { + if (!iso) return null; + const d = new Date(iso); + if (Number.isNaN(d.getTime())) return null; + return d.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' }); +} + +/** + * The line under the current plan's name: renewal or end date, and the card on + * file. Only what the billing state actually carries; empty when it has none. + */ +export function subscriptionMeta(state: BillingSubscriptionState | null | undefined, locale?: string): string { + if (!state) return ''; + const parts: string[] = []; + const renews = formatDate(state.renewsAt, locale); + const ends = formatDate(state.endsAt, locale); + if (state.status === 'trial') { + if (ends) parts.push(`Trial ends ${ends}`); + else if (typeof state.daysLeft === 'number') parts.push(`${state.daysLeft} days left in trial`); + } else if (state.status === 'cancel_at_period_end' || state.status === 'canceled') { + if (ends) parts.push(`Ends ${ends}`); + } else if (renews) { + parts.push(`Renews ${renews}`); + } + if (state.cardLast4) parts.push(`Card ending ${state.cardLast4}`); + return parts.join(' · '); +} diff --git a/bridge-angular/src/lib/components/subscription/plan-selector.component.spec.ts b/bridge-angular/src/lib/components/subscription/plan-selector.component.spec.ts index afee0ce..eb11939 100644 --- a/bridge-angular/src/lib/components/subscription/plan-selector.component.spec.ts +++ b/bridge-angular/src/lib/components/subscription/plan-selector.component.spec.ts @@ -1,7 +1,9 @@ -import { Component, signal } from '@angular/core'; +import { Component, signal, type Type } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import type { Plan, PriceOfferSdk } from '@nebulr-group/bridge-auth-core'; +import { Router, provideRouter } from '@angular/router'; import { describe, it, expect, beforeEach, vi } from 'vitest'; +import { checkoutResult, clearCheckoutResult } from '../../billing/checkout-result'; import { AuthService, type SubscriptionState } from '../../shared/services/auth.service'; import { PlanSelectorComponent } from './plan-selector.component'; @@ -159,10 +161,12 @@ describe('PlanSelectorComponent — S2 customisation parity (TBP-744 / TBP-515)' const el: HTMLElement = fixture.nativeElement; const tabs = [...el.querySelectorAll('.bridge-plan-interval-tab')] as HTMLButtonElement[]; expect(tabs.map((t) => t.textContent?.trim())).toEqual(['Monthly', 'Yearly']); - expect(el.querySelectorAll('.bridge-plan-select-btn')[0].textContent).toContain('10 USD / month'); + const firstPrice = () => + [...(el.querySelector('[data-bridge-plan-price]')?.children ?? [])].map((n) => n.textContent?.trim()).join(' '); + expect(firstPrice()).toBe('$10 / month'); tabs[1].click(); fixture.detectChanges(); - expect(el.querySelectorAll('.bridge-plan-select-btn')[0].textContent).toContain('100 USD / year'); + expect(firstPrice()).toBe('$100 / year'); }); it('passes the selected interval to a custom plan card', () => { @@ -204,7 +208,7 @@ describe('PlanSelectorComponent — plan-change confirmation (TBP-33 parity)', ( function pickBig(fixture: { nativeElement: HTMLElement; detectChanges(): void }) { const buttons = [...fixture.nativeElement.querySelectorAll('.bridge-plan-select-btn')] as HTMLButtonElement[]; - const big = buttons.find((b) => b.textContent?.includes('50 USD'))!; + const big = buttons.find((b) => b.textContent?.includes('Upgrade to Big'))!; big.click(); } @@ -225,7 +229,7 @@ describe('PlanSelectorComponent — plan-change confirmation (TBP-33 parity)', ( fixture.detectChanges(); const el: HTMLElement = fixture.nativeElement; const dialog = el.querySelector('[data-bridge-plan-confirm]'); - expect(dialog?.textContent).toContain('Switch from Small to Big (50 USD / month)'); + expect(dialog?.textContent?.replace(/\s+/g, ' ')).toContain('Switch from Small to Big ($50 / month)'); expect(changePlan).not.toHaveBeenCalled(); (el.querySelector('[data-bridge-plan-confirm-btn]') as HTMLButtonElement).click(); @@ -258,3 +262,155 @@ describe('PlanSelectorComponent — plan-change confirmation (TBP-33 parity)', ( expect(el.querySelector('[data-bridge-plan-confirm]')?.textContent).toContain('Card declined'); }); }); + +/** + * TBP-944 (svelte TBP-813) — the default plan card: a formatted price block, + * "Choose / Upgrade to / Switch to" buttons, the current plan flagged, and an + * optional heading. A Free pick records the one-shot checkout result and lands + * on `successRedirect`. Same cases as bridge-svelte's plan-selector-card.test.ts. + */ +describe('PlanSelectorComponent — the default card (TBP-944)', () => { + const MONTHLY = (id: string, amount: number): PriceOfferSdk => ({ id, amount, currency: 'usd', recurrenceInterval: 'month' }); + const FREE: Plan = { key: 'free', name: 'Free', prices: [MONTHLY('f', 0)] }; + const PRO: Plan = { key: 'pro', name: 'Pro', prices: [MONTHLY('p', 29)] }; + const TEAM: Plan = { key: 'team', name: 'Team', prices: [MONTHLY('t', 99)] }; + + let state: ReturnType>; + let selectFreePlan: ReturnType; + + class CatalogAuth extends StubAuthService { + override readonly subscription = state.asReadonly(); + override getBridgeAuth(): unknown { + return { selectFreePlan }; + } + } + + @Component({ + standalone: true, + imports: [PlanSelectorComponent], + template: ``, + }) + class CardHost { + heading: string | undefined = undefined; + } + + @Component({ + standalone: true, + imports: [PlanSelectorComponent], + template: ``, + }) + class SelectHost { + picked: string | null = null; + } + + function render(status: unknown, host: typeof CardHost | typeof SelectHost = CardHost, heading?: string) { + state.set({ status: status as SubscriptionState['status'], plans: [FREE, PRO, TEAM], loading: false, error: null }); + const fixture = TestBed.createComponent(host as Type); + if (heading && fixture.componentInstance instanceof CardHost) fixture.componentInstance.heading = heading; + fixture.detectChanges(); + return fixture; + } + + function card(fixture: { nativeElement: HTMLElement }, name: string): HTMLElement { + const cards = [...fixture.nativeElement.querySelectorAll('[data-bridge-plan-card]')]; + const found = cards.find((c) => c.querySelector('.bridge-plan-name')?.textContent?.trim() === name); + if (!found) throw new Error(`no card for ${name}`); + return found; + } + + const button = (c: HTMLElement) => c.querySelector('.bridge-plan-select-btn')!; + const text = (n: Element | null | undefined) => n?.textContent?.replace(/\s+/g, ' ').trim(); + + beforeEach(() => { + clearCheckoutResult(); + state = signal({ status: null, plans: [], loading: false, error: null }); + selectFreePlan = vi.fn(async () => {}); + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + imports: [CardHost, SelectHost], + providers: [provideRouter([{ path: '**', children: [] }]), { provide: AuthService, useClass: CatalogAuth }], + }); + }); + + it('with no current plan, every button is "Choose X" and no card is flagged', () => { + const fixture = render({ shouldSelectPlan: true }); + expect(text(button(card(fixture, 'Free')))).toBe('Choose Free'); + expect(text(button(card(fixture, 'Pro')))).toBe('Choose Pro'); + expect(text(button(card(fixture, 'Team')))).toBe('Choose Team'); + expect(card(fixture, 'Pro').getAttribute('data-pick')).toBe('choose'); + const el: HTMLElement = fixture.nativeElement; + expect(el.querySelector('[data-bridge-plan-current-flag]')).toBeNull(); + // The old labels are gone. + expect(el.textContent).not.toContain('Select free plan'); + expect(el.textContent).not.toContain('Select plan'); + expect(el.textContent).not.toContain('29 USD / month'); + }); + + it('relative to the current plan: Current plan / Upgrade to / Switch to', () => { + const fixture = render({ plan: 'pro', paymentsEnabled: false }); + + const pro = card(fixture, 'Pro'); + expect(text(button(pro))).toBe('Current plan'); + expect(pro.getAttribute('data-current')).toBe('true'); + expect(pro.getAttribute('data-pick')).toBe('current'); + expect(text(pro.querySelector('[data-bridge-plan-current-flag]'))).toBe('Your plan'); + expect(button(pro).disabled).toBe(true); + + const team = card(fixture, 'Team'); + expect(text(button(team))).toBe('Upgrade to Team'); + expect(team.getAttribute('data-pick')).toBe('upgrade'); + expect(button(team).classList).toContain('bridge-btn-primary'); + expect(team.querySelector('[data-bridge-plan-current-flag]')).toBeNull(); + + const free = card(fixture, 'Free'); + expect(text(button(free))).toBe('Switch to Free'); + expect(free.getAttribute('data-pick')).toBe('switch'); + expect(button(free).classList).toContain('bridge-btn-secondary'); + }); + + it('reads a current plan given as an object, as the REST status returns it', () => { + const fixture = render({ plan: { key: 'team', name: 'Team' } }); + expect(text(button(card(fixture, 'Team')))).toBe('Current plan'); + expect(text(button(card(fixture, 'Pro')))).toBe('Switch to Pro'); + }); + + it('each card shows its price as a formatted amount and interval, and check marks on features', () => { + const fixture = render({ shouldSelectPlan: true }); + const price = card(fixture, 'Pro').querySelector('[data-bridge-plan-price]'); + expect(text(price?.querySelector('.bridge-plan-price-amount'))).toBe('$29'); + expect(text(price?.querySelector('.bridge-plan-price-interval'))).toBe('/ month'); + expect(text(card(fixture, 'Free').querySelector('.bridge-plan-price-amount'))).toBe('$0'); + }); + + it('a heading renders above the plans only when given', () => { + expect(render({ shouldSelectPlan: true }).nativeElement.querySelector('[data-bridge-plan-head]')).toBeNull(); + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + imports: [CardHost], + providers: [provideRouter([{ path: '**', children: [] }]), { provide: AuthService, useClass: CatalogAuth }], + }); + const fixture = render({ shouldSelectPlan: true }, CardHost, 'Change plan'); + const heading = fixture.nativeElement.querySelector('[data-bridge-plan-head] h2.bridge-plan-heading'); + expect(text(heading)).toBe('Change plan'); + }); + + it('a Free pick records the result with the plan name and lands on successRedirect', async () => { + const router = TestBed.inject(Router); + const fixture = render({ plan: 'pro', paymentsEnabled: false }); + button(card(fixture, 'Free')).click(); + await fixture.whenStable(); + expect(selectFreePlan).toHaveBeenCalledWith('free'); + expect(checkoutResult()).toEqual({ kind: 'plan', planName: 'Free' }); + expect(router.url).toBe('/landed'); + }); + + it('a page that listens to (select) takes over: no banner result, no navigation', async () => { + const router = TestBed.inject(Router); + const fixture = render({ plan: 'pro', paymentsEnabled: false }, SelectHost); + button(card(fixture, 'Free')).click(); + await fixture.whenStable(); + expect((fixture.componentInstance as SelectHost).picked).toBe('free'); + expect(checkoutResult()).toBeNull(); + expect(router.url).toBe('/'); + }); +}); diff --git a/bridge-angular/src/lib/components/subscription/plan-selector.component.ts b/bridge-angular/src/lib/components/subscription/plan-selector.component.ts index 7bca9d4..c395578 100644 --- a/bridge-angular/src/lib/components/subscription/plan-selector.component.ts +++ b/bridge-angular/src/lib/components/subscription/plan-selector.component.ts @@ -17,6 +17,12 @@ * reloads the subscription, then redirects to the caller's `successRedirect` / * `cancelRedirect`. Mirrors bridge-svelte's BridgeBootstrap and bridge-react's * CallbackHandler. + * + * TBP-944 (svelte TBP-813): the default card is a surface of its own with a + * formatted price, "Choose / Upgrade to / Switch to" buttons and the current + * plan flagged; an optional `heading` sits beside the interval switch; a Free + * pick records the one-shot checkout result, so the landing page shows the same + * banner a paid checkout gets. */ import { NgTemplateOutlet } from '@angular/common'; import { @@ -32,8 +38,10 @@ import { } from '@angular/core'; import type { Plan, PriceOfferSdk } from '@nebulr-group/bridge-auth-core'; import { Router } from '@angular/router'; +import { markCheckoutComplete } from '../../billing/checkout-result'; import { BridgeConfigService } from '../../config/bridge-config.service'; import { AuthService } from '../../shared/services/auth.service'; +import { formatAmount, intervalSuffix, minAmount, pickKind, pickLabel, type PickKind } from './plan-format'; /** * Context passed to a custom `planCardTemplate`. Mirrors the data the @@ -99,11 +107,6 @@ export function pricesForInterval(plan: Plan, interval: BillingInterval): PriceO return free ? [free] : []; } -function minAmount(plan: Plan): number { - const amounts = (plan.prices ?? []).map((p) => p.amount); - return amounts.length > 0 ? Math.min(...amounts) : Number.POSITIVE_INFINITY; -} - /** Cheapest first, by each plan's cheapest price across all intervals (stable across tabs). */ export function sortPlans(plans: readonly Plan[] | null | undefined): Plan[] { return [...(plans ?? [])].sort((a, b) => minAmount(a) - minAmount(b)); @@ -177,7 +180,7 @@ type UiState =

No plans available.

} } @else if (plans()) { - @if (intervals().length >= 2) { +
@for (interval of intervals(); track interval) {
+
+ + @if (heading) { +
+

{{ heading }}

+ @if (intervals().length >= 2) { + + } +
+ } @else if (intervals().length >= 2) { + }
@for (plan of sortedPlans(); track plan.key) { @@ -204,8 +218,12 @@ type UiState = data-bridge-plan-card [attr.data-current]="plan.key === currentPlanKey()" [attr.data-trial]="plan.trial" + [attr.data-pick]="kindOf(plan)" class="bridge-plan-card" > + @if (plan.key === currentPlanKey()) { + Your plan + }

{{ plan.name }}

@if (plan.trial && (plan.trialDays ?? 0) > 0) { @@ -213,6 +231,13 @@ type UiState = }
+ @if (visiblePrices(plan)[0]; as shownPrice) { +
+ {{ amount(shownPrice) }} + {{ suffix(shownPrice) }} +
+ } + @if (planDescriptionTemplate) { 0) {
    @for (feature of features(plan); track feature.key) { -
  • {{ feature.name }}
  • +
  • + + {{ feature.name }} +
  • }
} @@ -234,28 +264,22 @@ type UiState = @for (price of visiblePrices(plan); track price.recurrenceInterval + price.currency) { } @if (plan.prices.length === 0) { }
@@ -289,7 +313,7 @@ type UiState = {{ target.plan.name }} ({{ formatPrice(target.price) }}).

- The change takes effect immediately — any price difference is prorated on your next invoice. + The change takes effect immediately. Any price difference is prorated on your next invoice.

@if (confirmError()) { @@ -315,6 +339,8 @@ type UiState = `, }) export class PlanSelectorComponent implements OnInit { + /** TBP-944 — a heading above the plans, beside the Monthly/Yearly switch. */ + @Input() heading?: string; /** Where to send the user after a successful Stripe payment. @default '/subscription' */ @Input() successRedirect = '/subscription'; /** Where to send the user if they cancel Stripe Checkout. @default '/subscription' */ @@ -402,6 +428,43 @@ export class PlanSelectorComponent implements OnInit { return planFeatures(plan); } + /** TBP-944 — what picking this plan does, relative to the current one. */ + protected kindOf(plan: Plan): PickKind { + return pickKind(plan, this.currentPlan()); + } + + /** "Choose X", "Upgrade to X", "Switch to X" or "Current plan". */ + protected label(plan: Plan): string { + return pickLabel(this.kindOf(plan), plan); + } + + /** The label, plus the price when the card offers more than one under this tab. */ + protected buttonLabel(plan: Plan, price: PriceOfferSdk): string { + const kind = this.kindOf(plan); + const label = pickLabel(kind, plan); + return this.visiblePrices(plan).length > 1 && kind !== 'current' + ? `${label} · ${formatAmount(price.amount, price.currency)}` + : label; + } + + /** An upgrade or a first pick is the primary action; a switch and the current plan are secondary. */ + protected buttonClass(plan: Plan): string { + const kind = this.kindOf(plan); + const variant = kind === 'current' || kind === 'switch' ? 'bridge-btn-secondary' : 'bridge-btn-primary'; + return `${variant} bridge-plan-select-btn`; + } + + protected amount(price: PriceOfferSdk): string { + return formatAmount(price.amount, price.currency); + } + + protected suffix(price: PriceOfferSdk): string { + return intervalSuffix(price); + } + + /** The price a plan with no prices is picked at (as svelte's card does). */ + protected readonly noPrice: PriceOfferSdk = { id: '', amount: 0, currency: 'usd', recurrenceInterval: 'month' }; + protected partContext(plan: Plan): PlanPartTemplateContext { const isCurrent = plan.key === this.currentPlanKey(); return { $implicit: { plan, isCurrent }, plan, isCurrent }; @@ -423,6 +486,11 @@ export class PlanSelectorComponent implements OnInit { return typeof planField === 'string' ? planField : planField?.key ?? null; }); + /** The current plan from the catalogue, or null. */ + protected readonly currentPlan = computed( + () => (this.plans() ?? []).find((p) => p.key === this.currentPlanKey()) ?? null, + ); + ngOnInit(): void { if (!this.status() && !this.loading()) { void this.authService.loadSubscription(); @@ -505,6 +573,9 @@ export class PlanSelectorComponent implements OnInit { this.select.emit({ plan, price }); return; } + // TBP-944 (svelte TBP-813) — the landing page shows the same banner a + // paid checkout gets. + markCheckoutComplete({ kind: 'plan', planName: plan.name }); void this.router?.navigateByUrl(this.successRedirect); } @@ -527,16 +598,12 @@ export class PlanSelectorComponent implements OnInit { protected readonly successNotice = signal(null); private successTimer: ReturnType | undefined; - protected readonly currentPlanName = computed(() => { - const key = this.currentPlanKey(); - const found = (this.plans() ?? []).find((p) => p.key === key); - return found?.name ?? key ?? 'your current plan'; - }); + protected readonly currentPlanName = computed( + () => this.currentPlan()?.name ?? this.currentPlanKey() ?? 'your current plan', + ); protected formatPrice(price: PriceOfferSdk): string { - return price.amount === 0 - ? 'Free' - : `${price.amount} ${price.currency.toUpperCase()} / ${price.recurrenceInterval}`; + return price.amount === 0 ? 'Free' : `${formatAmount(price.amount, price.currency)} ${intervalSuffix(price)}`; } /** Run the confirmed switch. A failure shows inside the dialog, which stays open. */ diff --git a/bridge-angular/src/lib/routing/billing-paths.ts b/bridge-angular/src/lib/routing/billing-paths.ts index 2bfa051..3ec23f0 100644 --- a/bridge-angular/src/lib/routing/billing-paths.ts +++ b/bridge-angular/src/lib/routing/billing-paths.ts @@ -38,8 +38,18 @@ export interface BridgeBillingPaths { paywallIsDefault: boolean; /** Where a failed checkout confirmation lands. */ paymentErrorRoute: string; - /** Where a completed checkout lands by default: `/success`. */ + /** + * Where a completed checkout (or a Free pick) lands: `billing.successRoute`, + * else the subscription page, which shows the confirmation banner (TBP-944, + * svelte TBP-813). It used to be `/success`. + */ successRoute: string; + /** + * True when `successRoute` is the default rather than the app's own choice. + * The `bridgeBillingRoutes()` pages then land on their own subscription page, + * wherever the routes live, instead of on `manageRoute`. + */ + successIsDefault: boolean; } /** @@ -55,7 +65,8 @@ export function resolveBillingPaths(billing?: BridgeConfig['billing']): BridgeBi paywallRoute: paywall === false ? null : paywall || BRIDGE_BILLING_DEFAULTS.paywallRoute, paywallIsDefault: paywall !== false && !paywall, paymentErrorRoute: billing?.paymentErrorRoute || BRIDGE_BILLING_DEFAULTS.paymentErrorRoute, - successRoute: `${manageRoute.replace(/\/+$/, '')}/success`, + successRoute: billing?.successRoute || manageRoute, + successIsDefault: !billing?.successRoute, }; } diff --git a/bridge-angular/src/lib/routing/bridge-routes.ts b/bridge-angular/src/lib/routing/bridge-routes.ts index 288340e..c30e346 100644 --- a/bridge-angular/src/lib/routing/bridge-routes.ts +++ b/bridge-angular/src/lib/routing/bridge-routes.ts @@ -85,7 +85,13 @@ export interface BridgeAuthRoutesOptions extends CommonRouteOptions; +export interface BridgeBillingRoutesOptions extends CommonRouteOptions { + /** + * TBP-944 — the "You're on Pro now" banner on the subscription page after a + * checkout or a Free pick. `false` hides it. @default true + */ + checkoutNotice?: boolean; +} /** What a Bridge page component reads from its route. */ export interface BridgePageOptions { @@ -97,6 +103,8 @@ export interface BridgePageOptions { framed?: boolean; redirectTo: string; messages?: MessageOverrides; + /** TBP-944 — the subscription page's checkout banner; `false` hides it. */ + checkoutNotice?: boolean; } function trimSlashes(path: string): string { @@ -160,12 +168,15 @@ export function bridgeAuthRoutes(options: BridgeAuthRoutesOptions = {}): Routes * pages `success` and `error`. These need a signed-in user: spread them inside * your guarded parent. Their addresses are the defaults of * `billing.manageRoute`, `billing.paywallRoute` and `billing.paymentErrorRoute`, - * so nothing Bridge redirects to is a 404. + * so nothing Bridge redirects to is a 404. A completed checkout lands back on + * the subscription page with a banner (TBP-944); `success` is the old + * confirmation page, served for an app whose `billing.successRoute` points at it. */ export function bridgeBillingRoutes(options: BridgeBillingRoutesOptions = {}): Routes { const pageOptions: BridgePageOptions = { heading: options.heading as BridgePageOptions['heading'], redirectTo: options.redirectTo ?? '/', + checkoutNotice: options.checkoutNotice ?? true, }; const pages: Array<[BridgeBillingPage, string]> = [ ['manage', ''], diff --git a/bridge-angular/src/lib/routing/callback.ts b/bridge-angular/src/lib/routing/callback.ts index ae25631..2a9893e 100644 --- a/bridge-angular/src/lib/routing/callback.ts +++ b/bridge-angular/src/lib/routing/callback.ts @@ -7,9 +7,10 @@ * - the hosted login (`?code=`) → exchange it, then the stashed deep link * (TBP-629) or the default route; * - a completed Stripe checkout (`?stripe_success&session_id=`) → confirm it - * with bridge-api, re-read billing, then `redirect` (default: the - * subscription page); a confirmation that fails lands on the payment-error - * page (default `/subscription/error`); + * with bridge-api, re-read billing, record the one-shot checkout result + * (TBP-944, svelte TBP-813) so the landing page shows its banner, then + * `redirect` (default: the subscription page); a confirmation that fails + * lands on the payment-error page (default `/subscription/error`); * - a cancelled checkout (`?stripe_cancel`) → `redirect`. */ import { sanitizeReturnTo } from '@nebulr-group/bridge-auth-core'; @@ -20,6 +21,11 @@ export interface CallbackDeps { confirmStripeCheckout(sessionId: string): Promise; /** Re-read the subscription so the landing page shows the new plan. Never throws. */ refreshBilling(): Promise; + /** + * TBP-944 — record that a paid checkout just went through, for the landing + * page's banner. Not called when the confirmation fails. + */ + completeCheckout?(): void; /** The deep link stashed before a hosted login (auth-core `takeReturnTo`). */ takeReturnTo(): string | null; logError?(message: string, err: unknown): void; @@ -67,6 +73,7 @@ export async function resolveCallbackTarget( return paths.paymentErrorRoute; } await deps.refreshBilling().catch(() => {}); + deps.completeCheckout?.(); return stripeReturnTarget(params, paths); } diff --git a/bridge-angular/src/lib/routing/ten-line-routing.spec.ts b/bridge-angular/src/lib/routing/ten-line-routing.spec.ts index 6d4de64..0e77b77 100644 --- a/bridge-angular/src/lib/routing/ten-line-routing.spec.ts +++ b/bridge-angular/src/lib/routing/ten-line-routing.spec.ts @@ -147,16 +147,38 @@ describe('billing destinations (TBP-744, svelte TBP-702)', () => { paywallRoute: '/subscription/plan', paywallIsDefault: true, paymentErrorRoute: '/subscription/error', - successRoute: '/subscription/success', + // TBP-944 (svelte TBP-813) — a checkout lands on the subscription page, which shows the banner. + successRoute: '/subscription', + successIsDefault: true, }); }); - it('keeps what the app set, and false turns the paywall off', () => { + it('keeps what the app set, false turns the paywall off, and a checkout lands on manageRoute', () => { const paths = resolveBillingPaths({ manageRoute: '/billing/', paywallRoute: false, paymentErrorRoute: '/oops' }); expect(paths.paywallRoute).toBeNull(); expect(paths.paywallIsDefault).toBe(false); expect(paths.paymentErrorRoute).toBe('/oops'); - expect(paths.successRoute).toBe('/billing/success'); + expect(paths.successRoute).toBe('/billing/'); + expect(paths.successIsDefault).toBe(true); + }); + + it('billing.successRoute sends a checkout anywhere in the app (TBP-944)', () => { + const paths = resolveBillingPaths({ successRoute: '/dashboard' }); + expect(paths.successRoute).toBe('/dashboard'); + expect(paths.successIsDefault).toBe(false); + expect(paths.manageRoute).toBe('/subscription'); + }); + + it('the old confirmation page is still reachable as an explicit successRoute (TBP-944)', () => { + const paths = resolveBillingPaths({ successRoute: '/subscription/success' }); + expect(paths.successRoute).toBe('/subscription/success'); + expect(paths.successIsDefault).toBe(false); + }); + + it('an empty successRoute counts as unset (TBP-944)', () => { + const paths = resolveBillingPaths({ manageRoute: '/billing', successRoute: '' }); + expect(paths.successRoute).toBe('/billing'); + expect(paths.successIsDefault).toBe(true); }); it('an app uses billing only when it has plans', () => { @@ -179,6 +201,7 @@ describe('the OAuth callback page (TBP-744)', () => { handleCallback: vi.fn(async () => {}), confirmStripeCheckout: vi.fn(async () => {}), refreshBilling: vi.fn(async () => {}), + completeCheckout: vi.fn(() => {}), takeReturnTo: vi.fn(() => '/deep/link' as string | null), }); @@ -201,6 +224,38 @@ describe('the OAuth callback page (TBP-744)', () => { expect(d.refreshBilling).toHaveBeenCalled(); }); + it('records the completed checkout after billing is re-read, for the landing page banner (TBP-944)', async () => { + const order: string[] = []; + const d = { + ...deps(), + refreshBilling: vi.fn(async () => { + order.push('refresh'); + }), + completeCheckout: vi.fn(() => { + order.push('complete'); + }), + }; + const params = new URLSearchParams('stripe_success=1&session_id=cs_1&redirect=%2Fsubscription'); + expect(await resolveCallbackTarget(params, paths, d)).toBe('/subscription'); + expect(order).toEqual(['refresh', 'complete']); + }); + + it('records nothing when the confirmation fails, on a cancel, or on a sign-in (TBP-944)', async () => { + const failed = { ...deps(), confirmStripeCheckout: vi.fn(async () => { + throw new Error('no'); + }) }; + await resolveCallbackTarget(new URLSearchParams('stripe_success=1&session_id=cs_1'), paths, failed); + expect(failed.completeCheckout).not.toHaveBeenCalled(); + + const cancelled = deps(); + await resolveCallbackTarget(new URLSearchParams('stripe_cancel=1&redirect=%2Fsubscription'), paths, cancelled); + expect(cancelled.completeCheckout).not.toHaveBeenCalled(); + + const signIn = deps(); + await resolveCallbackTarget(new URLSearchParams('code=abc'), paths, signIn); + expect(signIn.completeCheckout).not.toHaveBeenCalled(); + }); + it('a checkout that cannot be confirmed lands on /subscription/error', async () => { const d = { ...deps(), confirmStripeCheckout: vi.fn(async () => { throw new Error('no'); diff --git a/bridge-angular/src/lib/styles-layer.spec.ts b/bridge-angular/src/lib/styles-layer.spec.ts new file mode 100644 index 0000000..08c6c0e --- /dev/null +++ b/bridge-angular/src/lib/styles-layer.spec.ts @@ -0,0 +1,224 @@ +/** + * TBP-944 (svelte TBP-814) — the default stylesheet follows the app's type and + * loses to the app's CSS. Same contract as bridge-svelte's `styles.test.ts`: + * - the layer order statement comes first, `bridge` last after Tailwind v4's layers; + * - `--bridge-text-base` is registered with `@property`, outside any layer; + * - every rule after that sits inside one `@layer bridge` block; + * - no text size is a fixed `rem` any more, and no weight is hard-coded except + * the two avatar initials; + * - the token fallbacks are the values the rules had before, so an app that + * sets nothing sees no change. + * And the components' own `styles` (bridge-angular keeps almost everything in + * styles.css) sit in the same layer, except the realtime developer badge. + */ +import { readFileSync, readdirSync, statSync } from 'node:fs'; +import { join, resolve } from 'node:path'; +import { describe, expect, it } from 'vitest'; + +type Decl = { type: 'decl'; property: string; value: string }; +type Rule = { type: 'rule'; selector: string; children: Node[] }; +type AtRule = { type: 'atrule'; name: string; prelude: string; children: Node[] | null }; +type Node = Decl | Rule | AtRule; + +/** A small CSS parser: enough for rules, nested at-rules and declarations. */ +function parseCss(source: string): Node[] { + const css = source.replace(/\/\*[\s\S]*?\*\//g, ''); + let i = 0; + function block(): Node[] { + const nodes: Node[] = []; + let buf = ''; + while (i < css.length) { + const ch = css[i++]; + if (ch === '{') { + const head = buf.trim(); + buf = ''; + const children = block(); + if (head.startsWith('@')) { + const [, name, prelude] = head.match(/^@([\w-]+)\s*([\s\S]*)$/)!; + nodes.push({ type: 'atrule', name, prelude: prelude.trim(), children }); + } else { + nodes.push({ type: 'rule', selector: head.replace(/\s+/g, ' '), children }); + } + } else if (ch === '}') { + if (buf.trim()) nodes.push(decl(buf)); + return nodes; + } else if (ch === ';') { + const text = buf.trim(); + buf = ''; + if (!text) continue; + if (text.startsWith('@')) { + const [, name, prelude] = text.match(/^@([\w-]+)\s*([\s\S]*)$/)!; + nodes.push({ type: 'atrule', name, prelude: prelude.trim(), children: null }); + } else nodes.push(decl(text)); + } else buf += ch; + } + return nodes; + } + function decl(text: string): Decl { + const at = text.indexOf(':'); + return { type: 'decl', property: text.slice(0, at).trim(), value: text.slice(at + 1).trim().replace(/\s+/g, ' ') }; + } + return block(); +} + +type Found = { selector: string; property: string; value: string }; + +function declarations(nodes: Node[], out: Found[] = []): Found[] { + for (const node of nodes) { + if (node.type === 'rule') { + for (const c of node.children) if (c.type === 'decl') out.push({ selector: node.selector, property: c.property, value: c.value }); + declarations(node.children.filter((c) => c.type !== 'decl'), out); + } else if (node.type === 'atrule' && node.children) { + declarations(node.children, out); + } + } + return out; +} + +const source = readFileSync(resolve(__dirname, 'styles.css'), 'utf8'); +const sheet = parseCss(source); +const all = declarations(sheet); +const valueOf = (selector: string, property: string) => + all.find((d) => d.selector.split(',').map((s) => s.trim()).includes(selector) && d.property === property)?.value; + +describe('styles.css — cascade layer (TBP-944)', () => { + it('opens with the layer order statement, bridge after Tailwind v4’s layers', () => { + const first = sheet[0]; + expect(first.type === 'atrule' && first.name).toBe('layer'); + if (first.type !== 'atrule') return; + expect(first.children).toBeNull(); + expect(first.prelude.split(',').map((s) => s.trim())).toEqual(['theme', 'base', 'components', 'utilities', 'bridge']); + }); + + it('registers --bridge-text-base with @property, outside the layer', () => { + const second = sheet[1]; + expect(second.type === 'atrule' && second.name).toBe('property'); + if (second.type !== 'atrule' || !second.children) return; + expect(second.prelude).toBe('--bridge-text-base'); + const descriptors = Object.fromEntries( + second.children.map((c) => (c.type === 'decl' ? [c.property, c.value] : ['', ''])), + ); + expect(descriptors).toMatchObject({ syntax: "''", inherits: 'true', 'initial-value': '16px' }); + }); + + it('puts everything after the @property inside a single @layer bridge block', () => { + expect(sheet).toHaveLength(3); + const layer = sheet[2]; + expect(layer.type === 'atrule' && layer.name).toBe('layer'); + if (layer.type !== 'atrule') return; + expect(layer.prelude).toBe('bridge'); + expect(layer.children?.length).toBeGreaterThan(100); + expect(sheet.filter((n) => n.type === 'rule')).toHaveLength(0); + }); + + it('derives the base text size from the app’s ', () => { + expect(valueOf(':where(body)', '--bridge-text-base')).toBe('var(--bridge-font-size, 1em)'); + }); +}); + +describe('styles.css — type follows the app (TBP-944)', () => { + it('has no fixed rem font sizes left', () => { + const fixed = all.filter((d) => d.property === 'font-size' && /^[\d.]+rem$/.test(d.value)); + expect(fixed).toEqual([]); + }); + + it('scales every relative font size from --bridge-text-base with a 1rem fallback', () => { + const sizes = all.filter((d) => d.property === 'font-size' && d.value !== 'inherit'); + expect(sizes.length).toBeGreaterThan(50); + for (const d of sizes) { + expect(d.value, d.selector).toMatch(/^calc\([\d.]+ \* var\(--bridge-text-base, 1rem\)\)$/); + } + }); + + it('hard-codes no font-weight except the two avatar initials', () => { + // `inherit` (the sign-in page's text links, TBP-899) defers to the app, so it counts as following it. + const literal = all.filter((d) => d.property === 'font-weight' && !d.value.startsWith('var(') && d.value !== 'inherit'); + expect(literal.map((d) => d.selector).sort()).toEqual(['.bridge-tenant-avatar', '[data-bridge-workspace-avatar]']); + for (const d of all.filter((d) => d.property === 'font-weight' && d.value.startsWith('var('))) { + expect(d.value, d.selector).toMatch(/^var\(--bridge-font-weight-(heading|button|label), \d{3}\)$/); + } + }); + + it('keeps the previous values as the token fallbacks', () => { + // Before: `.bridge-btn { font-size: 0.875rem; font-weight: 500 }`. + expect(valueOf('.bridge-btn', 'font-size')).toBe('calc(0.875 * var(--bridge-text-base, 1rem))'); + expect(valueOf('.bridge-btn', 'font-weight')).toBe('var(--bridge-font-weight-button, 500)'); + // `.bridge-plan-price-amount { font-size: 1.9rem; font-weight: 700 }` (svelte TBP-813). + expect(valueOf('.bridge-plan-price-amount', 'font-size')).toBe('calc(1.9 * var(--bridge-text-base, 1rem))'); + expect(valueOf('.bridge-plan-price-amount', 'font-weight')).toBe('var(--bridge-font-weight-heading, 700)'); + // The Angular-only page styles too: `.bridge-billing-heading { 1.5rem; 700 }`. + expect(valueOf('.bridge-billing-heading', 'font-size')).toBe('calc(1.5 * var(--bridge-text-base, 1rem))'); + expect(valueOf('.bridge-billing-heading', 'font-weight')).toBe('var(--bridge-font-weight-heading, 700)'); + expect(valueOf('.bridge-billing-label', 'font-weight')).toBe('var(--bridge-font-weight-label, 600)'); + }); + + it('gives every button a shadow token that defaults to none', () => { + for (const selector of ['.bridge-btn', '.bridge-btn-primary', '.bridge-btn-secondary', '.bridge-btn-danger']) { + expect(valueOf(selector, 'box-shadow'), selector).toBe('var(--bridge-button-shadow, none)'); + } + }); + + it('lets --bridge-card-shadow style the plan-change dialog, defaulting to its old shadow', () => { + const dialog = all.filter( + (d) => d.property === 'box-shadow' && d.value === 'var(--bridge-card-shadow, 0 24px 60px -12px rgba(0, 0, 0, 0.35))', + ); + expect(dialog.map((d) => d.selector)).toEqual(['.bridge-plan-confirm']); + }); +}); + +describe('styles.css — the subscription page surfaces (TBP-944, svelte TBP-813)', () => { + it('plan cards and the current-plan panel are surfaces driven by the card tokens', () => { + expect(valueOf('[data-bridge-plan-card]', 'background')).toBe('var(--bridge-card-bg, var(--bridge-bg))'); + expect(valueOf('.bridge-billing-summary', 'box-shadow')).toBe( + 'var(--bridge-card-shadow, 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04))', + ); + }); + + it('marks the current plan with the brand colour, and styles the checkout banner from the success tokens', () => { + expect(valueOf('[data-bridge-plan-card][data-current="true"]', 'border')).toBe('2px solid var(--bridge-primary)'); + expect(valueOf('.bridge-plan-current-flag', 'background')).toBe('var(--bridge-primary)'); + expect(valueOf('.bridge-checkout-notice', 'background')).toBe('var(--bridge-alert-success-bg)'); + }); +}); + +describe('component styles sit in the bridge layer (TBP-944)', () => { + const root = resolve(__dirname, 'components'); + const files = (dir: string): string[] => + readdirSync(dir).flatMap((f) => { + const p = join(dir, f); + return statSync(p).isDirectory() ? files(p) : p.endsWith('.component.ts') ? [p] : []; + }); + + /** The CSS of each component that has inline `styles`. */ + const styled = files(root) + .map((path) => { + const ts = readFileSync(path, 'utf8'); + const m = ts.match(/styles:\s*\[\s*`([\s\S]*?)`\s*,?\s*\]/); + return m ? { path: path.slice(root.length + 1), css: m[1].replace(/\\`/g, '`') } : null; + }) + .filter((x): x is { path: string; css: string } => x !== null); + + it('finds the components that carry their own styles', () => { + expect(styled.map((s) => s.path).sort()).toEqual([ + 'developer/realtime-dev-badge.component.ts', + 'login/login.component.ts', + ]); + }); + + it('wraps every rule in one @layer bridge block, sized from the text base', () => { + for (const { path, css } of styled.filter((s) => !s.path.startsWith('developer/'))) { + const nodes = parseCss(css); + expect(nodes, path).toHaveLength(1); + const layer = nodes[0]; + expect(layer.type === 'atrule' && `${layer.name} ${layer.prelude}`, path).toBe('layer bridge'); + for (const d of declarations(nodes).filter((d) => d.property === 'font-size')) { + expect(d.value, path).toMatch(/^calc\([\d.]+ \* var\(--bridge-text-base, 1rem\)\)$/); + } + } + }); + + it('leaves the realtime developer badge unlayered: it is a developer overlay, not app UI', () => { + const badge = styled.find((s) => s.path.startsWith('developer/'))!; + expect(parseCss(badge.css).some((n) => n.type === 'atrule' && n.name === 'layer')).toBe(false); + }); +}); diff --git a/bridge-angular/src/lib/styles-tokens.spec.ts b/bridge-angular/src/lib/styles-tokens.spec.ts index 419a1ab..d01f479 100644 --- a/bridge-angular/src/lib/styles-tokens.spec.ts +++ b/bridge-angular/src/lib/styles-tokens.spec.ts @@ -27,6 +27,14 @@ const CONTRACT = [ '--bridge-muted-bg', '--bridge-border', '--bridge-border-radius', + // TBP-944 (svelte TBP-813 / TBP-814) — card surfaces, type and shadows. + '--bridge-card-bg', + '--bridge-card-shadow', + '--bridge-button-shadow', + '--bridge-font-size', + '--bridge-font-weight-heading', + '--bridge-font-weight-button', + '--bridge-font-weight-label', '--bridge-overlay', '--bridge-alert-error-bg', '--bridge-alert-error-fg', diff --git a/bridge-angular/src/lib/styles.css b/bridge-angular/src/lib/styles.css index f968b67..1137d71 100644 --- a/bridge-angular/src/lib/styles.css +++ b/bridge-angular/src/lib/styles.css @@ -30,6 +30,17 @@ * --bridge-muted-bg subtle fills: tab tracks, hovers, code boxes * --bridge-border input, table, card and secondary button borders * --bridge-border-radius corners of inputs, buttons, alerts, cards, dialogs + * --bridge-card-bg plan cards and the current-plan panel (defaults to --bridge-bg) + * --bridge-card-shadow their shadow, and the plan-change dialog's; `none` for a flat look + * --bridge-button-shadow every Bridge button's shadow, e.g. `4px 4px 0 #000` (default none) + * + * Type (TBP-944, svelte TBP-814). Bridge text follows your app: every size is + * relative to the text size of your page's , and the font family is inherited. + * --bridge-font-size the base all Bridge text sizes scale from + * (default: your text size) + * --bridge-font-weight-heading page, dialog and section titles, plan names, prices + * --bridge-font-weight-button every Bridge button + * --bridge-font-weight-label form labels, table headings, badges, names * --bridge-overlay backdrop behind dialogs * --bridge-alert-error-{bg,fg,border} errors, critical billing notices * --bridge-alert-success-{bg,fg,border} confirmations, active plan badge @@ -47,8 +58,8 @@ * major: --bridge-primary-foreground → --bridge-primary-fg * --bridge-bg-muted → --bridge-muted-bg * - * Fonts and body text colour are not tokens: Bridge pages render inside your - * layout and inherit them. + * Font family and text colour are not tokens: Bridge pages render inside your + * layout and inherit them. Text sizes follow your (see Type above). * * State selectors: * [data-active="true"] — active tab @@ -61,1689 +72,1902 @@ * [data-variant="danger"] — danger variant */ -/* ─── Token defaults — zero specificity, so the app's :root always wins ──── */ - -:where(:root) { - /* Derived tokens (primary-hover, primary-fg, primary-light, input-focus, - muted-bg, paywall-panel-bg) have no value here on purpose: each falls back - to its source where it is used, so setting --bridge-primary on a wrapper - re-derives them for that wrapper too. */ - --bridge-primary: #4f46e5; - --bridge-bg: #ffffff; - --bridge-foreground: #111827; - --bridge-muted: #6b7280; - --bridge-border: #d1d5db; - --bridge-border-radius: 6px; - --bridge-overlay: rgba(15, 23, 42, 0.45); - --bridge-alert-error-bg: #fef2f2; - --bridge-alert-error-fg: #991b1b; - --bridge-alert-error-border: #fca5a5; - --bridge-alert-success-bg: #f0fdf4; - --bridge-alert-success-fg: #166534; - --bridge-alert-success-border: #86efac; - --bridge-alert-info-bg: #eff6ff; - --bridge-alert-info-fg: #1e40af; - --bridge-alert-info-border: #bfdbfe; - --bridge-alert-warning-bg: #fffbeb; - --bridge-alert-warning-fg: #92400e; - --bridge-alert-warning-border: #fcd34d; - - --bridge-auth-page-padding: 3rem 1rem; - --bridge-billing-page-width: 60rem; - --bridge-billing-page-padding: 3rem 1rem; - --bridge-paywall-bg: rgba(15, 23, 42, 0.72); -} +/* ─── The cascade layer (TBP-944, svelte TBP-814) ──────────────────────────── + * + * Every Bridge rule lives in the `bridge` layer, so ANY CSS your app writes + * outside a layer wins over it — whatever its specificity, whatever the load + * order, no !important. Restyle a Bridge element with plain CSS: + * + * .bridge-btn-primary:hover { transform: translate(-2px, -2px); } + * [data-bridge-plan-card] { border-width: 2px; } + * + * Write those overrides outside any @layer. CSS inside a layer ranks below + * `bridge` unless that layer is declared after it. + * + * The order statement puts `bridge` after the layers Tailwind v4 declares, so + * its base reset can never strip Bridge's buttons, whichever stylesheet loads + * first. An app without those layers is unaffected: the names stay empty. + */ +@layer theme, base, components, utilities, bridge; -/* ─── Input visual defaults ──────────────────────────────────────────────── */ +/* ─── Text size follows the app (TBP-944, svelte TBP-814) ──────────────────── */ -:where(input[type="text"], input[type="email"], input[type="password"], input[type="tel"], - .bridge-input) { - border: 1px solid var(--bridge-border); - border-radius: var(--bridge-border-radius); - outline: none; -} -:where(input[type="text"]:focus, input[type="email"]:focus, - input[type="password"]:focus, input[type="tel"]:focus, - .bridge-input:focus) { - border-color: var(--bridge-input-focus, var(--bridge-primary)); - box-shadow: 0 0 0 2px color-mix(in srgb, var(--bridge-input-focus, var(--bridge-primary)) 20%, transparent); +/* Registered so `1em` resolves where it is declared — the — and + inherits as a fixed length. Unregistered, `1em` would resolve again at every + element that reads it, and sizes would compound inside nested Bridge parts. */ +@property --bridge-text-base { + syntax: ''; + inherits: true; + initial-value: 16px; } -/* ─── Buttons ────────────────────────────────────────────────────────────── */ - -.bridge-btn, -.bridge-btn-primary, -.bridge-btn-secondary, -.bridge-btn-outline, -.bridge-btn-danger, -.bridge-btn-danger-sm { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 0.5rem; - padding: 0.5rem 1rem; - cursor: pointer; - font-family: inherit; - font-size: 0.875rem; - font-weight: 500; - line-height: 1.25; - white-space: nowrap; - transition: opacity 0.15s; -} +@layer bridge { + :where(body) { + --bridge-text-base: var(--bridge-font-size, 1em); + } -.bridge-btn:disabled, -.bridge-btn-primary:disabled, -.bridge-btn-secondary:disabled, -.bridge-btn-outline:disabled, -.bridge-btn-danger:disabled { - cursor: not-allowed; - opacity: 0.5; -} + /* ─── Token defaults — zero specificity, so the app's :root always wins ──── */ + + :where(:root) { + /* Derived tokens (primary-hover, primary-fg, primary-light, input-focus, + muted-bg, paywall-panel-bg) have no value here on purpose: each falls back + to its source where it is used, so setting --bridge-primary on a wrapper + re-derives them for that wrapper too. */ + --bridge-primary: #4f46e5; + --bridge-bg: #ffffff; + --bridge-foreground: #111827; + --bridge-muted: #6b7280; + --bridge-border: #d1d5db; + --bridge-border-radius: 6px; + --bridge-overlay: rgba(15, 23, 42, 0.45); + --bridge-alert-error-bg: #fef2f2; + --bridge-alert-error-fg: #991b1b; + --bridge-alert-error-border: #fca5a5; + --bridge-alert-success-bg: #f0fdf4; + --bridge-alert-success-fg: #166534; + --bridge-alert-success-border: #86efac; + --bridge-alert-info-bg: #eff6ff; + --bridge-alert-info-fg: #1e40af; + --bridge-alert-info-border: #bfdbfe; + --bridge-alert-warning-bg: #fffbeb; + --bridge-alert-warning-fg: #92400e; + --bridge-alert-warning-border: #fcd34d; + + --bridge-auth-page-padding: 3rem 1rem; + --bridge-billing-page-width: 60rem; + --bridge-billing-page-padding: 3rem 1rem; + --bridge-paywall-bg: rgba(15, 23, 42, 0.72); + } -.bridge-btn-danger-sm { - padding: 0.25rem 0.625rem; - font-size: 0.75rem; - cursor: pointer; -} + /* ─── Input visual defaults ──────────────────────────────────────────────── */ -/* ─── Button visual defaults ─────────────────────────────────────────────── */ + :where(input[type="text"], input[type="email"], input[type="password"], input[type="tel"], + .bridge-input) { + border: 1px solid var(--bridge-border); + border-radius: var(--bridge-border-radius); + outline: none; + } + :where(input[type="text"]:focus, input[type="email"]:focus, + input[type="password"]:focus, input[type="tel"]:focus, + .bridge-input:focus) { + border-color: var(--bridge-input-focus, var(--bridge-primary)); + box-shadow: 0 0 0 2px color-mix(in srgb, var(--bridge-input-focus, var(--bridge-primary)) 20%, transparent); + } -:where(.bridge-btn-primary) { - background-color: var(--bridge-primary); - color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); - border: 1px solid var(--bridge-primary); - border-radius: var(--bridge-border-radius); -} -:where(.bridge-btn-primary:hover:not(:disabled)) { - background-color: var(--bridge-primary-hover, color-mix(in srgb, var(--bridge-primary) 85%, #000000)); - border-color: var(--bridge-primary-hover, color-mix(in srgb, var(--bridge-primary) 85%, #000000)); -} -:where(.bridge-btn-secondary, .bridge-btn-outline) { - background-color: transparent; - color: inherit; - border: 1px solid var(--bridge-border); - border-radius: var(--bridge-border-radius); -} -:where(.bridge-btn-secondary:hover:not(:disabled), .bridge-btn-outline:hover:not(:disabled)) { - background-color: color-mix(in srgb, currentColor 5%, transparent); -} + /* ─── Buttons ────────────────────────────────────────────────────────────── */ + + .bridge-btn, + .bridge-btn-primary, + .bridge-btn-secondary, + .bridge-btn-outline, + .bridge-btn-danger, + .bridge-btn-danger-sm { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + padding: 0.5rem 1rem; + cursor: pointer; + font-family: inherit; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-button, 500); + line-height: 1.25; + white-space: nowrap; + box-shadow: var(--bridge-button-shadow, none); + transition: opacity 0.15s; + } -/* ─── Spinner ─────────────────────────────────────────────────────────────── */ + .bridge-btn:disabled, + .bridge-btn-primary:disabled, + .bridge-btn-secondary:disabled, + .bridge-btn-outline:disabled, + .bridge-btn-danger:disabled { + cursor: not-allowed; + opacity: 0.5; + } -[data-bridge-spinner] { - display: inline-block; - border: 2px solid currentColor; - border-top-color: transparent; - border-radius: 50%; - animation: bridge-spin 0.6s linear infinite; -} + .bridge-btn-danger-sm { + padding: 0.25rem 0.625rem; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + cursor: pointer; + } -@keyframes bridge-spin { - to { transform: rotate(360deg); } -} + /* ─── Button visual defaults ─────────────────────────────────────────────── */ -/* ─── Alert ───────────────────────────────────────────────────────────────── */ + :where(.bridge-btn-primary) { + background-color: var(--bridge-primary); + color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); + border: 1px solid var(--bridge-primary); + border-radius: var(--bridge-border-radius); + } + :where(.bridge-btn-primary:hover:not(:disabled)) { + background-color: var(--bridge-primary-hover, color-mix(in srgb, var(--bridge-primary) 85%, #000000)); + border-color: var(--bridge-primary-hover, color-mix(in srgb, var(--bridge-primary) 85%, #000000)); + } + :where(.bridge-btn-secondary, .bridge-btn-outline) { + background-color: transparent; + color: inherit; + border: 1px solid var(--bridge-border); + border-radius: var(--bridge-border-radius); + } + :where(.bridge-btn-secondary:hover:not(:disabled), .bridge-btn-outline:hover:not(:disabled)) { + background-color: color-mix(in srgb, currentColor 5%, transparent); + } -[data-bridge-alert] { - padding: 0.625rem 0.875rem; - font-size: 0.875rem; -} + /* ─── Spinner ─────────────────────────────────────────────────────────────── */ -:where([data-bridge-alert]) { - border-radius: var(--bridge-border-radius); - border: 1px solid var(--bridge-border); -} -:where([data-bridge-alert][data-variant="error"]) { - background-color: var(--bridge-alert-error-bg); - color: var(--bridge-alert-error-fg); - border-color: var(--bridge-alert-error-border); -} -:where([data-bridge-alert][data-variant="success"]) { - background-color: var(--bridge-alert-success-bg); - color: var(--bridge-alert-success-fg); - border-color: var(--bridge-alert-success-border); -} + [data-bridge-spinner] { + display: inline-block; + border: 2px solid currentColor; + border-top-color: transparent; + border-radius: 50%; + animation: bridge-spin 0.6s linear infinite; + } -/* ─── AuthFormWrapper ─────────────────────────────────────────────────────── */ + @keyframes bridge-spin { + to { transform: rotate(360deg); } + } -[data-bridge-auth-form] { - width: 100%; - max-width: 400px; - margin: 0 auto; -} + /* ─── Alert ───────────────────────────────────────────────────────────────── */ -[data-bridge-auth-form] label { - display: block; - margin-bottom: 0.25rem; - font-size: 0.875rem; -} + [data-bridge-alert] { + padding: 0.625rem 0.875rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -[data-bridge-auth-form] input[type="text"], -[data-bridge-auth-form] input[type="email"], -[data-bridge-auth-form] input[type="password"], -[data-bridge-auth-form] input[type="tel"] { - width: 100%; - padding: 0.5rem 0.75rem; - box-sizing: border-box; - font-size: 0.875rem; -} + :where([data-bridge-alert]) { + border-radius: var(--bridge-border-radius); + border: 1px solid var(--bridge-border); + } + :where([data-bridge-alert][data-variant="error"]) { + background-color: var(--bridge-alert-error-bg); + color: var(--bridge-alert-error-fg); + border-color: var(--bridge-alert-error-border); + } + :where([data-bridge-alert][data-variant="success"]) { + background-color: var(--bridge-alert-success-bg); + color: var(--bridge-alert-success-fg); + border-color: var(--bridge-alert-success-border); + } -[data-bridge-auth-form] .bridge-btn, -[data-bridge-auth-form] .bridge-btn-primary, -[data-bridge-auth-form] .bridge-btn-secondary, -[data-bridge-auth-form] [data-bridge-passkey-login] { - width: 100%; - display: flex; - align-items: center; - justify-content: center; - gap: 0.5rem; - box-sizing: border-box; -} + /* ─── AuthFormWrapper ─────────────────────────────────────────────────────── */ -[data-bridge-auth-form] .bridge-form-group { - margin-bottom: 1rem; -} + [data-bridge-auth-form] { + width: 100%; + max-width: 400px; + margin: 0 auto; + } -[data-bridge-auth-form] .bridge-form-footer { - margin-top: 1rem; - text-align: center; - font-size: 0.875rem; -} + [data-bridge-auth-form] label { + display: block; + margin-bottom: 0.25rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -/* TBP-899 — every text link on the sign-in pages ("Sign up", "Forgot password?", - "Back to sign in") takes the form's own text colour and font, not the - browser's default blue. */ -[data-bridge-auth-form] .bridge-form-footer a, -[data-bridge-auth-form] .bridge-link { - cursor: pointer; - background: none; - border: none; - color: inherit; - font-family: inherit; - font-size: inherit; - font-weight: inherit; - padding: 0; - text-decoration: underline; - text-underline-offset: 0.2em; -} + [data-bridge-auth-form] input[type="text"], + [data-bridge-auth-form] input[type="email"], + [data-bridge-auth-form] input[type="password"], + [data-bridge-auth-form] input[type="tel"] { + width: 100%; + padding: 0.5rem 0.75rem; + box-sizing: border-box; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -[data-bridge-auth-form] .bridge-divider { - display: flex; - align-items: center; - margin: 1rem 0; - font-size: 0.75rem; - text-transform: uppercase; - letter-spacing: 0.05em; -} + [data-bridge-auth-form] .bridge-btn, + [data-bridge-auth-form] .bridge-btn-primary, + [data-bridge-auth-form] .bridge-btn-secondary, + [data-bridge-auth-form] [data-bridge-passkey-login] { + width: 100%; + display: flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + box-sizing: border-box; + } -[data-bridge-auth-form] .bridge-divider::before, -[data-bridge-auth-form] .bridge-divider::after { - content: ''; - flex: 1; - border-bottom: 1px solid; -} + [data-bridge-auth-form] .bridge-form-group { + margin-bottom: 1rem; + } -[data-bridge-auth-form] .bridge-divider::before { margin-right: 0.5rem; } -[data-bridge-auth-form] .bridge-divider::after { margin-left: 0.5rem; } + [data-bridge-auth-form] .bridge-form-footer { + margin-top: 1rem; + text-align: center; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -/* ─── PasskeyLogin ────────────────────────────────────────────────────────── */ + /* TBP-899 — every text link on the sign-in pages ("Sign up", "Forgot password?", + "Back to sign in") takes the form's own text colour and font, not the + browser's default blue. */ + [data-bridge-auth-form] .bridge-form-footer a, + [data-bridge-auth-form] .bridge-link { + cursor: pointer; + background: none; + border: none; + color: inherit; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + padding: 0; + text-decoration: underline; + text-underline-offset: 0.2em; + } -[data-bridge-passkey-login] { - display: flex; - align-items: center; - justify-content: center; - gap: 0.5rem; - cursor: pointer; - font-family: inherit; - font-size: 0.875rem; -} + [data-bridge-auth-form] .bridge-divider { + display: flex; + align-items: center; + margin: 1rem 0; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + text-transform: uppercase; + letter-spacing: 0.05em; + } -[data-bridge-passkey-login][data-loading="true"] { - cursor: not-allowed; - opacity: 0.5; -} + [data-bridge-auth-form] .bridge-divider::before, + [data-bridge-auth-form] .bridge-divider::after { + content: ''; + flex: 1; + border-bottom: 1px solid; + } -/* ─── SsoButton ──────────────────────────────────────────────────────────── */ - -[data-bridge-sso-button] { - display: flex; - align-items: center; - justify-content: center; - gap: 0.5rem; - width: 100%; - cursor: pointer; - font-family: inherit; - font-size: 0.875rem; - padding: 0.5rem 1rem; - box-sizing: border-box; -} + [data-bridge-auth-form] .bridge-divider::before { margin-right: 0.5rem; } + [data-bridge-auth-form] .bridge-divider::after { margin-left: 0.5rem; } -/* ─── Password visibility toggle ─────────────────────────────────────────── */ + /* ─── PasskeyLogin ────────────────────────────────────────────────────────── */ -.bridge-password-wrapper { - position: relative; -} + [data-bridge-passkey-login] { + display: flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + cursor: pointer; + font-family: inherit; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-password-wrapper input { - padding-right: 2.5rem; -} + [data-bridge-passkey-login][data-loading="true"] { + cursor: not-allowed; + opacity: 0.5; + } -.bridge-password-toggle { - position: absolute; - right: 0.5rem; - top: 50%; - transform: translateY(-50%); - display: flex; - align-items: center; - justify-content: center; - background: none; - border: none; - cursor: pointer; - padding: 0.25rem; - color: var(--bridge-muted); - line-height: 1; -} + /* ─── SsoButton ──────────────────────────────────────────────────────────── */ + + [data-bridge-sso-button] { + display: flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + width: 100%; + cursor: pointer; + font-family: inherit; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + padding: 0.5rem 1rem; + box-sizing: border-box; + } -.bridge-password-toggle:hover { - color: var(--bridge-foreground); -} + /* ─── Password visibility toggle ─────────────────────────────────────────── */ -/* ─── Auth form helpers ───────────────────────────────────────────────────── */ + .bridge-password-wrapper { + position: relative; + } -.bridge-sso-row { - margin-bottom: 0.5rem; -} + .bridge-password-wrapper input { + padding-right: 2.5rem; + } -.bridge-sso-btn { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - box-sizing: border-box; -} + .bridge-password-toggle { + position: absolute; + right: 0.5rem; + top: 50%; + transform: translateY(-50%); + display: flex; + align-items: center; + justify-content: center; + background: none; + border: none; + cursor: pointer; + padding: 0.25rem; + color: var(--bridge-muted); + line-height: 1; + } -/* TBP-899 — a sign-in method drawn as a link (the magic-link button) looks - like the other method buttons: no underline, no link colour. */ -a.bridge-btn, -a.bridge-btn:hover, -a.bridge-btn:visited { - text-decoration: none; -} + .bridge-password-toggle:hover { + color: var(--bridge-foreground); + } -a.bridge-sso-btn, -a.bridge-sso-btn:visited { - color: inherit; -} + /* ─── Auth form helpers ───────────────────────────────────────────────────── */ -.bridge-sso-btn-inner { - display: flex; - align-items: center; - gap: 0.75rem; - width: 12rem; - /* TBP-899 — grows past 12rem when the app's button text is larger, instead - of squeezing the method icon to nothing. */ - min-width: max-content; -} + .bridge-sso-row { + margin-bottom: 0.5rem; + } -.bridge-sso-btn-inner > :not(:last-child) { - flex-shrink: 0; -} + .bridge-sso-btn { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + box-sizing: border-box; + } -.bridge-step-desc { - font-size: 0.875rem; - margin: 0 0 1rem; -} + /* TBP-899 — a sign-in method drawn as a link (the magic-link button) looks + like the other method buttons: no underline, no link colour. */ + a.bridge-btn, + a.bridge-btn:hover, + a.bridge-btn:visited { + text-decoration: none; + } -/* TBP-635 — the card between a successful sign-in and the host app navigating. */ -.bridge-auth-settling { - display: flex; - align-items: center; - justify-content: center; - gap: 0.75rem; - /* Roughly the height of the credentials form it replaces, so the card does - not collapse and then re-expand under the cursor. */ - min-height: 8rem; - color: var(--bridge-muted); - font-size: 0.875rem; -} + a.bridge-sso-btn, + a.bridge-sso-btn:visited { + color: inherit; + } -.bridge-mfa-help { - font-size: 0.8125rem; - color: var(--bridge-muted); - margin: 0.75rem 0 0.25rem; - text-align: center; -} + .bridge-sso-btn-inner { + display: flex; + align-items: center; + gap: 0.75rem; + width: 12rem; + /* TBP-899 — grows past 12rem when the app's button text is larger, instead + of squeezing the method icon to nothing. */ + min-width: max-content; + } -.bridge-email-display { - display: flex; - align-items: center; - justify-content: space-between; - padding: 0.5rem 0.75rem; - font-size: 0.875rem; -} + .bridge-sso-btn-inner > :not(:last-child) { + flex-shrink: 0; + } -.bridge-forgot-row { - margin-top: 0.5rem; - text-align: right; - font-size: 0.875rem; -} + .bridge-step-desc { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + margin: 0 0 1rem; + } -.bridge-success-heading { - font-size: 1.25rem; - font-weight: 600; - text-align: center; - margin: 0 0 0.5rem; -} + /* TBP-635 — the card between a successful sign-in and the host app navigating. */ + .bridge-auth-settling { + display: flex; + align-items: center; + justify-content: center; + gap: 0.75rem; + /* Roughly the height of the credentials form it replaces, so the card does + not collapse and then re-expand under the cursor. */ + min-height: 8rem; + color: var(--bridge-muted); + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -/* ─── MfaSetup backup code ───────────────────────────────────────────────── */ + .bridge-mfa-help { + font-size: calc(0.8125 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + margin: 0.75rem 0 0.25rem; + text-align: center; + } -.bridge-backup-code { - display: flex; - align-items: center; - gap: 0.75rem; - margin-bottom: 1rem; - padding: 0.75rem; - background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); - border-radius: 0.5rem; -} + .bridge-email-display { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0.5rem 0.75rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-backup-code code { - flex: 1; - font-size: 1.125rem; - font-family: monospace; - letter-spacing: 0.05em; - white-space: nowrap; -} + .bridge-forgot-row { + margin-top: 0.5rem; + text-align: right; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -/* ─── TenantSelector ─────────────────────────────────────────────────────── */ + .bridge-success-heading { + font-size: calc(1.25 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + text-align: center; + margin: 0 0 0.5rem; + } -.bridge-tenant-list { - display: flex; - flex-direction: column; - gap: 0.5rem; -} + /* ─── MfaSetup backup code ───────────────────────────────────────────────── */ -.bridge-tenant-item { - display: flex; - align-items: center; - gap: 0.75rem; - padding: 0.75rem; - cursor: pointer; - text-align: left; - width: 100%; - font-family: inherit; -} + .bridge-backup-code { + display: flex; + align-items: center; + gap: 0.75rem; + margin-bottom: 1rem; + padding: 0.75rem; + background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); + border-radius: 0.5rem; + } -.bridge-tenant-item:disabled, -.bridge-tenant-item[data-loading="true"] { - opacity: 0.5; - cursor: not-allowed; -} + .bridge-backup-code code { + flex: 1; + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-family: monospace; + letter-spacing: 0.05em; + white-space: nowrap; + } -.bridge-tenant-avatar { - width: 36px; - height: 36px; - border-radius: 50%; - display: flex; - align-items: center; - justify-content: center; - font-size: 0.875rem; - font-weight: 600; - flex-shrink: 0; - overflow: hidden; -} + /* ─── TenantSelector ─────────────────────────────────────────────────────── */ -.bridge-tenant-avatar img { - width: 100%; - height: 100%; - object-fit: cover; -} + .bridge-tenant-list { + display: flex; + flex-direction: column; + gap: 0.5rem; + } -.bridge-tenant-info { - display: flex; - flex-direction: column; - flex: 1; - min-width: 0; -} + .bridge-tenant-item { + display: flex; + align-items: center; + gap: 0.75rem; + padding: 0.75rem; + cursor: pointer; + text-align: left; + width: 100%; + font-family: inherit; + } -.bridge-tenant-name { - font-size: 0.875rem; - font-weight: 500; -} + .bridge-tenant-item:disabled, + .bridge-tenant-item[data-loading="true"] { + opacity: 0.5; + cursor: not-allowed; + } -.bridge-tenant-user { - font-size: 0.75rem; -} + .bridge-tenant-avatar { + width: 36px; + height: 36px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: 600; + flex-shrink: 0; + overflow: hidden; + } -/* ─── TeamManagementPanel ────────────────────────────────────────────────── */ + .bridge-tenant-avatar img { + width: 100%; + height: 100%; + object-fit: cover; + } -.bridge-team-tabs { - display: flex; - margin-bottom: 1.5rem; -} + .bridge-tenant-info { + display: flex; + flex-direction: column; + flex: 1; + min-width: 0; + } -.bridge-team-tab { - padding: 0.75rem 1rem; - border: none; - background: transparent; - font-size: 0.875rem; - cursor: pointer; - font-family: inherit; -} + .bridge-tenant-name { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 500); + } -:where(.bridge-team-tabs) { - border-bottom: 1px solid var(--bridge-border); -} + .bridge-tenant-user { + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + } -:where(.bridge-team-tab) { - color: var(--bridge-muted); -} + /* ─── TeamManagementPanel ────────────────────────────────────────────────── */ -:where(.bridge-team-tab[data-active="true"]) { - color: var(--bridge-primary); - box-shadow: inset 0 -2px 0 var(--bridge-primary); -} + .bridge-team-tabs { + display: flex; + margin-bottom: 1.5rem; + } -/* ─── TeamUserList ───────────────────────────────────────────────────────── */ + .bridge-team-tab { + padding: 0.75rem 1rem; + border: none; + background: transparent; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + cursor: pointer; + font-family: inherit; + } -.bridge-team-users-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 1rem; -} + :where(.bridge-team-tabs) { + border-bottom: 1px solid var(--bridge-border); + } -.bridge-team-users-title { - margin: 0; - font-size: 1.125rem; - font-weight: 600; -} + :where(.bridge-team-tab) { + color: var(--bridge-muted); + } -.bridge-team-loading { - display: flex; - align-items: center; - justify-content: center; - gap: 0.75rem; - padding: 3rem 1rem; - font-size: 0.875rem; -} + :where(.bridge-team-tab[data-active="true"]) { + color: var(--bridge-primary); + box-shadow: inset 0 -2px 0 var(--bridge-primary); + } -.bridge-team-empty { - text-align: center; - padding: 3rem 1rem; -} + /* ─── TeamUserList ───────────────────────────────────────────────────────── */ -.bridge-team-empty p { - margin: 0 0 1rem; -} + .bridge-team-users-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 1rem; + } -.bridge-team-table-wrapper { - overflow-x: auto; -} + .bridge-team-users-title { + margin: 0; + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -.bridge-team-table { - width: 100%; - border-collapse: collapse; - font-size: 0.875rem; -} + .bridge-team-loading { + display: flex; + align-items: center; + justify-content: center; + gap: 0.75rem; + padding: 3rem 1rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-team-table th { - text-align: left; - padding: 0.75rem 1rem; - font-weight: 500; - font-size: 0.75rem; - text-transform: uppercase; - letter-spacing: 0.05em; -} + .bridge-team-empty { + text-align: center; + padding: 3rem 1rem; + } -.bridge-team-table td { - padding: 0.75rem 1rem; - vertical-align: middle; -} + .bridge-team-empty p { + margin: 0 0 1rem; + } -.bridge-team-user-cell { - display: flex; - flex-direction: column; -} + .bridge-team-table-wrapper { + overflow-x: auto; + } -.bridge-team-user-name { font-weight: 500; } + .bridge-team-table { + width: 100%; + border-collapse: collapse; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-team-user-email { font-size: 0.75rem; } + .bridge-team-table th { + text-align: left; + padding: 0.75rem 1rem; + font-weight: var(--bridge-font-weight-label, 500); + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + text-transform: uppercase; + letter-spacing: 0.05em; + } -.bridge-team-badge { - display: inline-block; - padding: 0.125rem 0.5rem; - font-size: 0.75rem; -} + .bridge-team-table td { + padding: 0.75rem 1rem; + vertical-align: middle; + } -.bridge-team-status { - display: inline-block; - padding: 0.125rem 0.5rem; - font-size: 0.75rem; -} + .bridge-team-user-cell { + display: flex; + flex-direction: column; + } -.bridge-team-actions-cell { - width: 48px; - text-align: right; -} + .bridge-team-user-name { font-weight: var(--bridge-font-weight-label, 500); } -/* ─── TeamProfileForm / TeamWorkspaceForm ────────────────────────────────── */ + .bridge-team-user-email { font-size: calc(0.75 * var(--bridge-text-base, 1rem)); } -.bridge-team-section-title { - margin: 0 0 1.5rem; - font-size: 1.125rem; - font-weight: 600; -} + .bridge-team-badge { + display: inline-block; + padding: 0.125rem 0.5rem; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + } -.bridge-team-alert { - margin-bottom: 1rem; -} + .bridge-team-status { + display: inline-block; + padding: 0.125rem 0.5rem; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + } -.bridge-team-form { - display: flex; - flex-direction: column; -} + .bridge-team-actions-cell { + width: 48px; + text-align: right; + } -.bridge-team-form-group { - margin-bottom: 1rem; -} + /* ─── TeamProfileForm / TeamWorkspaceForm ────────────────────────────────── */ -.bridge-team-form-group label { - display: block; - margin-bottom: 0.25rem; - font-size: 0.875rem; -} + .bridge-team-section-title { + margin: 0 0 1.5rem; + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -.bridge-team-form-group input, -.bridge-team-form-group select, -.bridge-team-form-group textarea { - width: 100%; - padding: 0.5rem 0.75rem; - font-size: 0.875rem; - font-family: inherit; - box-sizing: border-box; -} + .bridge-team-alert { + margin-bottom: 1rem; + } -.bridge-team-form-group textarea { - resize: vertical; -} + .bridge-team-form { + display: flex; + flex-direction: column; + } -.bridge-team-form-row { - display: grid; - grid-template-columns: 1fr 1fr; - gap: 1rem; -} + .bridge-team-form-group { + margin-bottom: 1rem; + } -.bridge-team-readonly { - padding: 0.5rem 0; - font-size: 0.875rem; -} + .bridge-team-form-group label { + display: block; + margin-bottom: 0.25rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-team-form-actions { - margin-top: 0.5rem; -} + .bridge-team-form-group input, + .bridge-team-form-group select, + .bridge-team-form-group textarea { + width: 100%; + padding: 0.5rem 0.75rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-family: inherit; + box-sizing: border-box; + } -.bridge-team-logo { - margin-bottom: 1.5rem; -} + .bridge-team-form-group textarea { + resize: vertical; + } -.bridge-team-logo img { - max-width: 120px; - max-height: 60px; - object-fit: contain; -} + .bridge-team-form-row { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 1rem; + } -.bridge-team-checkbox-label { - display: flex !important; - align-items: center; - gap: 0.5rem; - cursor: pointer; -} + .bridge-team-readonly { + padding: 0.5rem 0; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-team-checkbox-label input[type="checkbox"] { - width: 1rem; - height: 1rem; -} + .bridge-team-form-actions { + margin-top: 0.5rem; + } -/* ─── TeamUserActionsMenu ────────────────────────────────────────────────── */ + .bridge-team-logo { + margin-bottom: 1.5rem; + } -.bridge-team-actions { - position: relative; - display: inline-block; -} + .bridge-team-logo img { + max-width: 120px; + max-height: 60px; + object-fit: contain; + } -.bridge-team-actions-trigger { - display: flex; - align-items: center; - justify-content: center; - width: 32px; - height: 32px; - border: none; - background: transparent; - cursor: pointer; -} + .bridge-team-checkbox-label { + display: flex !important; + align-items: center; + gap: 0.5rem; + cursor: pointer; + } -.bridge-team-actions-menu { - position: absolute; - right: 0; - top: 100%; - z-index: 10; - min-width: 160px; -} + .bridge-team-checkbox-label input[type="checkbox"] { + width: 1rem; + height: 1rem; + } -:where(.bridge-team-actions-menu) { - background: var(--bridge-bg); - color: var(--bridge-foreground); - border: 1px solid var(--bridge-border); - border-radius: var(--bridge-border-radius); -} + /* ─── TeamUserActionsMenu ────────────────────────────────────────────────── */ -:where(.bridge-team-table th) { - color: var(--bridge-muted); - border-bottom: 1px solid var(--bridge-border); -} + .bridge-team-actions { + position: relative; + display: inline-block; + } -:where(.bridge-team-table td) { - border-bottom: 1px solid var(--bridge-border); -} + .bridge-team-actions-trigger { + display: flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + border: none; + background: transparent; + cursor: pointer; + } -.bridge-team-actions-item { - display: block; - width: 100%; - padding: 0.5rem 0.75rem; - border: none; - background: transparent; - font-size: 0.875rem; - text-align: left; - cursor: pointer; - font-family: inherit; -} + .bridge-team-actions-menu { + position: absolute; + right: 0; + top: 100%; + z-index: 10; + min-width: 160px; + } -/* ─── Team Dialogs ───────────────────────────────────────────────────────── */ + :where(.bridge-team-actions-menu) { + background: var(--bridge-bg); + color: var(--bridge-foreground); + border: 1px solid var(--bridge-border); + border-radius: var(--bridge-border-radius); + } -/* The team dialogs carry [data-bridge-team-dialog]; the upgrade dialog the class. */ -.bridge-team-dialog, -[data-bridge-team-dialog] { - border: none; - padding: 0; - max-width: 400px; - width: 90%; -} + :where(.bridge-team-table th) { + color: var(--bridge-muted); + border-bottom: 1px solid var(--bridge-border); + } -:where(.bridge-team-dialog, [data-bridge-team-dialog]) { - background: var(--bridge-bg); - color: var(--bridge-foreground); - border-radius: var(--bridge-border-radius); -} + :where(.bridge-team-table td) { + border-bottom: 1px solid var(--bridge-border); + } -.bridge-team-dialog::backdrop, -[data-bridge-team-dialog]::backdrop { - background: var(--bridge-overlay); -} + .bridge-team-actions-item { + display: block; + width: 100%; + padding: 0.5rem 0.75rem; + border: none; + background: transparent; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + text-align: left; + cursor: pointer; + font-family: inherit; + } -.bridge-team-dialog-content { - padding: 1.5rem; -} + /* ─── Team Dialogs ───────────────────────────────────────────────────────── */ -.bridge-team-dialog-title { - margin: 0 0 0.5rem; - font-size: 1.125rem; - font-weight: 600; -} + /* The team dialogs carry [data-bridge-team-dialog]; the upgrade dialog the class. */ + .bridge-team-dialog, + [data-bridge-team-dialog] { + border: none; + padding: 0; + max-width: 400px; + width: 90%; + } -.bridge-team-dialog-message, -.bridge-team-dialog-subtitle { - margin: 0 0 1rem; - font-size: 0.875rem; -} + :where(.bridge-team-dialog, [data-bridge-team-dialog]) { + background: var(--bridge-bg); + color: var(--bridge-foreground); + border-radius: var(--bridge-border-radius); + } -.bridge-team-dialog-error { - margin-bottom: 1rem; -} + .bridge-team-dialog::backdrop, + [data-bridge-team-dialog]::backdrop { + background: var(--bridge-overlay); + } -.bridge-team-dialog-actions { - display: flex; - justify-content: flex-end; - gap: 0.5rem; -} + .bridge-team-dialog-content { + padding: 1.5rem; + } -/* ─── ApiTokenManagement ─────────────────────────────────────────────────── */ + .bridge-team-dialog-title { + margin: 0 0 0.5rem; + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -[data-bridge-api-tokens] { - display: flex; - flex-direction: column; - gap: 1.5rem; -} + .bridge-team-dialog-message, + .bridge-team-dialog-subtitle { + margin: 0 0 1rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -[data-bridge-api-tokens] .bridge-api-header { - display: flex; - align-items: center; - justify-content: space-between; - padding-bottom: 1rem; -} + .bridge-team-dialog-error { + margin-bottom: 1rem; + } -[data-bridge-api-tokens] .bridge-api-title { - font-size: 1.25rem; - font-weight: 600; - margin: 0; -} + .bridge-team-dialog-actions { + display: flex; + justify-content: flex-end; + gap: 0.5rem; + } -[data-bridge-api-tokens] .bridge-api-subtitle { - font-size: 0.875rem; - margin: 0.25rem 0 0; -} + /* ─── ApiTokenManagement ─────────────────────────────────────────────────── */ -[data-bridge-api-tokens] .bridge-api-error-banner, -[data-bridge-api-tokens] .bridge-api-success-banner { - padding: 0.75rem; - font-size: 0.875rem; -} + [data-bridge-api-tokens] { + display: flex; + flex-direction: column; + gap: 1.5rem; + } -[data-bridge-api-tokens] .bridge-api-new-token-banner { - padding: 1rem; - display: flex; - flex-direction: column; - gap: 0.75rem; -} + [data-bridge-api-tokens] .bridge-api-header { + display: flex; + align-items: center; + justify-content: space-between; + padding-bottom: 1rem; + } -[data-bridge-api-tokens] .bridge-api-new-token-warning { - font-size: 0.875rem; - font-weight: 500; - margin: 0; -} + [data-bridge-api-tokens] .bridge-api-title { + font-size: calc(1.25 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + margin: 0; + } -[data-bridge-api-tokens] .bridge-api-new-token-row { - display: flex; - align-items: center; - gap: 0.5rem; -} + [data-bridge-api-tokens] .bridge-api-subtitle { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + margin: 0.25rem 0 0; + } -[data-bridge-api-tokens] .bridge-api-token-input { - font-family: monospace; - font-size: 0.875rem; - flex: 1; -} + [data-bridge-api-tokens] .bridge-api-error-banner, + [data-bridge-api-tokens] .bridge-api-success-banner { + padding: 0.75rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -[data-bridge-api-tokens] .bridge-api-empty { - text-align: center; - padding: 2.5rem 1rem; - font-size: 0.875rem; -} + [data-bridge-api-tokens] .bridge-api-new-token-banner { + padding: 1rem; + display: flex; + flex-direction: column; + gap: 0.75rem; + } -[data-bridge-api-tokens][data-loading="true"] .bridge-api-empty { - opacity: 0.6; -} + [data-bridge-api-tokens] .bridge-api-new-token-warning { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 500); + margin: 0; + } -[data-bridge-api-tokens] .bridge-api-table { - width: 100%; - font-size: 0.875rem; - border-collapse: collapse; -} + [data-bridge-api-tokens] .bridge-api-new-token-row { + display: flex; + align-items: center; + gap: 0.5rem; + } -[data-bridge-api-tokens] .bridge-api-th { - padding: 0.75rem 1rem; - font-size: 0.75rem; - text-transform: uppercase; - letter-spacing: 0.05em; - font-weight: 500; - text-align: left; - border-bottom: 1px solid var(--bridge-border); - color: var(--bridge-muted); -} + [data-bridge-api-tokens] .bridge-api-token-input { + font-family: monospace; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + flex: 1; + } -[data-bridge-api-tokens] .bridge-api-td, -[data-bridge-api-tokens] .bridge-api-td-name, -[data-bridge-api-tokens] .bridge-api-td-muted { - padding: 0.75rem 1rem; - border-bottom: 1px solid var(--bridge-border); -} + [data-bridge-api-tokens] .bridge-api-empty { + text-align: center; + padding: 2.5rem 1rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -[data-bridge-api-tokens] .bridge-api-td-muted { - color: var(--bridge-muted); -} + [data-bridge-api-tokens][data-loading="true"] .bridge-api-empty { + opacity: 0.6; + } -[data-bridge-api-tokens] .bridge-api-td-actions { - padding: 0.75rem 1rem; - text-align: right; - border-bottom: 1px solid var(--bridge-border); -} + [data-bridge-api-tokens] .bridge-api-table { + width: 100%; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + border-collapse: collapse; + } -[data-bridge-api-tokens] .bridge-api-privileges { - display: flex; - flex-wrap: wrap; - gap: 0.25rem; -} + [data-bridge-api-tokens] .bridge-api-th { + padding: 0.75rem 1rem; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + text-transform: uppercase; + letter-spacing: 0.05em; + font-weight: var(--bridge-font-weight-label, 500); + text-align: left; + border-bottom: 1px solid var(--bridge-border); + color: var(--bridge-muted); + } -[data-bridge-api-tokens] .bridge-api-inline-form { - border: 1px solid var(--bridge-border); - border-radius: 0.5rem; - padding: 1rem 1.25rem; -} + [data-bridge-api-tokens] .bridge-api-td, + [data-bridge-api-tokens] .bridge-api-td-name, + [data-bridge-api-tokens] .bridge-api-td-muted { + padding: 0.75rem 1rem; + border-bottom: 1px solid var(--bridge-border); + } -[data-bridge-api-tokens] .bridge-api-inline-form-title { - font-size: 0.9375rem; - font-weight: 600; - margin: 0 0 0.875rem; -} + [data-bridge-api-tokens] .bridge-api-td-muted { + color: var(--bridge-muted); + } -[data-bridge-api-tokens] .bridge-api-inline-form-fields { - display: flex; - flex-direction: column; - gap: 0.75rem; -} + [data-bridge-api-tokens] .bridge-api-td-actions { + padding: 0.75rem 1rem; + text-align: right; + border-bottom: 1px solid var(--bridge-border); + } -[data-bridge-api-tokens] .bridge-api-inline-form-row { - display: flex; - gap: 1rem; - flex-wrap: wrap; - align-items: flex-start; -} + [data-bridge-api-tokens] .bridge-api-privileges { + display: flex; + flex-wrap: wrap; + gap: 0.25rem; + } -[data-bridge-api-tokens] .bridge-api-inline-field { - display: flex; - flex-direction: column; - flex: 1 1 160px; - min-width: 0; -} + [data-bridge-api-tokens] .bridge-api-inline-form { + border: 1px solid var(--bridge-border); + border-radius: 0.5rem; + padding: 1rem 1.25rem; + } -[data-bridge-api-tokens] .bridge-api-inline-field--narrow { - flex: 0 1 160px; -} + [data-bridge-api-tokens] .bridge-api-inline-form-title { + font-size: calc(0.9375 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + margin: 0 0 0.875rem; + } -[data-bridge-api-tokens] .bridge-api-inline-form-actions { - display: flex; - gap: 0.5rem; - justify-content: flex-end; - padding-top: 0.25rem; -} + [data-bridge-api-tokens] .bridge-api-inline-form-fields { + display: flex; + flex-direction: column; + gap: 0.75rem; + } -[data-bridge-api-tokens] .bridge-api-hint { - font-size: 0.75rem; - margin: 0.25rem 0 0; -} + [data-bridge-api-tokens] .bridge-api-inline-form-row { + display: flex; + gap: 1rem; + flex-wrap: wrap; + align-items: flex-start; + } -[data-bridge-api-tokens] .bridge-api-required { - /* intentionally unstyled — consumer should color this */ -} + [data-bridge-api-tokens] .bridge-api-inline-field { + display: flex; + flex-direction: column; + flex: 1 1 160px; + min-width: 0; + } -[data-bridge-api-tokens] .bridge-api-form-error { - font-size: 0.875rem; -} + [data-bridge-api-tokens] .bridge-api-inline-field--narrow { + flex: 0 1 160px; + } -[data-bridge-api-tokens] .bridge-privilege-picker { position: relative; } -[data-bridge-api-tokens] .bridge-privilege-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; min-height: 2.25rem; cursor: pointer; padding: 0.375rem 0.5rem; align-items: center; } -[data-bridge-api-tokens] .bridge-privilege-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; font-size: 0.75rem; } -[data-bridge-api-tokens] .bridge-privilege-chip button { background: none; border: none; cursor: pointer; padding: 0; line-height: 1; } -[data-bridge-api-tokens] .bridge-privilege-placeholder { font-size: 0.875rem; } -[data-bridge-api-tokens] .bridge-privilege-dropdown { position: absolute; z-index: 20; width: 100%; max-height: 200px; overflow-y: auto; top: 100%; left: 0; } -[data-bridge-api-tokens] .bridge-privilege-search { display: block; width: 100%; padding: 0.375rem 0.5rem; font-size: 0.875rem; font-family: inherit; box-sizing: border-box; border: none; border-bottom: 1px solid; outline: none; } -[data-bridge-api-tokens] .bridge-privilege-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 0.375rem 0.75rem; background: none; border: none; cursor: pointer; text-align: left; font-family: inherit; } -[data-bridge-api-tokens] .bridge-privilege-option-key { font-size: 0.875rem; font-weight: 500; } -[data-bridge-api-tokens] .bridge-privilege-option-desc { font-size: 0.75rem; } -[data-bridge-api-tokens] .bridge-privilege-empty { padding: 0.5rem 0.75rem; font-size: 0.875rem; } - -.bridge-input { - display: block; - width: 100%; - padding: 0.5rem 0.75rem; - font-size: 0.875rem; - font-family: inherit; - box-sizing: border-box; -} + [data-bridge-api-tokens] .bridge-api-inline-form-actions { + display: flex; + gap: 0.5rem; + justify-content: flex-end; + padding-top: 0.25rem; + } -.bridge-label { - display: block; - font-size: 0.875rem; - font-weight: 500; - margin-bottom: 0.375rem; -} + [data-bridge-api-tokens] .bridge-api-hint { + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + margin: 0.25rem 0 0; + } -.bridge-badge { - display: inline-block; - padding: 0.125rem 0.5rem; - font-size: 0.7rem; - font-family: monospace; -} + [data-bridge-api-tokens] .bridge-api-required { + /* intentionally unstyled — consumer should color this */ + } -.bridge-dialog-overlay { - position: fixed; - inset: 0; - z-index: 50; -} + [data-bridge-api-tokens] .bridge-api-form-error { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-dialog { - position: fixed; - z-index: 51; - left: 50%; - top: 25%; - transform: translateX(-50%); - padding: 1.5rem; - width: 90vw; - max-width: 400px; -} + [data-bridge-api-tokens] .bridge-privilege-picker { position: relative; } + [data-bridge-api-tokens] .bridge-privilege-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; min-height: 2.25rem; cursor: pointer; padding: 0.375rem 0.5rem; align-items: center; } + [data-bridge-api-tokens] .bridge-privilege-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; font-size: calc(0.75 * var(--bridge-text-base, 1rem)); } + [data-bridge-api-tokens] .bridge-privilege-chip button { background: none; border: none; cursor: pointer; padding: 0; line-height: 1; } + [data-bridge-api-tokens] .bridge-privilege-placeholder { font-size: calc(0.875 * var(--bridge-text-base, 1rem)); } + [data-bridge-api-tokens] .bridge-privilege-dropdown { position: absolute; z-index: 20; width: 100%; max-height: 200px; overflow-y: auto; top: 100%; left: 0; } + [data-bridge-api-tokens] .bridge-privilege-search { display: block; width: 100%; padding: 0.375rem 0.5rem; font-size: calc(0.875 * var(--bridge-text-base, 1rem)); font-family: inherit; box-sizing: border-box; border: none; border-bottom: 1px solid; outline: none; } + [data-bridge-api-tokens] .bridge-privilege-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 0.375rem 0.75rem; background: none; border: none; cursor: pointer; text-align: left; font-family: inherit; } + [data-bridge-api-tokens] .bridge-privilege-option-key { font-size: calc(0.875 * var(--bridge-text-base, 1rem)); font-weight: var(--bridge-font-weight-label, 500); } + [data-bridge-api-tokens] .bridge-privilege-option-desc { font-size: calc(0.75 * var(--bridge-text-base, 1rem)); } + [data-bridge-api-tokens] .bridge-privilege-empty { padding: 0.5rem 0.75rem; font-size: calc(0.875 * var(--bridge-text-base, 1rem)); } + + .bridge-input { + display: block; + width: 100%; + padding: 0.5rem 0.75rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-family: inherit; + box-sizing: border-box; + } -.bridge-dialog-title { - font-size: 1.125rem; - font-weight: 600; - margin: 0 0 0.5rem 0; -} + .bridge-label { + display: block; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 500); + margin-bottom: 0.375rem; + } -.bridge-dialog-body { - font-size: 0.875rem; - margin: 0 0 1.25rem 0; -} + .bridge-badge { + display: inline-block; + padding: 0.125rem 0.5rem; + font-size: calc(0.7 * var(--bridge-text-base, 1rem)); + font-family: monospace; + } -.bridge-dialog-footer { - display: flex; - justify-content: flex-end; - gap: 0.5rem; -} + .bridge-dialog-overlay { + position: fixed; + inset: 0; + z-index: 50; + } -/* ─── PlanSelector ───────────────────────────────────────────────────────── */ + .bridge-dialog { + position: fixed; + z-index: 51; + left: 50%; + top: 25%; + transform: translateX(-50%); + padding: 1.5rem; + width: 90vw; + max-width: 400px; + } -[data-bridge-plan-selector] { - position: relative; -} + .bridge-dialog-title { + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + margin: 0 0 0.5rem 0; + } -[data-bridge-plan-selector][data-loading="true"] { - pointer-events: none; - opacity: 0.7; -} + .bridge-dialog-body { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + margin: 0 0 1.25rem 0; + } -.bridge-plan-loading { - display: flex; - align-items: center; - justify-content: center; - padding: 3rem 1rem; -} + .bridge-dialog-footer { + display: flex; + justify-content: flex-end; + gap: 0.5rem; + } -.bridge-plan-empty { - text-align: center; - padding: 2rem 1rem; - font-size: 0.875rem; -} + /* ─── PlanSelector ───────────────────────────────────────────────────────── */ -.bridge-plan-payment-failed { - margin-bottom: 1.5rem; -} + [data-bridge-plan-selector] { + position: relative; + } -.bridge-plan-portal-btn { - margin-top: 0.75rem; -} + [data-bridge-plan-selector][data-loading="true"] { + pointer-events: none; + opacity: 0.7; + } -.bridge-plan-interval-tabs { - /* Centered above the plan cards; flex + fit-content (not inline-flex) so - auto margins can center it regardless of the host page's text alignment. */ - display: flex; - width: fit-content; - margin-inline: auto; - gap: 0.25rem; - margin-bottom: 1.25rem; - padding: 0.25rem; - border: 1px solid var(--bridge-border); - border-radius: var(--bridge-border-radius); - background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); -} + .bridge-plan-loading { + display: flex; + align-items: center; + justify-content: center; + padding: 3rem 1rem; + } -.bridge-plan-interval-tab { - appearance: none; - border: none; - background: transparent; - cursor: pointer; - font: inherit; - font-size: 0.8125rem; - padding: 0.375rem 0.875rem; - border-radius: calc(var(--bridge-border-radius) - 0.2rem); - color: var(--bridge-muted); -} + .bridge-plan-empty { + text-align: center; + padding: 2rem 1rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bridge-plan-interval-tab[data-active="true"] { - background: var(--bridge-primary); - color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); -} + .bridge-plan-payment-failed { + margin-bottom: 1.5rem; + } -.bridge-plan-unavailable { - margin: 0; - font-size: 0.8125rem; - color: var(--bridge-muted); -} + .bridge-plan-portal-btn { + margin-top: 0.75rem; + } -/* Plan-change confirmation dialog + success notice (TBP-33) */ -.bridge-plan-success { - margin-bottom: 1rem; -} + /* TBP-944 (svelte TBP-813) — a heading beside the interval switch (`heading` input). */ + .bridge-plan-head { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + margin-bottom: 1.25rem; + } -.bridge-plan-confirm-backdrop { - position: fixed; - inset: 0; - background: var(--bridge-overlay); - display: grid; - place-items: center; - z-index: 1000; - padding: 1.25rem; -} + .bridge-plan-heading { + margin: 0; + font-size: calc(1.05 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -.bridge-plan-confirm { - background: var(--bridge-bg); - border: 1px solid var(--bridge-border); - border-radius: var(--bridge-border-radius); - box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35); - max-width: 26rem; - width: 100%; - padding: 1.25rem 1.25rem 1rem; - display: flex; - flex-direction: column; - gap: 0.75rem; -} + .bridge-plan-head .bridge-plan-interval-tabs { + margin: 0; + } -.bridge-plan-confirm-title { - margin: 0; - font-size: 1rem; - font-weight: 600; -} + .bridge-plan-interval-tabs { + /* Centered above the plan cards; flex + fit-content (not inline-flex) so + auto margins can center it regardless of the host page's text alignment. */ + display: flex; + width: fit-content; + margin-inline: auto; + gap: 0.25rem; + margin-bottom: 1.25rem; + padding: 0.25rem; + border: 1px solid var(--bridge-border); + border-radius: var(--bridge-border-radius); + background: var(--bridge-card-bg, var(--bridge-bg)); + } -.bridge-plan-confirm-body { - margin: 0; - font-size: 0.875rem; - line-height: 1.5; -} + .bridge-plan-interval-tab { + appearance: none; + border: none; + background: transparent; + cursor: pointer; + font: inherit; + font-size: calc(0.8125 * var(--bridge-text-base, 1rem)); + padding: 0.375rem 0.875rem; + border-radius: calc(var(--bridge-border-radius) - 0.2rem); + color: var(--bridge-muted); + } -.bridge-plan-confirm-note { - margin: 0; - font-size: 0.8125rem; - color: var(--bridge-muted); - line-height: 1.5; -} + .bridge-plan-interval-tab[data-active="true"] { + background: var(--bridge-primary); + color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); + } -.bridge-plan-confirm-actions { - display: flex; - justify-content: flex-end; - gap: 0.5rem; - margin-top: 0.25rem; -} + .bridge-plan-unavailable { + margin: 0; + font-size: calc(0.8125 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + } -.bridge-plan-cards { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); - gap: 1rem; -} + /* Plan-change confirmation dialog + success notice (TBP-33) */ + .bridge-plan-success { + margin-bottom: 1rem; + } -[data-bridge-plan-card] { - padding: 1.25rem; - display: flex; - flex-direction: column; - gap: 0.75rem; -} + .bridge-plan-confirm-backdrop { + position: fixed; + inset: 0; + background: var(--bridge-overlay); + display: grid; + place-items: center; + z-index: 1000; + padding: 1.25rem; + } -[data-bridge-plan-card][data-current="true"] { - outline: 2px solid currentColor; -} + .bridge-plan-confirm { + background: var(--bridge-bg); + border: 1px solid var(--bridge-border); + border-radius: var(--bridge-border-radius); + box-shadow: var(--bridge-card-shadow, 0 24px 60px -12px rgba(0, 0, 0, 0.35)); + max-width: 26rem; + width: 100%; + padding: 1.25rem 1.25rem 1rem; + display: flex; + flex-direction: column; + gap: 0.75rem; + } -.bridge-plan-card-header { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 0.5rem; -} + .bridge-plan-confirm-title { + margin: 0; + font-size: calc(1 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -.bridge-plan-name { - margin: 0; - font-size: 1rem; - font-weight: 600; -} + .bridge-plan-confirm-body { + margin: 0; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + line-height: 1.5; + } -.bridge-plan-trial-badge { - display: inline-block; - padding: 0.125rem 0.5rem; - font-size: 0.7rem; - white-space: nowrap; -} + .bridge-plan-confirm-note { + margin: 0; + font-size: calc(0.8125 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + line-height: 1.5; + } -.bridge-plan-description { - margin: 0; - font-size: 0.875rem; -} + .bridge-plan-confirm-actions { + display: flex; + justify-content: flex-end; + gap: 0.5rem; + margin-top: 0.25rem; + } -/* TBP-755 — the features a plan includes. */ -.bridge-plan-features { - margin: 0; - padding-left: 1.125rem; - font-size: 0.875rem; - display: flex; - flex-direction: column; - gap: 0.25rem; -} + .bridge-plan-cards { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); + gap: 1rem; + align-items: stretch; + } -.bridge-plan-prices { - display: flex; - flex-direction: column; - gap: 0.5rem; - margin-top: auto; -} + /* TBP-944 (svelte TBP-813) — cards, and the current-plan panel, are surfaces of + their own, so they read on any app background and take the app's tokens. */ + [data-bridge-plan-card], + .bridge-billing-summary { + background: var(--bridge-card-bg, var(--bridge-bg)); + color: var(--bridge-foreground); + border: 1px solid var(--bridge-border); + border-radius: calc(var(--bridge-border-radius) * 1.5); + box-shadow: var(--bridge-card-shadow, 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.04)); + } -.bridge-plan-select-btn { - width: 100%; - text-align: center; -} + .bridge-billing-summary { + padding: 1.1rem 1.25rem; + background: color-mix(in srgb, var(--bridge-primary) 6%, var(--bridge-card-bg, var(--bridge-bg))); + } -/* ─── WorkspaceSelector ─────────────────────────────────────────────── */ + .bridge-billing-summary .bss-plan { + font-size: calc(1.2 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 700); + } -[data-bridge-workspace-selector] { - display: flex; - flex-direction: column; - gap: 0.25rem; -} + .bridge-billing-summary-meta { + font-size: calc(0.85 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + font-variant-numeric: tabular-nums; + } -[data-bridge-workspace-loading] { - display: flex; - justify-content: center; - padding: 1.5rem 0; -} + [data-bridge-plan-card] { + position: relative; + padding: 1.35rem 1.25rem 1.25rem; + display: flex; + flex-direction: column; + gap: 0.9rem; + } -[data-bridge-workspace-list] { - display: flex; - flex-direction: column; - gap: 0.25rem; -} + [data-bridge-plan-card][data-current="true"] { + border: 2px solid var(--bridge-primary); + padding: calc(1.35rem - 1px) calc(1.25rem - 1px) calc(1.25rem - 1px); + } -[data-bridge-workspace-item] { - display: flex; - align-items: center; - gap: 0.75rem; - width: 100%; - padding: 0.625rem 0.75rem; - background: none; - border: 1px solid transparent; - border-radius: 0.5rem; - cursor: pointer; - text-align: left; - font-family: inherit; - transition: background 0.15s; -} + .bridge-plan-current-flag { + position: absolute; + top: -0.7rem; + left: 1.1rem; + padding: 0.15rem 0.55rem; + border-radius: 9999px; + font-size: calc(0.7 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 600); + background: var(--bridge-primary); + color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); + } -[data-bridge-workspace-item]:hover:not(:disabled) { - background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); -} + .bridge-plan-card-header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 0.5rem; + } -[data-bridge-workspace-item][data-active="true"] { - background: var(--bridge-primary-light, color-mix(in srgb, var(--bridge-primary) 10%, #ffffff)); - border-color: var(--bridge-primary); -} + .bridge-plan-name { + margin: 0; + font-size: calc(1 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -[data-bridge-workspace-item][data-loading="true"] { - opacity: 0.7; - cursor: wait; -} + .bridge-plan-trial-badge { + display: inline-block; + padding: 0.125rem 0.5rem; + font-size: calc(0.7 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 600); + white-space: nowrap; + border-radius: 9999px; + border: 1px solid var(--bridge-alert-info-border); + background: var(--bridge-alert-info-bg); + color: var(--bridge-alert-info-fg); + } -[data-bridge-workspace-item]:disabled { - cursor: not-allowed; -} + .bridge-plan-price { + display: flex; + align-items: baseline; + flex-wrap: wrap; + gap: 0.3rem; + font-variant-numeric: tabular-nums; + } -[data-bridge-workspace-avatar] { - display: flex; - align-items: center; - justify-content: center; - width: 2rem; - height: 2rem; - border-radius: 0.375rem; - background: var(--bridge-primary); - color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); - font-size: 0.875rem; - font-weight: 600; - flex-shrink: 0; - overflow: hidden; -} + .bridge-plan-price-amount { + font-size: calc(1.9 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 700); + letter-spacing: -0.02em; + line-height: 1.1; + } -[data-bridge-workspace-avatar] img { - width: 100%; - height: 100%; - object-fit: cover; -} + .bridge-plan-price-interval { + font-size: calc(0.85 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + } -[data-bridge-workspace-info] { - display: flex; - flex-direction: column; - gap: 0.125rem; - flex: 1; - min-width: 0; -} + .bridge-plan-description { + margin: 0; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + } -[data-bridge-workspace-name] { - font-size: 0.875rem; - font-weight: 500; - color: var(--bridge-foreground); - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} + /* TBP-755 — the features a plan includes. */ + .bridge-plan-features { + margin: 0; + padding: 0.9rem 0 0; + border-top: 1px solid var(--bridge-border); + list-style: none; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + display: flex; + flex-direction: column; + gap: 0.45rem; + } -[data-bridge-workspace-user] { - font-size: 0.75rem; - color: var(--bridge-muted); - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} + .bridge-plan-feature { + display: flex; + align-items: flex-start; + gap: 0.5rem; + } -/* ════════════════════════════════════════════════════════════════════════════ - * Component styles. bridge-svelte scopes these inside each component; Angular - * components here use no view encapsulation for them, so they live in this one - * file with the same `--bridge-*` tokens (TBP-744 — one token contract across - * the plugins). - * ════════════════════════════════════════════════════════════════════════════ */ - -/* ─── ─── */ -.bridge-subscription-status { - display: inline-flex; - align-items: center; - gap: 0.5rem; - font: inherit; -} + .bridge-plan-feature-check { + flex: none; + margin-top: 0.2rem; + color: var(--bridge-primary); + } -.bss-plan { - font-weight: 600; -} + .bridge-plan-prices { + display: flex; + flex-direction: column; + gap: 0.5rem; + margin-top: auto; + } -.bss-badge { - display: inline-block; - padding: 0.125rem 0.5rem; - border-radius: 9999px; - font-size: 0.75rem; - font-weight: 500; - text-transform: lowercase; - background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); - color: var(--bridge-foreground, #111827); -} + .bridge-plan-select-btn { + width: 100%; + text-align: center; + } -.bss-badge-active { - background: var(--bridge-alert-success-bg, #f0fdf4); - color: var(--bridge-alert-success-fg, #166534); -} + [data-bridge-plan-card][data-current="true"] .bridge-plan-select-btn:disabled { + background: transparent; + color: var(--bridge-muted); + opacity: 1; + } -.bss-badge-trial { - background: var(--bridge-alert-info-bg, #eff6ff); - color: var(--bridge-alert-info-fg, #1e40af); -} + /* ─── (TBP-944, svelte TBP-813) ────────────────── */ + + .bridge-checkout-notice { + display: flex; + align-items: flex-start; + gap: 0.75rem; + padding: 0.85rem 1rem; + border: 1px solid var(--bridge-alert-success-border); + border-radius: var(--bridge-border-radius); + background: var(--bridge-alert-success-bg); + color: var(--bridge-alert-success-fg); + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + } -.bss-badge-past_due, -.bss-badge-cancel_at_period_end { - background: var(--bridge-alert-warning-bg, #fffbeb); - color: var(--bridge-alert-warning-fg, #92400e); -} + .bridge-checkout-notice-icon { + flex: none; + margin-top: 0.1rem; + } -.bss-badge-canceled { - background: var(--bridge-alert-error-bg, #fef2f2); - color: var(--bridge-alert-error-fg, #991b1b); -} + .bridge-checkout-notice-body { + flex: 1; + min-width: 0; + } -.bss-loading, -.bss-empty { - color: var(--bridge-muted, #6b7280); - font-style: italic; -} + .bridge-checkout-notice-title { + display: block; + font-weight: var(--bridge-font-weight-heading, 600); + } -.bss-error, -.bss-error-reason { - color: var(--bridge-alert-error-fg, #991b1b); -} + .bridge-checkout-notice-close { + appearance: none; + border: 0; + background: none; + color: inherit; + cursor: pointer; + font: inherit; + font-size: calc(1.15 * var(--bridge-text-base, 1rem)); + line-height: 1; + padding: 0 0.2rem; + opacity: 0.7; + } -/* ─── and the billing lockscreen ─── */ -.bridge-billing-notice { - display: flex; - align-items: center; - justify-content: space-between; - gap: 1rem; - padding: 0.75rem 1rem; - border-radius: 0.5rem; - font: inherit; - transition: opacity 280ms ease, transform 320ms ease; -} + .bridge-checkout-notice-close:hover, + .bridge-checkout-notice-close:focus-visible { + opacity: 1; + } -.bbn-content { - display: flex; - flex-direction: column; - gap: 0.125rem; - flex: 1 1 auto; -} + /* ─── WorkspaceSelector ─────────────────────────────────────────────── */ -.bbn-title { - font-weight: 600; -} + [data-bridge-workspace-selector] { + display: flex; + flex-direction: column; + gap: 0.25rem; + } -.bbn-body { - font-size: 0.875rem; - opacity: 0.85; -} + [data-bridge-workspace-loading] { + display: flex; + justify-content: center; + padding: 1.5rem 0; + } -.bbn-cta { - padding: 0.5rem 1rem; - border-radius: 0.375rem; - border: 1px solid currentColor; - background: transparent; - color: inherit; - font: inherit; - font-weight: 500; - cursor: pointer; - flex: 0 0 auto; -} + [data-bridge-workspace-list] { + display: flex; + flex-direction: column; + gap: 0.25rem; + } -.bbn-cta:hover { - background: currentColor; - color: var(--bridge-bg, #ffffff); -} + [data-bridge-workspace-item] { + display: flex; + align-items: center; + gap: 0.75rem; + width: 100%; + padding: 0.625rem 0.75rem; + background: none; + border: 1px solid transparent; + border-radius: 0.5rem; + cursor: pointer; + text-align: left; + font-family: inherit; + transition: background 0.15s; + } -/* Chassis variants */ -.bbn-chassis-bar { - border-radius: 0; - width: 100%; -} + [data-bridge-workspace-item]:hover:not(:disabled) { + background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); + } -.bbn-chassis-rail { - border-left: 4px solid currentColor; - border-radius: 0 0.5rem 0.5rem 0; -} + [data-bridge-workspace-item][data-active="true"] { + background: var(--bridge-primary-light, color-mix(in srgb, var(--bridge-primary) 10%, #ffffff)); + border-color: var(--bridge-primary); + } -.bbn-chassis-card { - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); - border: 1px solid var(--bridge-border, #d1d5db); -} + [data-bridge-workspace-item][data-loading="true"] { + opacity: 0.7; + cursor: wait; + } -/* Severity tokens */ -.bbn-severity-info { - background: var(--bridge-alert-info-bg, #eff6ff); - color: var(--bridge-alert-info-fg, #1e40af); -} + [data-bridge-workspace-item]:disabled { + cursor: not-allowed; + } -.bbn-severity-warn { - background: var(--bridge-alert-warning-bg, #fffbeb); - color: var(--bridge-alert-warning-fg, #92400e); -} + [data-bridge-workspace-avatar] { + display: flex; + align-items: center; + justify-content: center; + width: 2rem; + height: 2rem; + border-radius: 0.375rem; + background: var(--bridge-primary); + color: var(--bridge-primary-fg, var(--bridge-primary-foreground, #ffffff)); + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: 600; + flex-shrink: 0; + overflow: hidden; + } -.bbn-severity-critical { - background: var(--bridge-alert-error-bg, #fef2f2); - color: var(--bridge-alert-error-fg, #991b1b); -} + [data-bridge-workspace-avatar] img { + width: 100%; + height: 100%; + object-fit: cover; + } -/* Locked inverts the surface: foreground as background, and vice versa. */ -.bbn-severity-locked { - background: var(--bridge-foreground, #111827); - color: var(--bridge-bg, #ffffff); -} + [data-bridge-workspace-info] { + display: flex; + flex-direction: column; + gap: 0.125rem; + flex: 1; + min-width: 0; + } + + [data-bridge-workspace-name] { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 500); + color: var(--bridge-foreground); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + [data-bridge-workspace-user] { + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + /* ════════════════════════════════════════════════════════════════════════════ + * Component styles. bridge-svelte scopes these inside each component; Angular + * components here use no view encapsulation for them, so they live in this one + * file with the same `--bridge-*` tokens (TBP-744 — one token contract across + * the plugins). + * ════════════════════════════════════════════════════════════════════════════ */ + + /* ─── ─── */ + .bridge-subscription-status { + display: inline-flex; + align-items: center; + gap: 0.5rem; + font: inherit; + } + + .bss-plan { + font-weight: var(--bridge-font-weight-heading, 600); + } -@media (prefers-reduced-motion: reduce) { + .bss-badge { + display: inline-block; + padding: 0.125rem 0.5rem; + border-radius: 9999px; + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 500); + text-transform: lowercase; + background: var(--bridge-muted-bg, var(--bridge-bg-muted, #f3f4f6)); + color: var(--bridge-foreground, #111827); + } + + .bss-badge-active { + background: var(--bridge-alert-success-bg, #f0fdf4); + color: var(--bridge-alert-success-fg, #166534); + } + + .bss-badge-trial { + background: var(--bridge-alert-info-bg, #eff6ff); + color: var(--bridge-alert-info-fg, #1e40af); + } + + .bss-badge-past_due, + .bss-badge-cancel_at_period_end { + background: var(--bridge-alert-warning-bg, #fffbeb); + color: var(--bridge-alert-warning-fg, #92400e); + } + + .bss-badge-canceled { + background: var(--bridge-alert-error-bg, #fef2f2); + color: var(--bridge-alert-error-fg, #991b1b); + } + + .bss-loading, + .bss-empty { + color: var(--bridge-muted, #6b7280); + font-style: italic; + } + + .bss-error, + .bss-error-reason { + color: var(--bridge-alert-error-fg, #991b1b); + } + + /* ─── and the billing lockscreen ─── */ .bridge-billing-notice { - transition: none; + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + padding: 0.75rem 1rem; + border-radius: 0.5rem; + font: inherit; + transition: opacity 280ms ease, transform 320ms ease; } -} -/* Hard-mode lockscreen — full-viewport blocking overlay */ -.bridge-billing-lockscreen { - position: fixed; - inset: 0; - z-index: 9999; - display: flex; - align-items: center; - justify-content: center; - padding: 1rem; - background: var(--bridge-paywall-bg, rgba(15, 23, 42, 0.72)); - backdrop-filter: blur(2px); -} + .bbn-content { + display: flex; + flex-direction: column; + gap: 0.125rem; + flex: 1 1 auto; + } -.bbl-panel { - display: flex; - flex-direction: column; - gap: 0.75rem; - max-width: 28rem; - width: 100%; - padding: 1.5rem; - border-radius: 0.75rem; - background: var(--bridge-foreground, #111827); - color: var(--bridge-bg, #ffffff); - box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); - text-align: center; -} + .bbn-title { + font-weight: var(--bridge-font-weight-heading, 600); + } -.bbl-title { - font-size: 1.125rem; - font-weight: 600; -} + .bbn-body { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + opacity: 0.85; + } -.bbl-body { - font-size: 0.9375rem; - opacity: 0.85; -} + .bbn-cta { + padding: 0.5rem 1rem; + border-radius: 0.375rem; + border: 1px solid currentColor; + background: transparent; + color: inherit; + font: inherit; + font-weight: var(--bridge-font-weight-button, 500); + cursor: pointer; + flex: 0 0 auto; + } -.bbl-cta { - align-self: center; - margin-top: 0.5rem; - padding: 0.625rem 1.25rem; - border-radius: 0.5rem; - border: 1px solid currentColor; - background: transparent; - color: inherit; - font: inherit; - font-weight: 500; - cursor: pointer; -} + .bbn-cta:hover { + background: currentColor; + color: var(--bridge-bg, #ffffff); + } -.bbl-cta:hover { - background: var(--bridge-bg, #ffffff); - color: var(--bridge-foreground, #111827); -} + /* Chassis variants */ + .bbn-chassis-bar { + border-radius: 0; + width: 100%; + } -/* ─── ─── */ -.bridge-quota-banner { - display: flex; - align-items: center; - justify-content: space-between; - gap: 1rem; - padding: 0.75rem 1rem; - border-radius: 0.5rem; - font: inherit; - transition: opacity 280ms ease, transform 320ms ease; -} + .bbn-chassis-rail { + border-left: 4px solid currentColor; + border-radius: 0 0.5rem 0.5rem 0; + } -.bqb-content { - display: flex; - flex-direction: column; - gap: 0.25rem; - flex: 1 1 auto; -} + .bbn-chassis-card { + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border: 1px solid var(--bridge-border, #d1d5db); + } -.bqb-title { - font-weight: 600; -} + /* Severity tokens */ + .bbn-severity-info { + background: var(--bridge-alert-info-bg, #eff6ff); + color: var(--bridge-alert-info-fg, #1e40af); + } -.bqb-body { - font-size: 0.875rem; - opacity: 0.85; -} + .bbn-severity-warn { + background: var(--bridge-alert-warning-bg, #fffbeb); + color: var(--bridge-alert-warning-fg, #92400e); + } -.bqb-meter { - margin-top: 0.25rem; - width: 100%; - height: 0.375rem; - background: color-mix(in srgb, currentColor 15%, transparent); - border-radius: 999px; - overflow: hidden; -} + .bbn-severity-critical { + background: var(--bridge-alert-error-bg, #fef2f2); + color: var(--bridge-alert-error-fg, #991b1b); + } -.bqb-meter-fill { - height: 100%; - background: currentColor; - border-radius: 999px; - transition: width 320ms ease; -} + /* Locked inverts the surface: foreground as background, and vice versa. */ + .bbn-severity-locked { + background: var(--bridge-foreground, #111827); + color: var(--bridge-bg, #ffffff); + } -.bqb-cta { - padding: 0.5rem 1rem; - border-radius: 0.375rem; - border: 1px solid currentColor; - background: transparent; - color: inherit; - font: inherit; - font-weight: 500; - cursor: pointer; - flex: 0 0 auto; -} + @media (prefers-reduced-motion: reduce) { + .bridge-billing-notice { + transition: none; + } + } -.bqb-cta:hover { - background: currentColor; - color: var(--bridge-bg, #ffffff); -} + /* Hard-mode lockscreen — full-viewport blocking overlay */ + .bridge-billing-lockscreen { + position: fixed; + inset: 0; + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + padding: 1rem; + background: var(--bridge-paywall-bg, rgba(15, 23, 42, 0.72)); + backdrop-filter: blur(2px); + } -/* Chassis — rail only for US-11. */ -.bqb-chassis-rail { - border-left: 4px solid currentColor; - border-radius: 0 0.5rem 0.5rem 0; -} + .bbl-panel { + display: flex; + flex-direction: column; + gap: 0.75rem; + max-width: 28rem; + width: 100%; + padding: 1.5rem; + border-radius: 0.75rem; + background: var(--bridge-foreground, #111827); + color: var(--bridge-bg, #ffffff); + box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); + text-align: center; + } -/* Severity tokens — mirror BridgeBillingNotice for visual consistency. */ -.bqb-severity-warn { - background: var(--bridge-alert-warning-bg, #fffbeb); - color: var(--bridge-alert-warning-fg, #92400e); -} + .bbl-title { + font-size: calc(1.125 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + } -.bqb-severity-critical { - background: var(--bridge-alert-error-bg, #fef2f2); - color: var(--bridge-alert-error-fg, #991b1b); -} + .bbl-body { + font-size: calc(0.9375 * var(--bridge-text-base, 1rem)); + opacity: 0.85; + } + + .bbl-cta { + align-self: center; + margin-top: 0.5rem; + padding: 0.625rem 1.25rem; + border-radius: 0.5rem; + border: 1px solid currentColor; + background: transparent; + color: inherit; + font: inherit; + font-weight: var(--bridge-font-weight-button, 500); + cursor: pointer; + } + + .bbl-cta:hover { + background: var(--bridge-bg, #ffffff); + color: var(--bridge-foreground, #111827); + } + + /* ─── ─── */ + .bridge-quota-banner { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + padding: 0.75rem 1rem; + border-radius: 0.5rem; + font: inherit; + transition: opacity 280ms ease, transform 320ms ease; + } + + .bqb-content { + display: flex; + flex-direction: column; + gap: 0.25rem; + flex: 1 1 auto; + } + + .bqb-title { + font-weight: var(--bridge-font-weight-heading, 600); + } + + .bqb-body { + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + opacity: 0.85; + } + + .bqb-meter { + margin-top: 0.25rem; + width: 100%; + height: 0.375rem; + background: color-mix(in srgb, currentColor 15%, transparent); + border-radius: 999px; + overflow: hidden; + } -@media (prefers-reduced-motion: reduce) { - .bridge-quota-banner, .bqb-meter-fill { - transition: none; + height: 100%; + background: currentColor; + border-radius: 999px; + transition: width 320ms ease; } -} -/* ─── ─── */ -.bridge-paywall { - position: fixed; - inset: 0; - z-index: 9000; - display: flex; - align-items: center; - justify-content: center; - padding: 1rem; - background: var(--bridge-paywall-bg, rgba(15, 23, 42, 0.72)); - backdrop-filter: blur(2px); -} + .bqb-cta { + padding: 0.5rem 1rem; + border-radius: 0.375rem; + border: 1px solid currentColor; + background: transparent; + color: inherit; + font: inherit; + font-weight: var(--bridge-font-weight-button, 500); + cursor: pointer; + flex: 0 0 auto; + } -.bridge-paywall-panel { - display: flex; - flex-direction: column; - gap: 1.5rem; - width: 100%; - max-width: 42rem; - max-height: 90vh; - overflow-y: auto; - padding: 2rem; - border-radius: 0.75rem; - background: var(--bridge-paywall-panel-bg, var(--bridge-bg, #ffffff)); - box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); -} + .bqb-cta:hover { + background: currentColor; + color: var(--bridge-bg, #ffffff); + } -.bridge-paywall-heading { - margin: 0; - font-size: 1.25rem; - font-weight: 600; - text-align: center; -} + /* Chassis — rail only for US-11. */ + .bqb-chassis-rail { + border-left: 4px solid currentColor; + border-radius: 0 0.5rem 0.5rem 0; + } -/* ─── bridgeBillingRoutes() pages ─── */ -/* The default frame. A `frame` snippet replaces it entirely. */ -.bridge-billing-page { - display: flex; - flex-direction: column; - gap: 1.25rem; - max-width: var(--bridge-billing-page-width, 60rem); - margin: 0 auto; - padding: var(--bridge-billing-page-padding, 3rem 1rem); -} + /* Severity tokens — mirror BridgeBillingNotice for visual consistency. */ + .bqb-severity-warn { + background: var(--bridge-alert-warning-bg, #fffbeb); + color: var(--bridge-alert-warning-fg, #92400e); + } -.bridge-billing-heading { - margin: 0; - font-size: 1.5rem; - font-weight: 700; -} + .bqb-severity-critical { + background: var(--bridge-alert-error-bg, #fef2f2); + color: var(--bridge-alert-error-fg, #991b1b); + } -.bridge-billing-text { - margin: 0; - opacity: 0.8; -} + @media (prefers-reduced-motion: reduce) { + .bridge-quota-banner, + .bqb-meter-fill { + transition: none; + } + } -.bridge-billing-current { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 0.75rem; -} + /* ─── ─── */ + .bridge-paywall { + position: fixed; + inset: 0; + z-index: 9000; + display: flex; + align-items: center; + justify-content: center; + padding: 1rem; + background: var(--bridge-paywall-bg, rgba(15, 23, 42, 0.72)); + backdrop-filter: blur(2px); + } -.bridge-billing-label { - font-size: 0.75rem; - font-weight: 600; - text-transform: uppercase; - letter-spacing: 0.05em; - opacity: 0.7; -} + .bridge-paywall-panel { + display: flex; + flex-direction: column; + gap: 1.5rem; + width: 100%; + max-width: 42rem; + max-height: 90vh; + overflow-y: auto; + padding: 2rem; + border-radius: 0.75rem; + background: var(--bridge-paywall-panel-bg, var(--bridge-bg, #ffffff)); + box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); + } -.bridge-billing-action { - align-self: flex-start; - text-decoration: none; -} + .bridge-paywall-heading { + margin: 0; + font-size: calc(1.25 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 600); + text-align: center; + } -/* ─── ─── */ -.bridge-paywall-page { - display: flex; - flex-direction: column; - gap: 1.25rem; - max-width: var(--bridge-billing-page-width, 60rem); - margin: 0 auto; - padding: var(--bridge-billing-page-padding, 3rem 1rem); -} + /* ─── bridgeBillingRoutes() pages ─── */ + /* The default frame. A `frame` snippet replaces it entirely. */ + .bridge-billing-page { + display: flex; + flex-direction: column; + gap: 1.25rem; + max-width: var(--bridge-billing-page-width, 60rem); + margin: 0 auto; + padding: var(--bridge-billing-page-padding, 3rem 1rem); + } -.bridge-paywall-page-heading { - margin: 0; - font-size: 1.5rem; - font-weight: 700; -} + .bridge-billing-heading { + margin: 0; + font-size: calc(1.5 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 700); + } -/* ─── bridgeAuthRoutes() pages ─── */ -/* The default frame — the centred container every guide page used to paste. - A `frame` snippet replaces it entirely. */ -.bridge-auth-page { - display: flex; - justify-content: center; - padding: var(--bridge-auth-page-padding, 3rem 1rem); -} + .bridge-billing-text { + margin: 0; + opacity: 0.8; + } -/* TBP-899 — the page's form component is the flex item here (an Angular host - element), so give it the row's width; the form inside centres itself at its - 400px max, as in the other SDKs. */ -.bridge-auth-page > * { - width: 100%; -} + /* The subtitle sits with its heading, closer than the page's gap. */ + .bridge-billing-heading + .bridge-billing-text { + margin-top: -0.75rem; + } -/* ─── Team seats (TBP-763) — shown instead of an enabled Invite when every seat is taken ─── */ -.bridge-team-seats-limit { - margin: -0.5rem 0 1rem; - font-size: 0.875rem; - color: var(--bridge-muted, #6b7280); -} + .bridge-billing-current { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.75rem; + } -/* ─── (TBP-744) ─── */ -.bridge-quota-gate-limit { - margin-top: 0.5rem; - font-size: 0.875rem; - color: var(--bridge-muted, #6b7280); -} -.bridge-quota-gate-limit a { - color: var(--bridge-primary, #4f46e5); -} + /* TBP-944 — the current-plan panel's layout; its surface is with the plan cards. */ + .bridge-billing-summary { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 1rem; + } + + .bridge-billing-summary-plan { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 0.25rem; + min-width: 0; + } + + .bridge-billing-label { + font-size: calc(0.75 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-label, 600); + text-transform: uppercase; + letter-spacing: 0.05em; + opacity: 0.7; + } -/* ─── prompt (TBP-744) ─── */ -.bridge-feature-upgrade { - display: inline-flex; - align-items: center; - gap: 0.5rem; + .bridge-billing-action { + align-self: flex-start; + text-decoration: none; + } + + /* ─── ─── */ + .bridge-paywall-page { + display: flex; + flex-direction: column; + gap: 1.25rem; + max-width: var(--bridge-billing-page-width, 60rem); + margin: 0 auto; + padding: var(--bridge-billing-page-padding, 3rem 1rem); + } + + .bridge-paywall-page-heading { + margin: 0; + font-size: calc(1.5 * var(--bridge-text-base, 1rem)); + font-weight: var(--bridge-font-weight-heading, 700); + } + + /* ─── bridgeAuthRoutes() pages ─── */ + /* The default frame — the centred container every guide page used to paste. + A `frame` snippet replaces it entirely. */ + .bridge-auth-page { + display: flex; + justify-content: center; + padding: var(--bridge-auth-page-padding, 3rem 1rem); + } + + /* TBP-899 — the page's form component is the flex item here (an Angular host + element), so give it the row's width; the form inside centres itself at its + 400px max, as in the other SDKs. */ + .bridge-auth-page > * { + width: 100%; + } + + /* ─── Team seats (TBP-763) — shown instead of an enabled Invite when every seat is taken ─── */ + .bridge-team-seats-limit { + margin: -0.5rem 0 1rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted, #6b7280); + } + + /* ─── (TBP-744) ─── */ + .bridge-quota-gate-limit { + margin-top: 0.5rem; + font-size: calc(0.875 * var(--bridge-text-base, 1rem)); + color: var(--bridge-muted, #6b7280); + } + .bridge-quota-gate-limit a { + color: var(--bridge-primary, #4f46e5); + } + + /* ─── prompt (TBP-744) ─── */ + .bridge-feature-upgrade { + display: inline-flex; + align-items: center; + gap: 0.5rem; + } } diff --git a/bridge-angular/src/lib/types/config.ts b/bridge-angular/src/lib/types/config.ts index 640039a..b99f612 100644 --- a/bridge-angular/src/lib/types/config.ts +++ b/bridge-angular/src/lib/types/config.ts @@ -130,11 +130,21 @@ export interface BridgeConfig { /** * The subscription page — the default destination of the Upgrade/Manage * CTA in ``, ``, - * `` and the upgrade dialog. A completed checkout lands - * on `/success` by default. + * `` and the upgrade dialog, and where a completed + * checkout lands unless `successRoute` says otherwise. * @default '/subscription' */ manageRoute?: string; + /** + * TBP-944 (svelte TBP-813) — where a completed checkout, or a Free plan + * pick, lands: any page of your app, e.g. `'/dashboard'`. The subscription + * page shows a confirmation banner; anywhere else, render + * `` for the same banner, or read the + * `checkoutResult` signal for your own message. The old confirmation page + * is `'/subscription/success'`. + * @default the subscription page (`manageRoute`) + */ + successRoute?: string; /** * The dialog `provideBridge()` mounts, which opens when your backend refuses * a request because a plan limit is reached (`402` with diff --git a/bridge-angular/src/public-api.ts b/bridge-angular/src/public-api.ts index 2ab995c..416aae0 100644 --- a/bridge-angular/src/public-api.ts +++ b/bridge-angular/src/public-api.ts @@ -167,6 +167,12 @@ export type { BillingInterval, } from './lib/components/subscription/plan-selector.component'; export { BillingPortalButtonComponent } from './lib/components/subscription/billing-portal-button.component'; +// TBP-944 (svelte TBP-813) — a completed checkout lands on `billing.successRoute` +// (the subscription page by default); this banner, or `checkoutResult`, says so. +export { CheckoutNoticeComponent } from './lib/components/subscription/checkout-notice.component'; +export type { CheckoutNoticeTemplateContext } from './lib/components/subscription/checkout-notice.component'; +export { checkoutResult, takeCheckoutResult, clearCheckoutResult } from './lib/billing/checkout-result'; +export type { BridgeCheckoutResult } from './lib/billing/checkout-result'; export { BridgePaywallPageComponent } from './lib/components/subscription/paywall-page.component'; export { SubscriptionStatusComponent } from './lib/components/subscription/subscription-status.component'; export { BillingNoticeComponent } from './lib/components/subscription/billing-notice.component'; diff --git a/docs/parity-with-svelte.md b/docs/parity-with-svelte.md index afedc7e..4145833 100644 --- a/docs/parity-with-svelte.md +++ b/docs/parity-with-svelte.md @@ -51,6 +51,11 @@ Legend: **present** (already on `main` before TBP-744) · **added** (TBP-744 / t | Interval tabs, `defaultInterval`, cheapest-first, feature list | same | added | | Free pick goes on to `successRedirect` (TBP-762) | same, unless `(select)` is observed | added | | Plan-change confirmation dialog (TBP-33) | same "Change plan?" dialog | added | +| Plan cards on a surface, formatted price, "Choose / Upgrade to / Switch to", current plan flagged, `heading` (svelte 0.9.2, TBP-813) | same, `heading` input | added (TBP-944) | +| Current-plan panel with renewal date and card on `/subscription` (TBP-813) | same | added (TBP-944) | +| `billing.successRoute` (default: the subscription page); a checkout and a Free pick land there (TBP-813) | same | added (TBP-944) | +| ``, `checkoutResult` store, `takeCheckoutResult`, `clearCheckoutResult` (TBP-813) | `` (`contentTemplate`), `checkoutResult` signal, same functions | added (TBP-944) · **different**: a read-only signal instead of a store; the custom text is an `ng-template` instead of a snippet | +| `` | `bridgeBillingRoutes({ checkoutNotice: false })` | added (TBP-944) | | ``, ``, ``, `` | same | present | | Level 0: global `fetch` wrapper + `bridgeFetch` → upgrade dialog on `402` | `bridgeInterceptor` (HttpClient) + `bridgeFetch` | added — **different**: Angular apps call APIs through `HttpClient`; an interceptor is the idiom, and it sends the token only to watched origins | | ``, `billing.upgradeDialog` (`false` / component), `billing.apiOrigins` | ``, same options | added | @@ -70,6 +75,9 @@ Legend: **present** (already on `main` before TBP-744) · **added** (TBP-744 / t | bridge-svelte | bridge-angular | Status | |---|---|---| | `--bridge-*` token contract, defaults on `:where(:root)`, deprecated aliases | same stylesheet contract | added (was plain `:root`, fewer tokens) | +| `--bridge-card-bg`, `--bridge-card-shadow` (svelte 0.9.2, TBP-813) | same | added (TBP-944) | +| Text sizes from `--bridge-text-base` (`@property`, from `--bridge-font-size` or the ``), `--bridge-font-weight-heading` / `-button` / `-label`, `--bridge-button-shadow` (svelte 0.9.3, TBP-814) | same | added (TBP-944) | +| Every style in `@layer bridge`, ordered after Tailwind v4's layers (TBP-814) | same; the stylesheet and the one component with its own styles (``); the dev badge stays unlayered as in svelte | added (TBP-944) | | Headless without the stylesheet | same | present | ## Flags, live updates, team, developer @@ -86,4 +94,4 @@ Legend: **present** (already on `main` before TBP-744) · **added** (TBP-744 / t ## Tests -Every row marked **added** has vitest coverage in `bridge-angular/src/lib/**/*.spec.ts`: `routing/ten-line-routing.spec.ts`, `guards/ten-line-guard.spec.ts`, `billing/plan-limits.spec.ts`, `config/resolve-config.spec.ts`, `styles-tokens.spec.ts`, `billing/double-count-warning.spec.ts`, and the S2 and confirmation blocks of `components/subscription/plan-selector.component.spec.ts`. +Every row marked **added** has vitest coverage in `bridge-angular/src/lib/**/*.spec.ts`: `routing/ten-line-routing.spec.ts`, `guards/ten-line-guard.spec.ts`, `billing/plan-limits.spec.ts`, `config/resolve-config.spec.ts`, `styles-tokens.spec.ts`, `billing/double-count-warning.spec.ts`, and the S2 and confirmation blocks of `components/subscription/plan-selector.component.spec.ts`. The TBP-944 rows: `styles-layer.spec.ts`, `billing/checkout-result.spec.ts`, `components/subscription/plan-format.spec.ts`, `components/subscription/checkout-notice.component.spec.ts`, the default-card block of `plan-selector.component.spec.ts`, and the billing-destination and callback blocks of `routing/ten-line-routing.spec.ts`. diff --git a/e2e/playwright/tests/customisation/app-style-wins.spec.ts b/e2e/playwright/tests/customisation/app-style-wins.spec.ts new file mode 100644 index 0000000..67b0f51 --- /dev/null +++ b/e2e/playwright/tests/customisation/app-style-wins.spec.ts @@ -0,0 +1,77 @@ +/** + * TBP-944 (svelte TBP-814) — Bridge pages follow the app's type, and the app's own CSS wins. + * + * The plugin's styles live in `@layer bridge`, so any unlayered app CSS beats + * them whatever its specificity or load order. Text sizes scale from the app's + * text size; button weight and shadow are tokens. Asserted on computed + * styles of the sign-up page's primary button. Same checks as bridge-svelte's + * app-style-wins.spec.ts. + */ + +import type { Page } from '@playwright/test'; +import { test, expect } from '../../fixtures/auth'; +import { MED_TIMEOUT } from '../../fixtures/timeouts'; + +const BUTTON = '[data-bridge-auth-route="signup"] .bridge-btn-primary'; + +const style = (page: Page, prop: string) => + page.locator(BUTTON).first().evaluate((el, p) => getComputedStyle(el).getPropertyValue(p), prop); + +async function openSignup(page: Page) { + await page.goto('/auth/signup'); + await expect(page.locator(BUTTON).first()).toBeVisible({ timeout: MED_TIMEOUT }); + + // The demo must be serving the TBP-944 stylesheet, or every assertion below is + // about the old CSS. Fail with that, not with a puzzling computed value. + const layered = await page.evaluate(() => + [...document.styleSheets].some((s) => { + try { + return [...s.cssRules].some((r) => r instanceof CSSLayerBlockRule && r.name === 'bridge'); + } catch { + return false; + } + }), + ); + expect(layered, 'the demo serves no `@layer bridge` styles; its bridge-angular build is stale').toBe(true); +} + +test.describe('TBP-944 — the app’s style wins', () => { + test('button text scales from the app’s font size', async ({ page }) => { + await openSignup(page); + expect(await style(page, 'font-size')).toBe('14px'); // 0.875 × the default 16px + + await page.addStyleTag({ content: 'body { font-size: 20px }' }); + expect(await style(page, 'font-size')).toBe('17.5px'); // 0.875 × 20px + }); + + test('button weight and shadow follow their tokens', async ({ page }) => { + await openSignup(page); + expect(await style(page, 'font-weight')).toBe('500'); + expect(await style(page, 'box-shadow')).toBe('none'); + + await page.addStyleTag({ + content: ':root { --bridge-font-weight-button: 800; --bridge-button-shadow: 4px 4px 0 rgb(0, 0, 0) }', + }); + expect(await style(page, 'font-weight')).toBe('800'); + expect(await style(page, 'box-shadow')).toBe('rgb(0, 0, 0) 4px 4px 0px 0px'); + }); + + test('an unlayered app rule beats the Bridge button rule', async ({ page }) => { + await openSignup(page); + expect(await style(page, 'background-color')).not.toBe('rgb(255, 0, 0)'); + + // Same specificity as the plugin's own rule: it wins only because the + // plugin's rule is layered and this one is not. + await page.addStyleTag({ content: '.bridge-btn-primary { background-color: rgb(255, 0, 0) }' }); + expect(await style(page, 'background-color')).toBe('rgb(255, 0, 0)'); + }); + + test('with no app overrides a Bridge button keeps its filled background', async ({ page }) => { + await openSignup(page); + const bg = await style(page, 'background-color'); + expect(bg).not.toBe('rgba(0, 0, 0, 0)'); + expect(bg).not.toBe('transparent'); + // The demo sets no --bridge-primary, so the default indigo applies. + expect(bg).toBe('rgb(79, 70, 229)'); + }); +}); diff --git a/e2e/playwright/tests/subscription/subscription-flows.spec.ts b/e2e/playwright/tests/subscription/subscription-flows.spec.ts index 6c7ee58..78f77cb 100644 --- a/e2e/playwright/tests/subscription/subscription-flows.spec.ts +++ b/e2e/playwright/tests/subscription/subscription-flows.spec.ts @@ -8,7 +8,8 @@ * hit the real API to verify the end-to-end UX. * * Test scenarios: - * 1. Select a free plan via the PlanSelector UI + * 1. Select a free plan via the PlanSelector UI (lands back on /subscription + * with the checkout banner, TBP-944 / svelte TBP-813) * 2. Switch from one plan to another via the UI * 3. (Optional) Stripe checkout is triggered for a paid plan when Stripe is configured */ @@ -50,25 +51,37 @@ test.describe('Subscription Flows', () => { timeout: LONG_TIMEOUT, }); - // Find the free plan card and click "Select free plan" - const selectBtn = page.locator( - `[data-bridge-plan-card] button:has-text("Select free plan")`, - ).first(); + // Find the free plan's card and click its button. TBP-944: the label + // names the plan relative to the current one: "Choose Free E2E" with no + // plan yet, "Switch to Free E2E" from a pricier one (the worker's). + const freeCard = page + .locator('[data-bridge-plan-card]') + .filter({ has: page.getByRole('heading', { name: 'Free E2E', exact: true }) }); + const selectBtn = freeCard.getByRole('button', { name: /^(Choose|Switch to|Upgrade to) Free E2E$/ }); await expect(selectBtn).toBeVisible({ timeout: MED_TIMEOUT }); await selectBtn.click(); + // TBP-944 — a Free pick lands back on the subscription page itself (no + // /subscription/success stop) and says so in the checkout banner. + const notice = page.locator('[data-bridge-checkout-notice]'); + await expect(notice).toBeVisible({ timeout: LONG_TIMEOUT }); + await expect(notice).toHaveAttribute('data-kind', 'plan'); + await expect(notice).toContainText("You're on Free E2E now"); + expect(new URL(page.url()).pathname).toBe('/subscription'); + // Wait for the plan selector to reload await expect(planSelector).not.toHaveAttribute('data-loading', 'true', { timeout: LONG_TIMEOUT, }); - // After selecting, the button for this plan should now say "Current plan" - const currentPlanBtn = page - .locator('[data-bridge-plan-card][data-current="true"] button') - .first(); - await expect(currentPlanBtn).toBeVisible({ timeout: MED_TIMEOUT }); - const btnText = await currentPlanBtn.textContent(); - expect(btnText?.trim()).toContain('Current plan'); + // After selecting, this plan's card is the current one: flagged, with + // the disabled "Current plan" button. + const currentCard = page.locator('[data-bridge-plan-card][data-current="true"]'); + await expect(currentCard.getByRole('heading', { name: 'Free E2E', exact: true })).toBeVisible({ + timeout: MED_TIMEOUT, + }); + await expect(currentCard.locator('[data-bridge-plan-current-flag]')).toBeVisible(); + await expect(currentCard.getByRole('button', { name: 'Current plan' })).toBeDisabled(); } finally { await testDataClient.deletePlan(planKey).catch(() => {}); } diff --git a/e2e/playwright/tests/subscription/welcome-paywall.spec.ts b/e2e/playwright/tests/subscription/welcome-paywall.spec.ts index c4716be..34469bf 100644 --- a/e2e/playwright/tests/subscription/welcome-paywall.spec.ts +++ b/e2e/playwright/tests/subscription/welcome-paywall.spec.ts @@ -374,6 +374,12 @@ test.describe('Welcome Paywall — first-time user flow', () => { await expect(page.locator('[data-bridge-plan-selector][data-state="active"]')).toBeVisible({ timeout: LONG_TIMEOUT, }); + // TBP-944 (svelte TBP-813) — the return lands on the subscription page, + // which says the checkout went through, once. + expect(new URL(page.url()).pathname).toBe('/subscription'); + const notice = page.locator('[data-bridge-billing-route="manage"] [data-bridge-checkout-notice]'); + await expect(notice).toBeVisible({ timeout: LONG_TIMEOUT }); + await expect(notice).toHaveAttribute('data-kind', 'checkout'); const postCheckoutUrl = page.url(); const postCheckoutPath = new URL(postCheckoutUrl).pathname; diff --git a/learning/README.md b/learning/README.md index a43e3b7..d319e34 100644 --- a/learning/README.md +++ b/learning/README.md @@ -18,5 +18,5 @@ Guides to get you up and running. | [quickstart/hosted-quickstart.md](quickstart/hosted-quickstart.md) | Install and configure the plugin (hosted auth) in a new Angular 19 app | | [sdk-auth/sdk-quickstart.md](sdk-auth/sdk-quickstart.md) | Embed in-app login/signup forms (SDK auth) | | [live-updates/live-updates.md](live-updates/live-updates.md) | The unified `bridge` object, live channel events, and app-wide flag attributes | -| [theming/theming.md](theming/theming.md) | Customize component styles with CSS variables | +| [theming/theming.md](theming/theming.md) | CSS variable theming, matching your app's type and shadows, overriding with plain CSS | | [branding/branding.md](branding/branding.md) | Per-workspace white-labeling with the live branding snapshot | diff --git a/learning/auth/config/config.md b/learning/auth/config/config.md index 32a4cd2..656e319 100644 --- a/learning/auth/config/config.md +++ b/learning/auth/config/config.md @@ -130,6 +130,7 @@ Set `loginRoute: '/auth/login'` and `bridgeAuthGuard()` sends unauthenticated us | `billing.paywallRoute` | `string \| false` | `'/subscription/plan'` | Where a workspace (called a *tenant* in the API) with no plan is redirected. The default applies only to an app with plans; `false` turns the redirect off | | `billing.paymentErrorRoute` | `string` | `'/subscription/error'` | Where a failed Stripe checkout confirmation lands | | `billing.manageRoute` | `string` | `'/subscription'` | The subscription page — where Upgrade/Manage buttons and the upgrade dialog link | +| `billing.successRoute` | `string` | `billing.manageRoute` | Where a completed checkout or a Free plan pick lands. The subscription page shows a confirmation banner; on any other page, render `` for it | | `billing.upgradeDialog` | `boolean \| Type` | `true` | The dialog shown on a plan-limit `402`. `false` turns it off; a standalone component replaces it and receives `BridgeUpgradeDialogInputs` | | `billing.apiOrigins` | `string[]` | (none) | Origins of your own backend when it is not the page's origin; `bridgeInterceptor` sends the user's token to, and reads plan-limit refusals from, these | | `locale` | `string` | `'en'` | UI language for the SDK auth components, e.g. `'sv'`. Region variants (`'sv-SE'`) resolve to their base language; an unknown locale falls back to English | diff --git a/learning/billing/onboarding/choose-switch-plans.md b/learning/billing/onboarding/choose-switch-plans.md index c386539..aac15d9 100644 --- a/learning/billing/onboarding/choose-switch-plans.md +++ b/learning/billing/onboarding/choose-switch-plans.md @@ -2,7 +2,7 @@ This is the self-service billing page most apps need: one place where a user picks their first plan, upgrades, downgrades, or switches billing interval. `` is the whole thing in one component. Unlike [``](/billing/onboarding/require-plan/), which *forces* a choice before the app loads, this is the always-available page a user visits when they choose to. -**`bridgeBillingRoutes()` already serves this page** at `/subscription` (with the current plan and a "Manage billing" button), plus `/subscription/success` and `/subscription/error` for the checkout return. Use the component directly only for a page of your own. +**`bridgeBillingRoutes()` already serves this page** at `/subscription`: the current plan with its renewal date and card, a "Manage billing" button, and the plan picker. A completed checkout lands back on `/subscription` with a confirmation banner, and so does a cancelled one (without the banner); `/subscription/error` is where a checkout that could not be confirmed lands. Use the component directly only for a page of your own. Drop `` onto your subscription page. It loads the plans and the status of the current workspace (called a *tenant* in the API) automatically, renders plan cards, and handles free plan selection, Stripe Checkout, and plan changes. @@ -16,7 +16,7 @@ import { PlanSelectorComponent } from '@nebulr-group/bridge-angular'; standalone: true, imports: [PlanSelectorComponent], template: ` - + `, }) export class SubscriptionComponent {} @@ -26,7 +26,8 @@ export class SubscriptionComponent {} | Input | Type | Default | Description | |------|------|---------|-------------| -| `successRedirect` | `string` | `'/subscription'` | In-app route to land on after successful payment | +| `heading` | `string` | (none) | A heading above the plans, beside the Monthly/Yearly switch | +| `successRedirect` | `string` | `'/subscription'` | In-app route to land on after successful payment. Render `` there to confirm it | | `cancelRedirect` | `string` | `'/subscription'` | In-app route to land on if the user cancels checkout | | `defaultInterval` | `'day' \| 'week' \| 'month' \| 'year'` | `'year'` | Interval tab selected first; falls back to the first offered one | | `(select)` | `EventEmitter<{ plan, price }>` | (none) | Called after a free plan is selected or a plan change completes. Without a listener, the picker goes on to `successRedirect` | @@ -39,7 +40,7 @@ export class SubscriptionComponent {} Under the hood, a pick branches on the price and the workspace's payment state: -- `price.amount === 0` (and no metered cost) → calls `selectFreePlan`, refreshes the subscription state, then goes to `successRedirect` +- `price.amount === 0` (and no metered cost) → calls `selectFreePlan`, refreshes the subscription state, then goes to `successRedirect`, where `` confirms it - paid + `paymentsEnabled` → asks first ("Change plan?" naming both plans and the price, since the switch is instant), then calls `changePlan` on confirm and refreshes the subscription state - paid + no payment method yet → calls `startCheckout`, launches Stripe Checkout @@ -59,7 +60,7 @@ Under the hood, a pick branches on the price and the workspace's payment state: ``` -The default card also lists each plan's features (the same list the upgrade dialog reads), sorts plans cheapest first, and offers Monthly / Yearly tabs when prices come in more than one interval. +The default card shows the price large, lists each plan's features (the same list the upgrade dialog reads) with check marks, sorts plans cheapest first, and offers Monthly / Yearly tabs when prices come in more than one interval. Its button says "Choose Pro" when the workspace has no plan yet, and "Upgrade to Team" or "Switch to Free" relative to the current plan, which is marked in your primary colour. The cards follow your `--bridge-*` tokens (see [Theming](/theming/)); for a different card altogether, pass `planCardTemplate`. **Data attributes for CSS styling:** @@ -70,4 +71,7 @@ The default card also lists each plan's features (the same list the upgrade dial | `data-state` | `"idle"` `"select-plan"` `"active"` `"trial"` `"payment-failed"` `"setup-payments"` | Current status | | `data-bridge-plan-card` | (no value) | On each plan card | | `data-current` | `"true"` / `"false"` | Whether this card is the current plan | +| `data-pick` | `"current"` / `"choose"` / `"upgrade"` / `"switch"` | What picking this card does, relative to the current plan | +| `data-bridge-plan-price` | (no value) | The price block on a card | +| `data-bridge-plan-current-flag` | (no value) | The "Your plan" flag on the current plan's card | | `data-trial` | `"true"` / `"false"` | Whether this plan has a trial | diff --git a/learning/billing/onboarding/require-plan.md b/learning/billing/onboarding/require-plan.md index 62fa1cd..92a5273 100644 --- a/learning/billing/onboarding/require-plan.md +++ b/learning/billing/onboarding/require-plan.md @@ -83,7 +83,7 @@ provideBridge({ appId: environment.bridgeAppId, billing: { paywallRoute: '/welco export class WelcomeComponent {} ``` -A completed checkout lands on `/subscription/success`; a cancelled one comes back to the page. +A completed checkout lands on `billing.successRoute` (the subscription page, with a confirmation banner); a cancelled one comes back to the page. > **Tip:** `` is the same picker `` renders inside its modal. See [Choose & switch plans](/billing/onboarding/choose-switch-plans/) for its full input table and customization options. diff --git a/learning/billing/setup/add-billing-to-your-app.md b/learning/billing/setup/add-billing-to-your-app.md index cc101f3..b64b0c3 100644 --- a/learning/billing/setup/add-billing-to-your-app.md +++ b/learning/billing/setup/add-billing-to-your-app.md @@ -77,7 +77,9 @@ export const appConfig: ApplicationConfig = { wherever your `` lives. (Workspaces that opt out via `paymentsAutoRedirect: false` are exempt.) - **`paymentErrorRoute`**: where Bridge sends the user if a Stripe checkout - confirmation fails on the return trip. Defaults to `/payment-error`. + confirmation fails on the return trip. Defaults to `/subscription/error`. +- **`successRoute`**: where a completed checkout, or a Free plan pick, lands. + Defaults to the subscription page; see [Where a checkout lands](#where-a-checkout-lands). Both are optional. Leave `paywallRoute` unset if you'd rather gate the app with `` (below) than redirect. @@ -89,6 +91,48 @@ Both are optional. Leave `paywallRoute` unset if you'd rather gate the app with > confirms the checkout session before landing on your redirect target; see > [Require a plan to use the app](/billing/onboarding/require-plan/). +### Where a checkout lands + +After a paid checkout, or a Free plan pick, the user comes back to the +subscription page `bridgeBillingRoutes()` serves, which shows a "You're on Pro +now" banner. There is no separate confirmation step. To send them somewhere +else, set `billing.successRoute` in `provideBridge()`: + +```ts +provideBridge({ appId: environment.bridgeAppId, billing: { successRoute: '/dashboard' } }), +``` + +To show the same banner there, put `` on that page or +in your app shell (import `CheckoutNoticeComponent`). It renders nothing until a +checkout has just completed, shows once, and is gone after a reload. For a +message of your own, read the `checkoutResult` signal instead: + +```ts +import { Component } from '@angular/core'; +import { checkoutResult, clearCheckoutResult } from '@nebulr-group/bridge-angular'; + +@Component({ + selector: 'app-thanks', + standalone: true, + template: ` + @if (result()) { +

Thanks for upgrading!

+ } + `, +}) +export class ThanksComponent { + protected readonly result = checkoutResult; + protected dismiss() { + clearCheckoutResult(); + } +} +``` + +`checkoutResult()?.kind` is `'checkout'` after a paid checkout and `'plan'` after +a Free pick. The old confirmation page is still served: `successRoute: +'/subscription/success'` brings it back. `bridgeBillingRoutes({ checkoutNotice: false })` +hides the banner on the subscription page. + ## Adding billing to your UI Here are three use cases for billing in your UI: @@ -131,7 +175,7 @@ import { PlanSelectorComponent } from '@nebulr-group/bridge-angular'; standalone: true, imports: [PlanSelectorComponent], template: ` - + `, }) export class SubscriptionComponent {} diff --git a/learning/mechanisms.md b/learning/mechanisms.md index 7c95fac..4edfb27 100644 --- a/learning/mechanisms.md +++ b/learning/mechanisms.md @@ -137,7 +137,7 @@ The same ladder holds for the sign-in pages (`bridgeAuthRoutes()`) and the subsc | Rung | What you do | What you own | |---|---|---| | **0 — nothing** | Bridge's pages render in your `` | Your navigation, header and shell already surround them | -| **1 — tokens** | Set `--bridge-*` CSS variables in your CSS | Colours, radius, spacing | +| **1 — tokens** | Set `--bridge-*` CSS variables in your CSS, and plain CSS for anything else | Colours, radius, spacing, weights, shadows | | **2 — frame and heading** | `bridgeAuthRoutes({ frame: AuthLayoutComponent, heading: (page) => … })` | Everything around the form on every page (the frame is a layout component with its own ``), and each page's heading | | **3 — take over one page** | `bridgeAuthRoutes({ overrides: { login: { component: MyLoginComponent } } })`, or your own route for that address placed before the spread | That one page; every other page keeps working | | **4 — headless** | Build your own UI on `AuthService.getBridgeAuth()` | Everything | @@ -152,12 +152,12 @@ The same ladder holds for the sign-in pages (`bridgeAuthRoutes()`) and the subsc `heading` replaces only each page's main heading; return `null` to keep a page's default. A sign-in page you own navigates itself after sign-in: `(login)="router.navigateByUrl(readReturnTo(location.href) ?? '/')"`. -**The token contract (rung 1).** The same `--bridge-*` variables as every Bridge plugin; the full table is in [theming](theming/theming.md). The plugin declares its defaults on `:where(:root)`, which has zero specificity, so your `:root` wins whichever stylesheet loads first. Leaving out the stylesheet makes the components headless: plain HTML for you to style. +**The token contract (rung 1).** The same `--bridge-*` variables as every Bridge plugin; the full table is in [theming](theming/theming.md). Set only what your app does not already give: Bridge inherits your font and text colour, and every Bridge text size follows your `` text size. Besides colours there are card, weight and shadow tokens (`--bridge-card-bg`, `--bridge-card-shadow`, `--bridge-font-weight-heading` / `-button` / `-label`, `--bridge-button-shadow`, and `--bridge-font-size` to make Bridge text differ from your body). All Bridge styles sit in a CSS cascade layer named `bridge`, so your `:root` wins whichever stylesheet loads first, and any plain CSS you write outside a layer overrides Bridge's classes and data attributes with no `!important`. Leaving out the stylesheet makes the components headless: plain HTML for you to style. ## 6. Pages Bridge serves, and the one it only offers - **Sign-in:** `bridgeAuthRoutes()` serves `/auth/login`, `/auth/signup`, `/auth/oauth-callback`, `/auth/set-password/:token` (where signup verification and password-reset emails land), `/auth/forgot-password`, `/auth/magic-link`, `/auth/setup-passkey/:token` and `/auth/workspaces`. They are public by construction (the guard honours their route data). Which methods appear comes from the app's settings at runtime. Hosted and in-app sign-in use the same routes; `loginRoute: '/auth/login'` is the whole switch to in-app. -- **Subscription:** `bridgeBillingRoutes()` serves `/subscription`, the paywall `/subscription/plan`, and the checkout return pages `/subscription/success` and `/subscription/error`. These are the defaults of `billing.manageRoute`, `billing.paywallRoute` and `billing.paymentErrorRoute`, so Bridge's redirects and upgrade links point at pages that exist. +- **Subscription:** `bridgeBillingRoutes()` serves `/subscription`, the paywall `/subscription/plan`, and the checkout return pages `/subscription/success` and `/subscription/error`. These are the defaults of `billing.manageRoute`, `billing.paywallRoute` and `billing.paymentErrorRoute`, so Bridge's redirects and upgrade links point at pages that exist. A completed checkout, or a Free plan pick, lands back on `/subscription` with a confirmation banner (``); `billing.successRoute` moves it anywhere in the app. - **The paywall** redirects a signed-in workspace with no plan to `/subscription/plan` before a protected page renders — only when the app has plans and its `paymentsAutoRedirect` setting is on (the default). `billing: { paywallRoute: false }` turns it off. - **A `/welcome` onboarding page is offered, never created unasked.** Only if the developer wants one: a route rendering `` and `billing: { paywallRoute: '/welcome' }` in `provideBridge()`. - Any other address falls through to the app's own `**` route. diff --git a/learning/theming/theming.md b/learning/theming/theming.md index 947b61d..fbf5f65 100644 --- a/learning/theming/theming.md +++ b/learning/theming/theming.md @@ -20,9 +20,44 @@ The stylesheet provides two layers: - **Structural CSS**: layout, spacing, and sizing that components need to render correctly. - **Visual defaults**: a minimal but complete out-of-the-box appearance so forms look reasonable with no extra work. These include a visible input border/focus ring, an indigo primary button, and colored error/success alert banners. +All of it sits in a CSS cascade layer named `bridge`, so your own CSS wins over it (see [Your CSS wins](#your-css-wins)). + +## Matching your app's look + +Take these steps in order, and stop as soon as Bridge looks like the rest of your app: + +1. **Nothing.** Bridge pages render inside your layout and inherit your font, text size and text colour. +2. **Set a few `--bridge-*` variables**: your primary colour, borders, corners, and if your app has a distinct type style, its weights and shadows. The tables below list them all. +3. **Write plain CSS** against Bridge's classes and data attributes for anything the variables don't cover. It wins over Bridge's styles with no `!important`. + +For example, an app with heavy type and hard offset shadows gets there with variables alone: + +```css +/* src/styles.css */ +:root { + --bridge-primary: #ff6b2c; + --bridge-primary-fg: #111; + --bridge-border: #111; + --bridge-border-radius: 10px; + --bridge-font-weight-heading: 800; + --bridge-font-weight-button: 800; + --bridge-font-weight-label: 700; + --bridge-button-shadow: 4px 4px 0 #111; + --bridge-card-shadow: 6px 6px 0 #111; +} +``` + +And a press effect on its buttons is one plain rule: + +```css +.bridge-btn-primary:hover { + transform: translate(-2px, -2px); +} +``` + ## The token contract -The `--bridge-*` variables are the supported way to restyle every Bridge page and component — the same contract as every Bridge plugin (TBP-744). Set them in your own stylesheet on `:root`, or on a wrapper to theme one area. The plugin declares its defaults on `:where(:root)`, which has zero specificity, so **your `:root` wins whichever stylesheet loads first**. +The `--bridge-*` variables are the supported way to restyle every Bridge page and component, the same contract as every Bridge plugin. Set them in your own stylesheet on `:root`, or on a wrapper to theme one area. Bridge's defaults sit in its cascade layer, so **your `:root` wins whichever stylesheet loads first**. ```css /* src/styles.css */ @@ -45,9 +80,10 @@ The `--bridge-*` variables are the supported way to restyle every Bridge page an | `--bridge-muted-bg` | `#f3f4f6` | Subtle fills: tab tracks, hovers, the MFA backup code | | `--bridge-border` | `#d1d5db` | Input, table, card and secondary button borders | | `--bridge-border-radius` | `6px` | Corners of inputs, buttons, alerts, cards and dialogs | +| `--bridge-card-bg` | `--bridge-bg` | Plan cards and the current-plan panel on the subscription page | | `--bridge-overlay` | `rgba(15, 23, 42, 0.45)` | Backdrop behind dialogs | | `--bridge-alert-error-{bg,fg,border}` | `#fef2f2` / `#991b1b` / `#fca5a5` | Errors, critical billing notices, cancelled plan badge | -| `--bridge-alert-success-{bg,fg,border}` | `#f0fdf4` / `#166534` / `#86efac` | Confirmations, active plan badge | +| `--bridge-alert-success-{bg,fg,border}` | `#f0fdf4` / `#166534` / `#86efac` | Confirmations, the checkout banner, active plan badge | | `--bridge-alert-info-{bg,fg,border}` | `#eff6ff` / `#1e40af` / `#bfdbfe` | Info notices, trial badge | | `--bridge-alert-warning-{bg,fg,border}` | `#fffbeb` / `#92400e` / `#fcd34d` | Warnings, a quota nearing its limit, past-due badge | | `--bridge-auth-page-padding` | `3rem 1rem` | Padding of the sign-in pages `bridgeAuthRoutes()` serves | @@ -56,22 +92,50 @@ The `--bridge-*` variables are the supported way to restyle every Bridge page an | `--bridge-paywall-bg` | `rgba(15, 23, 42, 0.72)` | Backdrop of the `` overlay and the billing lockscreen | | `--bridge-paywall-panel-bg` | `--bridge-bg` | Panel of the `` overlay | -The derived tokens (hover, light, focus) follow `--bridge-primary` wherever you set it, unless you set them too. Two older names still work as deprecated aliases: `--bridge-primary-foreground` for `--bridge-primary-fg`, and `--bridge-bg-muted` for `--bridge-muted-bg`. Fonts and body text colour are not tokens: Bridge pages render inside your layout and inherit them. +The derived tokens (hover, light, focus) follow `--bridge-primary` wherever you set it, unless you set them too. Two older names still work as deprecated aliases: `--bridge-primary-foreground` for `--bridge-primary-fg`, and `--bridge-bg-muted` for `--bridge-muted-bg`. + +### Type and shadow + +Every default is the look Bridge has without them. + +| Token | Default | Styles | +|---|---|---| +| `--bridge-font-size` | your `` text size | The base every Bridge text size scales from. Set it only to size Bridge text differently from your body text, e.g. `18px` | +| `--bridge-font-weight-heading` | `600`, `700` on a few titles | Page, dialog and section titles, plan names, prices | +| `--bridge-font-weight-button` | `500` | Every Bridge button | +| `--bridge-font-weight-label` | `500`, `600` on a few | Form labels, table headings, badges, names | +| `--bridge-button-shadow` | `none` | Every Bridge button's shadow, e.g. `4px 4px 0 #111` | +| `--bridge-card-shadow` | a soft 1 to 3px shadow on cards, a deeper one on the dialog | Plan cards, the current-plan panel and the plan-change dialog. `none` gives a flat look, which suits most dark themes | + +A weight token sets every element it covers to the same weight. -## Zero specificity +### Not tokens -All visual-default rules use the `:where()` pseudo-class, which has zero specificity. This means any class or element selector in your own CSS wins automatically, no `!important` needed. +Font family and text colour. Bridge pages render inside your layout, so they inherit your font, text colour and background like any other page. Text size follows your page too: every Bridge text size is relative to your `` text size, so at the browser default of 16px nothing changes, and if your body text is 18px, Bridge's is sized to match. `--bridge-font-size` is there only for when Bridge should differ from your body. -For example, the default primary button is styled as: +## Your CSS wins + +Every Bridge style, in the stylesheet and in the components themselves, lives in a CSS cascade layer named `bridge`. Any CSS you write outside a layer overrides it, whatever its specificity and whatever the load order, with no `!important`: ```css -:where(.bridge-btn-primary) { - background-color: var(--bridge-primary); - /* ... */ +.bridge-btn-primary:hover { + transform: translate(-2px, -2px); +} + +[data-bridge-plan-card] { + border-width: 2px; } ``` -Your own `.bridge-btn-primary { background: red; }` or even a simple `.my-button { background: red; }` will override it without specificity battles. +A plain `.bridge-btn-primary { background: red; }` is enough; there is no specificity to match. + +The one exception is CSS you put in a layer of your own. A layer declared before `bridge` ranks below it, so write overrides outside any `@layer`, or in a layer declared after `bridge`. + +### Tailwind + +With Tailwind, keep the styles import and point the tokens at your theme (`--bridge-primary: var(--color-brand-600)`). Utility classes work in full on your own markup, including inside a `frame` layout. On Bridge's own elements, and in a component's `className`, a utility loses wherever Bridge sets the same property: Tailwind puts its utilities in a cascade layer that comes before Bridge's. Use plain CSS for those, or Tailwind's important modifier (`bg-red-500!` in v4, `!bg-red-500` in v3). + +Bridge declares its layer after Tailwind v4's (`@layer theme, base, components, utilities, bridge;`), so Tailwind's base reset never strips Bridge's buttons, whichever stylesheet loads first. ## Component-level overrides @@ -87,7 +151,7 @@ Components expose a `className` input forwarded to their root element, so you ca } ``` -You can also set CSS variables inline via the `style` attribute (custom properties inherit down into the component): +Plain CSS like this wins over Bridge's styles; Tailwind utilities in `className` follow the rule in [Tailwind](#tailwind). You can also set CSS variables inline via the `style` attribute (custom properties inherit down into the component): ```html @@ -110,6 +174,11 @@ Bridge components expose data attributes that you can use as CSS selectors for s | `[data-bridge-plan-selector]` | (none) | Plan selector root | | `[data-bridge-plan-card]` | (none) | Individual plan card | | `[data-current="true"]` | `"true"` / `"false"` | Current plan card | +| `[data-pick]` | `"current"` / `"choose"` / `"upgrade"` / `"switch"` | What picking a plan card does, relative to the current plan | +| `[data-bridge-plan-price]` | (none) | The price block on a plan card | +| `[data-bridge-plan-current-flag]` | (none) | The "Your plan" flag on the current plan's card | +| `[data-bridge-billing-summary]` | (none) | The current-plan panel on the subscription page | +| `[data-bridge-checkout-notice]` | (none) | The banner after a checkout; `[data-kind]` is `"checkout"` or `"plan"` | | `[data-bridge-alert]` | (none) | Alert component | | `[data-bridge-auth-form]` | (none) | Auth form wrapper | | `[data-bridge-passkey-login]` | (none) | Passkey login button | diff --git a/mcp/billing-prompt.md b/mcp/billing-prompt.md index 4e6243c..e8495a9 100644 --- a/mcp/billing-prompt.md +++ b/mcp/billing-prompt.md @@ -12,12 +12,13 @@ Billing is not one component. Pick the rows that match what the app has to do; m | You need | Use | What it does | |---|---|---| -| **The subscription page, the paywall and the checkout return pages** | `...bridgeBillingRoutes()` in `app.routes.ts` (Step 1) | Serves `/subscription` (current plan, "Manage billing", plan picker), `/subscription/plan` (paywall), `/subscription/success`, `/subscription/error` | +| **The subscription page, the paywall and the checkout return pages** | `...bridgeBillingRoutes()` in `app.routes.ts` (Step 1) | Serves `/subscription` (current plan, "Manage billing", plan picker; a completed checkout lands here with a banner), `/subscription/plan` (paywall), `/subscription/success`, `/subscription/error` | | **The app unusable until the workspace has a plan** | Nothing more | With plans, `bridgeAuthGuard()` redirects a plan-less workspace to `/subscription/plan` | | Let users update their card, see invoices or cancel | `` | Already on `/subscription`; place it anywhere else you want it (Step 5) | | Let a tenant pick or change a plan on a page of your own | `` | Loads plans, applies a free plan directly, launches Stripe Checkout for paid ones | | Tell the user about a failed payment, ending trial or cancellation | `` | Renders nothing while billing is healthy | | Show the current plan and status | `` | Display only | +| Confirm a checkout on a page other than `/subscription` | `` with `billing.successRoute` | The one-time "You're on Pro now" banner; `/subscription` already shows it | | Warn as a metered limit fills up | `` | Silent below 80% of the cap | | Branch your **code** on plan, status or usage | `createSubscriptionSignal()` / `createQuotaSignal(metric)`, or `bridge.tenant.subscription` | Signals — the `create*` pair must be `.destroy()`-ed in `ngOnDestroy` | | Gate a feature on what the plan **bought** | `bridge.tenant.entitlements.can(key)` / `.snapshot()` | Fail-closed until the snapshot loads | @@ -75,12 +76,14 @@ That one spread is the whole subscription surface: | Address | Page | Config default it serves | |---|---|---| -| `/subscription` | Current plan, "Manage billing" (``), plan picker | `billing.manageRoute` | +| `/subscription` | Current plan with renewal date and card, "Manage billing" (``), plan picker. A completed checkout or a free pick lands here with a confirmation banner | `billing.manageRoute`; also `billing.successRoute` | | `/subscription/plan` | The paywall | `billing.paywallRoute` | -| `/subscription/success` | Where a checkout or a free pick lands | `/success` | +| `/subscription/success` | An optional separate confirmation page; used only when `billing.successRoute` points at it | — | | `/subscription/error` | Where a failed checkout confirmation lands | `billing.paymentErrorRoute` | -The plan picker loads plans cheapest first, shows interval tabs and each plan's features, selects a free plan directly, confirms before an instant switch, and launches Stripe Checkout for a paid plan. Stripe returns through Bridge's `/auth/oauth-callback`, which confirms the checkout and lands on `/subscription/success`. +The plan picker loads plans cheapest first, shows interval tabs and each plan's features, selects a free plan directly, confirms before an instant switch, and launches Stripe Checkout for a paid plan. Stripe returns through Bridge's `/auth/oauth-callback`, which confirms the checkout and lands on `billing.successRoute` (the subscription page, which shows a confirmation banner). + +**Landing somewhere else after checkout.** If the developer wants users back in the app after paying, set `billing: { successRoute: '/dashboard' }` (their page) in `provideBridge()`. To confirm it there, render `` (import `CheckoutNoticeComponent`) on that page or in the app shell; it shows once, only right after a checkout. For custom copy, read the `checkoutResult` signal. Do not build a confirmation page by hand. To customise, cheapest first: the `--bridge-*` CSS tokens; then `bridgeBillingRoutes({ frame, heading })` (`frame` is a layout component with a ``, `heading(page)` returns each page's heading); then take one page over and keep the others, `bridgeBillingRoutes({ overrides: { plan: { component: MyPricing } } })`, building it from ``. `path: 'billing'` moves the whole set; set `billing.manageRoute` / `paywallRoute` / `paymentErrorRoute` in `provideBridge()` to match. @@ -88,7 +91,8 @@ To customise, cheapest first: the `--bridge-*` CSS tokens; then `bridgeBillingRo | Binding | Type | Default | Description | |---------|------|---------|-------------| -| `successRedirect` | `string` (input) | `/subscription` | Where to send the user after a successful payment | +| `heading` | `string` (input) | (none) | A heading above the plans, beside the Monthly/Yearly switch | +| `successRedirect` | `string` (input) | `/subscription` | Where to send the user after a successful payment; render `` there to confirm it | | `cancelRedirect` | `string` (input) | `/subscription` | Where to send the user after a cancelled payment | | `className` / `style` | `string` (input) | `''` | Pass-through styling | | `(select)` | `EventEmitter<{ plan, price }>` (output) | — | Fires after free-plan selection or a plan change | @@ -267,9 +271,9 @@ Before verifying, confirm every item was applied: ## Verify 1. Open `/subscription` — plan cards render cheapest first; a tier with monthly + yearly pricing shows interval tabs. -2. Select a free plan — the plan changes and you land on `/subscription/success`. +2. Select a free plan — the plan changes and you land on `/subscription` with a "You're on Free now" banner. 3. Select a paid plan — Stripe Checkout launches. -4. Complete payment — you land on `/subscription/success` with the new plan showing. +4. Complete payment — you land on `/subscription` with the new plan showing and a "You're on … now" banner, shown once (gone after a reload). 5. Cancel payment — you are back on the page you picked from. 6. Back on `/subscription` as the workspace owner with a paid plan: "Manage billing" shows next to the current plan and opens the Stripe customer portal. Signed in as a member, it is not shown. 7. Paywall: sign in as a new workspace with no plan — you are sent to `/subscription/plan` before a guarded page renders. diff --git a/mcp/branding-prompt.md b/mcp/branding-prompt.md index 951b272..77ca585 100644 --- a/mcp/branding-prompt.md +++ b/mcp/branding-prompt.md @@ -67,12 +67,18 @@ Not app code. Over MCP: `update_branding`. On the CLI: `bridge branding …`. Or > `update_branding` is a write tool with real user-visible effect. Confirm with the user before changing a logo or colour — this is the sort of change somebody notices immediately and did not ask for. +## Theming the Bridge components + +Theming is plain CSS against a fixed set of tokens: the `--bridge-*` variables, set in the app's global stylesheet (`src/styles.css`), after the `@import '@nebulr-group/bridge-angular/styles.css'` line. The full list with defaults is in `bridge guide mechanisms`; hover, focus and tint follow `--bridge-primary` unless set. Besides colours there are card, weight and shadow tokens (`--bridge-card-bg`, `--bridge-card-shadow`, `--bridge-font-weight-heading` / `-button` / `-label`, `--bridge-button-shadow`) for an app with its own type style. Don't set what the app already gives: Bridge inherits the font and text colour, and its text sizes follow the app's `` (`--bridge-font-size` only to make them differ). + +All Bridge styles sit in a CSS cascade layer named `bridge`, so the app's `:root` wins whatever order the stylesheets load in, and any plain CSS the app writes outside a layer overrides Bridge's classes and data attributes without `!important` (`[data-bridge-plan-card] { border-width: 2px; }`). Tailwind utilities are themselves in a layer, so on Bridge's elements they lose where Bridge sets the same property: use plain CSS there, or Tailwind's important modifier. To bind a token to the workspace's live branding, set it from the signal: `
`. + ## Common mistakes - **Fetching branding from your own API.** It is already on the live channel; a copy in your backend is stale the moment an admin edits it, and you lose the push. - **Reading it once at startup.** It updates live; a one-shot read silently reverts the feature to "needs a reload". - **Assuming the colours exist.** They are optional. Always pass a fallback. -- **Using branding to style the Bridge components.** That is theming — plain CSS. +- **Using branding to style the Bridge components.** That is theming: start with the `--bridge-*` tokens, and for anything they don't cover, write plain CSS against Bridge's classes and the `[data-bridge-*]` attributes (the theming docs list them). - **Confusing it with the hosted login page.** Bridge brands its own pages from the same record; nothing you do in app code affects those. ## Related guides diff --git a/mcp/sdk-auth-prompt.md b/mcp/sdk-auth-prompt.md index 55517ac..2390424 100644 --- a/mcp/sdk-auth-prompt.md +++ b/mcp/sdk-auth-prompt.md @@ -89,7 +89,9 @@ The sign-in pages render inside the app, so they must look like the rest of it. } ``` - The names on the right are examples: use the variables the app actually defines, or its literal values when it has none. Map its error and success colours to the `--bridge-alert-*` tokens. The components inherit the page font; set nothing for it unless the app puts its font on something other than `body`. The full token list: `bridge guide mechanisms`. + The names on the right are examples: use the variables the app actually defines, or its literal values when it has none. Map its error and success colours to the `--bridge-alert-*` tokens. If the app has a type style of its own (heavy headings, bold buttons, hard offset shadows), map that too: `--bridge-font-weight-heading`, `--bridge-font-weight-button`, `--bridge-font-weight-label`, `--bridge-button-shadow` and `--bridge-card-shadow`. Don't set what the app already gives: the components inherit the font and text colour, and every Bridge text size follows the app's `` text size. Set a font only if the app puts it on something other than `body`. The full token list: `bridge guide mechanisms`. + + For anything the tokens don't cover (a hover effect, a border width), write plain CSS against Bridge's classes and `[data-bridge-*]` attributes in the app's global stylesheet, outside any `@layer`. Bridge's styles sit in a cascade layer named `bridge`, so that CSS wins with no `!important`. Tailwind utility classes on Bridge's elements lose where Bridge sets the same property; use plain CSS there. 3. **Give the pages the app's frame** when the app's own pages sit in a card, a panel or a split layout: pass `bridgeAuthRoutes({ frame: AuthLayoutComponent })`, built from the app's own classes or components, so sign-in is not the one page that looks different. The frame is a layout route, not a wrapper: `bridgeAuthRoutes()` makes it the parent of every sign-in page, so it must contain its own `` and import `RouterOutlet`. The page renders in that outlet. `` receives nothing there, so a frame built on it shows up empty. ```ts diff --git a/package-lock.json b/package-lock.json index 3a3a171..9dec83f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ }, "bridge-angular": { "name": "@nebulr-group/bridge-angular", - "version": "0.8.1", + "version": "0.9.0", "license": "MIT", "dependencies": { "@simplewebauthn/browser": "^13.0.0",