From 3e341ba8f113b2f8b400c11b10f08a2068e59f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 09:21:45 +0100 Subject: [PATCH 01/14] feat(roi): pure ROI calculation and figure formatting computeRoi multiplies reps, opportunities, win rate, deal value and duration, then applies a conservative or ambitious RevOps scenario. The formatting helpers write euros, counts and percentages in French and English. Both are covered by unit tests (#248). --- app/utils/roi-format.test.ts | 84 ++++++++++++++++++ app/utils/roi-format.ts | 72 ++++++++++++++++ app/utils/roi.test.ts | 125 +++++++++++++++++++++++++++ app/utils/roi.ts | 159 +++++++++++++++++++++++++++++++++++ 4 files changed, 440 insertions(+) create mode 100644 app/utils/roi-format.test.ts create mode 100644 app/utils/roi-format.ts create mode 100644 app/utils/roi.test.ts create mode 100644 app/utils/roi.ts diff --git a/app/utils/roi-format.test.ts b/app/utils/roi-format.test.ts new file mode 100644 index 00000000..c691ed9a --- /dev/null +++ b/app/utils/roi-format.test.ts @@ -0,0 +1,84 @@ +import { describe, expect, it } from 'vitest'; +import { + formatRoiCount, + formatRoiDecimal, + formatRoiEuro, + formatRoiPercent, + formatRoiPercentDelta, +} from './roi-format'; + +const NBSP = ' '; + +describe('formatRoiEuro', () => { + it('writes millions with two decimals in French', () => { + expect(formatRoiEuro(9_000_000, 'fr')).toBe(`9,00${NBSP}M€`); + expect(formatRoiEuro(3_439_800, 'fr')).toBe(`3,44${NBSP}M€`); + }); + + it('drops to one decimal from ten million, none from a hundred million', () => { + expect(formatRoiEuro(10_319_400, 'fr')).toBe(`10,3${NBSP}M€`); + expect(formatRoiEuro(123_456_789, 'fr')).toBe(`123${NBSP}M€`); + }); + + it('writes thousands with one decimal, without a trailing zero', () => { + expect(formatRoiEuro(26_250, 'fr')).toBe(`26,3${NBSP}k€`); + expect(formatRoiEuro(25_000, 'fr')).toBe(`25${NBSP}k€`); + expect(formatRoiEuro(1_250, 'fr')).toBe(`1,3${NBSP}k€`); + expect(formatRoiEuro(439_800, 'fr')).toBe(`440${NBSP}k€`); + }); + + it('rounds amounts under a thousand', () => { + expect(formatRoiEuro(812.4, 'fr')).toBe(`812${NBSP}€`); + }); + + it('puts the symbol first in English', () => { + expect(formatRoiEuro(9_000_000, 'en')).toBe('€9.00M'); + expect(formatRoiEuro(26_250, 'en')).toBe('€26.3k'); + expect(formatRoiEuro(25_000, 'en')).toBe('€25k'); + expect(formatRoiEuro(812.4, 'en')).toBe('€812'); + }); + + it('keeps the sign of a negative amount', () => { + expect(formatRoiEuro(-1_250, 'en')).toBe('-€1.3k'); + }); +}); + +describe('formatRoiDecimal', () => { + it('shows a decimal only when the value has one', () => { + expect(formatRoiDecimal(3, 'fr')).toBe('3'); + expect(formatRoiDecimal(1.5, 'fr')).toBe('1,5'); + expect(formatRoiDecimal(10.5, 'en')).toBe('10.5'); + }); + + it('rounds to one decimal', () => { + expect(formatRoiDecimal(0.55, 'en')).toBe('0.6'); + expect(formatRoiDecimal(5.999, 'en')).toBe('6'); + }); +}); + +describe('formatRoiCount', () => { + it('rounds to a whole number', () => { + expect(formatRoiCount(131.04, 'fr')).toBe('131'); + }); + + it('groups thousands', () => { + expect(formatRoiCount(1_234, 'en')).toBe('1,234'); + expect(formatRoiCount(1_234, 'fr')).toMatch(/^1\s234$/u); + }); +}); + +describe('formatRoiPercentDelta', () => { + it('signs a relative change and rounds it', () => { + expect(formatRoiPercentDelta(0.05, 'fr')).toBe(`+5${NBSP}%`); + expect(formatRoiPercentDelta(0.1466, 'en')).toBe('+15%'); + expect(formatRoiPercentDelta(-0.02, 'en')).toBe('-2%'); + expect(formatRoiPercentDelta(0, 'en')).toBe('+0%'); + }); +}); + +describe('formatRoiPercent', () => { + it('writes a win rate', () => { + expect(formatRoiPercent(25, 'fr')).toBe(`25${NBSP}%`); + expect(formatRoiPercent(26, 'en')).toBe('26%'); + }); +}); diff --git a/app/utils/roi-format.ts b/app/utils/roi-format.ts new file mode 100644 index 00000000..34ae7e7a --- /dev/null +++ b/app/utils/roi-format.ts @@ -0,0 +1,72 @@ +import type { Language } from '~/localization/resources'; + +/** + * Number formatting for the ROI calculator (#248). + * + * French writes "3,44 M€" and "+15 %" with a non-breaking space; English + * writes "€3.44M" and "+15%". Unit words (years, points, opportunities) + * stay in the locale files: these helpers only return figures. + */ + +const NBSP = ' '; + +const INTL_LOCALE: Record = { + fr: 'fr-FR', + en: 'en-GB', +}; + +const toLocaleDecimal = (value: string, lang: Language): string => + lang === 'fr' ? value.replace('.', ',') : value; + +/** One decimal when the value has one, none otherwise: "3", "1,5". */ +export const formatRoiDecimal = (value: number, lang: Language): string => { + const rounded = Math.round(value * 10) / 10; + const digits = Number.isInteger(rounded) ? 0 : 1; + return toLocaleDecimal(rounded.toFixed(digits), lang); +}; + +const scaleEuro = (amount: number): { figure: string; suffix: string } => { + if (amount >= 1e6) { + const digits = amount >= 1e8 ? 0 : amount >= 1e7 ? 1 : 2; + return { figure: (amount / 1e6).toFixed(digits), suffix: 'M' }; + } + if (amount >= 1e3) { + const digits = amount >= 1e5 ? 0 : 1; + const figure = (amount / 1e3).toFixed(digits).replace(/\.0$/, ''); + return { figure, suffix: 'k' }; + } + return { figure: String(Math.round(amount)), suffix: '' }; +}; + +/** A euro amount, shortened to k€ or M€: "26,3 k€", "€9.00M". */ +export const formatRoiEuro = (value: number, lang: Language): string => { + const sign = value < 0 ? '-' : ''; + const { figure, suffix } = scaleEuro(Math.abs(value)); + const localised = toLocaleDecimal(figure, lang); + return lang === 'fr' + ? `${sign}${localised}${NBSP}${suffix}€` + : `${sign}€${localised}${suffix}`; +}; + +/** A whole number with thousands grouped: "1 234", "1,234". */ +export const formatRoiCount = (value: number, lang: Language): string => + new Intl.NumberFormat(INTL_LOCALE[lang], { + maximumFractionDigits: 0, + }).format(value); + +const percentSuffix = (lang: Language): string => + lang === 'fr' ? `${NBSP}%` : '%'; + +/** A win rate in percent: "25 %", "25%". */ +export const formatRoiPercent = (value: number, lang: Language): string => + `${formatRoiDecimal(value, lang)}${percentSuffix(lang)}`; + +/** A signed relative change, from a fraction: 0.05 gives "+5 %". */ +export const formatRoiPercentDelta = ( + fraction: number, + lang: Language, +): string => { + const rounded = Math.round(fraction * 100); + const sign = rounded >= 0 ? '+' : ''; + return `${sign}${rounded}${percentSuffix(lang)}`; +}; diff --git a/app/utils/roi.test.ts b/app/utils/roi.test.ts new file mode 100644 index 00000000..b1cdbd05 --- /dev/null +++ b/app/utils/roi.test.ts @@ -0,0 +1,125 @@ +import { describe, expect, it } from 'vitest'; +import { + ROI_DEFAULT_INPUTS, + ROI_INPUT_RANGES, + ROI_SCENARIOS, + clampRoiInput, + computeRoi, +} from './roi'; + +describe('computeRoi', () => { + it('computes the current funnel from the five inputs', () => { + const { today } = computeRoi(ROI_DEFAULT_INPUTS, 'conservative'); + + expect(today.oppsPerRepPerYear).toBe(120); + expect(today.oppsPerYear).toBe(480); + expect(today.deals).toBe(120); + expect(today.booking).toBe(3_000_000); + expect(today.contractValue).toBe(9_000_000); + }); + + it('applies the conservative levers to opportunities, win rate and deal value', () => { + const { withRevops } = computeRoi(ROI_DEFAULT_INPUTS, 'conservative'); + + expect(withRevops.reps).toBe(4); + expect(withRevops.oppsPerRepPerMonth).toBeCloseTo(10.5); + expect(withRevops.oppsPerRepPerYear).toBeCloseTo(126); + expect(withRevops.oppsPerYear).toBeCloseTo(504); + expect(withRevops.winRate).toBe(26); + expect(withRevops.deals).toBeCloseTo(131.04); + expect(withRevops.acv).toBeCloseTo(26_250); + expect(withRevops.booking).toBeCloseTo(3_439_800); + expect(withRevops.durationYears).toBe(3); + expect(withRevops.contractValue).toBeCloseTo(10_319_400); + }); + + it('applies the ambitious levers', () => { + const { withRevops } = computeRoi(ROI_DEFAULT_INPUTS, 'ambitious'); + + expect(withRevops.oppsPerRepPerMonth).toBeCloseTo(11); + expect(withRevops.winRate).toBe(28); + expect(withRevops.acv).toBeCloseTo(27_500); + // 4 x 11 x 12 x 28% x 27,500 = 4,065,600 + expect(withRevops.booking).toBeCloseTo(4_065_600); + }); + + it('reports the gain and the lever increments', () => { + const result = computeRoi(ROI_DEFAULT_INPUTS, 'conservative'); + + expect(result.gain.contractValue).toBeCloseTo(1_319_400); + expect(result.gain.booking).toBeCloseTo(439_800); + expect(result.levers.oppsPerRepPerMonth).toBeCloseTo(0.5); + expect(result.levers.oppsPerRepPerYear).toBeCloseTo(6); + expect(result.levers.winRatePoints).toBe(1); + expect(result.levers.acv).toBeCloseTo(1_250); + }); + + it('reports the relative change of each computed row', () => { + const { deltas } = computeRoi(ROI_DEFAULT_INPUTS, 'conservative'); + + expect(deltas.oppsPerYear).toBeCloseTo(0.05); + expect(deltas.deals).toBeCloseTo(0.092); + expect(deltas.booking).toBeCloseTo(0.1466); + expect(deltas.contractValue).toBeCloseTo(0.1466); + }); + + it('caps the improved win rate at 100', () => { + const result = computeRoi( + { ...ROI_DEFAULT_INPUTS, winRate: 99 }, + 'ambitious', + ); + + expect(result.withRevops.winRate).toBe(100); + expect(result.levers.winRatePoints).toBe(1); + }); + + it('returns zero deltas instead of NaN when the base row is zero', () => { + const result = computeRoi( + { ...ROI_DEFAULT_INPUTS, reps: 0 }, + 'conservative', + ); + + expect(result.deltas.oppsPerYear).toBe(0); + expect(result.deltas.contractValue).toBe(0); + }); +}); + +describe('ROI_SCENARIOS', () => { + it('keeps the ambitious levers above the conservative ones', () => { + const { conservative, ambitious } = ROI_SCENARIOS; + + expect(ambitious.oppsUplift).toBeGreaterThan(conservative.oppsUplift); + expect(ambitious.winRatePoints).toBeGreaterThan(conservative.winRatePoints); + expect(ambitious.acvUplift).toBeGreaterThan(conservative.acvUplift); + }); +}); + +describe('clampRoiInput', () => { + it('keeps a value inside its range', () => { + expect(clampRoiInput('reps', 12)).toBe(12); + }); + + it('clamps to the range bounds', () => { + expect(clampRoiInput('reps', 0)).toBe(ROI_INPUT_RANGES.reps.min); + expect(clampRoiInput('winRate', 95)).toBe(ROI_INPUT_RANGES.winRate.max); + }); + + it('snaps to the step', () => { + expect(clampRoiInput('durationYears', 2.3)).toBe(2.5); + expect(clampRoiInput('acv', 25_400)).toBe(25_000); + }); + + it('falls back to the default on a non-numeric value', () => { + expect(clampRoiInput('reps', Number.NaN)).toBe(ROI_DEFAULT_INPUTS.reps); + }); + + it('keeps every default inside its range', () => { + for (const key of Object.keys(ROI_INPUT_RANGES) as Array< + keyof typeof ROI_INPUT_RANGES + >) { + expect(clampRoiInput(key, ROI_DEFAULT_INPUTS[key])).toBe( + ROI_DEFAULT_INPUTS[key], + ); + } + }); +}); diff --git a/app/utils/roi.ts b/app/utils/roi.ts new file mode 100644 index 00000000..70819685 --- /dev/null +++ b/app/utils/roi.ts @@ -0,0 +1,159 @@ +/** + * ROI calculator for the `/roi` page (#248). + * + * The sales funnel is a product: reps x opportunities x win rate x deal + * value x contract duration. A RevOps scenario lifts three of those factors + * a little, and the gains multiply instead of adding up. Pure functions only: + * the page wires its sliders to `computeRoi` and formats the result. + */ + +export type RoiScenario = 'conservative' | 'ambitious'; + +export type RoiInputs = { + /** Number of people who sign deals. */ + reps: number; + /** Qualified opportunities per rep and per month. */ + oppsPerRepPerMonth: number; + /** Share of opportunities signed, in percent (25 means 25 %). */ + winRate: number; + /** Average annual value of a contract, in euros. */ + acv: number; + /** Average customer lifetime, in years. */ + durationYears: number; +}; + +export type RoiInputKey = keyof RoiInputs; + +export type RoiLevers = { + /** Relative lift of qualified opportunities (0.05 means +5 %). */ + oppsUplift: number; + /** Win rate gain, in percentage points. */ + winRatePoints: number; + /** Relative lift of the average deal value. */ + acvUplift: number; +}; + +export type RoiFunnel = RoiInputs & { + oppsPerRepPerYear: number; + oppsPerYear: number; + deals: number; + booking: number; + contractValue: number; +}; + +export type RoiResult = { + today: RoiFunnel; + withRevops: RoiFunnel; + /** What each lever adds, in the unit of its input. */ + levers: { + oppsPerRepPerMonth: number; + oppsPerRepPerYear: number; + winRatePoints: number; + acv: number; + }; + /** Relative change of each computed row (0.05 means +5 %). */ + deltas: { + oppsPerYear: number; + deals: number; + booking: number; + contractValue: number; + }; + /** Absolute gain, in euros. */ + gain: { + booking: number; + contractValue: number; + }; +}; + +export type RoiInputRange = { min: number; max: number; step: number }; + +const MONTHS_PER_YEAR = 12; +const MAX_WIN_RATE = 100; + +export const ROI_SCENARIOS: Readonly> = { + conservative: { oppsUplift: 0.05, winRatePoints: 1, acvUplift: 0.05 }, + ambitious: { oppsUplift: 0.1, winRatePoints: 3, acvUplift: 0.1 }, +}; + +export const ROI_DEFAULT_SCENARIO: RoiScenario = 'conservative'; + +export const ROI_DEFAULT_INPUTS: Readonly = { + reps: 4, + oppsPerRepPerMonth: 10, + winRate: 25, + acv: 25_000, + durationYears: 3, +}; + +export const ROI_INPUT_RANGES: Readonly> = { + reps: { min: 1, max: 60, step: 1 }, + oppsPerRepPerMonth: { min: 1, max: 40, step: 1 }, + winRate: { min: 5, max: 60, step: 1 }, + acv: { min: 2_000, max: 200_000, step: 1_000 }, + durationYears: { min: 1, max: 5, step: 0.5 }, +}; + +const buildFunnel = (inputs: RoiInputs): RoiFunnel => { + const oppsPerRepPerYear = inputs.oppsPerRepPerMonth * MONTHS_PER_YEAR; + const oppsPerYear = inputs.reps * oppsPerRepPerYear; + const deals = (oppsPerYear * inputs.winRate) / 100; + const booking = deals * inputs.acv; + return { + ...inputs, + oppsPerRepPerYear, + oppsPerYear, + deals, + booking, + contractValue: booking * inputs.durationYears, + }; +}; + +const relativeChange = (before: number, after: number): number => + before === 0 ? 0 : after / before - 1; + +export const computeRoi = ( + inputs: RoiInputs, + scenario: RoiScenario, +): RoiResult => { + const levers = ROI_SCENARIOS[scenario]; + const today = buildFunnel(inputs); + const withRevops = buildFunnel({ + ...inputs, + oppsPerRepPerMonth: inputs.oppsPerRepPerMonth * (1 + levers.oppsUplift), + winRate: Math.min(inputs.winRate + levers.winRatePoints, MAX_WIN_RATE), + acv: inputs.acv * (1 + levers.acvUplift), + }); + + return { + today, + withRevops, + levers: { + oppsPerRepPerMonth: + withRevops.oppsPerRepPerMonth - today.oppsPerRepPerMonth, + oppsPerRepPerYear: withRevops.oppsPerRepPerYear - today.oppsPerRepPerYear, + winRatePoints: withRevops.winRate - today.winRate, + acv: withRevops.acv - today.acv, + }, + deltas: { + oppsPerYear: relativeChange(today.oppsPerYear, withRevops.oppsPerYear), + deals: relativeChange(today.deals, withRevops.deals), + booking: relativeChange(today.booking, withRevops.booking), + contractValue: relativeChange( + today.contractValue, + withRevops.contractValue, + ), + }, + gain: { + booking: withRevops.booking - today.booking, + contractValue: withRevops.contractValue - today.contractValue, + }, + }; +}; + +/** Brings a raw slider value back inside its range, snapped to the step. */ +export const clampRoiInput = (key: RoiInputKey, value: number): number => { + if (!Number.isFinite(value)) return ROI_DEFAULT_INPUTS[key]; + const { min, max, step } = ROI_INPUT_RANGES[key]; + const snapped = min + Math.round((value - min) / step) * step; + return Math.min(Math.max(snapped, min), max); +}; From c279cc9a8239f2e9ca0bdc68db4fa3abc4695cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 09:25:28 +0100 Subject: [PATCH 02/14] feat(flags): hold roi in production until its copy is signed off Production sets DISABLED_PAGES without roi, so dropping roi from the unbuilt list would publish the page. AWAITING_SIGN_OFF_PAGES keeps it off in production whatever the env var says, and lets Vercel previews and local dev follow DISABLED_PAGES so the page can be reviewed. Refs #248. --- app/hooks/useMenuItems.test.tsx | 7 +++-- app/modules/feature-flags.test.ts | 44 +++++++++++++++++++++++---- app/modules/feature-flags.ts | 30 +++++++++++++----- docs/development/operational-guide.md | 4 ++- 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/app/hooks/useMenuItems.test.tsx b/app/hooks/useMenuItems.test.tsx index ad9d4855..07dc4509 100644 --- a/app/hooks/useMenuItems.test.tsx +++ b/app/hooks/useMenuItems.test.tsx @@ -2,7 +2,7 @@ * @vitest-environment jsdom */ import { cleanup } from '@testing-library/react'; -import { afterEach, describe, expect, it } from 'vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; import { challengePalette } from '~/components/challenges/challenge-palette'; import type { NavItem } from '~/components/navbar-v2/types'; @@ -250,9 +250,12 @@ describe('useMenuItems', () => { } else { process.env.DISABLED_PAGES = originalEnv; } + vi.unstubAllEnvs(); }); - it('hides the ROI calculator until its page exists (#248)', () => { + it('hides the ROI calculator in production until its copy is signed off (#248)', () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', 'production'); process.env.DISABLED_PAGES = 'news,tools'; const resources = find( renderMenu({ disabledPages: getDisabledPages() }), diff --git a/app/modules/feature-flags.test.ts b/app/modules/feature-flags.test.ts index 7b4d70c5..18cceca5 100644 --- a/app/modules/feature-flags.test.ts +++ b/app/modules/feature-flags.test.ts @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from 'vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; import { DISABLED_PAGES_DEFAULT, @@ -16,6 +16,7 @@ describe('feature-flags', () => { } else { process.env.DISABLED_PAGES = originalEnv; } + vi.unstubAllEnvs(); }); describe('getDisabledPages', () => { @@ -24,22 +25,53 @@ describe('feature-flags', () => { expect(getDisabledPages()).toEqual(DISABLED_PAGES_DEFAULT); }); - it('keeps only the unbuilt pages when env var is empty', () => { + it('returns no page when env var is empty', () => { process.env.DISABLED_PAGES = ''; - expect(getDisabledPages()).toEqual(['roi']); + expect(getDisabledPages()).toEqual([]); }); it('parses comma-separated slugs', () => { process.env.DISABLED_PAGES = 'news, tools'; - expect(getDisabledPages()).toEqual(['news', 'tools', 'roi']); + expect(getDisabledPages()).toEqual(['news', 'tools']); }); + }); - it('keeps roi disabled whatever the env var says, until #248', () => { + describe('pages awaiting copy sign-off (roi)', () => { + it('keeps roi disabled in production whatever the env var says', () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', 'production'); process.env.DISABLED_PAGES = 'news,tools'; expect(isPageEnabled('roi')).toBe(false); process.env.DISABLED_PAGES = ''; expect(isPageEnabled('roi')).toBe(false); }); + + it('keeps roi disabled on a production build outside Vercel', () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', undefined); + process.env.DISABLED_PAGES = ''; + expect(isPageEnabled('roi')).toBe(false); + }); + + it('lets the env var enable roi on a Vercel preview', () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', 'preview'); + process.env.DISABLED_PAGES = 'news,tools'; + expect(isPageEnabled('roi')).toBe(true); + }); + + it('lets the env var enable roi in local development', () => { + vi.stubEnv('NODE_ENV', 'development'); + process.env.DISABLED_PAGES = 'news,tools'; + expect(isPageEnabled('roi')).toBe(true); + }); + + it('keeps roi disabled by default on a preview', () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', 'preview'); + delete process.env.DISABLED_PAGES; + expect(isPageEnabled('roi')).toBe(false); + }); }); describe('isPageEnabled', () => { @@ -75,7 +107,7 @@ describe('feature-flags', () => { it('ignores invalid slugs in env var', () => { process.env.DISABLED_PAGES = 'news,bogus,tools'; - expect(getDisabledPages()).toEqual(['news', 'tools', 'roi']); + expect(getDisabledPages()).toEqual(['news', 'tools']); }); it('does not throw when page is enabled', () => { diff --git a/app/modules/feature-flags.ts b/app/modules/feature-flags.ts index 59c342f7..281f5bfc 100644 --- a/app/modules/feature-flags.ts +++ b/app/modules/feature-flags.ts @@ -25,25 +25,39 @@ const VALID_SLUGS: Set = new Set([ ]); /** - * P2+ pages disabled by default until launched. `roi` waits for the ROI page - * (#248) and Ocobo's sign-off on its assumptions copy. + * P2+ pages disabled by default until launched. `roi` also waits for Ocobo's + * sign-off on its assumptions copy (#248). */ export const DISABLED_PAGES_DEFAULT: PageSlug[] = ['news', 'tools', 'roi']; /** - * Pages not built yet: disabled whatever DISABLED_PAGES says, since that env - * var replaces the default list. #248 removes `roi` from here when it ships - * the ROI calculator page. + * Built pages waiting for Ocobo's sign-off on their copy. Production keeps + * them off whatever DISABLED_PAGES says, since that env var replaces the + * default list. Vercel previews and local development follow DISABLED_PAGES, + * so the copy can be reviewed there. Remove a slug once Ocobo approves it. */ -const UNBUILT_PAGES: PageSlug[] = ['roi']; +const AWAITING_SIGN_OFF_PAGES: PageSlug[] = ['roi']; + +/** + * True on a Vercel preview and outside production builds. Fails closed: a + * production build without VERCEL_ENV counts as production. + */ +function isReviewEnvironment(): boolean { + return ( + process.env.VERCEL_ENV === 'preview' || + process.env.NODE_ENV !== 'production' + ); +} /** * Returns the list of currently disabled page slugs. * Reads from DISABLED_PAGES env var, falls back to DISABLED_PAGES_DEFAULT, - * then adds UNBUILT_PAGES. Server-only, reads process.env. + * then adds AWAITING_SIGN_OFF_PAGES in production. Server-only, reads + * process.env. */ export function getDisabledPages(): PageSlug[] { - return [...new Set([...readDisabledPages(), ...UNBUILT_PAGES])]; + const held = isReviewEnvironment() ? [] : AWAITING_SIGN_OFF_PAGES; + return [...new Set([...readDisabledPages(), ...held])]; } function readDisabledPages(): PageSlug[] { diff --git a/docs/development/operational-guide.md b/docs/development/operational-guide.md index dadc49fe..5979b219 100644 --- a/docs/development/operational-guide.md +++ b/docs/development/operational-guide.md @@ -65,10 +65,12 @@ AGO_BASEPATH="https://your-ago-instance.com" ```bash # Pages to disable, comma-separated. Unset: the default list in # app/modules/feature-flags.ts (news, tools, roi). Empty: all pages on, -# except the pages not built yet (roi). +# except the pages awaiting Ocobo's copy sign-off (roi) in production. DISABLED_PAGES="news,tools" ``` +Pages awaiting copy sign-off (`AWAITING_SIGN_OFF_PAGES` in `app/modules/feature-flags.ts`) stay off in production whatever the variable says. On a Vercel preview (`VERCEL_ENV=preview`) and in local development they follow the variable, so `DISABLED_PAGES="news,tools"` shows them there for review. To launch such a page, remove its slug from that list. + The variable replaces the whole default list: to enable one page, list every other page that must stay disabled. A slug with a typo is ignored, so the page it meant to disable goes live. On Vercel, a change to the variable applies only after a redeploy. A disabled page answers 404 and is hidden from the navigation. The challenge pages carry no flag: every challenge file published on the content repository is live. From 8794172b9f6d9db5c8433c780eec27ede5e84297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 09:25:28 +0100 Subject: [PATCH 03/14] feat(roi): list the ROI page in the sitemap when enabled Refs #248. --- app/routes/sitemap[.xml].test.ts | 40 ++++++++++++++++++++++++++++++++ app/routes/sitemap[.xml].tsx | 22 ++++++++++++++---- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/app/routes/sitemap[.xml].test.ts b/app/routes/sitemap[.xml].test.ts index ce06f609..e41827fc 100644 --- a/app/routes/sitemap[.xml].test.ts +++ b/app/routes/sitemap[.xml].test.ts @@ -9,6 +9,7 @@ * 5. Loader degrades gracefully when any content fetcher fails. * 6. All fetchers fire in parallel (no sequential awaiting). * 7. Challenge routes are listed in both languages. + * 8. The ROI page is listed in both languages only while its flag is on. * * Uses the `invokeLoader` harness (`app/test/loader-harness.ts`). */ @@ -379,4 +380,43 @@ describe('sitemap loader', () => { resolveJobs([200, 'success', []]); await loaderPromise; }); + + describe('ROI page', () => { + async function sitemapBody() { + fetchStoriesMock.mockResolvedValue([200, 'success', []]); + fetchBlogpostsMock.mockResolvedValue([200, 'success', []]); + fetchJobsMock.mockResolvedValue([200, 'success', []]); + const { loader } = await import('./sitemap[.xml]'); + const outcome = await invokeLoader(loader); + if (outcome.type !== 'response') throw new Error('expected response'); + return outcome.response.text(); + } + + it('omits the ROI page while its flag is off', async () => { + vi.stubEnv('DISABLED_PAGES', 'news,tools,roi'); + + const body = await sitemapBody(); + + expect(body).not.toContain('/roi'); + }); + + it('omits the ROI page in production until its copy is signed off', async () => { + vi.stubEnv('NODE_ENV', 'production'); + vi.stubEnv('VERCEL_ENV', 'production'); + vi.stubEnv('DISABLED_PAGES', 'news,tools'); + + const body = await sitemapBody(); + + expect(body).not.toContain('/roi'); + }); + + it('lists the ROI page in both languages once its flag is on', async () => { + vi.stubEnv('DISABLED_PAGES', 'news,tools'); + + const body = await sitemapBody(); + + expect(body).toContain('https://www.ocobo.co/fr/roi'); + expect(body).toContain('https://www.ocobo.co/en/roi'); + }); + }); }); diff --git a/app/routes/sitemap[.xml].tsx b/app/routes/sitemap[.xml].tsx index f9734161..b3213381 100644 --- a/app/routes/sitemap[.xml].tsx +++ b/app/routes/sitemap[.xml].tsx @@ -4,6 +4,7 @@ import type { Language } from '~/localization/resources'; import { shouldBypassCache } from '~/modules/cache'; import { loadChallengeMenu } from '~/modules/challenge-menu.server'; import { fetchBlogposts, fetchJobs, fetchStories } from '~/modules/content'; +import { isPageEnabled } from '~/modules/feature-flags'; const baseUrl = 'https://www.ocobo.co'; @@ -19,6 +20,7 @@ function generateSiteMap( posts: { slug: string; date: Date }[], jobs: { slug: string; date: Date }[], challenges: { slug: string; lang: Language }[], + flaggedPaths: string[], ) { return ` @@ -66,6 +68,14 @@ function generateSiteMap( ), ) .join('\n')} + ${flaggedPaths + .map((path) => + getUrlElementWithDate( + `${baseUrl}${path}`, + new Date().toISOString(), + ), + ) + .join('\n')} ${getUrlElementWithDate(`${baseUrl}/legal/confidentialite`, new Date().toISOString())} ${getUrlElementWithDate(`${baseUrl}/legal/cgu`, new Date().toISOString())} `; @@ -124,9 +134,13 @@ export async function loader({ request }: LoaderFunctionArgs) { challengesQuery('en'), ]); const challenges = [...frChallenges, ...enChallenges]; - return new Response(generateSiteMap(stories, posts, jobs, challenges), { - headers: { - 'content-type': 'application/xml', + const flaggedPaths = isPageEnabled('roi') ? ['/fr/roi', '/en/roi'] : []; + return new Response( + generateSiteMap(stories, posts, jobs, challenges, flaggedPaths), + { + headers: { + 'content-type': 'application/xml', + }, }, - }); + ); } From bb59d2deefc6776224323169278bd7ba0bac9e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 09:37:01 +0100 Subject: [PATCH 04/14] feat(roi): ROI page sections, the walkthrough and the calculator One shared state (five figures and a scenario) feeds the worked example, the sliders, the result card and the detail table. Copy lives in the new roi namespace, FR and EN. --- app/components/roi/roi-detail.tsx | 280 ++++++++++++++++ app/components/roi/roi-diagnostic.tsx | 20 ++ app/components/roi/roi-experience.tsx | 103 ++++++ app/components/roi/roi-hero-chart.tsx | 204 ++++++++++++ app/components/roi/roi-hero.tsx | 63 ++++ app/components/roi/roi-ids.ts | 4 + app/components/roi/roi-inputs-card.tsx | 226 +++++++++++++ app/components/roi/roi-range-input.tsx | 122 +++++++ app/components/roi/roi-result-card.tsx | 155 +++++++++ app/components/roi/roi-step.tsx | 48 +++ app/components/roi/roi-styles.ts | 41 +++ app/components/roi/roi-walkthrough.tsx | 442 +++++++++++++++++++++++++ app/components/roi/use-roi-format.ts | 50 +++ app/localization/resources.ts | 4 + locales/en/roi.json | 93 ++++++ locales/fr/roi.json | 93 ++++++ 16 files changed, 1948 insertions(+) create mode 100644 app/components/roi/roi-detail.tsx create mode 100644 app/components/roi/roi-diagnostic.tsx create mode 100644 app/components/roi/roi-experience.tsx create mode 100644 app/components/roi/roi-hero-chart.tsx create mode 100644 app/components/roi/roi-hero.tsx create mode 100644 app/components/roi/roi-ids.ts create mode 100644 app/components/roi/roi-inputs-card.tsx create mode 100644 app/components/roi/roi-range-input.tsx create mode 100644 app/components/roi/roi-result-card.tsx create mode 100644 app/components/roi/roi-step.tsx create mode 100644 app/components/roi/roi-styles.ts create mode 100644 app/components/roi/roi-walkthrough.tsx create mode 100644 app/components/roi/use-roi-format.ts create mode 100644 locales/en/roi.json create mode 100644 locales/fr/roi.json diff --git a/app/components/roi/roi-detail.tsx b/app/components/roi/roi-detail.tsx new file mode 100644 index 00000000..c65ddd44 --- /dev/null +++ b/app/components/roi/roi-detail.tsx @@ -0,0 +1,280 @@ +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { card } from '@ocobo/styled-system/recipes'; + +import type { RoiResult } from '~/utils/roi'; + +import { ROI_DETAIL_ID } from './roi-ids'; +import { type RoiFormat, useRoiFormat } from './use-roi-format'; + +/** + * "Le détail, ligne par ligne" (mockup `roi`): every step of the funnel, + * today, the RevOps lever and the result. Input rows carry a lever; grey + * result rows carry the relative change. ARIA table roles keep it a table + * for screen readers while the grid reflows on a phone. + */ + +type RowKind = 'input' | 'result' | 'final'; + +type Row = { + key: string; + operator: string; + kind: RowKind; + today: string; + withRevops: string; + /** The lever (input rows) or the relative change (result rows). */ + change?: string; +}; + +const buildRows = (result: RoiResult, f: RoiFormat): Row[] => { + const { today: a, withRevops: b, levers, deltas } = result; + return [ + { + key: 'reps', + operator: '', + kind: 'input', + today: f.count(a.reps), + withRevops: f.count(b.reps), + }, + { + key: 'oppsPerRepPerMonth', + operator: '×', + kind: 'input', + today: f.decimal(a.oppsPerRepPerMonth), + withRevops: f.decimal(b.oppsPerRepPerMonth), + change: f.oppsPerMonth(levers.oppsPerRepPerMonth), + }, + { + key: 'oppsPerYear', + operator: '=', + kind: 'result', + today: f.count(a.oppsPerYear), + withRevops: f.count(b.oppsPerYear), + change: f.delta(deltas.oppsPerYear), + }, + { + key: 'winRate', + operator: '×', + kind: 'input', + today: f.percent(a.winRate), + withRevops: f.percent(b.winRate), + change: f.signedPoints(levers.winRatePoints), + }, + { + key: 'deals', + operator: '=', + kind: 'result', + today: f.count(a.deals), + withRevops: f.count(b.deals), + change: f.delta(deltas.deals), + }, + { + key: 'acv', + operator: '×', + kind: 'input', + today: f.euro(a.acv), + withRevops: f.euro(b.acv), + change: f.signedEuro(levers.acv), + }, + { + key: 'booking', + operator: '=', + kind: 'result', + today: f.euro(a.booking), + withRevops: f.euro(b.booking), + change: f.delta(deltas.booking), + }, + { + key: 'durationYears', + operator: '×', + kind: 'input', + today: f.years(a.durationYears), + withRevops: f.years(b.durationYears), + }, + { + key: 'contractValue', + operator: '=', + kind: 'final', + today: f.euro(a.contractValue), + withRevops: f.euro(b.contractValue), + change: f.delta(deltas.contractValue), + }, + ]; +}; + +const rowGrid = css({ + display: 'grid', + gridTemplateColumns: { + base: '28px minmax(0,1.2fr) auto minmax(0,1fr)', + md: '36px minmax(0,1.5fr) minmax(0,1.3fr) 120px minmax(0,1fr)', + }, + alignItems: 'center', + columnGap: '4', + rowGap: '1', + px: '4', + py: '3.5', +}); +const rowKinds: Record = { + input: css({ + borderTopWidth: '1px', + borderTopStyle: 'solid', + borderTopColor: 'gray.100', + }), + result: css({ bg: 'gray.light', rounded: '2xl', my: '1' }), + final: css({ bg: 'dark', color: 'white', rounded: '2xl', my: '1' }), +}; +// On a phone the label takes the top line and the figures sit below it. +const operatorCell = css({ + gridRow: { base: 'span 2', md: 'auto' }, + fontFamily: 'display', + fontWeight: 'black', + fontSize: 'xl', + color: 'gray.400', + textAlign: 'center', +}); +const labelCell = css({ + gridColumn: { base: '2 / -1', md: 'auto' }, + fontWeight: 'semibold', +}); +const todayCell = css({ fontVariantNumeric: 'tabular-nums' }); +const changeCell = css({ justifySelf: 'center' }); +const revopsCell = css({ + justifySelf: 'end', + fontFamily: 'display', + fontWeight: 'black', + fontSize: 'xl', + fontVariantNumeric: 'tabular-nums', + whiteSpace: 'nowrap', +}); +const pill = css({ + display: 'inline-block', + minW: '16', + textAlign: 'center', + fontSize: 'caption', + fontWeight: 'bold', + rounded: 'full', + px: '2.5', + py: '1', + whiteSpace: 'nowrap', +}); +const pillKinds: Record = { + input: css({ + bg: 'yellow.light', + color: 'dark', + boxShadow: '[inset 0 0 0 1px var(--colors-yellow)]', + }), + result: css({ bg: 'mint.light', color: 'mint.dark' }), + final: css({ bg: 'mint.light', color: 'mint.dark' }), +}; +const headCell = css({ + fontSize: 'xs', + fontWeight: 'bold', + textTransform: 'uppercase', + letterSpacing: 'label', + color: 'gray.400', +}); + +type RoiDetailProps = { + result: RoiResult; +}; + +export function RoiDetail({ result }: RoiDetailProps) { + const { t } = useTranslation('roi'); + const f = useRoiFormat(); + const rows = buildRows(result, f); + + return ( +
+
+

+ {t('detail.title')} +

+

+ {t('detail.hint')} +

+
+
+
+
+ + + + {t('detail.head.today')} + + + {t('detail.head.lever')} + + + {t('detail.head.withRevops')} + +
+ {rows.map((row) => ( +
+ + + {t(`detail.rows.${row.key}`)} + + + {row.today} + + + {row.change ? ( + + {row.change} + + ) : ( + + + + {t('detail.noLever')} + + + )} + + + {row.withRevops} + +
+ ))} +
+
+
+ ); +} diff --git a/app/components/roi/roi-diagnostic.tsx b/app/components/roi/roi-diagnostic.tsx new file mode 100644 index 00000000..994b2bae --- /dev/null +++ b/app/components/roi/roi-diagnostic.tsx @@ -0,0 +1,20 @@ +import { useTranslation } from 'react-i18next'; + +import { ChallengeDiagnostic } from '~/components/challenges/challenge-diagnostic'; + +/** The closing call to action of the ROI page, the challenge pages' block. */ +export function RoiDiagnostic() { + const { t } = useTranslation('roi'); + const cta = t('diagnostic.cta'); + + return ( + + ); +} diff --git a/app/components/roi/roi-experience.tsx b/app/components/roi/roi-experience.tsx new file mode 100644 index 00000000..3ac6e5dc --- /dev/null +++ b/app/components/roi/roi-experience.tsx @@ -0,0 +1,103 @@ +import { useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { section, text } from '@ocobo/styled-system/recipes'; + +import { Container } from '~/components/ui/Container'; +import { + ROI_DEFAULT_INPUTS, + ROI_DEFAULT_SCENARIO, + type RoiInputKey, + type RoiInputs, + type RoiScenario, + clampRoiInput, + computeRoi, +} from '~/utils/roi'; + +import { RoiDetail } from './roi-detail'; +import { ROI_CALCULATOR_ID } from './roi-ids'; +import { RoiInputsCard } from './roi-inputs-card'; +import { RoiResultCard } from './roi-result-card'; +import { dotBackdropTop } from './roi-styles'; +import { RoiWalkthrough } from './roi-walkthrough'; + +/** + * The interactive part of the ROI page. One state (five figures and a + * scenario) feeds the walkthrough, the calculator and the detail table, so + * the worked example follows the visitor's own numbers. + */ +export function RoiExperience() { + const { t } = useTranslation('roi'); + const [inputs, setInputs] = useState(ROI_DEFAULT_INPUTS); + const [scenario, setScenario] = useState(ROI_DEFAULT_SCENARIO); + const result = useMemo( + () => computeRoi(inputs, scenario), + [inputs, scenario], + ); + + const handleInputChange = (key: RoiInputKey, value: number) => { + setInputs((current) => ({ ...current, [key]: clampRoiInput(key, value) })); + }; + + return ( + <> + +
+ +
+

+ {t('calculator.title')} +

+

+ {t('calculator.intro')} +

+
+
+ +
+ +
+
+ +
+
+ + ); +} diff --git a/app/components/roi/roi-hero-chart.tsx b/app/components/roi/roi-hero-chart.tsx new file mode 100644 index 00000000..24c5c00e --- /dev/null +++ b/app/components/roi/roi-hero-chart.tsx @@ -0,0 +1,204 @@ +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; + +/** + * The hero curve of the ROI page (mockup `roi`): revenue grows in a straight + * line without RevOps, and bends upward as each lever adds to the others. + * Decorative: the copy above says the same thing in words. It draws itself + * on load with the shared `il-*` keyframes, and stays still under reduced + * motion. + */ + +const easeOut = 'cubic-bezier(0.2, 0.8, 0.2, 1)'; +const easeBack = 'cubic-bezier(0.2, 0.8, 0.2, 1.4)'; + +const root = css({ + position: 'relative', + maxW: '6xl', + mx: 'auto', + mt: '14', + '& svg': { display: 'block', overflow: 'visible', w: 'full', h: 'auto' }, + '& .hx-exp': { + strokeDasharray: '1', + animation: '[il-draw 1.8s cubic-bezier(0.6, 0, 0.2, 1) 0.2s backwards]', + }, + '& .hx-lin': { animation: '[il-fade 0.8s ease 0.2s backwards]' }, + '& .hx-area': { animation: '[il-fade 1s ease 1.4s backwards]' }, + '& .hx-lt': { animation: '[il-fade 0.6s ease 0.9s backwards]' }, + '& .hx-dot': { + transformBox: 'fill-box', + transformOrigin: 'center', + animation: `[il-pop 0.4s ${easeBack} backwards]`, + }, + '& .hx-d1': { animationDelay: '[0.9s]' }, + '& .hx-d2': { animationDelay: '[1.25s]' }, + '& .hx-d3': { animationDelay: '[1.55s]' }, + '& .hx-d4': { animationDelay: '[1.95s]' }, + '& .hx-chip': { animation: `[il-fade 0.5s ${easeOut} backwards]` }, + '& .hx-c1': { animationDelay: '[1s]' }, + '& .hx-c2': { animationDelay: '[1.35s]' }, + '& .hx-c3': { animationDelay: '[1.65s]' }, + '& .hx-end': { animationDelay: '[2.05s]' }, + _motionReduce: { + '& .hx-exp, & .hx-lin, & .hx-area, & .hx-lt, & .hx-dot, & .hx-chip': { + animation: '[none]', + }, + }, +}); + +const axis = css({ stroke: 'gray.200', strokeWidth: '2' }); +const gridLine = css({ + stroke: 'gray.100', + strokeWidth: '1', + strokeDasharray: '4 6', +}); +const area = css({ fill: 'yellow.light' }); +const linear = css({ + fill: '[none]', + stroke: 'gray.400', + strokeWidth: '3', + strokeLinecap: 'round', +}); +const curve = css({ + fill: '[none]', + stroke: 'dark', + strokeWidth: '5', + strokeLinecap: 'round', +}); +const dotBase = css({ stroke: 'white', strokeWidth: '4' }); +const dotFills = { + mint: css({ fill: 'mint' }), + sky: css({ fill: 'sky' }), + coral: css({ fill: 'coral' }), +}; +const dotEnd = css({ fill: 'yellow', stroke: 'dark', strokeWidth: '4' }); +const axisLabel = css({ + fill: 'gray.400', + fontSize: 'sm', + fontStyle: 'italic', +}); +const linearLabel = css({ + fill: 'gray', + fontSize: 'sm', + fontWeight: 'semibold', +}); + +const chip = css({ + position: 'absolute', + // Centred above its point on the curve. + transform: 'translate(-50%, calc(-100% - 18px))', + whiteSpace: 'nowrap', + bg: 'white', + borderWidth: '1px', + borderStyle: 'solid', + borderColor: 'gray.200', + boxShadow: 'rest', + rounded: 'full', + px: { base: '2', md: '3.5' }, + py: { base: '1', md: '1.5' }, + fontSize: { base: 'xs', md: 'sm' }, + fontWeight: 'bold', + color: 'dark', +}); +// Two chips would overlap the others on a phone. +const chipWide = css({ display: { base: 'none', md: 'block' } }); +const chipEnd = css({ + bg: 'dark', + borderColor: 'dark', + color: 'yellow', + fontFamily: 'display', + fontWeight: 'black', + fontSize: { base: 'sm', md: 'lg' }, + px: { base: '3', md: '5' }, + py: { base: '1.5', md: '2.5' }, + transform: { + base: 'translate(-100%, calc(-100% - 14px))', + md: 'translate(-80%, calc(-100% - 22px))', + }, +}); +// The points of the curve, as a share of the 1000 x 320 view box. +const chipPositions = { + c1: css({ left: '[45.6%]', top: '[75.3%]' }), + c2: css({ left: '[68.2%]', top: '[59%]' }), + c3: css({ left: '[83.2%]', top: '[39%]' }), + end: css({ left: '[96%]', top: '[12.5%]' }), +}; + +const CURVE = 'M40,270 C500,265 760,200 960,40'; + +export function RoiHeroChart() { + const { t } = useTranslation('roi'); + + return ( + + ); +} diff --git a/app/components/roi/roi-hero.tsx b/app/components/roi/roi-hero.tsx new file mode 100644 index 00000000..f2f6c1a8 --- /dev/null +++ b/app/components/roi/roi-hero.tsx @@ -0,0 +1,63 @@ +import { ArrowDown } from 'lucide-react'; +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { badge, button, text } from '@ocobo/styled-system/recipes'; + +import { Container } from '~/components/ui/Container'; + +import { RoiHeroChart } from './roi-hero-chart'; +import { ROI_WALKTHROUGH_ID } from './roi-ids'; + +// A yellow marker under the last words of the headline (mockup `roi`). +// The page keeps gradient text for AI content only (ADR 0002). +const marker = css({ + bgImage: '[linear-gradient(var(--colors-yellow), var(--colors-yellow))]', + bgRepeat: 'no-repeat', + bgSize: '[100% 0.32em]', + bgPosition: '[0 88%]', +}); + +export function RoiHero() { + const { t } = useTranslation('roi'); + + return ( +
+ +
+ + {t('hero.badge')} + +

+ {t('hero.title.line1')} +
+ {t('hero.title.highlight')} +

+

+ {t('hero.subtitle')} +

+ + {t('hero.cta')} + +
+ +
+
+ ); +} diff --git a/app/components/roi/roi-ids.ts b/app/components/roi/roi-ids.ts new file mode 100644 index 00000000..e4841777 --- /dev/null +++ b/app/components/roi/roi-ids.ts @@ -0,0 +1,4 @@ +/** Anchors of the ROI page, the targets of its in-page links. */ +export const ROI_WALKTHROUGH_ID = 'calcul'; +export const ROI_CALCULATOR_ID = 'calculateur'; +export const ROI_DETAIL_ID = 'detail'; diff --git a/app/components/roi/roi-inputs-card.tsx b/app/components/roi/roi-inputs-card.tsx new file mode 100644 index 00000000..110ccc71 --- /dev/null +++ b/app/components/roi/roi-inputs-card.tsx @@ -0,0 +1,226 @@ +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { card } from '@ocobo/styled-system/recipes'; + +import { + ROI_INPUT_RANGES, + ROI_SCENARIOS, + type RoiInputKey, + type RoiInputs, + type RoiScenario, +} from '~/utils/roi'; + +import { RoiRangeInput } from './roi-range-input'; +import { RoiStep } from './roi-step'; +import { type RoiFormat, useRoiFormat } from './use-roi-format'; + +/** + * Steps 1 and 2 of the ROI calculator (mockup `roi`): the visitor's five + * figures, then the RevOps scenario and the levers it applies. + */ + +const INPUT_KEYS: ReadonlyArray = [ + 'reps', + 'oppsPerRepPerMonth', + 'winRate', + 'acv', + 'durationYears', +]; + +const SCENARIOS: ReadonlyArray = ['conservative', 'ambitious']; + +const formatInput = (key: RoiInputKey, value: number, f: RoiFormat) => { + switch (key) { + case 'reps': + return f.count(value); + case 'oppsPerRepPerMonth': + return f.decimal(value); + case 'winRate': + return f.percent(value); + case 'acv': + return f.euro(value); + case 'durationYears': + return f.years(value); + } +}; + +// A hairline between figures, except above the first row of the grid. +const inputSeparators = { + none: css({}), + wide: css({ + borderTopWidth: { base: '1px', md: '0' }, + borderTopStyle: 'solid', + borderTopColor: 'gray.100', + }), + all: css({ + borderTopWidth: '1px', + borderTopStyle: 'solid', + borderTopColor: 'gray.100', + }), +}; +const separatorFor = (index: number) => + index === 0 + ? inputSeparators.none + : index === 1 + ? inputSeparators.wide + : inputSeparators.all; +// The last figure takes the whole row when the count is odd. +const lastOdd = css({ gridColumn: { md: '1 / -1' } }); + +const toggleButton = css({ + minH: '11', + rounded: 'full', + fontSize: 'md', + fontWeight: 'bold', + cursor: 'pointer', + transition: 'colors', + _focusVisible: { + outlineWidth: '2px', + outlineStyle: 'solid', + outlineColor: 'yellow', + outlineOffset: '0.5', + }, +}); +const toggleStates = { + active: css({ bg: 'dark', color: 'white' }), + idle: css({ bg: 'transparent', color: 'gray', _hover: { color: 'dark' } }), +}; + +const leverPill = css({ + display: 'inline-flex', + alignItems: 'baseline', + gap: '1', + fontSize: 'caption', + color: 'gray.600', + bg: 'white', + borderWidth: '1px', + borderStyle: 'solid', + borderColor: 'line', + rounded: 'full', + px: '3', + py: '1.5', +}); + +type RoiInputsCardProps = { + inputs: RoiInputs; + scenario: RoiScenario; + onInputChange: (key: RoiInputKey, value: number) => void; + onScenarioChange: (scenario: RoiScenario) => void; +}; + +export function RoiInputsCard({ + inputs, + scenario, + onInputChange, + onScenarioChange, +}: RoiInputsCardProps) { + const { t } = useTranslation('roi'); + const f = useRoiFormat(); + const levers = ROI_SCENARIOS[scenario]; + const leverPills = [ + { key: 'opps', value: f.delta(levers.oppsUplift) }, + { key: 'winRate', value: f.signedPoints(levers.winRatePoints) }, + { key: 'acv', value: f.delta(levers.acvUplift) }, + ]; + + return ( +
+ +
+ {INPUT_KEYS.map((key, index) => ( +
+ onInputChange(key, value)} + /> +
+ ))} +
+ +
+ + +
+ + {t('calculator.scenario.label')} + + {SCENARIOS.map((option) => ( + + ))} +
+
    + {leverPills.map((pill) => ( +
  • + + {pill.value} + + {t(`calculator.levers.${pill.key}`)} +
  • + ))} +
+
+ ); +} diff --git a/app/components/roi/roi-range-input.tsx b/app/components/roi/roi-range-input.tsx new file mode 100644 index 00000000..f414b805 --- /dev/null +++ b/app/components/roi/roi-range-input.tsx @@ -0,0 +1,122 @@ +import { useId } from 'react'; + +import { css } from '@ocobo/styled-system/css'; + +import type { RoiInputRange } from '~/utils/roi'; + +/** + * One figure of the ROI calculator: a label, its formatted value and a + * native range slider. The native input keeps keyboard and screen reader + * support for free; `aria-valuetext` reads the formatted value aloud. + */ + +const thumb = { + appearance: 'none', + w: '6', + h: '6', + rounded: 'full', + bg: 'white', + borderWidth: '3px', + borderStyle: 'solid', + borderColor: 'dark', + boxShadow: 'rest', + cursor: 'grab', +} as const; + +const range = css({ + appearance: 'none', + display: 'block', + w: 'full', + h: '1.5', + rounded: 'full', + cursor: 'pointer', + outline: 'none', + '&::-webkit-slider-thumb': thumb, + '&::-moz-range-thumb': thumb, + '&:focus-visible::-webkit-slider-thumb': { + boxShadow: '[0 0 0 3px var(--colors-yellow)]', + }, + '&:focus-visible::-moz-range-thumb': { + boxShadow: '[0 0 0 3px var(--colors-yellow)]', + }, +}); + +type RoiRangeInputProps = { + label: string; + hint: string; + value: number; + formatted: string; + range: RoiInputRange; + onChange: (value: number) => void; +}; + +export function RoiRangeInput({ + label, + hint, + value, + formatted, + range: { min, max, step }, + onChange, +}: RoiRangeInputProps) { + const id = useId(); + const filled = ((value - min) / (max - min)) * 100; + + return ( +
+
+ + + {formatted} + +
+ onChange(Number(event.target.value))} + className={range} + // The filled part of the track follows the value. + style={{ + background: `linear-gradient(to right, var(--colors-dark) ${filled}%, var(--colors-gray-200) ${filled}%)`, + }} + /> +
+ ); +} diff --git a/app/components/roi/roi-result-card.tsx b/app/components/roi/roi-result-card.tsx new file mode 100644 index 00000000..3750cb2d --- /dev/null +++ b/app/components/roi/roi-result-card.tsx @@ -0,0 +1,155 @@ +import { ArrowDown, ArrowRight } from 'lucide-react'; +import { Trans, useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { card, text } from '@ocobo/styled-system/recipes'; + +import type { RoiResult } from '~/utils/roi'; + +import { ROI_DETAIL_ID } from './roi-ids'; +import { RoiStep } from './roi-step'; +import { useRoiFormat } from './use-roi-format'; + +/** + * Step 3 of the ROI calculator (mockup `roi`): contract value today and with + * RevOps, and the gain between the two. Announced politely to screen + * readers as the sliders move. + */ + +const compareLabel = cx(text({ variant: 'label' }), css({ color: 'white/55' })); +const compareValue = css({ + fontFamily: 'display', + fontWeight: 'black', + fontSize: { base: 'xl', md: 'h3' }, + fontVariantNumeric: 'tabular-nums', + whiteSpace: 'nowrap', +}); + +type RoiResultCardProps = { + result: RoiResult; +}; + +export function RoiResultCard({ result }: RoiResultCardProps) { + const { t } = useTranslation('roi'); + const f = useRoiFormat(); + const { today, withRevops, gain } = result; + + return ( +
+
+ +
+
+
+ {t('calculator.today')} + + {f.euro(today.contractValue)} + +
+
+
+ {t('calculator.gain')} + + {f.signedEuro(gain.contractValue)} + +
+

+ , + ]} + /> +

+
+ + {t('calculator.detailLink')} + +
+

+ {t('calculator.disclaimer')} +

+
+ ); +} diff --git a/app/components/roi/roi-step.tsx b/app/components/roi/roi-step.tsx new file mode 100644 index 00000000..87ce6bcc --- /dev/null +++ b/app/components/roi/roi-step.tsx @@ -0,0 +1,48 @@ +import { css, cx } from '@ocobo/styled-system/css'; + +// The numbered step header of the calculator cards (mockup `roi`). + +const hintTones = { + light: css({ color: 'gray' }), + dark: css({ color: 'white/55' }), +}; + +type RoiStepProps = { + number: number; + title: string; + hint: string; + tone?: keyof typeof hintTones; +}; + +export function RoiStep({ number, title, hint, tone = 'light' }: RoiStepProps) { + return ( +
+ +
+

+ {title} +

+

+ {hint} +

+
+
+ ); +} diff --git a/app/components/roi/roi-styles.ts b/app/components/roi/roi-styles.ts new file mode 100644 index 00000000..1cd043cd --- /dev/null +++ b/app/components/roi/roi-styles.ts @@ -0,0 +1,41 @@ +import { css, cx } from '@ocobo/styled-system/css'; + +// The dotted backdrop of the ROI sections (mockup `roi`), the same dot grid +// as the challenge pages. `overflow: clip` keeps the dots inside the section +// without turning it into a scroll box, so the sticky result card still +// sticks. +const dotBase = css({ + position: 'relative', + isolation: 'isolate', + overflow: 'clip', + _before: { + content: '""', + position: 'absolute', + inset: '0', + zIndex: -1, + pointerEvents: 'none', + backgroundImage: + '[radial-gradient(rgba(33,35,35,0.11) 1px, transparent 1.2px)]', + backgroundSize: '[22px 22px]', + }, +}); + +export const dotBackdrop = cx( + dotBase, + css({ + _before: { + maskImage: + '[radial-gradient(ellipse 70% 60% at 50% 60%, black, transparent)]', + }, + }), +); + +export const dotBackdropTop = cx( + dotBase, + css({ + _before: { + maskImage: + '[radial-gradient(ellipse 60% 50% at 50% 30%, black, transparent)]', + }, + }), +); diff --git a/app/components/roi/roi-walkthrough.tsx b/app/components/roi/roi-walkthrough.tsx new file mode 100644 index 00000000..cc8f55f7 --- /dev/null +++ b/app/components/roi/roi-walkthrough.tsx @@ -0,0 +1,442 @@ +import { ArrowDown } from 'lucide-react'; +import { useTranslation } from 'react-i18next'; + +import { css, cx } from '@ocobo/styled-system/css'; +import { card, section, text } from '@ocobo/styled-system/recipes'; + +import { Container } from '~/components/ui/Container'; +import type { RoiFunnel, RoiResult, RoiScenario } from '~/utils/roi'; + +import { ROI_CALCULATOR_ID, ROI_WALKTHROUGH_ID } from './roi-ids'; +import { dotBackdrop } from './roi-styles'; +import { type RoiFormat, useRoiFormat } from './use-roi-format'; + +/** + * "Le calcul, pas à pas" (mockup `roi`): the funnel formula written out as a + * staircase, once with today's figures and once with the RevOps scenario. + * It reads the same state as the calculator below, so it follows the + * visitor's numbers. Too wide for a phone: it scrolls sideways there. + */ + +type CellKind = 'label' | 'op' | 'value' | 'ring' | 'result' | 'final'; + +type Cell = { + key: string; + column: number; + row: number; + kind: CellKind; + content: string; +}; + +type Term = + | 'reps' + | 'opps' + | 'winRate' + | 'deals' + | 'acv' + | 'booking' + | 'duration' + | 'contractValue'; + +// Where each term sits: three steps down, one per result. +const TERMS: ReadonlyArray<{ + term: Term; + column: number; + row: number; + result?: boolean; + lever?: boolean; +}> = [ + { term: 'reps', column: 1, row: 1 }, + { term: 'opps', column: 3, row: 1, lever: true }, + { term: 'winRate', column: 5, row: 1, lever: true }, + { term: 'deals', column: 7, row: 1, result: true }, + { term: 'acv', column: 9, row: 2, lever: true }, + { term: 'booking', column: 11, row: 2, result: true }, + { term: 'duration', column: 13, row: 3 }, + { term: 'contractValue', column: 15, row: 3, result: true }, +]; + +const OPERATORS: ReadonlyArray<{ column: number; row: number; sign: string }> = + [ + { column: 2, row: 1, sign: '×' }, + { column: 4, row: 1, sign: '×' }, + { column: 6, row: 1, sign: '=' }, + { column: 8, row: 2, sign: '×' }, + { column: 10, row: 2, sign: '=' }, + { column: 12, row: 3, sign: '×' }, + { column: 14, row: 3, sign: '=' }, + ]; + +const termValue = (term: Term, funnel: RoiFunnel, f: RoiFormat): string => { + switch (term) { + case 'reps': + return f.count(funnel.reps); + case 'opps': + return f.decimal(funnel.oppsPerRepPerYear); + case 'winRate': + return f.percent(funnel.winRate); + case 'deals': + return f.count(funnel.deals); + case 'acv': + return f.euro(funnel.acv); + case 'booking': + return f.euro(funnel.booking); + case 'duration': + return f.years(funnel.durationYears); + case 'contractValue': + return f.euro(funnel.contractValue); + } +}; + +type BandKind = 'formula' | 'today' | 'revops'; + +const buildCells = ( + band: BandKind, + label: (term: Term) => string, + funnel: RoiFunnel, + f: RoiFormat, +): Cell[] => { + const terms = TERMS.map(({ term, column, row, result, lever }): Cell => { + const base = { key: term, column, row }; + if (band === 'formula') { + return { ...base, kind: 'label', content: label(term) }; + } + const content = termValue(term, funnel, f); + if (band === 'today') { + return { ...base, kind: lever ? 'ring' : 'value', content }; + } + if (term === 'contractValue') return { ...base, kind: 'final', content }; + return { ...base, kind: result ? 'result' : 'value', content }; + }); + const operators = OPERATORS.map( + ({ column, row, sign }): Cell => ({ + key: `op-${column}`, + column, + row, + kind: 'op', + content: sign, + }), + ); + return [...terms, ...operators]; +}; + +// 8 terms and 7 operators side by side (mockup `pg-grid`). +const grid = css({ + display: 'grid', + gridTemplateColumns: + 'minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,.8fr) 24px minmax(0,1.2fr)', + rowGap: '0.5', + fontVariantNumeric: 'tabular-nums', +}); + +const cellBase = css({ + justifySelf: 'center', + alignSelf: 'center', + textAlign: 'center', + whiteSpace: 'nowrap', + px: '1', + py: '2', +}); +const cellStyles: Record = { + label: cx(text({ variant: 'label', color: 'muted' }), css({ px: '1' })), + op: css({ fontSize: 'md', color: 'gray.300' }), + value: css({ fontSize: 'md', fontWeight: 'semibold', color: 'dark' }), + ring: css({ + fontSize: 'md', + fontWeight: 'semibold', + color: 'dark', + bg: 'mint.light', + boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', + rounded: 'full', + px: '3', + py: '1.5', + }), + result: css({ fontSize: 'md', fontWeight: 'extrabold', color: 'dark' }), + final: css({ + fontFamily: 'display', + fontWeight: 'black', + fontSize: 'lg', + color: 'white', + bg: 'dark', + rounded: 'full', + px: '4', + py: '2', + }), +}; + +const band = cx( + card({ padding: 'sm', radius: 'lg' }), + css({ position: 'relative', pt: '12', px: '6' }), +); +const bandRevops = css({ + borderColor: 'mint', + boxShadow: 'hover', +}); +const tag = cx( + text({ variant: 'label', color: 'muted' }), + css({ + position: 'absolute', + top: '5', + left: '6', + display: 'inline-flex', + alignItems: 'center', + gap: '2', + _before: { + content: '""', + w: '1.5', + h: '1.5', + rounded: 'full', + bg: 'gray.300', + }, + }), +); +const tagRevops = css({ + color: 'dark', + _before: { bg: 'mint', boxShadow: '[0 0 0 3px var(--colors-mint-light)]' }, +}); +const gainPill = css({ + justifySelf: 'center', + alignSelf: 'center', + whiteSpace: 'nowrap', + fontFamily: 'display', + fontWeight: 'black', + fontSize: 'xl', + color: 'mint.dark', + bg: 'mint.light', + boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', + rounded: 'full', + px: '4', + py: '1.5', +}); +const leverChip = css({ + fontSize: 'xs', + fontWeight: 'bold', + color: 'mint.dark', + bg: 'white', + borderWidth: '1px', + borderStyle: 'solid', + borderColor: 'mint', + rounded: 'full', + px: '2.5', + py: '0.5', + whiteSpace: 'nowrap', +}); + +type BandProps = { + title: string; + cells: Cell[]; + revops?: boolean; + gain?: string; +}; + +function Band({ title, cells, revops, gain }: BandProps) { + return ( +
+ {title} +
+ {cells.map((cell) => ( + + {cell.content} + + ))} + {gain ? ( + + {gain} + + ) : null} +
+
+ ); +} + +type RoiWalkthroughProps = { + result: RoiResult; + scenario: RoiScenario; +}; + +export function RoiWalkthrough({ result, scenario }: RoiWalkthroughProps) { + const { t } = useTranslation('roi'); + const f = useRoiFormat(); + const { today, withRevops, levers } = result; + const label = (term: Term) => t(`walkthrough.terms.${term}`); + + const leverChips = [ + { column: 3, content: f.oppsPerYear(levers.oppsPerRepPerYear) }, + { column: 5, content: f.signedPoints(levers.winRatePoints) }, + { column: 9, content: f.signedEuro(levers.acv) }, + ]; + + return ( +
+ +
+ + {t('walkthrough.eyebrow')} + +

+ {t('walkthrough.title')} +

+

+ {t('walkthrough.intro')} +

+
+ +
+ + {t('walkthrough.example.label')} + +

+ {t('walkthrough.example.text', { + reps: f.count(today.reps), + opps: f.decimal(today.oppsPerRepPerMonth), + winRate: f.percent(today.winRate), + acv: f.euro(today.acv), + oppsLever: f.decimal(levers.oppsPerRepPerMonth), + winRateLever: f.points(levers.winRatePoints), + acvLever: f.euro(levers.acv), + })} +

+
+ +

+ {t('walkthrough.scrollHint')} +

+
+
+ + +
+ {leverChips.map((chip) => ( + + + ))} +
+ +
+
+ + {t('walkthrough.edit')} + +
+
+ ); +} diff --git a/app/components/roi/use-roi-format.ts b/app/components/roi/use-roi-format.ts new file mode 100644 index 00000000..b0ff2095 --- /dev/null +++ b/app/components/roi/use-roi-format.ts @@ -0,0 +1,50 @@ +import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useParams } from 'react-router'; + +import { getLang } from '~/utils/lang'; +import { + formatRoiCount, + formatRoiDecimal, + formatRoiEuro, + formatRoiPercent, + formatRoiPercentDelta, +} from '~/utils/roi-format'; + +const withSign = (formatted: string, value: number): string => + value >= 0 ? `+${formatted}` : formatted; + +/** + * The figures of the ROI page in the page language. Numbers come from + * `~/utils/roi-format`; unit words come from the `roi` locale files. + */ +export function useRoiFormat() { + const { t } = useTranslation('roi'); + const lang = getLang(useParams()); + + return useMemo(() => { + const decimal = (value: number) => formatRoiDecimal(value, lang); + const euro = (value: number) => formatRoiEuro(value, lang); + const points = (value: number) => + t('units.points', { count: value, value: decimal(value) }); + + return { + decimal, + euro, + signedEuro: (value: number) => withSign(euro(value), value), + count: (value: number) => formatRoiCount(value, lang), + percent: (value: number) => formatRoiPercent(value, lang), + delta: (fraction: number) => formatRoiPercentDelta(fraction, lang), + years: (value: number) => + t('units.years', { count: value, value: decimal(value) }), + points, + signedPoints: (value: number) => withSign(points(value), value), + oppsPerYear: (value: number) => + t('units.oppsPerYear', { value: decimal(value) }), + oppsPerMonth: (value: number) => + t('units.oppsPerMonth', { value: decimal(value) }), + }; + }, [t, lang]); +} + +export type RoiFormat = ReturnType; diff --git a/app/localization/resources.ts b/app/localization/resources.ts index 6dc11e80..aa35549f 100644 --- a/app/localization/resources.ts +++ b/app/localization/resources.ts @@ -9,6 +9,7 @@ import en_jobs from '../../locales/en/jobs.json'; import en_method from '../../locales/en/method.json'; import en_offer from '../../locales/en/offer.json'; import en_projects from '../../locales/en/projects.json'; +import en_roi from '../../locales/en/roi.json'; import en_stack from '../../locales/en/stack.json'; import en_strategy from '../../locales/en/strategy.json'; import en_studio from '../../locales/en/studio.json'; @@ -24,6 +25,7 @@ import fr_jobs from '../../locales/fr/jobs.json'; import fr_method from '../../locales/fr/method.json'; import fr_offer from '../../locales/fr/offer.json'; import fr_projects from '../../locales/fr/projects.json'; +import fr_roi from '../../locales/fr/roi.json'; import fr_stack from '../../locales/fr/stack.json'; import fr_strategy from '../../locales/fr/strategy.json'; import fr_studio from '../../locales/fr/studio.json'; @@ -42,6 +44,7 @@ export const resources = { contact: fr_contact, offer: fr_offer, method: fr_method, + roi: fr_roi, studio: fr_studio, technology: fr_technology, about: fr_about, @@ -59,6 +62,7 @@ export const resources = { contact: en_contact, offer: en_offer, method: en_method, + roi: en_roi, studio: en_studio, technology: en_technology, about: en_about, diff --git a/locales/en/roi.json b/locales/en/roi.json new file mode 100644 index 00000000..9f2d6746 --- /dev/null +++ b/locales/en/roi.json @@ -0,0 +1,93 @@ +{ + "meta.title": "RevOps ROI calculator", + "meta.description": "Five figures are enough to estimate what a RevOps team is worth, in euros: more opportunities, a better win rate and larger deals multiply.", + "hero.badge": "ROI Calculator", + "hero.title.line1": "What a RevOps team is worth,", + "hero.title.highlight": "in euros.", + "hero.subtitle": "Every sales metric multiplies with the others. Gaining a few points on each does not add up: it multiplies. Five figures are enough to see it.", + "hero.cta": "Run the numbers", + "hero.chart.revenue": "Revenue", + "hero.chart.time": "Time", + "hero.chart.linear": "Without RevOps", + "hero.chart.opps": "More opportunities", + "hero.chart.winRate": "Better win rate", + "hero.chart.acv": "Larger deals", + "hero.chart.multiplier": "Multiplier effect", + "walkthrough.eyebrow": "The demonstration", + "walkthrough.title": "The maths, step by step.", + "walkthrough.intro": "A Revenue Ops team is an investment. Its leverage works on every sales metric at once: a small improvement to each has an outsized cash impact.", + "walkthrough.example.label": "The example", + "walkthrough.example.text": "Over one year of activity: {{reps}} sales reps, {{opps}} qualified opportunities per rep per month, a {{winRate}} win rate and an average deal size of {{acv}}. All else being equal, we add {{oppsLever}} opportunity per rep per month, {{winRateLever}} of win rate and {{acvLever}} of average deal size.", + "walkthrough.formula": "The formula", + "walkthrough.today": "Today", + "walkthrough.withRevops": "With RevOps · {{scenario}}", + "walkthrough.scenario.conservative": "conservative scenario", + "walkthrough.scenario.ambitious": "ambitious scenario", + "walkthrough.terms.reps": "Sales reps", + "walkthrough.terms.opps": "Opportunities / yr", + "walkthrough.terms.winRate": "Win rate", + "walkthrough.terms.deals": "Deals", + "walkthrough.terms.acv": "Deal size", + "walkthrough.terms.booking": "Bookings", + "walkthrough.terms.duration": "Duration", + "walkthrough.terms.contractValue": "Contract value", + "walkthrough.gain": "Gain: {{amount}}", + "walkthrough.scrollHint": "Swipe to see the rest →", + "walkthrough.scrollLabel": "The maths, step by step", + "walkthrough.edit": "Change the figures to yours", + "calculator.title": "Your turn.", + "calculator.intro": "Enter your five figures and pick a scenario: we work out the rest.", + "calculator.step1.title": "Your figures today", + "calculator.step1.hint": "Rough orders of magnitude are enough", + "calculator.inputs.reps.label": "Sales reps", + "calculator.inputs.reps.hint": "The people who close deals", + "calculator.inputs.oppsPerRepPerMonth.label": "Qualified opportunities", + "calculator.inputs.oppsPerRepPerMonth.hint": "Per rep, per month", + "calculator.inputs.winRate.label": "Win rate", + "calculator.inputs.winRate.hint": "Share of opportunities won", + "calculator.inputs.acv.label": "Average deal size", + "calculator.inputs.acv.hint": "Annual value of a contract", + "calculator.inputs.durationYears.label": "Contract duration", + "calculator.inputs.durationYears.hint": "Average customer lifetime", + "calculator.step2.title": "The RevOps scenario", + "calculator.step2.hint.conservative": "Cautious assumptions, observed with our clients", + "calculator.step2.hint.ambitious": "High assumptions, for a team already structured", + "calculator.scenario.label": "RevOps scenario", + "calculator.scenario.conservative": "Conservative", + "calculator.scenario.ambitious": "Ambitious", + "calculator.levers.opps": "qualified opportunities", + "calculator.levers.winRate": "win rate", + "calculator.levers.acv": "average deal size", + "calculator.step3.title": "The result", + "calculator.step3.hint": "Contract value over {{duration}}", + "calculator.today": "Today", + "calculator.withRevops": "With RevOps", + "calculator.gain": "Gain", + "calculator.bookingGain": "including <0>{{amount}} of extra bookings every year. No lever is spectacular on its own: their combination makes the difference.", + "calculator.detailLink": "See the detailed calculation", + "calculator.disclaimer": "Indicative simulation over one year of activity, all else being equal. The assumptions need checking against your own data, in a conversation with us.", + "detail.title": "The detail, line by line", + "detail.hint": "Each grey line is the result of the lines above it.", + "detail.head.today": "Today", + "detail.head.lever": "RevOps lever", + "detail.head.withRevops": "With RevOps", + "detail.noLever": "No lever", + "detail.rows.reps": "Sales reps", + "detail.rows.oppsPerRepPerMonth": "Qualified opportunities", + "detail.rows.oppsPerYear": "Opportunities per year", + "detail.rows.winRate": "Win rate", + "detail.rows.deals": "Deals won per year", + "detail.rows.acv": "Average deal size", + "detail.rows.booking": "Annual bookings", + "detail.rows.durationYears": "Contract duration", + "detail.rows.contractValue": "Contract value", + "diagnostic.question": "And for you, which lever moves first?", + "diagnostic.subtitle": "We redo this calculation with your real data, and we find the two or three levers that pay back fastest.", + "diagnostic.cta": "Talk to an architect", + "units.years_one": "{{value}} year", + "units.years_other": "{{value}} years", + "units.points_one": "{{value}} pt", + "units.points_other": "{{value}} pts", + "units.oppsPerYear": "+{{value}} opp/yr", + "units.oppsPerMonth": "+{{value}} opp/month" +} diff --git a/locales/fr/roi.json b/locales/fr/roi.json new file mode 100644 index 00000000..311ca4c7 --- /dev/null +++ b/locales/fr/roi.json @@ -0,0 +1,93 @@ +{ + "meta.title": "Calculateur ROI RevOps", + "meta.description": "Cinq chiffres suffisent pour estimer ce que rapporte une équipe RevOps, en euros : plus d'opportunités, un meilleur win rate et un panier plus élevé se multiplient.", + "hero.badge": "ROI Calculator", + "hero.title.line1": "Ce que vaut une équipe RevOps,", + "hero.title.highlight": "en euros.", + "hero.subtitle": "Chaque indicateur commercial se multiplie avec les autres. Gagner quelques points sur chacun ne s'additionne pas : ça se multiplie. Cinq chiffres suffisent pour le voir.", + "hero.cta": "Lancer le calcul", + "hero.chart.revenue": "Revenu", + "hero.chart.time": "Temps", + "hero.chart.linear": "Sans RevOps", + "hero.chart.opps": "Plus d'opportunités", + "hero.chart.winRate": "Meilleur win rate", + "hero.chart.acv": "Panier plus élevé", + "hero.chart.multiplier": "Effet multiplicateur", + "walkthrough.eyebrow": "La démonstration", + "walkthrough.title": "Le calcul, pas à pas.", + "walkthrough.intro": "Une équipe Revenue Ops est un investissement. L'effet de levier joue sur tous les indicateurs commerciaux à la fois : une amélioration minime de chacun a un impact cash décuplé.", + "walkthrough.example.label": "L'exemple", + "walkthrough.example.text": "Sur une année d'activité : {{reps}} commerciaux, {{opps}} opportunités qualifiées par commercial et par mois, un win rate de {{winRate}} et un panier moyen de {{acv}}. Toutes choses égales par ailleurs, nous ajoutons {{oppsLever}} opportunité par mois et par commercial, {{winRateLever}} de win rate et {{acvLever}} de panier moyen.", + "walkthrough.formula": "La formule", + "walkthrough.today": "Aujourd'hui", + "walkthrough.withRevops": "Avec RevOps · {{scenario}}", + "walkthrough.scenario.conservative": "scénario conservateur", + "walkthrough.scenario.ambitious": "scénario ambitieux", + "walkthrough.terms.reps": "Commerciaux", + "walkthrough.terms.opps": "Opportunités / an", + "walkthrough.terms.winRate": "Win rate", + "walkthrough.terms.deals": "Contrats", + "walkthrough.terms.acv": "Panier moyen", + "walkthrough.terms.booking": "Booking", + "walkthrough.terms.duration": "Durée", + "walkthrough.terms.contractValue": "Valeur contrat", + "walkthrough.gain": "Gain : {{amount}}", + "walkthrough.scrollHint": "Faites glisser pour voir la suite →", + "walkthrough.scrollLabel": "Le calcul pas à pas", + "walkthrough.edit": "Changer les chiffres avec les vôtres", + "calculator.title": "À vous de jouer.", + "calculator.intro": "Renseignez vos cinq chiffres, choisissez un scénario : nous calculons le reste.", + "calculator.step1.title": "Vos chiffres aujourd'hui", + "calculator.step1.hint": "Ordres de grandeur suffisants", + "calculator.inputs.reps.label": "Commerciaux", + "calculator.inputs.reps.hint": "Les personnes qui signent", + "calculator.inputs.oppsPerRepPerMonth.label": "Opportunités qualifiées", + "calculator.inputs.oppsPerRepPerMonth.hint": "Par commercial et par mois", + "calculator.inputs.winRate.label": "Win rate", + "calculator.inputs.winRate.hint": "Part des opportunités signées", + "calculator.inputs.acv.label": "Panier moyen", + "calculator.inputs.acv.hint": "Valeur annuelle d'un contrat", + "calculator.inputs.durationYears.label": "Durée des contrats", + "calculator.inputs.durationYears.hint": "Durée moyenne d'un client", + "calculator.step2.title": "Le scénario RevOps", + "calculator.step2.hint.conservative": "Hypothèses prudentes, observées chez nos clients", + "calculator.step2.hint.ambitious": "Hypothèses hautes, équipe déjà structurée", + "calculator.scenario.label": "Scénario RevOps", + "calculator.scenario.conservative": "Conservateur", + "calculator.scenario.ambitious": "Ambitieux", + "calculator.levers.opps": "d'opportunités qualifiées", + "calculator.levers.winRate": "de win rate", + "calculator.levers.acv": "de panier moyen", + "calculator.step3.title": "Le résultat", + "calculator.step3.hint": "Valeur contractuelle sur {{duration}}", + "calculator.today": "Aujourd'hui", + "calculator.withRevops": "Avec RevOps", + "calculator.gain": "Gain", + "calculator.bookingGain": "dont <0>{{amount}} de booking en plus chaque année. Aucun levier n'est spectaculaire seul, c'est leur cumul qui fait la différence.", + "calculator.detailLink": "Voir le détail du calcul", + "calculator.disclaimer": "Simulation indicative sur une année d'activité, toutes choses égales par ailleurs. Les hypothèses sont à valider sur vos données lors d'un échange avec nous.", + "detail.title": "Le détail, ligne par ligne", + "detail.hint": "Chaque ligne grise est le résultat des lignes du dessus.", + "detail.head.today": "Aujourd'hui", + "detail.head.lever": "Levier RevOps", + "detail.head.withRevops": "Avec RevOps", + "detail.noLever": "Pas de levier", + "detail.rows.reps": "Commerciaux", + "detail.rows.oppsPerRepPerMonth": "Opportunités qualifiées", + "detail.rows.oppsPerYear": "Opportunités par an", + "detail.rows.winRate": "Win rate", + "detail.rows.deals": "Contrats signés par an", + "detail.rows.acv": "Panier moyen", + "detail.rows.booking": "Booking annuel", + "detail.rows.durationYears": "Durée des contrats", + "detail.rows.contractValue": "Valeur contractuelle", + "diagnostic.question": "Et chez vous, quel levier bouge en premier ?", + "diagnostic.subtitle": "Nous refaisons ce calcul avec vos vraies données, et nous identifions les deux ou trois leviers qui rapportent le plus vite.", + "diagnostic.cta": "Échanger avec un architecte", + "units.years_one": "{{value}} an", + "units.years_other": "{{value}} ans", + "units.points_one": "{{value}} pt", + "units.points_other": "{{value}} pts", + "units.oppsPerYear": "+{{value}} opp/an", + "units.oppsPerMonth": "+{{value}} opp/mois" +} From 7a992c281882b2a720d6ec6bbfce85c0d01ec137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 09:37:01 +0100 Subject: [PATCH 05/14] feat(roi): /roi and /en/roi route behind the roi flag --- app/routes/_main.($lang).roi.test.ts | 81 ++++++++++++++++++++++++++++ app/routes/_main.($lang).roi.tsx | 49 +++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 app/routes/_main.($lang).roi.test.ts create mode 100644 app/routes/_main.($lang).roi.tsx diff --git a/app/routes/_main.($lang).roi.test.ts b/app/routes/_main.($lang).roi.test.ts new file mode 100644 index 00000000..908518c9 --- /dev/null +++ b/app/routes/_main.($lang).roi.test.ts @@ -0,0 +1,81 @@ +/** + * Loader tests for the ROI route (#248). + * + * Behaviours verified: + * 1. The page answers 404 while the `roi` flag is off. + * 2. The meta copy resolves in the page language. + */ + +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import { invokeLoader } from '~/test/loader-harness'; + +const getFixedTMock = vi.fn(); +const throwIfDisabledMock = vi.fn(); + +vi.mock('~/localization/i18n.server', () => ({ + default: { + getFixedT: (...args: unknown[]) => getFixedTMock(...args), + }, +})); + +vi.mock('~/modules/feature-flags', () => ({ + throwIfDisabled: (...args: unknown[]) => throwIfDisabledMock(...args), +})); + +vi.mock('~/utils/redirections', () => ({ + redirectWithLocale: vi.fn().mockResolvedValue(undefined), +})); + +afterEach(() => { + vi.resetAllMocks(); +}); + +async function runLoader(url: string, params: Record = {}) { + const { loader } = await import('./_main.($lang).roi'); + return invokeLoader(loader, { url, params }); +} + +describe('roi loader', () => { + it('answers 404 while the roi flag is off', async () => { + throwIfDisabledMock.mockImplementation(() => { + throw new Response('Not Found', { status: 404 }); + }); + + const outcome = await runLoader('http://test.local/roi'); + + expect(throwIfDisabledMock).toHaveBeenCalledWith('roi'); + expect(getFixedTMock).not.toHaveBeenCalled(); + expect(outcome.type).toBe('response'); + if (outcome.type !== 'response') throw new Error('expected a response'); + expect(outcome.response.status).toBe(404); + }); + + it('returns the French meta copy on /roi', async () => { + getFixedTMock.mockResolvedValue((key: string) => `fr:${key}`); + + const outcome = await runLoader('http://test.local/roi'); + + if (outcome.type !== 'data') throw new Error('expected data'); + expect(getFixedTMock).toHaveBeenCalledWith('fr', 'roi'); + expect(outcome.data).toEqual({ + title: 'fr:meta.title', + description: 'fr:meta.description', + ogImageSrc: 'http://test.local/og/homepage.jpg', + lang: 'fr', + }); + }); + + it('returns the English meta copy on /en/roi', async () => { + getFixedTMock.mockResolvedValue((key: string) => `en:${key}`); + + const outcome = await runLoader('http://test.local/en/roi', { + lang: 'en', + }); + + if (outcome.type !== 'data') throw new Error('expected data'); + expect(getFixedTMock).toHaveBeenCalledWith('en', 'roi'); + expect(outcome.data.title).toBe('en:meta.title'); + expect(outcome.data.lang).toBe('en'); + }); +}); diff --git a/app/routes/_main.($lang).roi.tsx b/app/routes/_main.($lang).roi.tsx new file mode 100644 index 00000000..fdfd14d8 --- /dev/null +++ b/app/routes/_main.($lang).roi.tsx @@ -0,0 +1,49 @@ +import type { LoaderFunctionArgs, MetaFunction } from 'react-router'; + +import { RoiDiagnostic } from '~/components/roi/roi-diagnostic'; +import { RoiExperience } from '~/components/roi/roi-experience'; +import { RoiHero } from '~/components/roi/roi-hero'; +import i18nServer from '~/localization/i18n.server'; +import { createHybridLoader } from '~/modules/cache'; +import { throwIfDisabled } from '~/modules/feature-flags'; +import { getLang } from '~/utils/lang'; +import { getMetaTags } from '~/utils/metatags'; +import { redirectWithLocale } from '~/utils/redirections'; +import { getImageOgFullPath } from '~/utils/url'; + +export const loader = createHybridLoader(async (args: LoaderFunctionArgs) => { + await redirectWithLocale(args); + throwIfDisabled('roi'); + const lang = getLang(args.params); + const t = await i18nServer.getFixedT(lang, 'roi'); + + return { + title: t('meta.title'), + description: t('meta.description'), + // No ROI share image yet: the homepage one stands in. + ogImageSrc: getImageOgFullPath('homepage', args.request.url), + lang, + }; +}, 'static'); + +export const meta: MetaFunction = ({ data, params }) => { + if (!data) { + return []; + } + return getMetaTags({ + title: data.title, + description: data.description, + image: data.ogImageSrc, + locale: getLang(params), + }); +}; + +export default function RoiPage() { + return ( +
+ + + +
+ ); +} From c386ec8fbff1a1affee652e7b3214224b89c8ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 11:40:07 +0100 Subject: [PATCH 06/14] fix(roi): small card titles in the body font The global h3 rule set them in Bermia and pushed the hint down. They now share stepTitle and stepHint with the walkthrough steps. --- app/components/roi/roi-detail.tsx | 7 +++---- app/components/roi/roi-step.tsx | 17 +++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/components/roi/roi-detail.tsx b/app/components/roi/roi-detail.tsx index c65ddd44..db06b5a5 100644 --- a/app/components/roi/roi-detail.tsx +++ b/app/components/roi/roi-detail.tsx @@ -6,6 +6,7 @@ import { card } from '@ocobo/styled-system/recipes'; import type { RoiResult } from '~/utils/roi'; import { ROI_DETAIL_ID } from './roi-ids'; +import { stepHint, stepTitle } from './roi-step'; import { type RoiFormat, useRoiFormat } from './use-roi-format'; /** @@ -201,10 +202,8 @@ export function RoiDetail({ result }: RoiDetailProps) { )} >
-

- {t('detail.title')} -

-

+

{t('detail.title')}

+

{t('detail.hint')}

diff --git a/app/components/roi/roi-step.tsx b/app/components/roi/roi-step.tsx index 87ce6bcc..91461933 100644 --- a/app/components/roi/roi-step.tsx +++ b/app/components/roi/roi-step.tsx @@ -2,6 +2,15 @@ import { css, cx } from '@ocobo/styled-system/css'; // The numbered step header of the calculator cards (mockup `roi`). +// Small card titles in the body font, as on the home challenge cards. +export const stepTitle = css({ + fontFamily: 'body', + fontSize: 'body', + fontWeight: 'bold', +}); +// Cancels the global `h3 + p` gap: the title and hint sit as one block. +export const stepHint = css({ mt: '0', fontSize: 'caption' }); + const hintTones = { light: css({ color: 'gray' }), dark: css({ color: 'white/55' }), @@ -36,12 +45,8 @@ export function RoiStep({ number, title, hint, tone = 'light' }: RoiStepProps) { {number}
-

- {title} -

-

- {hint} -

+

{title}

+

{hint}

); From 8e154686c5415d0ef48f29062556c2ff5666c428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 11:40:27 +0100 Subject: [PATCH 07/14] docs(roi): list the ROI page components in the inventory --- docs/development/component-inventory.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/development/component-inventory.md b/docs/development/component-inventory.md index 33dfb0aa..9f3b5ff9 100644 --- a/docs/development/component-inventory.md +++ b/docs/development/component-inventory.md @@ -211,7 +211,7 @@ Shared pieces: | **ChallengeClientCase** | `challenge-client-case.tsx` | Case headline, summary, metric cards and the link to the Story; one column without metrics | Challenge-specific | | **ChallengeExperts** | `challenge-experts.tsx` | Expert cards (`PersonCard`) of the Team members on the challenge | Challenge-specific | | **ChallengeStack** | `challenge-stack.tsx` | Revenue Systems only (key `sy`): heading, CTA to the technology page and `StackDiagram`; copy in the `challenges` namespace | Challenge-specific | -| **ChallengeDiagnostic** | `challenge-diagnostic.tsx` | Yellow closing block with the contact CTA (`#diagnostic`) | Challenge-specific | +| **ChallengeDiagnostic** | `challenge-diagnostic.tsx` | Yellow closing block with the contact CTA (`#diagnostic`) | Reusable (challenge pages, ROI page) | | **ChallengeOtherChallenges** | `challenge-other-challenges.tsx` | Pills to the other challenges, from the navbar list | Challenge-specific | ### Stack diagram (`app/components/stack/`) @@ -222,6 +222,21 @@ Ocobo's Revenue Systems stack: the CRM at the centre, four numbered layers aroun | **StackDiagram** | `stack-diagram.tsx` | The whole figure: layer cards, CRM core, animated connectors; entrance on scroll, animations off under reduced motion | Reusable (challenge page, technology page, home) | | **StackLabel**, **ToolChips**, **ToolList**, **ToolIcon** | `stack-parts.tsx` | Layer label with its dot, tool chips, tool rows with their role, logo or monogram | Stack-specific | +### ROI page components (`app/components/roi/`) +Sections of the ROI calculator page (`app/routes/_main.($lang).roi.tsx`), behind the `roi` page flag. The calculation is pure and lives in `app/utils/roi.ts` (`computeRoi`, `clampRoiInput`, the scenarios and the input ranges); the components only format and display it. `RoiExperience` holds the five inputs and the scenario in state and passes the same result to the walkthrough, the result card and the detail. Figures are formatted per language by `useRoiFormat` (`use-roi-format.ts`). Copy lives in the `roi` locale namespace. Anchor ids (`#calcul`, `#calculateur`, `#detail`) are in `roi-ids.ts`; the dotted backdrop classes are in `roi-styles.ts`. + +| Component | File | Purpose | Reusability | +|-----------|------|---------|-------------| +| **RoiHero** | `roi-hero.tsx` | Pill, title with the yellow marker, lead, CTA to the walkthrough, and `RoiHeroChart` (`roi-hero-chart.tsx`, the animated multiplier curve) | ROI-specific | +| **RoiExperience** | `roi-experience.tsx` | State owner: walkthrough, then the calculator section (inputs, sticky result from `lg`, detail) | ROI-specific | +| **RoiWalkthrough** | `roi-walkthrough.tsx` | The multiplication laid out in three bands (formula, today, with RevOps) and the gain; scrolls inside its own region on a phone | ROI-specific | +| **RoiInputsCard** | `roi-inputs-card.tsx` | Steps 1 and 2: five sliders, the scenario toggle (`aria-pressed`) and the lever pills | ROI-specific | +| **RoiRangeInput** | `roi-range-input.tsx` | Native range input with label, hint, formatted `` and `aria-valuetext` | Reusable (any slider) | +| **RoiStep** | `roi-step.tsx` | Numbered step heading; also exports `stepTitle` and `stepHint` for small card titles | ROI-specific | +| **RoiResultCard** | `roi-result-card.tsx` | Step 3 on a dark card: today against RevOps, the gain, the booking gain and the disclaimer | ROI-specific | +| **RoiDetail** | `roi-detail.tsx` | Line-by-line table (ARIA table roles) with the lever or relative change per row; reflows on a phone | ROI-specific | +| **RoiDiagnostic** | `roi-diagnostic.tsx` | `ChallengeDiagnostic` with the `roi` copy | ROI-specific | + ### Design system showcase (`app/components/design-system/`) One `*-section.tsx` module per `/design-system` section, each wrapped in `ShowcaseSection` (`showcase-section.tsx`), whose heading carries an anchor id derived from its title. The registry `designSystemGroups` in `subpages.ts` lists the pages in three groups (foundations, components, patterns) and each page's section titles. It feeds the sidebar (`design-system-sidebar.tsx`) and the grouped index (`design-system._index.tsx`). The sidebar lists the current page's sections under its link when the page has more than one, from `lg`. `app/routes/design-system.tsx` is the layout: one sidebar, then the page title and `Outlet`. Each page is a route `design-system..tsx` that only composes its section modules. A new showcase section is a new module, its title in the registry and one line in its page route. From 0fa1874f37d8fbeaedef08442f47354a26df09a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 11:43:49 +0100 Subject: [PATCH 08/14] fix(roi): euro figures change unit when rounding reaches a thousand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 999 600 € read "1000 k€" and 9 999 000 € read "10,00 M€". The unit and the decimals now follow the rounded figure. French counts group with NBSP like the other helpers. --- app/utils/roi-format.test.ts | 13 ++++++++- app/utils/roi-format.ts | 53 ++++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/app/utils/roi-format.test.ts b/app/utils/roi-format.test.ts index c691ed9a..e2d56fac 100644 --- a/app/utils/roi-format.test.ts +++ b/app/utils/roi-format.test.ts @@ -41,6 +41,17 @@ describe('formatRoiEuro', () => { it('keeps the sign of a negative amount', () => { expect(formatRoiEuro(-1_250, 'en')).toBe('-€1.3k'); }); + + it('moves to the next unit when rounding reaches a thousand', () => { + expect(formatRoiEuro(999.6, 'fr')).toBe(`1${NBSP}k€`); + expect(formatRoiEuro(999_600, 'fr')).toBe(`1,00${NBSP}M€`); + }); + + it('takes the decimals of the rounded figure', () => { + expect(formatRoiEuro(9_999_000, 'fr')).toBe(`10,0${NBSP}M€`); + expect(formatRoiEuro(99_960_000, 'en')).toBe('€100M'); + expect(formatRoiEuro(99_960, 'en')).toBe('€100k'); + }); }); describe('formatRoiDecimal', () => { @@ -63,7 +74,7 @@ describe('formatRoiCount', () => { it('groups thousands', () => { expect(formatRoiCount(1_234, 'en')).toBe('1,234'); - expect(formatRoiCount(1_234, 'fr')).toMatch(/^1\s234$/u); + expect(formatRoiCount(1_234, 'fr')).toBe(`1${NBSP}234`); }); }); diff --git a/app/utils/roi-format.ts b/app/utils/roi-format.ts index 34ae7e7a..10ef4057 100644 --- a/app/utils/roi-format.ts +++ b/app/utils/roi-format.ts @@ -25,17 +25,40 @@ export const formatRoiDecimal = (value: number, lang: Language): string => { return toLocaleDecimal(rounded.toFixed(digits), lang); }; +type EuroUnit = { size: number; suffix: string; maxDigits: number }; + +const EURO_UNITS: ReadonlyArray = [ + { size: 1e6, suffix: 'M', maxDigits: 2 }, + { size: 1e3, suffix: 'k', maxDigits: 1 }, + { size: 1, suffix: '', maxDigits: 0 }, +]; + +// Fewer decimals as the figure grows: "3,44", "10,3", "123". +const digitsFor = (scaled: number, maxDigits: number): number => + scaled >= 100 ? 0 : scaled >= 10 ? Math.min(1, maxDigits) : maxDigits; + +// Decimals come from the rounded figure, so 9,999 M€ reads "10,0", not +// "10,00". +const figureIn = (amount: number, unit: EuroUnit): string => { + const scaled = amount / unit.size; + const figure = scaled.toFixed(digitsFor(scaled, unit.maxDigits)); + const digits = digitsFor(Number(figure), unit.maxDigits); + return Number(figure).toFixed(digits); +}; + const scaleEuro = (amount: number): { figure: string; suffix: string } => { - if (amount >= 1e6) { - const digits = amount >= 1e8 ? 0 : amount >= 1e7 ? 1 : 2; - return { figure: (amount / 1e6).toFixed(digits), suffix: 'M' }; - } - if (amount >= 1e3) { - const digits = amount >= 1e5 ? 0 : 1; - const figure = (amount / 1e3).toFixed(digits).replace(/\.0$/, ''); - return { figure, suffix: 'k' }; - } - return { figure: String(Math.round(amount)), suffix: '' }; + const start = amount >= 1e6 ? 0 : amount >= 1e3 ? 1 : 2; + // Rounding can reach a thousand ("1000 k€"): show the next unit instead. + const index = + start > 0 && Number(figureIn(amount, EURO_UNITS[start])) >= 1000 + ? start - 1 + : start; + const unit = EURO_UNITS[index]; + const figure = figureIn(amount, unit); + return { + figure: unit.suffix === 'k' ? figure.replace(/\.0$/, '') : figure, + suffix: unit.suffix, + }; }; /** A euro amount, shortened to k€ or M€: "26,3 k€", "€9.00M". */ @@ -48,11 +71,17 @@ export const formatRoiEuro = (value: number, lang: Language): string => { : `${sign}€${localised}${suffix}`; }; -/** A whole number with thousands grouped: "1 234", "1,234". */ +/** + * A whole number with thousands grouped: "1 234", "1,234". French Intl + * groups with a narrow space; the other helpers use NBSP, so this one does + * too. + */ export const formatRoiCount = (value: number, lang: Language): string => new Intl.NumberFormat(INTL_LOCALE[lang], { maximumFractionDigits: 0, - }).format(value); + }) + .format(value) + .replace(/\s/gu, NBSP); const percentSuffix = (lang: Language): string => lang === 'fr' ? `${NBSP}%` : '%'; From d4acfd86efff3f16a0b41b25222481ad8ffa7bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 11:45:50 +0100 Subject: [PATCH 09/14] refactor(roi): move the walkthrough band to its own module The walkthrough file passed 400 lines. The band cells are now sorted by row and column, so a screen reader reads the formula in order rather than all terms, then all operators. The example copy takes a plural for the opportunity lever. --- app/components/roi/roi-walkthrough-band.tsx | 256 ++++++++++++++++++++ app/components/roi/roi-walkthrough.tsx | 253 +------------------ docs/development/component-inventory.md | 1 + 3 files changed, 268 insertions(+), 242 deletions(-) create mode 100644 app/components/roi/roi-walkthrough-band.tsx diff --git a/app/components/roi/roi-walkthrough-band.tsx b/app/components/roi/roi-walkthrough-band.tsx new file mode 100644 index 00000000..9abc22e7 --- /dev/null +++ b/app/components/roi/roi-walkthrough-band.tsx @@ -0,0 +1,256 @@ +import { css, cx } from '@ocobo/styled-system/css'; +import { card, text } from '@ocobo/styled-system/recipes'; + +import type { RoiFunnel } from '~/utils/roi'; + +import type { RoiFormat } from './use-roi-format'; + +/** + * One band of the ROI walkthrough: the funnel formula on a 15-column grid, + * with labels (the formula), today's figures or the RevOps figures. + */ + +type CellKind = 'label' | 'op' | 'value' | 'ring' | 'result' | 'final'; + +type Cell = { + key: string; + column: number; + row: number; + kind: CellKind; + content: string; +}; + +export type Term = + | 'reps' + | 'opps' + | 'winRate' + | 'deals' + | 'acv' + | 'booking' + | 'duration' + | 'contractValue'; + +// Where each term sits: three steps down, one per result. +const TERMS: ReadonlyArray<{ + term: Term; + column: number; + row: number; + result?: boolean; + lever?: boolean; +}> = [ + { term: 'reps', column: 1, row: 1 }, + { term: 'opps', column: 3, row: 1, lever: true }, + { term: 'winRate', column: 5, row: 1, lever: true }, + { term: 'deals', column: 7, row: 1, result: true }, + { term: 'acv', column: 9, row: 2, lever: true }, + { term: 'booking', column: 11, row: 2, result: true }, + { term: 'duration', column: 13, row: 3 }, + { term: 'contractValue', column: 15, row: 3, result: true }, +]; + +const OPERATORS: ReadonlyArray<{ column: number; row: number; sign: string }> = + [ + { column: 2, row: 1, sign: '×' }, + { column: 4, row: 1, sign: '×' }, + { column: 6, row: 1, sign: '=' }, + { column: 8, row: 2, sign: '×' }, + { column: 10, row: 2, sign: '=' }, + { column: 12, row: 3, sign: '×' }, + { column: 14, row: 3, sign: '=' }, + ]; + +const termValue = (term: Term, funnel: RoiFunnel, f: RoiFormat): string => { + switch (term) { + case 'reps': + return f.count(funnel.reps); + case 'opps': + return f.decimal(funnel.oppsPerRepPerYear); + case 'winRate': + return f.percent(funnel.winRate); + case 'deals': + return f.count(funnel.deals); + case 'acv': + return f.euro(funnel.acv); + case 'booking': + return f.euro(funnel.booking); + case 'duration': + return f.years(funnel.durationYears); + case 'contractValue': + return f.euro(funnel.contractValue); + } +}; + +export type BandKind = 'formula' | 'today' | 'revops'; + +export const buildCells = ( + band: BandKind, + label: (term: Term) => string, + funnel: RoiFunnel, + f: RoiFormat, +): Cell[] => { + const terms = TERMS.map(({ term, column, row, result, lever }): Cell => { + const base = { key: term, column, row }; + if (band === 'formula') { + return { ...base, kind: 'label', content: label(term) }; + } + const content = termValue(term, funnel, f); + if (band === 'today') { + return { ...base, kind: lever ? 'ring' : 'value', content }; + } + if (term === 'contractValue') return { ...base, kind: 'final', content }; + return { ...base, kind: result ? 'result' : 'value', content }; + }); + const operators = OPERATORS.map( + ({ column, row, sign }): Cell => ({ + key: `op-${column}`, + column, + row, + kind: 'op', + content: sign, + }), + ); + // Grid placement only moves cells visually: sort them so a screen reader + // reads the formula in order. + return [...terms, ...operators].sort( + (a, b) => a.row - b.row || a.column - b.column, + ); +}; + +// 8 terms and 7 operators side by side (mockup `pg-grid`). +export const grid = css({ + display: 'grid', + gridTemplateColumns: + 'minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,.8fr) 24px minmax(0,1.2fr)', + rowGap: '0.5', + fontVariantNumeric: 'tabular-nums', +}); + +const cellBase = css({ + justifySelf: 'center', + alignSelf: 'center', + textAlign: 'center', + whiteSpace: 'nowrap', + px: '1', + py: '2', +}); +const cellStyles: Record = { + label: cx(text({ variant: 'label', color: 'muted' }), css({ px: '1' })), + op: css({ fontSize: 'md', color: 'gray.300' }), + value: css({ fontSize: 'md', fontWeight: 'semibold', color: 'dark' }), + ring: css({ + fontSize: 'md', + fontWeight: 'semibold', + color: 'dark', + bg: 'mint.light', + boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', + rounded: 'full', + px: '3', + py: '1.5', + }), + result: css({ fontSize: 'md', fontWeight: 'extrabold', color: 'dark' }), + final: cx( + text({ variant: 'display-md-black' }), + css({ + fontSize: 'lg', + color: 'white', + bg: 'dark', + rounded: 'full', + px: '4', + py: '2', + }), + ), +}; + +const band = cx( + card({ padding: 'sm', radius: 'lg' }), + css({ position: 'relative', pt: '12', px: '6' }), +); +const bandRevops = css({ + borderColor: 'mint', + boxShadow: 'hover', +}); +const tag = cx( + text({ variant: 'label', color: 'muted' }), + css({ + position: 'absolute', + top: '5', + left: '6', + display: 'inline-flex', + alignItems: 'center', + gap: '2', + _before: { + content: '""', + w: '1.5', + h: '1.5', + rounded: 'full', + bg: 'gray.300', + }, + }), +); +const tagRevops = css({ + color: 'dark', + _before: { bg: 'mint', boxShadow: '[0 0 0 3px var(--colors-mint-light)]' }, +}); +const gainPill = cx( + text({ variant: 'display-md-black' }), + css({ + justifySelf: 'center', + alignSelf: 'center', + whiteSpace: 'nowrap', + fontSize: 'xl', + color: 'mint.dark', + bg: 'mint.light', + boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', + rounded: 'full', + px: '4', + py: '1.5', + }), +); +export const leverChip = css({ + fontSize: 'xs', + fontWeight: 'bold', + color: 'mint.dark', + bg: 'white', + borderWidth: '1px', + borderStyle: 'solid', + borderColor: 'mint', + rounded: 'full', + px: '2.5', + py: '0.5', + whiteSpace: 'nowrap', +}); + +type BandProps = { + title: string; + cells: Cell[]; + revops?: boolean; + gain?: string; +}; + +export function Band({ title, cells, revops, gain }: BandProps) { + return ( +
+ {title} +
+ {cells.map((cell) => ( + + {cell.content} + + ))} + {gain ? ( + + {gain} + + ) : null} +
+
+ ); +} diff --git a/app/components/roi/roi-walkthrough.tsx b/app/components/roi/roi-walkthrough.tsx index cc8f55f7..053c54b7 100644 --- a/app/components/roi/roi-walkthrough.tsx +++ b/app/components/roi/roi-walkthrough.tsx @@ -2,14 +2,21 @@ import { ArrowDown } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { css, cx } from '@ocobo/styled-system/css'; -import { card, section, text } from '@ocobo/styled-system/recipes'; +import { section, text } from '@ocobo/styled-system/recipes'; import { Container } from '~/components/ui/Container'; -import type { RoiFunnel, RoiResult, RoiScenario } from '~/utils/roi'; +import type { RoiResult, RoiScenario } from '~/utils/roi'; import { ROI_CALCULATOR_ID, ROI_WALKTHROUGH_ID } from './roi-ids'; import { dotBackdrop } from './roi-styles'; -import { type RoiFormat, useRoiFormat } from './use-roi-format'; +import { + Band, + type Term, + buildCells, + grid, + leverChip, +} from './roi-walkthrough-band'; +import { useRoiFormat } from './use-roi-format'; /** * "Le calcul, pas à pas" (mockup `roi`): the funnel formula written out as a @@ -18,245 +25,6 @@ import { type RoiFormat, useRoiFormat } from './use-roi-format'; * visitor's numbers. Too wide for a phone: it scrolls sideways there. */ -type CellKind = 'label' | 'op' | 'value' | 'ring' | 'result' | 'final'; - -type Cell = { - key: string; - column: number; - row: number; - kind: CellKind; - content: string; -}; - -type Term = - | 'reps' - | 'opps' - | 'winRate' - | 'deals' - | 'acv' - | 'booking' - | 'duration' - | 'contractValue'; - -// Where each term sits: three steps down, one per result. -const TERMS: ReadonlyArray<{ - term: Term; - column: number; - row: number; - result?: boolean; - lever?: boolean; -}> = [ - { term: 'reps', column: 1, row: 1 }, - { term: 'opps', column: 3, row: 1, lever: true }, - { term: 'winRate', column: 5, row: 1, lever: true }, - { term: 'deals', column: 7, row: 1, result: true }, - { term: 'acv', column: 9, row: 2, lever: true }, - { term: 'booking', column: 11, row: 2, result: true }, - { term: 'duration', column: 13, row: 3 }, - { term: 'contractValue', column: 15, row: 3, result: true }, -]; - -const OPERATORS: ReadonlyArray<{ column: number; row: number; sign: string }> = - [ - { column: 2, row: 1, sign: '×' }, - { column: 4, row: 1, sign: '×' }, - { column: 6, row: 1, sign: '=' }, - { column: 8, row: 2, sign: '×' }, - { column: 10, row: 2, sign: '=' }, - { column: 12, row: 3, sign: '×' }, - { column: 14, row: 3, sign: '=' }, - ]; - -const termValue = (term: Term, funnel: RoiFunnel, f: RoiFormat): string => { - switch (term) { - case 'reps': - return f.count(funnel.reps); - case 'opps': - return f.decimal(funnel.oppsPerRepPerYear); - case 'winRate': - return f.percent(funnel.winRate); - case 'deals': - return f.count(funnel.deals); - case 'acv': - return f.euro(funnel.acv); - case 'booking': - return f.euro(funnel.booking); - case 'duration': - return f.years(funnel.durationYears); - case 'contractValue': - return f.euro(funnel.contractValue); - } -}; - -type BandKind = 'formula' | 'today' | 'revops'; - -const buildCells = ( - band: BandKind, - label: (term: Term) => string, - funnel: RoiFunnel, - f: RoiFormat, -): Cell[] => { - const terms = TERMS.map(({ term, column, row, result, lever }): Cell => { - const base = { key: term, column, row }; - if (band === 'formula') { - return { ...base, kind: 'label', content: label(term) }; - } - const content = termValue(term, funnel, f); - if (band === 'today') { - return { ...base, kind: lever ? 'ring' : 'value', content }; - } - if (term === 'contractValue') return { ...base, kind: 'final', content }; - return { ...base, kind: result ? 'result' : 'value', content }; - }); - const operators = OPERATORS.map( - ({ column, row, sign }): Cell => ({ - key: `op-${column}`, - column, - row, - kind: 'op', - content: sign, - }), - ); - return [...terms, ...operators]; -}; - -// 8 terms and 7 operators side by side (mockup `pg-grid`). -const grid = css({ - display: 'grid', - gridTemplateColumns: - 'minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1fr) 24px minmax(0,1.1fr) 24px minmax(0,.8fr) 24px minmax(0,1.2fr)', - rowGap: '0.5', - fontVariantNumeric: 'tabular-nums', -}); - -const cellBase = css({ - justifySelf: 'center', - alignSelf: 'center', - textAlign: 'center', - whiteSpace: 'nowrap', - px: '1', - py: '2', -}); -const cellStyles: Record = { - label: cx(text({ variant: 'label', color: 'muted' }), css({ px: '1' })), - op: css({ fontSize: 'md', color: 'gray.300' }), - value: css({ fontSize: 'md', fontWeight: 'semibold', color: 'dark' }), - ring: css({ - fontSize: 'md', - fontWeight: 'semibold', - color: 'dark', - bg: 'mint.light', - boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', - rounded: 'full', - px: '3', - py: '1.5', - }), - result: css({ fontSize: 'md', fontWeight: 'extrabold', color: 'dark' }), - final: css({ - fontFamily: 'display', - fontWeight: 'black', - fontSize: 'lg', - color: 'white', - bg: 'dark', - rounded: 'full', - px: '4', - py: '2', - }), -}; - -const band = cx( - card({ padding: 'sm', radius: 'lg' }), - css({ position: 'relative', pt: '12', px: '6' }), -); -const bandRevops = css({ - borderColor: 'mint', - boxShadow: 'hover', -}); -const tag = cx( - text({ variant: 'label', color: 'muted' }), - css({ - position: 'absolute', - top: '5', - left: '6', - display: 'inline-flex', - alignItems: 'center', - gap: '2', - _before: { - content: '""', - w: '1.5', - h: '1.5', - rounded: 'full', - bg: 'gray.300', - }, - }), -); -const tagRevops = css({ - color: 'dark', - _before: { bg: 'mint', boxShadow: '[0 0 0 3px var(--colors-mint-light)]' }, -}); -const gainPill = css({ - justifySelf: 'center', - alignSelf: 'center', - whiteSpace: 'nowrap', - fontFamily: 'display', - fontWeight: 'black', - fontSize: 'xl', - color: 'mint.dark', - bg: 'mint.light', - boxShadow: '[inset 0 0 0 1px var(--colors-mint)]', - rounded: 'full', - px: '4', - py: '1.5', -}); -const leverChip = css({ - fontSize: 'xs', - fontWeight: 'bold', - color: 'mint.dark', - bg: 'white', - borderWidth: '1px', - borderStyle: 'solid', - borderColor: 'mint', - rounded: 'full', - px: '2.5', - py: '0.5', - whiteSpace: 'nowrap', -}); - -type BandProps = { - title: string; - cells: Cell[]; - revops?: boolean; - gain?: string; -}; - -function Band({ title, cells, revops, gain }: BandProps) { - return ( -
- {title} -
- {cells.map((cell) => ( - - {cell.content} - - ))} - {gain ? ( - - {gain} - - ) : null} -
-
- ); -} - type RoiWalkthroughProps = { result: RoiResult; scenario: RoiScenario; @@ -342,6 +110,7 @@ export function RoiWalkthrough({ result, scenario }: RoiWalkthroughProps) { winRate: f.percent(today.winRate), acv: f.euro(today.acv), oppsLever: f.decimal(levers.oppsPerRepPerMonth), + count: levers.oppsPerRepPerMonth, winRateLever: f.points(levers.winRatePoints), acvLever: f.euro(levers.acv), })} diff --git a/docs/development/component-inventory.md b/docs/development/component-inventory.md index 9f3b5ff9..9ff9fd74 100644 --- a/docs/development/component-inventory.md +++ b/docs/development/component-inventory.md @@ -230,6 +230,7 @@ Sections of the ROI calculator page (`app/routes/_main.($lang).roi.tsx`), behind | **RoiHero** | `roi-hero.tsx` | Pill, title with the yellow marker, lead, CTA to the walkthrough, and `RoiHeroChart` (`roi-hero-chart.tsx`, the animated multiplier curve) | ROI-specific | | **RoiExperience** | `roi-experience.tsx` | State owner: walkthrough, then the calculator section (inputs, sticky result from `lg`, detail) | ROI-specific | | **RoiWalkthrough** | `roi-walkthrough.tsx` | The multiplication laid out in three bands (formula, today, with RevOps) and the gain; scrolls inside its own region on a phone | ROI-specific | +| **Band**, `buildCells` | `roi-walkthrough-band.tsx` | One band of the walkthrough: the terms and operators on a 15-column grid, in reading order | ROI-specific | | **RoiInputsCard** | `roi-inputs-card.tsx` | Steps 1 and 2: five sliders, the scenario toggle (`aria-pressed`) and the lever pills | ROI-specific | | **RoiRangeInput** | `roi-range-input.tsx` | Native range input with label, hint, formatted `` and `aria-valuetext` | Reusable (any slider) | | **RoiStep** | `roi-step.tsx` | Numbered step heading; also exports `stepTitle` and `stepHint` for small card titles | ROI-specific | From 1adb7889460eea9c52a68e845f66951969217bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?je=CC=81ro=CC=82me=20boileux?= Date: Tue, 17 Nov 2026 11:45:50 +0100 Subject: [PATCH 10/14] fix(roi): display figures through text(), accessibility fixes - Figures use text({ variant: 'display-md-black' }) with a size override instead of an inline display font (ADR 0001). - The detail table hides its operator column header, as every row does, so headers match cells. - One polite live region announces the contract value gain; the result card and the lever pills no longer announce on every slider step. - The slider hint is linked with aria-describedby, out of the label. - The hero is a div, not a second banner landmark. --- app/components/roi/roi-detail.tsx | 39 +++++++++++--------- app/components/roi/roi-hero-chart.tsx | 13 +++++-- app/components/roi/roi-hero.tsx | 4 +- app/components/roi/roi-inputs-card.tsx | 5 +-- app/components/roi/roi-range-input.tsx | 26 ++++++++----- app/components/roi/roi-result-card.tsx | 51 ++++++++++++++++---------- app/components/roi/roi-step.tsx | 28 +++++++------- locales/en/roi.json | 4 +- locales/fr/roi.json | 4 +- 9 files changed, 103 insertions(+), 71 deletions(-) diff --git a/app/components/roi/roi-detail.tsx b/app/components/roi/roi-detail.tsx index db06b5a5..b612c340 100644 --- a/app/components/roi/roi-detail.tsx +++ b/app/components/roi/roi-detail.tsx @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next'; import { css, cx } from '@ocobo/styled-system/css'; -import { card } from '@ocobo/styled-system/recipes'; +import { card, text } from '@ocobo/styled-system/recipes'; import type { RoiResult } from '~/utils/roi'; @@ -126,28 +126,30 @@ const rowKinds: Record = { final: css({ bg: 'dark', color: 'white', rounded: '2xl', my: '1' }), }; // On a phone the label takes the top line and the figures sit below it. -const operatorCell = css({ - gridRow: { base: 'span 2', md: 'auto' }, - fontFamily: 'display', - fontWeight: 'black', - fontSize: 'xl', - color: 'gray.400', - textAlign: 'center', -}); +const operatorCell = cx( + text({ variant: 'display-md-black' }), + css({ + gridRow: { base: 'span 2', md: 'auto' }, + fontSize: 'xl', + color: 'gray.400', + textAlign: 'center', + }), +); const labelCell = css({ gridColumn: { base: '2 / -1', md: 'auto' }, fontWeight: 'semibold', }); const todayCell = css({ fontVariantNumeric: 'tabular-nums' }); const changeCell = css({ justifySelf: 'center' }); -const revopsCell = css({ - justifySelf: 'end', - fontFamily: 'display', - fontWeight: 'black', - fontSize: 'xl', - fontVariantNumeric: 'tabular-nums', - whiteSpace: 'nowrap', -}); +const revopsCell = cx( + text({ variant: 'display-md-black' }), + css({ + justifySelf: 'end', + fontSize: 'xl', + fontVariantNumeric: 'tabular-nums', + whiteSpace: 'nowrap', + }), +); const pill = css({ display: 'inline-block', minW: '16', @@ -220,7 +222,8 @@ export function RoiDetail({ result }: RoiDetailProps) { css({ display: { base: 'none', md: 'grid' }, py: '2' }), )} > - + {/* The operator column is hidden in every row, so here too. */} +