Files
Ely-GPUI-Components/examples/gallery/pages/misc/web.rs
T
ZacharyZhang-NY 3f1597fa28 Port · Parity: every page matches gpui 0.2.2's; the rules re-tested
Every page and scripted state was shot with gpui 0.2.2 and with the
port, light and dark, full width and at 280px, judged pair by pair by
agents with skeptics, and every page's log diffed. What differed is
fixed, each with a test that fails without it where the test platform
can show it:

- The gallery's harness takes posted mouse moves (gpui_macos listens
  to a tracking area), posts each drag move twice (it no longer
  replays a held drag), and waits three frames before each shot.
- Rolling digits: a block column, so taffy 0.13 lends the cell no
  baseline, and a line of whole device pixels, since gpui snaps each
  length on its own. DescriptionList's row aligns ends.
- Margins that taffy 0.13 collapses through a plain block: the
  drawer's pull and snap, the stagger and transition rise, the dialog
  and palette rises, the fullscreen dialog's slide.
- An Input keeps room to type in a squeezed row; the field rows drop
  w_full, whose reason was taffy 0.9's.

AGENTS.md's rules that named gpui 0.2.2 or taffy 0.9 were re-tested
against both sources and rewritten, and new ones say what the port
changed. TASKS.md's tags follow: what the new gpui makes possible is
prove. Captions, doc comments and README say what holds now.
2026-09-29 10:39:55 -04:00

61 lines
2.0 KiB
Rust

use ely_gpui_component::misc::{IframeEmbed, WebSource, WebView};
use gpui::{App, IntoElement, ParentElement, Styled, div, px};
use crate::probe::probe;
use crate::ui::{blocked, section};
const PAGE: &str = r#"<!doctype html>
<meta charset="utf-8">
<style>
:root { color-scheme: light dark; font: 15px -apple-system, sans-serif; }
body { margin: 0; height: 100vh; display: grid; place-items: center;
background: linear-gradient(135deg, #5b8cff33, #b35bff33); }
h1 { font-size: 22px; margin: 0 0 6px; }
p { margin: 0; opacity: .7; }
</style>
<main>
<h1>Hello from WebKit</h1>
<p>HTML the owner hands in, drawn by a native web view.</p>
</main>"#;
pub fn render(cx: &App) -> impl IntoElement + use<> {
div()
.child(
section(
"WebView / HTMLPreview",
"A native web view laid over its box: an address, or HTML the owner hands in, which makes it an HTML preview. It draws above everything gpui paints and follows the box each frame.",
cx,
)
.child(probe(
"web",
div()
.w(px(480.0))
.h(px(200.0))
.child(WebView::new("web", WebSource::Html(PAGE.into()))),
)),
)
.child(
section(
"IframeEmbed / EmbedCard",
"A page from another address in a frame of its own, with Open in browser. EmbedCard is chat::LinkPreviewCard, shown on the AI Chat page.",
cx,
)
.child(div().w(px(480.0)).child(IframeEmbed::new(
"iframe",
"https://example.com",
16.0 / 9.0,
))),
)
.child(
section(
"PrintButton · ShareSheet",
"ShareSheet is buttons::ShareButton, shown on the Buttons & Actions page.",
cx,
)
.child(blocked(
"PrintButton: gpui has no print API.",
cx,
)),
)
}