diff --git a/projects/packages/my-jetpack/_inc/components/onboarding-screen/index.tsx b/projects/packages/my-jetpack/_inc/components/onboarding-screen/index.tsx index 3ac0d8af8064..a3c928749de2 100644 --- a/projects/packages/my-jetpack/_inc/components/onboarding-screen/index.tsx +++ b/projects/packages/my-jetpack/_inc/components/onboarding-screen/index.tsx @@ -1,14 +1,24 @@ import { Container, Col } from '@automattic/jetpack-components'; import clsx from 'clsx'; +import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state'; import { useFullScreen } from '../../hooks/use-fullscreen'; import Testimonials from '../testimonials'; import ConnectionForm from './connection-form/connection-form'; import styles from './styles.module.scss'; +import { Wizard } from './wizard'; import type { FC } from 'react'; const OnboardingScreen: FC = () => { useFullScreen(); + // Only set when the wizard's feature flag is on; the page carries its configuration + // rather than the flag itself. + const wizard = getMyJetpackWindowInitialState( 'onboardingWizard' ); + + if ( wizard?.exitUrl ) { + return ; + } + return ( >; +} + +/** + * The steps, in order. Placeholder content until stage 3 brings the real steps. + * + * @return One entry per step, translated at call time. + */ +export function wizardSteps(): WizardStepMeta[] { + return [ + { + id: 'start', + kind: 'start', + label: __( 'Connect', 'jetpack-my-jetpack' ), + title: __( 'Start with Jetpack for free', 'jetpack-my-jetpack' ), + description: __( + 'One plugin, and your site can do the things it usually takes five to do.', + 'jetpack-my-jetpack' + ), + options: [], + }, + { + id: 'site-type', + kind: 'question', + label: __( 'Your site', 'jetpack-my-jetpack' ), + title: __( "Tell us what you're building", 'jetpack-my-jetpack' ), + /* + * The prototype's line here says the site is new and there is nothing to + * read yet, which is true of its own new-site scenario only. V1 asks every + * site the same question, so the reassurance it carries is what survives. + */ + description: __( + 'Pick the closest fit — you can change any of this later.', + 'jetpack-my-jetpack' + ), + /* + * Slugs rather than the prototype's prose values. Its label and stored + * value disagree on the business row, and these go to Tracks. + */ + options: [ + { + value: 'blog', + label: __( 'A blog or publication', 'jetpack-my-jetpack' ), + description: __( 'Regular writing for an audience.', 'jetpack-my-jetpack' ), + icon: post, + }, + { + value: 'store', + label: __( 'An online store', 'jetpack-my-jetpack' ), + description: __( 'Selling products or taking orders.', 'jetpack-my-jetpack' ), + icon: store, + }, + { + value: 'portfolio', + label: __( 'A portfolio or personal site', 'jetpack-my-jetpack' ), + description: __( 'Your work, a project, or somewhere to start.', 'jetpack-my-jetpack' ), + icon: image, + }, + { + value: 'business', + label: __( 'A business or brochure site', 'jetpack-my-jetpack' ), + description: __( + 'Services, opening hours, and how to get in touch.', + 'jetpack-my-jetpack' + ), + icon: page, + }, + { + value: SITE_TYPE_OTHER, + label: __( 'Something else…', 'jetpack-my-jetpack' ), + description: __( 'Tell us in your own words.', 'jetpack-my-jetpack' ), + icon: comment, + freeText: true, + }, + ], + }, + { + id: 'features', + kind: 'question', + label: __( 'What you need', 'jetpack-my-jetpack' ), + title: __( 'The feature list is not decided yet', 'jetpack-my-jetpack' ), + description: __( + 'These three are stand-ins for it. Picking one turns nothing on and saves nothing.', + 'jetpack-my-jetpack' + ), + options: [ + { + value: 'protect', + label: __( 'Example: keeping the site safe', 'jetpack-my-jetpack' ), + description: __( 'A stand-in. Nothing is turned on.', 'jetpack-my-jetpack' ), + icon: shield, + }, + { + value: 'grow', + label: __( 'Example: reaching more people', 'jetpack-my-jetpack' ), + description: __( 'A stand-in. Nothing is turned on.', 'jetpack-my-jetpack' ), + icon: megaphone, + }, + { + value: 'speed', + label: __( 'Example: making the site faster', 'jetpack-my-jetpack' ), + description: __( 'A stand-in. Nothing is turned on.', 'jetpack-my-jetpack' ), + icon: trendingUp, + }, + ], + }, + { + id: 'done', + kind: 'question', + label: __( 'Finish', 'jetpack-my-jetpack' ), + title: __( 'The rest of this is not built yet', 'jetpack-my-jetpack' ), + description: __( + 'Nothing has been turned on and nothing is saved. This step exists so the end of the flow can be judged alongside the rest.', + 'jetpack-my-jetpack' + ), + options: [], + }, + ]; +} + +/** + * The start screen's benefits, in order. + * + * Every feature named here is in the free tier. VideoPress and Backup are + * deliberately absent: both are paid, and this screen cannot promise what sits + * behind a plan. Do not add a row without checking its tier. + * + * @return One entry per row, translated at call time. + */ +export function startBenefits(): WizardBenefit[] { + return [ + { + id: 'secure', + icon: shield, + text: __( 'Spam, brute force and downtime, handled for you', 'jetpack-my-jetpack' ), + }, + { + id: 'fast', + icon: cloud, + text: __( 'Pages and images served fast from a global network', 'jetpack-my-jetpack' ), + }, + { + id: 'grow', + icon: chartBar, + text: __( 'Stats, SEO and social sharing, in one place', 'jetpack-my-jetpack' ), + }, + { + id: 'publish', + icon: postCommentsForm, + text: __( 'Forms, newsletters and podcasting, built in', 'jetpack-my-jetpack' ), + }, + ]; +} + +/** + * How the user left setup. + * + * Finishing is recorded for the whole site, because the flow connects the site + * and switches modules on; skipping is recorded against the person, so the first + * admin to say "not now" does not answer for everyone else. + */ +export type SettleOutcome = 'completed' | 'skipped'; + +/** + * Record that setup has been settled, so the takeover stops interrupting. + * + * The caller navigates whether or not this lands. A failed write means the user + * is offered setup again on their next visit, which is a far better outcome than + * holding them on a screen they have asked to leave. + * + * @param outcome - Whether they finished or skipped. + * @return Resolves when the request has been answered. + */ +export function settleOnboarding( outcome: SettleOutcome ): Promise< unknown > { + return apiFetch( { + path: '/my-jetpack/v1/site/onboarding/settled', + method: 'POST', + data: { outcome }, + } ); +} + +/** + * Which step the wizard opens on after the round trip to WordPress.com. + * + * Derived, not stored: a `step` parameter would be editable by the person it + * describes. Keyed on the user connection rather than the site registration, + * because a blog token with no owner is a half-finished connect step. + * + * @param isUserConnected - Whether this user holds a WordPress.com token. + * @return The step index to open on. + */ +export function openingStep( isUserConnected: boolean ): WizardStep { + return isUserConnected ? 1 : 0; +} + +/** + * Whether the user may advance from the given step. + * + * A step that offers options needs one picked; a step that offers none is free to leave. + * + * @param step - The current step index. + * @param state - The collected wizard state. + * @return True when the primary action is enabled. + */ +export function canContinue( step: WizardStep, state: WizardState ): boolean { + const meta = wizardSteps()[ step ]; + + // The start screen asks nothing, and carries its own way forward. + return meta.kind === 'start' || meta.options.length === 0 || state.choices[ step ] !== undefined; +} + +/** + * Whether the given step is the final one. + * + * @param step - The current step index. + * @return True on the last step. + */ +export function isLastStep( step: WizardStep ): boolean { + return step === TOTAL_STEPS - 1; +} diff --git a/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/panel-art.tsx b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/panel-art.tsx new file mode 100644 index 000000000000..aaa6c476f6d3 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/panel-art.tsx @@ -0,0 +1,169 @@ +import clsx from 'clsx'; +import { useLayoutEffect, useRef } from 'react'; +import styles from './styles.module.scss'; + +/** + * The brand artwork's own geometry: 14 hairline strokes making the isometric + * Jetpack bolt inside two organic circles. + * + * Copied verbatim from the prototype's `components/onboarding/panel-art.tsx`, + * which inlined it from Layer_1.svg. It is hand-drawn brand art: the path data + * and the two stroke widths are not to be redrawn, rounded or simplified. + * + * The stroke colour is not here. The prototype writes `#48FF50` on every path; + * that value is `$brand-gradient-green-bright` in styles.module.scss, so the + * paths take `currentColor` and the stylesheet is the one place it lives. + */ +const ART_PATHS: { d: string; width: number }[] = [ + { + d: 'M658.827 323.388C662.115 173.215 560.214 30.5771 400.987 26.5906C278.987 23.5433 167.999 99.9342 106.151 201.163C40.7016 308.277 24.9988 451.896 91.2647 562.558C168.92 692.256 332.879 719.994 460.867 650.199C565.113 593.344 638.058 484.185 655.038 367.469C657.152 352.859 658.43 338.144 658.827 323.388Z', + width: 0.327402, + }, + { + d: 'M610.777 289.158C610.274 408.044 551.42 524.447 456.282 596.079C347.598 677.896 189.837 690.858 86.9936 591.299C-11.348 496.123 -19.1366 341.985 33.939 222.16C80.6496 116.715 175.39 28.824 290.816 6.42852C450.168 -24.5035 588.479 88.8097 608.118 245.703C609.918 260.105 610.756 274.632 610.777 289.158Z', + width: 0.327402, + }, + { + d: 'M321.636 275.049L321.615 592.823L369.477 618.975L369.561 300.847L321.636 275.049Z', + width: 0.327402, + }, + { + d: 'M473.932 253.509L321.636 275.049L369.561 300.847L521.983 279.265L473.932 253.509Z', + width: 0.982206, + }, + { + d: 'M321.615 592.823L473.933 253.509L521.983 279.265L369.477 618.975L321.615 592.823Z', + width: 0.982206, + }, + { + d: 'M138.792 410.591L290.795 388.988L338.678 414.911L186.529 436.576L138.792 410.591Z', + width: 0.327402, + }, + { + d: 'M290.795 71.2773L138.792 410.591L186.529 436.576L338.72 96.8452L290.795 71.2773Z', + width: 0.982206, + }, + { + d: 'M290.795 388.988V71.2773L338.72 96.8452L338.679 414.911L290.795 388.988Z', + width: 0.982206, + }, + { + d: 'M658.954 314.914C658.43 433.946 599.513 550.453 504.27 622.189C395.02 704.487 236.15 717.156 133.37 616.241C30.5893 515.326 28.7469 366.593 82.0527 246.956C129.182 141.219 224.781 53.2859 340.793 31.5792C499.706 1.83689 636.76 115.275 656.294 271.438C658.095 285.861 658.933 300.388 658.954 314.935V314.914Z', + width: 0.982206, + }, + { + d: 'M610.672 297.611C613.959 146.019 509.923 2.88015 349.189 1.06431C228.298 -0.313235 119.006 75.7855 57.8701 176.346C-7.39078 283.752 -22.4655 427.643 44.5542 538.013C122.566 666.458 285.708 693.362 412.921 624.047C517.063 567.317 589.944 458.22 606.883 341.651C608.997 327.061 610.254 312.347 610.651 297.611H610.672Z', + width: 0.982206, + }, + { d: 'M369.477 618.975L521.983 279.265L369.561 300.847L369.477 618.975Z', width: 0.982206 }, + { + d: 'M473.933 253.509L321.615 592.823V275.049C372.409 267.869 423.16 260.689 473.933 253.509Z', + width: 0.982206, + }, + { + d: 'M338.678 414.911L338.72 96.8452L186.549 436.555C237.259 429.334 287.969 422.112 338.678 414.89V414.911Z', + width: 0.982206, + }, + { d: 'M290.795 71.2773V388.988L138.792 410.591L290.795 71.2773Z', width: 0.982206 }, +]; + +/* + * The draw-in's stagger, from the prototype's panel-art.tsx: a delay of + * `0.15 + index * 0.08` seconds. Written as seconds because the CSS duration + * it runs against is, and kept here rather than in the stylesheet because one + * selector per path is 14 selectors. + */ +const DRAW_DELAY_BASE_S = 0.15; +const DRAW_DELAY_STEP_S = 0.08; + +// The artwork's own coordinate space, from Layer_1.svg. +const ART_VIEW_BOX = '0 0 660 689'; + +type PanelArtProps = { + /* + * Draw the paths in, one after another. True on the start step only, which + * is what the prototype does: its other panels render the art complete. + */ + animate?: boolean; +}; + +/** + * The brand panel's artwork. + * + * Each path's own length is measured and published as `--draw-length`, which the + * dash rules read. `pathLength` would be tidier, but Chrome only normalises + * against it for presentation attributes: a `stroke-dasharray` coming from a + * stylesheet stays in user units, so the whole bolt draws as a 1px dotted line + * at a third of a pixel wide and nothing appears on screen. + * + * @param props - The component props. + * @param props.animate - Whether the paths draw themselves in. + * @return The rendered artwork. + */ +export function PanelArt( { animate = false }: PanelArtProps ) { + const svgRef = useRef< SVGSVGElement >( null ); + + useLayoutEffect( () => { + if ( ! animate ) { + return; + } + + const paths = Array.from( svgRef.current?.querySelectorAll( 'path' ) ?? [] ); + + // Chrome rasterises a dashed hairline at far lower coverage than a plain one, + // so a finished path left dashed renders a third as bright as a static one. + const clearDash = ( event: AnimationEvent ) => + ( event.currentTarget as SVGPathElement ).style.setProperty( 'stroke-dasharray', 'none' ); + + paths.forEach( path => { + // jsdom has no SVG geometry, so the measurement is skipped under test. + if ( typeof path.getTotalLength === 'function' ) { + path.style.setProperty( '--draw-length', `${ Math.ceil( path.getTotalLength() ) }` ); + } + path.addEventListener( 'animationend', clearDash, { once: true } ); + } ); + + return () => paths.forEach( path => path.removeEventListener( 'animationend', clearDash ) ); + }, [ animate ] ); + + return ( +
+ +
+ ); +} diff --git a/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/choice-step.tsx b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/choice-step.tsx new file mode 100644 index 000000000000..b28e04d7c475 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/choice-step.tsx @@ -0,0 +1,203 @@ +import { isRTL, __ } from '@wordpress/i18n'; +import { check } from '@wordpress/icons'; +import { Icon, InputControl, Stack, Text } from '@wordpress/ui'; +import { useCallback, useEffect, useRef } from 'react'; +import styles from '../styles.module.scss'; +import type { WizardStepOption } from '../lib'; +import type { ChangeEvent, KeyboardEvent, MouseEvent } from 'react'; + +type ChoiceStepProps = { + // Owned by the wizard so the panel region can be labelled by the heading. + titleId: string; + title: string; + description: string; + // An empty list renders the heading alone, with nothing to choose. + options: WizardStepOption[]; + value?: string; + onChange: ( value: string ) => void; + // The answer typed into the field a `freeText` option opens. + freeText?: string; + onFreeTextChange?: ( value: string ) => void; +}; + +// Arrow keys move the selection inside a radiogroup, as they do for native radios. +const VERTICAL_STEP_BY_KEY: Record< string, number > = { + ArrowDown: 1, + ArrowUp: -1, +}; + +// Horizontal arrows follow the writing direction; the vertical pair never mirrors. +const HORIZONTAL_STEP_BY_KEY: Record< string, number > = { + ArrowRight: 1, + ArrowLeft: -1, +}; + +/** + * The field an option opens, and the only thing that mounts with it. + * + * Focus is moved here on mount rather than by `autoFocus`, and the difference is + * not cosmetic: the field exists because the user chose the row above it, so this + * carries their action on. `autoFocus` would also fire on a step that opened with + * the answer already chosen, taking focus from the heading on arrival. + * + * The ref sits on the wrapper and the input is found inside it, because the + * control owns its own markup and forwarding is not part of its contract. + * + * @param props - The component props. + * @param props.value - What has been typed so far. + * @param props.onChange - Called with what the user types. + * @return The rendered field. + */ +function FreeTextField( { + value, + onChange, +}: { + value: string; + onChange: ( value: string ) => void; +} ) { + const wrapperRef = useRef< HTMLDivElement >( null ); + + useEffect( () => { + wrapperRef.current?.querySelector( 'input' )?.focus(); + }, [] ); + + const handleChange = useCallback( + ( event: ChangeEvent< HTMLInputElement > ) => onChange( event.target.value ), + [ onChange ] + ); + + return ( +
+ +
+ ); +} + +/** + * A question: a heading, a standfirst, and one hand-rolled radio group. + * + * `@wordpress/ui` has no RadioGroup, so the group carries its own ARIA and roving + * tab stop. An option marked `freeText` opens a field under the list for an answer + * the list does not cover. + * + * @param props - The component props. + * @param props.titleId - The id the panel region is labelled by. + * @param props.title - The step heading. + * @param props.description - The line under the heading. + * @param props.options - The choices offered, possibly none. + * @param props.value - The chosen option's value, if any. + * @param props.onChange - Called with the value the user picks. + * @param props.freeText - What has been typed into the free-text field. + * @param props.onFreeTextChange - Called with what the user types. + * @return The rendered step. + */ +export function ChoiceStep( { + titleId, + title, + description, + options, + value, + onChange, + freeText = '', + onFreeTextChange, +}: ChoiceStepProps ) { + const groupRef = useRef< HTMLDivElement >( null ); + + const handleClick = useCallback( + ( event: MouseEvent< HTMLButtonElement > ) => onChange( event.currentTarget.value ), + [ onChange ] + ); + + const handleKeyDown = useCallback( + ( event: KeyboardEvent< HTMLButtonElement > ) => { + const offset = + VERTICAL_STEP_BY_KEY[ event.key ] ?? + ( HORIZONTAL_STEP_BY_KEY[ event.key ] ?? 0 ) * ( isRTL() ? -1 : 1 ); + if ( ! offset ) { + return; + } + event.preventDefault(); + + const radios = Array.from( + groupRef.current?.querySelectorAll< HTMLButtonElement >( '[role="radio"]' ) ?? [] + ); + const next = + radios[ + ( radios.indexOf( event.currentTarget ) + offset + radios.length ) % radios.length + ]; + + next.focus(); + onChange( next.value ); + }, + [ onChange ] + ); + + // The first option holds the group's tab stop until something is chosen. + const tabStop = value ?? options[ 0 ]?.value; + const chosen = options.find( option => option.value === value ); + + return ( + + + }> + { title } + + } className={ styles[ 'step-description' ] }> + { description } + + + + { options.length > 0 && ( +
+
+ { options.map( ( option, index ) => ( + + ) ) } +
+ + { /* + * Mounted only while its option is chosen, so the field is never a tab + * stop the user cannot see. + */ } + { chosen?.freeText && onFreeTextChange && ( + + ) } +
+ ) } +
+ ); +} diff --git a/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/start-step.tsx b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/start-step.tsx new file mode 100644 index 000000000000..030fb5e04e08 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/steps/start-step.tsx @@ -0,0 +1,170 @@ +import { JetpackLogo, TermsOfService } from '@automattic/jetpack-components'; +import { useConnection } from '@automattic/jetpack-connection'; +import { __ } from '@wordpress/i18n'; +import { ThemeProvider } from '@wordpress/theme'; +import { Button, Icon, Notice, Text } from '@wordpress/ui'; +import clsx from 'clsx'; +import { useCallback, useRef, useState } from 'react'; +import useAnalytics from '../../../../hooks/use-analytics'; +import { + CONNECTION_FROM, + CONNECTION_RETURN_URL, + connectionErrorCode, + connectionErrorDetail, + startBenefits, +} from '../lib'; +import styles from '../styles.module.scss'; +import { useRestoredConnection } from '../use-restored-connection'; + +type StartStepProps = { + // Owned by the wizard so the panel region can be labelled by the heading. + titleId: string; + title: string; + description: string; +}; + +/** + * The start screen: what Jetpack does for the site, and the way in. + * + * "Get started" registers the site and then hands the browser to WordPress.com to + * create or sign in to an account, because the features this wizard turns on need + * an owner: Newsletter keeps its subscribers behind a user token, and Activity + * Log's permission callback requires one outright. `redirectUri` brings them back + * to the wizard, which resumes past this step from the connection itself. + * + * `skipPricingPage` is what makes that return actually happen. Without it + * WordPress.com shows its plans page after the authorization, and that page does + * not carry `redirect_after_auth`, so the user lands on My Jetpack and the wizard + * is over. Every one of the six features this wizard offers is free, so there is + * nothing to choose there anyway. + * + * @param props - The component props. + * @param props.titleId - The id the panel region is labelled by. + * @param props.title - The screen's heading. + * @param props.description - The line under the heading. + * @return The rendered step. + */ +export function StartStep( { titleId, title, description }: StartStepProps ) { + const { handleRegisterSite, siteIsRegistering, userIsConnecting, registrationError } = + useConnection( { + from: CONNECTION_FROM, + redirectUri: CONNECTION_RETURN_URL, + skipPricingPage: true, + } ); + const { recordEvent } = useAnalytics(); + + // Only registration failures reach the store. Fetching the authorization URL can + // fail too, and that rejection is ours to hold or the screen says nothing. + const [ handoffError, setHandoffError ] = useState< unknown >( null ); + + // A hand-off rejection leaves `userIsConnecting` set in the store (CONNECT-499), + // so on a real site the button stays busy and the retry below is unreachable. + const isConnecting = siteIsRegistering || userIsConnecting; + const error = registrationError || handoffError; + + // Named once: the terms sentence has to say the same words as the button it is about. + const primaryLabel = __( 'Get started', 'jetpack-my-jetpack' ); + + // The button is disabled while the request is in flight, which already swallows + // a second click. This closes the gap before that state has rendered, so a + // double click cannot register the site twice. + const inFlight = useRef( false ); + + // Back from WordPress.com can return this page with the click still in flight. + useRestoredConnection( + useCallback( () => { + inFlight.current = false; + }, [] ) + ); + + const handleConnect = useCallback( () => { + if ( inFlight.current ) { + return; + } + inFlight.current = true; + setHandoffError( null ); + + // The name the single-screen flow already reports, so the two are one funnel. + recordEvent( 'jetpack_my_jetpack_onboarding_click', { flow: 'wizard' } ); + + // No success event: this resolves as the browser leaves for WordPress.com, + // which is not the same thing as anyone having connected. + handleRegisterSite().catch( ( caught: unknown ) => { + inFlight.current = false; + setHandoffError( caught ); + // The code only: the message interpolates the server's prose, which + // can carry the site's own URL. + recordEvent( 'jetpack_my_jetpack_onboarding_connect_error', { + error_code: connectionErrorCode( caught ), + } ); + } ); + }, [ handleRegisterSite, recordEvent ] ); + + return ( +
+
+ +
+ +
+ } + className={ styles[ 'start-title' ] } + > + { title } + + } className={ styles[ 'start-body' ] }> + { description } + +
+ +
    + { startBenefits().map( benefit => ( +
  • + + + { benefit.text } + +
  • + ) ) } +
+ +
+ { /* + * Above the control it is about, so it is read before the retry. + * A sentence a person can act on, and the server's own words under + * it: mapping the causes to better copy is its own piece of work. + */ } + { error && ( + + + { __( 'We could not connect this site. Please try again.', 'jetpack-my-jetpack' ) } + + + { connectionErrorDetail( error ) } + + + ) } + + { /* Square corners from the theme's own radius scale, not a hardcoded zero. */ } + + + + + +
+
+ ); +} diff --git a/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/styles.module.scss b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/styles.module.scss new file mode 100644 index 000000000000..cc9762d0bfc8 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/onboarding-screen/wizard/styles.module.scss @@ -0,0 +1,1028 @@ +/* + * The --jp-* brand variables the panel needs. Imported here rather than + * inherited from the Testimonials stylesheet, which the wizard will outlive. + */ +@use "@automattic/jetpack-base-styles/root-variables"; + +/* + * The prototype's own constants. Each is a design value with no WPDS token; + * everything else on this screen is a token. + */ +$rail-width: 300px; +$panel-width: 38%; + +/* + * The one departure from the prototype on this screen, and deliberate: the + * prototype drops its panel at Tailwind's `lg` (1024px), but it has no rail. + * The rail changes the arithmetic. The panel is $panel-width of the whole grid + * and the rail takes $rail-width off what is left, so the content frame is + * `W * (1 - $panel-width) - $rail-width - 2 * $canvas-inset`: at 1024px that is + * 239px and all four benefits wrap onto two lines. + * + * Measured rather than derived, because the first attempt at this number was + * wrong: the panel is a share of the WHOLE grid, not of what the rail leaves, + * so 1200px still gives only a 412px frame and two benefits still wrap. The + * frame clears the benefit copy at 1280px (461.6px), which is where it sits. + */ +$panel-breakpoint: 1280px; +$glow-height: 55%; +$row-glyph-size: 28px; +$row-glyph-gap: 14px; +$row-min-height: 56px; + +/* + * The panel's own inset, from the prototype's `inset-x-10` on + * components/onboarding/brand-panel.tsx — Tailwind's 10, so 2.5rem. No WPDS + * padding token is 40px. + */ +$panel-inset: 40px; + +/* + * The three stops of the shared gradient artwork, read off the linearGradient + * in testimonials/slide-01-gradient.tsx — the same SVG this panel draws as its + * glow. Named here so the mesh, the panel artwork and that SVG cannot drift + * apart. The composition's fourth colour, the ground, is already a variable: + * --jp-green-90, #003010. + */ +$brand-gradient-green-bright: #48ff50; +$brand-gradient-green-mid: #108642; +$brand-gradient-blue: #2e38fa; + +/* + * The mesh gradient: four blurred blobs drifting behind the glow, built as + * MESH-GRADIENT.md specifies. Nothing here has a token — the WPDS motion + * durations stop in the hundreds of milliseconds and this is a half-minute + * field, and a blur radius has no scale at all. + * + * The periods are primes, so the four never visibly re-align: the shortest + * cycle they share is 17 x 19 x 23 x 29 seconds, about 48 hours. They were + * 37/47/59, which showed roughly one pass before anyone had read the screen. + */ +$mesh-period-1: 17s; +$mesh-period-2: 19s; +$mesh-period-3: 23s; +$mesh-period-4: 29s; + +/* + * Blur is what makes four circles read as one field, so it is large next to + * the blobs. Nothing reads over them now, so the opacities are free. + */ +$mesh-blur: 64px; +$mesh-opacity-bright: 0.34; +$mesh-opacity-mid: 0.8; +$mesh-opacity-blue: 0.58; +$mesh-opacity-deep: 0.62; + +/* + * The panel artwork. Its width is the prototype's own proportion: 560px of art + * (`max-w-[560px]`) in its 728px panel, so 77%. + * + * The draw-in runs 1.4s there (app/globals.css, `.panel-draw`). The nearest + * WPDS duration is --wpds-motion-duration-xl at 400ms, far too fast to read as + * drawing, so the prototype's value is kept. + */ +$panel-art-width: 77%; +$panel-art-draw-duration: 1.4s; + +/* + * The option rows' cascade, from the prototype's questions-card.tsx: 0.3s, a + * 10px rise, delay 0.12 + index * 0.05. Its own comment records why the step + * was cut from 0.12: at five options the commit button sat unusable for 1.29s, + * and the house bar is 30-80ms because "stagger is decoration and must never + * block interaction". None of the three has a WPDS step. + */ +$option-cascade-duration: 0.3s; +$option-cascade-rise: 10px; +$option-cascade-base: 0.12s; +$option-cascade-step: 0.05s; + +/* + * The free-text field's reveal, from the same file: 0.22s of height with the + * opacity lagging 0.06s behind it over 0.16s, which is what stops the text + * smearing as the row opens. Height is animated as grid rows, since `auto` is + * not an animatable length. + */ +$freetext-open-duration: 0.22s; +$freetext-fade-duration: 0.16s; +$freetext-fade-delay: 0.06s; + +/* + * The start column, from the prototype's app/page.tsx:40 — `max-w-md`, which + * is Tailwind's 28rem, so 448px. `--wpds-dimension-surface-width-md` is 400px + * and wraps the first benefit onto a second line. + */ +$start-column-width: 448px; + +/* + * The start heading, from the prototype's components/chat/chat-pane.tsx:335 — + * `text-[28px] leading-tight sm:text-[32px]`, so 28px is its real value below + * 640px and `leading-tight` is 1.25. Neither is on the WPDS scale: the sizes + * step 20 -> 32 with nothing between them. + */ +$start-title-size: 28px; +$start-title-line-height: 1.25; + +/* + * The Site Editor's own measurements, read off wp-admin/site-editor.php: the + * canvas inset, and the padding and height of one sidebar navigation row. + * 6px has no token, so the row padding is written out whole. + */ +$canvas-inset: 16px; +$rail-row-padding-block: 8px; +$rail-row-padding-inline: 16px 6px; +$rail-row-min-height: 40px; + +.layout { + display: grid; + grid-template-columns: minmax(0, 1fr); + + // Named, or the collapsed rail is stretched to half the viewport by the + // default row distribution and leaves a dead band under its header. + grid-template-rows: auto minmax(0, 1fr); + block-size: 100%; + min-block-size: 100vh; + + // Dark, because the ThemeProvider around it is seeded dark: this is the + // token the Site Editor's own shell reads, and it lands on rgb(30, 30, 30). + background: var(--wpds-color-background-surface-neutral); + color: var(--wpds-color-foreground-content-neutral); + font-family: var(--wpds-typography-font-family-body); + + // Stack from @wordpress/ui writes gap and alignment as inline styles, which + // cannot carry this query, so the split is plain grid. + @media (min-width: $panel-breakpoint) { + grid-template-columns: $rail-width minmax(0, 1fr) $panel-width; + grid-template-rows: minmax(0, 1fr); + } +} + +/* + * The canvas: the shell's gutter around the sheet, the same inset the Site + * Editor holds its canvas at. + */ +.canvas { + display: flex; + min-inline-size: 0; + min-block-size: 0; + padding: $canvas-inset; +} + +/* + * The content frame: a white sheet floating on the dark shell. Its tokens come + * from the nested ThemeProvider, which puts this subtree on the light ramp. + */ +.frame { + display: flex; + flex-direction: column; + flex-grow: 1; + min-inline-size: 0; + min-block-size: 0; + border-radius: var(--wpds-border-radius-xl); + background: var(--wpds-color-background-surface-neutral-strong); + color: var(--wpds-color-foreground-content-neutral); + overflow: hidden; + box-shadow: + 0 5px 15px rgba(0, 0, 0, 0.08), + 0 15px 27px rgba(0, 0, 0, 0.07), + 0 30px 36px rgba(0, 0, 0, 0.04), + 0 50px 43px rgba(0, 0, 0, 0.02); +} + +/* -------------------------------------------------------------- rail */ + +/* + * The sidebar region, as the Site Editor builds it: transparent, so the shell's + * ground shows through, and as wide as the layout grid's first column. + */ +.rail { + display: flex; + flex-direction: column; + gap: var(--wpds-dimension-gap-lg); + min-inline-size: 0; + padding-block: var(--wpds-dimension-padding-lg); +} + +.rail-head { + display: flex; + flex-direction: column; + align-items: flex-start; + flex-shrink: 0; + gap: var(--wpds-dimension-gap-xs); + padding-inline: var(--wpds-dimension-padding-lg); +} + +/* + * The icon-only exit control, sized the way @wordpress/ui's own icon buttons + * are: square, at the compact height. + */ +.exit { + --wp-ui-button-aspect-ratio: 1; + --wp-ui-button-min-width: unset; + --wp-ui-button-padding-inline: 0; + + align-self: flex-start; +} + +/* + * Heading writes its size and colour as runtime styles at one class of + * specificity, so the line height is set from two. + */ +.rail-head .rail-title { + line-height: var(--wpds-typography-line-height-xl); +} + +.rail-count { + color: var(--wpds-color-foreground-content-neutral-weak); + font-variant-numeric: tabular-nums; +} + +/* + * The landmark itself goes below the breakpoint, rather than its contents, so + * the collapsed rail leaves neither an empty