1pub mod content;
24
25use dioxus::prelude::*;
26
27use crate::ui::clipboard;
28use crate::ui::components::footer::Footer;
29use crate::ui::components::icon::{Icon, IconSize, IconVariant};
30use crate::ui::components::main_nav::{ActivePage, MainNav};
31use crate::ui::pages::studio_workbench::{use_shelf, StudioFrame, WorkbenchState, FRAME_ID};
32use crate::ui::router::Route;
33use crate::ui::seo::{faq_schema, organization_schema, pages as seo_pages, website_schema, JsonLdMultiple, PageHead};
34use content::{compare, compare_lead, faq, features, how, install_commands, library, prompt, prompt_text, said, Install, Line, System, COMPARE_HEADING, HEADING, INSTALL_HEADING, INSTRUCTIONS_ID, LIBRARY_HEADING};
35
36const LANDING_STYLE: &str = r#"
37.landing {
38 min-height: 100vh;
39 color: var(--text-primary);
40 font-family: var(--font-sans);
41 /* The page's emerald: the one colour for what a reader is asked to press. */
42 --landing-emerald: #34d399;
43 --landing-emerald-deep: #10b981;
44 --landing-emerald-ink: #052e22;
45}
46
47.landing-main { padding: 0 0 96px; }
48
49.landing [id] { scroll-margin-top: 96px; }
50
51.landing a:focus-visible,
52.landing button:focus-visible,
53.landing pre:focus-visible {
54 outline: 2px solid var(--accent-primary);
55 outline-offset: 3px;
56}
57
58/* The words first: the heading, the one line on how, the install box and the three copy buttons,
59 then the Studio across the page below them. One column at every width. */
60.landing-intro {
61 max-width: 1200px;
62 margin: 0 auto;
63 padding: 40px 16px 36px;
64}
65
66.landing-heading {
67 margin: 0;
68 font-size: clamp(38px, 9vw, 68px);
69 line-height: 1.04;
70 letter-spacing: -0.03em;
71 font-weight: 800;
72 color: var(--text-primary);
73}
74
75.landing-heading span { display: block; text-wrap: balance; }
76.landing-heading span + span { color: var(--text-tertiary); }
77
78.landing-how {
79 margin: 20px 0 0;
80 max-width: 62ch;
81 color: var(--text-secondary);
82 font-size: var(--font-body-lg);
83 line-height: 1.5;
84}
85
86.landing-actions {
87 display: flex;
88 flex-wrap: wrap;
89 align-items: center;
90 gap: 12px;
91 margin-top: 28px;
92}
93
94.landing-primary,
95.landing-secondary {
96 display: inline-flex;
97 align-items: center;
98 justify-content: center;
99 gap: 10px;
100 min-height: 48px;
101 padding: 0 20px;
102 border-radius: var(--radius-md);
103 font: 650 var(--font-body-md)/1 var(--font-sans);
104 text-decoration: none;
105 cursor: pointer;
106}
107
108.landing-primary {
109 border: 1px solid var(--landing-emerald-deep);
110 background: var(--landing-emerald-deep);
111 color: var(--landing-emerald-ink);
112}
113
114.landing-primary:hover { background: var(--landing-emerald); border-color: var(--landing-emerald); }
115
116/* The three copy buttons: each system's mark large, stacked above the words, so the marks are what a
117 reader sees first. The three stand in a row and take equal widths; on a phone they stack. */
118.landing-copy {
119 flex: 1 1 0;
120 flex-direction: column;
121 gap: 12px;
122 min-width: 200px;
123 min-height: 0;
124 padding: 20px 20px 18px;
125 text-align: center;
126 line-height: 1.25;
127}
128
129.landing-os-mark {
130 display: inline-flex;
131 width: 44px;
132 height: 44px;
133 flex: none;
134}
135
136.landing-os-mark svg { width: 100%; height: 100%; fill: currentColor; }
137
138@media (max-width: 719px) {
139 .landing-copy { flex-basis: 100%; }
140}
141
142/* The box for a reader who installs by hand: a straight emerald edge on its left, a command per
143 kind of system in the editor's mono, each with its copy. */
144.landing-install {
145 max-width: 72ch;
146 margin: 24px 0 0;
147 padding: 12px 16px 14px;
148 border: 1px solid rgba(255, 255, 255, 0.10);
149 border-left: 3px solid var(--landing-emerald-deep);
150 border-radius: 0 var(--radius-md) var(--radius-md) 0;
151 background: rgba(255, 255, 255, 0.025);
152}
153
154.landing-install-label {
155 display: block;
156 margin: 0 0 8px;
157 font-size: var(--font-body-sm);
158 font-weight: 650;
159 color: var(--text-secondary);
160}
161
162.landing-install-row {
163 display: flex;
164 flex-wrap: wrap;
165 align-items: center;
166 gap: 8px 12px;
167 padding: 6px 0;
168}
169
170.landing-install-os {
171 flex: 0 0 9.5em;
172 color: var(--text-tertiary);
173 font-size: var(--font-body-sm);
174}
175
176.landing-install-cmd {
177 flex: 1 1 24ch;
178 min-width: 0;
179 overflow-wrap: anywhere;
180 font: 13px/1.6 var(--font-mono);
181 color: var(--text-primary);
182}
183
184.landing-copy-cmd {
185 flex: none;
186 display: inline-flex;
187 align-items: center;
188 gap: 6px;
189 min-height: 32px;
190 padding: 0 10px;
191 border: 1px solid rgba(52, 211, 153, 0.45);
192 border-radius: var(--radius-md);
193 background: transparent;
194 color: var(--landing-emerald);
195 font: 650 var(--font-body-sm)/1 var(--font-sans);
196 cursor: pointer;
197}
198
199.landing-copy-cmd:hover { background: rgba(52, 211, 153, 0.12); }
200
201.landing-secondary {
202 border: 1px solid rgba(255, 255, 255, 0.16);
203 background: transparent;
204 color: var(--text-primary);
205}
206
207.landing-secondary:hover { border-color: rgba(255, 255, 255, 0.32); }
208
209.landing-status {
210 margin: 14px 0 0;
211 font-size: var(--font-body-sm);
212 color: var(--text-secondary);
213}
214
215.landing-visually-hidden {
216 position: absolute;
217 width: 1px;
218 height: 1px;
219 margin: -1px;
220 overflow: hidden;
221 clip: rect(0 0 0 0);
222 white-space: nowrap;
223}
224
225/* The prompt, shown only when the browser refuses to copy: five lines in the editor's mono, wrapping
226 rather than scrolling sideways, so a phone reads them whole. */
227.landing-prompt { margin-top: 20px; }
228
229.landing-prompt[hidden] { display: none; }
230
231.landing-instructions {
232 margin: 0;
233 padding: 18px 20px;
234 border: 1px solid rgba(255, 255, 255, 0.10);
235 border-left: 3px solid var(--accent-primary);
236 border-radius: var(--radius-lg);
237 background: rgba(255, 255, 255, 0.025);
238 font: 13.5px/1.65 var(--font-mono);
239 color: var(--text-secondary);
240 white-space: pre-wrap;
241 overflow-wrap: anywhere;
242 tab-size: 4;
243}
244
245.landing-instructions .step { color: var(--text-primary); font-weight: 700; }
246.landing-instructions .run,
247.landing-instructions .open { color: var(--accent-primary); }
248
249/* The prompts stay hidden until a browser refuses a copy; then the one copied shows, selected. */
250.landing-instructions[hidden] { display: none; }
251
252/* Below the hero: the comparison, the library and the FAQ, each a band with a hairline above. */
253.landing-wrap {
254 max-width: 1200px;
255 margin: 56px auto 0;
256 padding: 0 16px;
257}
258
259.landing-compare,
260.landing-library,
261.landing-faq {
262 padding: 56px 0;
263 border-top: 1px solid rgba(255, 255, 255, 0.06);
264}
265
266.landing-compare h2,
267.landing-library h2,
268.landing-faq h2 {
269 margin: 0 0 12px;
270 font-size: var(--font-heading-lg);
271 line-height: 1.2;
272 letter-spacing: -0.01em;
273 font-weight: 750;
274}
275
276.landing-lead {
277 margin: 0 0 28px;
278 max-width: 62ch;
279 color: var(--text-secondary);
280 font-size: var(--font-body-md);
281 line-height: 1.6;
282}
283
284/* The cards: a grid that takes as many across as fit, each a kind of work. */
285.landing-cards {
286 display: grid;
287 grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
288 gap: 14px;
289}
290
291.landing-card {
292 display: flex;
293 flex-direction: column;
294 gap: 8px;
295 padding: 18px 18px 16px;
296 border: 1px solid rgba(255, 255, 255, 0.10);
297 border-radius: var(--radius-lg);
298 background: rgba(255, 255, 255, 0.025);
299}
300
301.landing-card h3 {
302 margin: 0;
303 font-size: var(--font-body-md);
304 font-weight: 700;
305}
306
307.landing-usually {
308 margin: 0;
309 color: var(--text-tertiary);
310 font-size: var(--font-body-sm);
311 line-height: 1.5;
312}
313
314.landing-usually-label { color: var(--text-secondary); }
315
316.landing-logos {
317 margin: 0;
318 flex: 1 1 auto;
319 color: var(--text-primary);
320 font-size: var(--font-body-md);
321 line-height: 1.55;
322}
323
324.landing-card-foot {
325 display: flex;
326 flex-wrap: wrap;
327 align-items: center;
328 gap: 8px;
329 margin-top: 4px;
330}
331
332.landing-tag {
333 display: inline-flex;
334 align-items: center;
335 padding: 3px 8px;
336 border: 1px solid rgba(0, 212, 255, 0.35);
337 border-radius: 999px;
338 color: var(--accent-primary);
339 font-size: 12px;
340 font-weight: 600;
341 line-height: 1.2;
342 white-space: nowrap;
343}
344
345.landing-try {
346 margin-left: auto;
347 min-height: 36px;
348 padding: 0 14px;
349 border: 1px solid var(--landing-emerald-deep);
350 border-radius: var(--radius-md);
351 background: var(--landing-emerald-deep);
352 color: var(--landing-emerald-ink);
353 font: 650 var(--font-body-sm)/1 var(--font-sans);
354 cursor: pointer;
355}
356
357.landing-try:hover { background: var(--landing-emerald); border-color: var(--landing-emerald); }
358
359/* The library: two lines of figures, the release tag, then what 0.11.0 brings, one line each. */
360.landing-library-line {
361 margin: 0 0 8px;
362 max-width: 70ch;
363 color: var(--text-primary);
364 font-size: var(--font-body-md);
365 line-height: 1.6;
366}
367
368.landing-library .landing-tag { margin: 4px 0 20px; }
369
370.landing-features {
371 display: grid;
372 grid-template-columns: minmax(0, 1fr);
373 gap: 8px 32px;
374 margin: 0;
375 padding: 0;
376 list-style: none;
377}
378
379.landing-features li {
380 position: relative;
381 padding-left: 18px;
382 color: var(--text-secondary);
383 font-size: var(--font-body-md);
384 line-height: 1.55;
385}
386
387.landing-features li::before {
388 content: "";
389 position: absolute;
390 left: 0;
391 top: 0.68em;
392 width: 8px;
393 height: 8px;
394 border-radius: 50%;
395 background: var(--accent-primary);
396}
397
398/* The FAQ. */
399.landing-faq dl {
400 margin: 0;
401 display: grid;
402 grid-template-columns: minmax(0, 1fr);
403 gap: 28px 48px;
404}
405
406.landing-faq dt {
407 font-weight: 700;
408 font-size: var(--font-body-md);
409 margin-bottom: 6px;
410}
411
412.landing-faq dd {
413 margin: 0;
414 color: var(--text-secondary);
415 font-size: var(--font-body-md);
416 line-height: 1.6;
417 max-width: 62ch;
418}
419
420.landing-faq dd a { color: var(--accent-primary); }
421
422@media (min-width: 720px) {
423 .landing-intro,
424 .landing-wrap { padding-left: 24px; padding-right: 24px; }
425 .landing-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
426 .landing-faq dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
427}
428
429@media (min-width: 1100px) {
430 .landing-intro { padding-top: 56px; padding-bottom: 44px; }
431 .landing-heading { font-size: clamp(40px, 3.5vw, 54px); }
432}
433
434@media (prefers-reduced-motion: reduce) {
435 .landing *, .landing *::before, .landing *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
436}
437"#;
438
439const TOUR_SCRIPT: &str = r#"(() => {
444 // The router rewrites the address once the app takes over; the address the page was opened at
445 // stays in its navigation entry.
446 const opened = performance.getEntriesByType('navigation')[0];
447 const search = (opened ? new URL(opened.name).search : '') || location.search;
448 const m = search.match(/[?&]tour=(\d+)(?:.*&rest=(\d+))?/);
449 if (!m) return;
450 const period = Number(m[1]) * 1000, rest = (m[2] ? Number(m[2]) : 3) * 1000;
451 const scroller = () => [document.scrollingElement, document.body].reduce((a, b) => (b.scrollHeight - b.clientHeight > a.scrollHeight - a.clientHeight ? b : a));
452 const max = () => { const s = scroller(); return s.scrollHeight - s.clientHeight; };
453 const ease = (u) => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
454 let t0 = null;
455 const frame = (now) => {
456 if (t0 === null) t0 = now;
457 const cycle = 2 * (period + rest), t = (now - t0) % cycle;
458 let y;
459 if (t < period) y = ease(t / period) * max();
460 else if (t < period + rest) y = max();
461 else if (t < 2 * period + rest) y = (1 - ease((t - period - rest) / period)) * max();
462 else y = 0;
463 scroller().scrollTop = y;
464 requestAnimationFrame(frame);
465 };
466 // The app renders this after the document has loaded, so start now; a prerendered page waits for load.
467 const start = () => setTimeout(() => requestAnimationFrame(frame), 1500);
468 if (document.readyState === 'complete') start(); else addEventListener('load', start);
469 window.__logosTour = { period, rest };
470})();"#;
471
472#[component]
473pub fn Landing() -> Element {
474 let faq = faq();
475 let pairs: Vec<(&str, &str)> = faq.iter().map(|item| (item.question, item.answer.text.as_str())).collect();
476 let schemas = vec![organization_schema(), website_schema(), faq_schema(&pairs)];
477 let frame = use_shelf(content::shelf());
478
479 rsx! {
480 PageHead {
481 title: seo_pages::LANDING.title,
482 description: seo_pages::LANDING.description,
483 canonical_path: seo_pages::LANDING.canonical_path,
484 }
485 style { "{LANDING_STYLE}" }
486 if option_env!("LOGOS_TOUR").is_some() {
487 script { dangerous_inner_html: TOUR_SCRIPT }
488 }
489 JsonLdMultiple { schemas }
490
491 div { class: "landing",
492 MainNav { active: ActivePage::Other }
493 main { class: "landing-main",
494 section { id: "top", class: "landing-hero",
495 div { class: "landing-intro",
496 div { class: "landing-pitch",
497 h1 { class: "landing-heading",
498 for (i, line) in HEADING.iter().enumerate() {
501 if i > 0 { " " }
502 span { "{line}" }
503 }
504 }
505 How {}
506 InstallBox {}
507 CopyInstructions {}
508 }
509 }
510 StudioFrame { state: frame }
511 }
512 div { class: "landing-wrap",
513 Comparison { frame }
514 Library {}
515 Questions {}
516 }
517 }
518 Footer {}
519 }
520 }
521}
522
523#[component]
526fn Comparison(frame: WorkbenchState) -> Element {
527 rsx! {
528 section { id: "compare", class: "landing-compare",
529 h2 { "{COMPARE_HEADING}" }
530 p { class: "landing-lead", "{compare_lead().text}" }
531 div { class: "landing-cards",
532 for card in compare() {
533 article { class: "landing-card",
534 h3 { "{card.kind}" }
535 p { class: "landing-usually",
536 span { class: "landing-usually-label", "Usually: " }
537 "{card.usually_names()}"
538 }
539 p { class: "landing-logos", "{card.logos.text}" }
540 div { class: "landing-card-foot",
541 for tag in card.tags {
542 span { class: "landing-tag", "{tag.label()}" }
543 }
544 if let Some(file) = card.try_it {
545 button {
546 r#type: "button",
547 class: "landing-try",
548 "data-file": file,
549 aria_controls: FRAME_ID,
550 title: "Open {file} in the Studio above",
551 onclick: move |_| {
552 frame.choose(file.to_string());
553 #[cfg(target_arch = "wasm32")]
554 if let Some(studio) = web_sys::window().and_then(|w| w.document()).and_then(|d| d.get_element_by_id(FRAME_ID)) {
555 studio.scroll_into_view();
556 }
557 },
558 "Try it"
559 }
560 }
561 }
562 }
563 }
564 }
565 }
566 }
567}
568
569#[component]
572fn Library() -> Element {
573 rsx! {
574 section { id: "library", class: "landing-library",
575 h2 { "{LIBRARY_HEADING}" }
576 for (i, line) in library().iter().enumerate() {
577 p { key: "{i}", class: "landing-library-line", "{line.text}" }
578 }
579 ul { class: "landing-features",
580 for (i, line) in features().iter().enumerate() {
581 li { key: "{i}", "{line.text}" }
582 }
583 }
584 }
585 }
586}
587
588#[component]
590fn Questions() -> Element {
591 rsx! {
592 section { id: "faq", class: "landing-faq",
593 h2 { "FAQ" }
594 dl {
595 for (i, item) in faq().iter().enumerate() {
596 div { key: "{i}",
597 dt { "{item.question}" }
598 dd { {answer(item)} }
599 }
600 }
601 }
602 }
603 }
604}
605
606fn answer(item: &content::Faq) -> Element {
608 match item.link {
609 Some((text, href)) => {
610 let (before, after) = item.answer.text.split_once(text).unwrap_or((item.answer.text.as_str(), ""));
611 rsx! {
612 "{before}"
613 a { href, "{text}" }
614 "{after}"
615 }
616 }
617 None => rsx! { "{item.answer.text}" },
618 }
619}
620
621#[component]
623fn How() -> Element {
624 rsx! {
625 p { class: "landing-how", "{how().text}" }
626 }
627}
628
629#[component]
632fn InstallBox() -> Element {
633 let mut copied = use_signal(|| None::<usize>);
634 let mut presses = use_signal(|| 0u32);
635 rsx! {
636 div { class: "landing-install",
637 span { class: "landing-install-label", "{INSTALL_HEADING}" }
638 for (i, (os, command)) in install_commands().into_iter().enumerate() {
639 div { key: "{i}", class: "landing-install-row",
640 span { class: "landing-install-os", "{os}" }
641 code { id: "landing-install-cmd-{i}", class: "landing-install-cmd", "{command}" }
642 button {
643 r#type: "button",
644 class: "landing-copy-cmd",
645 title: "Copy the {os} install command",
646 onclick: move |_| {
647 let press = *presses.peek() + 1;
648 presses.set(press);
649 let pending = clipboard::copy(command);
651 spawn(async move {
652 if pending.await {
653 copied.set(Some(i));
654 #[cfg(target_arch = "wasm32")]
655 gloo_timers::future::TimeoutFuture::new(2400).await;
656 if *presses.peek() == press {
657 copied.set(None);
658 }
659 }
660 });
661 },
662 Icon { variant: if copied() == Some(i) { IconVariant::Check } else { IconVariant::Copy }, size: IconSize::Small }
663 if copied() == Some(i) { "{said::COMMAND_COPIED}" } else { "Copy" }
664 }
665 }
666 }
667 }
668 }
669}
670
671#[derive(Clone, Copy, PartialEq)]
673enum Copied {
674 Not,
675 Yes,
676 Refused,
678}
679
680#[component]
684fn CopyInstructions() -> Element {
685 let mut copied = use_signal(|| (System::MacOs, Copied::Not));
686 let mut presses = use_signal(|| 0u32);
687 let (last, state) = copied();
688 let status = match state {
689 Copied::Not => "",
690 Copied::Yes => said::COPIED_STATUS,
691 Copied::Refused => said::COPY_REFUSED,
692 };
693 rsx! {
694 div { class: "landing-actions",
695 for system in System::ALL {
696 button {
697 key: "{system.slug()}",
698 r#type: "button",
699 class: "landing-primary landing-copy",
700 "data-system": system.slug(),
701 aria_controls: INSTRUCTIONS_ID,
702 onclick: move |_| {
703 let press = *presses.peek() + 1;
704 presses.set(press);
705 let install = system.install();
706 let pending = clipboard::copy(prompt_text(install));
708 spawn(async move {
709 let done = pending.await;
710 copied.set((system, if done { Copied::Yes } else { Copied::Refused }));
711 if !done {
712 #[cfg(target_arch = "wasm32")]
714 gloo_timers::future::TimeoutFuture::new(50).await;
715 clipboard::select_contents(&prompt_id(install));
716 }
717 if done {
718 #[cfg(target_arch = "wasm32")]
719 gloo_timers::future::TimeoutFuture::new(2400).await;
720 if *presses.peek() == press {
721 copied.set((system, Copied::Not));
722 }
723 }
724 });
725 },
726 span { class: "landing-os-mark", "aria-hidden": "true",
727 svg { view_box: "0 0 24 24", role: "img", path { d: system.mark() } }
728 }
729 span {
730 if last == system && state == Copied::Yes { "{said::COPIED}" } else { "{system.copy_label()}" }
731 }
732 }
733 }
734 }
735 div { class: "landing-actions",
736 Link { to: Route::Studio { file: None }, class: "landing-secondary", "Open Studio" }
737 Link { to: Route::Learn { module: String::new() }, class: "landing-secondary", "Learn" }
738 Link { to: Route::Contact { section: String::new() }, class: "landing-secondary", "Contact" }
739 }
740 p {
741 class: if state == Copied::Refused { "landing-status" } else { "landing-visually-hidden" },
742 role: "status",
743 "{status}"
744 }
745 Prompts { revealed: (state == Copied::Refused).then_some(last.install()) }
746 }
747}
748
749fn prompt_id(install: Install) -> String {
751 format!("agent-prompt-{}", install.name())
752}
753
754#[component]
758fn Prompts(revealed: Option<Install>) -> Element {
759 rsx! {
760 div { id: INSTRUCTIONS_ID, class: "landing-prompt", hidden: revealed.is_none(),
761 for install in Install::ALL.iter().copied() {
762 pre {
763 key: "{install.name()}",
764 id: prompt_id(install),
765 class: "landing-instructions",
766 "data-install": install.name(),
767 hidden: revealed != Some(install),
768 tabindex: "0",
769 aria_label: "Agent instructions",
770 for (i, line) in prompt(install).iter().enumerate() {
771 span { key: "{i}", class: kind(line), if i + 1 == prompt(install).len() { "{line.text()}" } else { "{line.text()}\n" } }
772 }
773 }
774 }
775 }
776 }
777}
778
779fn kind(line: &Line) -> &'static str {
781 match line {
782 Line::Step(_) => "step",
783 Line::Say(_) => "say",
784 Line::Rule(_) => "rule",
785 Line::Agree(_) => "agree",
786 Line::Run(_) => "run",
787 Line::Open(_) => "open",
788 Line::Blank => "blank",
789 }
790}