Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/gpui/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ best starting point for new applications:
- `active_state_bug` is a focused active-state reproduction.
- `layer_shell` demonstrates Linux layer-shell windows.
- `list_example` demonstrates bottom-aligned list state and scrollbar behavior.
- `native_webview` demonstrates the macOS native-surface overlay API with a
directly hosted `WKWebView`, without depending on wry. It also demonstrates
click-anywhere overlay dismissal and native-focus handoff back to GPUI.
- `ownership_post` supports the ownership and data-flow documentation.
- `paths_bench` is a path rendering benchmark.
- `tree` renders a deep tree of nested elements.
117 changes: 117 additions & 0 deletions crates/gpui/examples/native_webview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
:root {
color-scheme: dark;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
background: #0d1016;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
background: #0d1016;
color: #bfbdb6;
}
main {
display: grid;
grid-template-columns: 1.2fr .8fr;
gap: 28px;
padding: 42px 38px;
}
.eyebrow {
color: #5ac1fe;
font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .16em;
text-transform: uppercase;
}
h1 {
max-width: 360px;
margin: 14px 0;
font-size: 34px;
font-weight: 590;
letter-spacing: -.035em;
line-height: 1.06;
}
p {
max-width: 390px;
margin: 0;
color: #8a8986;
font-size: 14px;
line-height: 1.6;
}
.details { display: grid; gap: 10px; align-content: start; }
.datum {
display: flex;
justify-content: space-between;
padding: 12px 0;
border-bottom: 1px solid #3f4043;
color: #8a8986;
font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.datum strong { color: #bfbdb6; font-weight: 600; }
input {
grid-column: 1 / -1;
width: 100%;
margin-top: 8px;
padding: 13px 14px;
border: 1px solid #3f4043;
border-radius: 7px;
outline: none;
background: #1f2127;
color: #bfbdb6;
font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}
input:focus {
border-color: #5ac1fe;
box-shadow: 0 0 0 3px rgba(90, 193, 254, .16);
}
#keyboard-event {
grid-column: 1 / -1;
min-height: 16px;
color: #8a8986;
font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
white-space: nowrap;
}
</style>
</head>
<body>
<main>
<section>
<div class="eyebrow">Native surface / live</div>
<h1>A real browser inside GPUI’s scene.</h1>
<p>
This page is rendered by WKWebView. GPUI owns the surfaces
below and above it, while AppKit composes all three.
</p>
</section>
<aside class="details">
<div class="datum"><span>ENGINE</span><strong>WEBKIT</strong></div>
<div class="datum"><span>HOST</span><strong>NSVIEW</strong></div>
<div class="datum"><span>STATE</span><strong>INTERACTIVE</strong></div>
</aside>
<input autofocus value="Focus and type inside the native layer">
<div id="keyboard-event" aria-live="polite">Keyboard event: waiting for input</div>
</main>
<script>
const keyboardEvent = document.querySelector("#keyboard-event");

function showKeyboardEvent(event) {
const modifiers = [
event.metaKey && "Meta",
event.ctrlKey && "Ctrl",
event.altKey && "Alt",
event.shiftKey && "Shift",
].filter(Boolean).join("+") || "None";
const key = event.key === " " ? "Space" : event.key;
keyboardEvent.textContent =
`${event.type}: key=${key} · code=${event.code} · modifiers=${modifiers} · repeat=${event.repeat}`;
}

window.addEventListener("keydown", showKeyboardEvent, true);
window.addEventListener("keyup", showKeyboardEvent, true);
</script>
</body>
</html>
Loading