From a12314116eb7c0bb4af2217f6f764825939fbe90 Mon Sep 17 00:00:00 2001 From: Chenglong Wang Date: Wed, 21 Oct 2026 12:44:28 -0700 Subject: [PATCH 1/3] local --- site/src/routes/McpExperience.tsx | 29 +++- site/src/routes/mcp-experience-data.ts | 2 +- site/src/talk/sketches.ts | 73 ++++++++++ site/src/talk/slides.tsx | 181 +++++++++++++++---------- site/src/talk/talk.css | 17 ++- 5 files changed, 222 insertions(+), 80 deletions(-) diff --git a/site/src/routes/McpExperience.tsx b/site/src/routes/McpExperience.tsx index 80939732..b3919d91 100644 --- a/site/src/routes/McpExperience.tsx +++ b/site/src/routes/McpExperience.tsx @@ -48,6 +48,29 @@ export function McpExperience() { ); } +/** One of the introduction's two chat turns, without its heading: the talk deck shows them one to a slide. */ +export function McpChatTurn({ kind }: { kind: 'chart' | 'board' }) { + const { t } = useTranslation(); + useMcpStyles(SCOPE); + useHostPage(); + return ( + <> + + + {kind === 'chart' ? ( + } + /> + ) : ( + } + /> + )} + + + ); +} + /** The step-by-step stories, one chart and then a board, each a chat drawn with the real MCP cards. */ export function McpExperienceStories() { useMcpStyles(SCOPE); @@ -62,11 +85,11 @@ export function McpExperienceStories() { } /** One ask and what the agent produces, in a chat window that grows to hold it. */ -function SimpleStory({ heading, children }: { heading: string; children: ReactNode }) { +function SimpleStory({ heading, children }: { heading?: string; children: ReactNode }) { const { t } = useTranslation(); return ( -
-

{heading}

+
+ {heading &&

{heading}

}
diff --git a/site/src/routes/mcp-experience-data.ts b/site/src/routes/mcp-experience-data.ts index 7ca22b1b..ad102878 100644 --- a/site/src/routes/mcp-experience-data.ts +++ b/site/src/routes/mcp-experience-data.ts @@ -80,7 +80,7 @@ const coffeeByCountry: ChartAssemblyInput = { chart_spec: { chartType: 'Line Chart', encodings: { x: { field: 'Year' }, y: { field: 'Bags' }, color: { field: 'Country' } }, - title: 'Asia is learning to love coffee', + title: "Asia's love for coffee has grown", // Wider than tall: the card holds 480px of chart, and the legend takes two rows above the plot. baseSize: { width: 520, height: 280 }, subtitle: 'Coffee consumed in each country, million 60-kg bags, 2005–2025', diff --git a/site/src/talk/sketches.ts b/site/src/talk/sketches.ts index 0139ac06..03be3e5a 100644 --- a/site/src/talk/sketches.ts +++ b/site/src/talk/sketches.ts @@ -617,3 +617,76 @@ Object.assign(SKETCHES, { }); }, }); + +// ---------------------------------------------------------------- act 4: three ways to use Flint + +/** The three use cases side by side; with `focus`, that one is circled and spelled out, the others fade back. */ +function useCases(focus?: number): Draw { + return (ctx, w, h) => { + const s = Math.min(w / 1500, h / 410); + const X = (v: number) => v * s + (w - 1500 * s) / 2, Y = (v: number) => v * s + (h - 410 * s) / 2, S = (v: number) => v * s; + const PW = 420, PH = 330, xs = [45, 540, 1035], py = 40; + const frame = (x: number, seed: number) => { + card(ctx, X(x), Y(py), S(PW), S(PH), { seed, color: C.ink, fill: C.paper, w: 2.5 }); + line(ctx, X(x), Y(py + 34), X(x + PW), Y(py + 34), { w: S(2), color: C.soft, seed: seed + 1 }); + [0, 1, 2].forEach((i) => dot(ctx, X(x + 20 + i * 18), Y(py + 17), S(5), [C.red, C.amber, C.green][i], { seed: seed + 2 + i })); + }; + + // 1. a chat with a chart card in the reply + { + const x = xs[0]; + frame(x, 1100); + washRect(ctx, X(x + 150), Y(py + 52), S(250), S(46), C.blue, { alpha: 0.22, seed: 1106 }); + line(ctx, X(x + 166), Y(py + 70), X(x + 376), Y(py + 70), { w: S(3), color: C.blue, seed: 1107 }); + line(ctx, X(x + 166), Y(py + 84), X(x + 320), Y(py + 84), { w: S(3), color: C.blue, seed: 1108 }); + dot(ctx, X(x + 32), Y(py + 128), S(12), C.ink, { seed: 1109 }); + card(ctx, X(x + 54), Y(py + 116), S(346), S(196), { seed: 1110, color: C.soft, fill: '#ffffff', w: 2 }); + miniLines(ctx, X(x + 74), Y(py + 140), S(306), S(150), { seed: 1111, series: 3 }); + } + // 2. an app: a table, a chart, and the link between them + { + const x = xs[1]; + frame(x, 1200); + text(ctx, '', X(x + 20), Y(py + 66), { size: S(22), kind: 'mono', color: C.meaning, maxWidth: S(220), maxLines: 1 }); + rect(ctx, X(x + 20), Y(py + 86), S(150), S(220), { w: S(2), color: C.soft, seed: 1201 }); + for (let i = 0; i < 6; i++) { + line(ctx, X(x + 32), Y(py + 112 + i * 32), X(x + 158), Y(py + 112 + i * 32), { w: S(i === 2 ? 4 : 2), color: i === 2 ? C.amber : C.soft, seed: 1202 + i }); + } + card(ctx, X(x + 196), Y(py + 86), S(204), S(220), { seed: 1210, color: C.soft, fill: '#ffffff', w: 2 }); + miniBars(ctx, X(x + 212), Y(py + 110), S(172), S(180), { seed: 1211, bars: 5, color: [C.soft, C.soft, C.amber, C.soft, C.soft] }); + arrow(ctx, X(x + 162), Y(py + 176), X(x + 252), Y(py + 176), { w: S(3), color: C.amber, seed: 1212, head: S(12) }); + } + // 3. a theme: swatches and a typeface, carried onto three charts + { + const x = xs[2]; + frame(x, 1300); + text(ctx, 'Aa', X(x + 28), Y(py + 100), { size: S(48), kind: 'handBold', color: C.ink, maxWidth: S(90), maxLines: 1 }); + ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d'].forEach((c, i) => dot(ctx, X(x + 140 + i * 52), Y(py + 82), S(17), c, { seed: 1301 + i })); + const pal = ['#1f3b73', '#1b998b', '#e3a72f']; + [0, 1, 2].forEach((i) => { + const cx = x + 22 + i * 132; + card(ctx, X(cx), Y(py + 136), S(118), S(170), { seed: 1310 + i * 3, color: C.soft, fill: '#ffffff', w: 2 }); + if (i === 0) miniBars(ctx, X(cx + 12), Y(py + 160), S(94), S(130), { seed: 1320, bars: 4, color: pal[0] }); + if (i === 1) miniLines(ctx, X(cx + 10), Y(py + 160), S(98), S(130), { seed: 1321, series: 2, colors: pal }); + if (i === 2) miniHeatmap(ctx, X(cx + 12), Y(py + 164), S(94), S(118), { rows: 4, cols: 4, seed: 1322, palette: pal, frame: false }); + }); + } + + // the focus: the others fade back, and this one is circled + if (focus !== undefined) { + ctx.save(); + ctx.fillStyle = 'rgba(255, 255, 255, 0.66)'; + xs.forEach((x, i) => { if (i !== focus) ctx.fillRect(X(x - 20), Y(0), S(PW + 40), S(410)); }); + ctx.restore(); + const cx = xs[focus] + PW / 2; + ellipse(ctx, X(cx), Y(py + PH / 2), S(PW / 2 + 30), S(PH / 2 + 26), { w: S(5), color: C.red, seed: 1400 + focus }); + } + }; +} + +Object.assign(SKETCHES, { + useCases: useCases(), + useCase1: useCases(0), + useCase2: useCases(1), + useCase3: useCases(2), +}); diff --git a/site/src/talk/slides.tsx b/site/src/talk/slides.tsx index bcfc8dce..43384648 100644 --- a/site/src/talk/slides.tsx +++ b/site/src/talk/slides.tsx @@ -4,13 +4,13 @@ import { THEME_PRESETS } from 'flint-chart'; import { SizingPlayground } from '../components/SizingPlayground'; import { ThemeExplorer } from './ThemeExplorer'; import { WorldCupScorersDemo } from '../playground/WorldCupScorersDemo'; -import { CountryTableStage } from '../playground/ExternalToChartLab'; +import { CarOriginTableStage, CountryTableStage } from '../playground/ExternalToChartLab'; +import { McpChatTurn } from '../routes/McpExperience'; import { GlobeWarmingStage } from '../playground/GlobeWarmingStage'; import { RetailDrilldownStage } from '../playground/RetailDrilldownStage'; import { YouDrawItStage } from '../playground/YouDrawItStage'; import { ArticleSection } from '../playground/InteractiveDataReportLab'; import { TIME_USE } from '../playground/interactive-data-report-content'; -import { InteractionDashboardLab } from '../playground/InteractionDashboardLab'; import { FLINT_BASE, LONG_ROWS, TYPES_FLINT, typesCompiled, CARS, flintInput, flintShown, linkedYears, PICKED_GAME, PICKED_ROWS, STEPS, VL, foodLines, gameBars, heatmap, lineByType, penguins, picked, withData, type FlintState, @@ -64,18 +64,18 @@ const DIFF = { }; const GLUE_LINES = glue.trimEnd().split('\n').length; -/** A playful theme an agent might write from a one-line prompt; the slide shows this exact object. */ -const FUN_THEME = { - extends: 'cartoon', - id: 'theme-park', - label: 'Theme park', +/** A brand theme an agent might write from a short style guide; the slide shows this exact object. */ +const BRAND_THEME = { + extends: 'swiss', + id: 'northwind', + label: 'Northwind', ink: { - surface: { source: 'house', canvas: '#fdf6ff', plot: '#fdf6ff' }, - series: { categorical: ['#ff6fb5', '#4cb8ff', '#ffc93c', '#9b6cff', '#38d39f', '#ff8a5c'] }, - accent: '#ff6fb5', + text: { primary: '#14213d', secondary: '#4a5568' }, + series: { single: '#1f3b73', categorical: ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d', '#5b8e7d'] }, + accent: '#1b998b', }, - type: { headline: { family: "'Chalkboard SE', 'Comic Neue', cursive", weight: 'bold' } }, - marks: { cornerRadius: 12, strokeWeight: 5 }, + type: { headline: { family: "Georgia, 'Times New Roman', serif", weight: 'bold' } }, + structure: { grid: { measure: 'quiet', category: 'omit' } }, } as unknown as ThemeSpec; const PRESETS: { caption: string; spec: ChartAssemblyInput }[] = [ @@ -109,6 +109,28 @@ const TLDR_SPEC = `{ // After the Flint version: one request at a time, each starting where the last one left off. const FLINT_W = 52; +/** The three use cases, labelled under the sketch's three panels. */ +const USE_CASES = [ + { title: 'Explore data', short: 'A chart or a dashboard, right in your chat.', long: 'Ask, and a live chart or dashboard opens in your chat through the Flint MCP server.' }, + { title: 'Build apps', short: 'Flint as a component in your app.', long: 'Your coding agent writes Flint into the app as a component and wires it to the rest of the page.' }, + { title: 'Design', short: 'One theme for every chart.', long: 'Write your house style once as a theme, and every chart in every library follows it.' }, +]; + +/** The use-case sketch with readable labels under its panels; `focus` circles one and spells it out. */ +const UseCases = ({ focus }: { focus?: number }) => ( +
+
+
+ {USE_CASES.map((u, i) => ( +
+

{i + 1}. {u.title}

+

{focus === i ? u.long : u.short}

+
+ ))} +
+
+); + /** The "draw your guess" demo's interaction, condensed: a trigger, and a handler that answers with an update. */ const BESPOKE_ROWS: CodeRow[] = [ { text: 'const draw: CanvasInteractionDef = {', hot: true }, @@ -599,36 +621,57 @@ export const SLIDES: SlideDef[] = [ ), }, + { + id: 'bespoke-pair', render: () => (<> +

More bespoke interactions, built the same way

+
+
+ +

Drag to turn the globe; the country facing you is the focus.

+
+
+ +

Scroll to zoom the months, and the bars, axis, and labels are laid out again.

+
+
+ ), + }, + // Summary // ======================================================== Act 4 { - id: 'act4', kind: 'section', render: () => (<> -

What you can build with it

-

In a chat, in your app, and beyond the presets.

+ id: 'act4', render: () => (<> +

What you can build with it

+ ), }, { - id: 'chat', render: () => (<> -

In a chat, tell your agent what you want

-
-
-

Describe the chart and how it should behave. The agent writes the interaction spec next to the chart spec, and the chart appears in the conversation, ready to hover and read.

-
-
-
-

Visualize U.S. egg and bread prices since 2015, and let me hover to read both at any month.

-
-

Here it is. Hover along the timeline to read both prices.

- -
-
-
-
+ id: 'uc-explore', render: () => (<> +

1. When you explore data

+ + ), + }, + { + id: 'chat-chart', render: () => (<> +

Ask for a chart, and a live chart opens in the chat

+
+ ), + }, + { + id: 'chat-board', render: () => (<> +

Ask for a dashboard, and its charts work together

+
+ ), + }, + { + id: 'uc-apps', render: () => (<> +

2. When you build apps

+ ), }, { id: 'app', render: () => (<> -

In your app, events go out and updates come in

+

Your agent writes Flint as a component of your app

"Show goals by team, and when I click a team, list its scorers in the panel beside it."

@@ -641,9 +684,27 @@ export const SLIDES: SlideDef[] = [
), }, + { + id: 'app-tables', render: () => (<> +

Connect charts to your own components and tables

+
+ +

Pick a row in the table, and the chart follows; select points in the chart, and the table follows.

+
+ ), + }, + { + id: 'story', render: () => (<> +

Create interactive data stories

+
+ +

Hover a sentence in the text, and the chart shows what it is about.

+
+ ), + }, { id: 'bespoke-code', render: () => (<> -

Beyond presets, write your own interaction

+

Create bespoke interactions beyond the presets

"Let readers draw where they think coal's share of U.S. electricity went, then reveal the real line."

@@ -657,18 +718,9 @@ export const SLIDES: SlideDef[] = [ ), }, { - id: 'story', render: () => (<> -

Create interactive data stories

-
- -

Hover a sentence in the text, and the chart shows what it is about.

-
- ), - }, - { - id: 'dashboard', render: () => (<> -

Create dashboards where every chart works together

-
+ id: 'uc-design', render: () => (<> +

3. When you design

+ ), }, { @@ -676,30 +728,14 @@ export const SLIDES: SlideDef[] = [

You can create your own theme like a designer

-

"Create a theme inspired by a Disneyland day out: candy colors, rounded shapes, and a playful font."

- +

"Here is our brand guide: navy and teal, slate for supporting series, Georgia for headlines, and quiet grids. Write a Flint theme so every chart in our reports matches."

+
- )} /> - )} /> - - -
-
- ), - }, - - { - id: 'bespoke-pair', render: () => (<> -

More bespoke interactions, built the same way

-
-
- -

Drag to turn the globe; the country facing you is the focus.

-
-
- -

Scroll to zoom the months, and the bars, axis, and labels are laid out again.

+ )} /> + )} /> + +
), @@ -719,18 +755,19 @@ export const SLIDES: SlideDef[] = [ id: 'try', render: () => (<>

Let's build with Flint

+
-

If you work with data

-

Add the Flint MCP server to GitHub Copilot or your own agent with npx -y flint-chart-mcp, and ask for styled, interactive charts, reports, and dashboards right in the chat.

+

1. If you explore data

+

Add the Flint MCP server to GitHub Copilot or your own agent with npx -y flint-chart-mcp, and ask for charts and dashboards right in the chat.

-

If you build interactive apps

+

2. If you build apps

Build Flint into your product with npm install flint-chart. Give your agent the Flint skills, and its charts will talk to your tables, widgets, and app state.

-

If you design

-

Let's work on new themes together. Your team's style guide can become a Flint theme that every chart, on every library, follows.

+

3. If you design

+

Let's work on new themes together. Your team's style guide can become a Flint theme that every chart follows.

We want to collaborate! Ping me and I'm happy to demonstrate Flint to your team, and to work together on the next generation of interactive artifacts.

diff --git a/site/src/talk/talk.css b/site/src/talk/talk.css index 8c6b5cbe..9970d929 100644 --- a/site/src/talk/talk.css +++ b/site/src/talk/talk.css @@ -164,14 +164,16 @@ .talk-dashboard .idash-heading h1 { font-size: 44px; line-height: 1.1; max-width: none; } /* Call to action: one card per audience, each with its section color on top. */ -.talk-cta-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 32px; } +.talk-cta-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 22px; } +/* The three use cases, as the act 4 sketch draws them, above the card for each. */ +.talk-cta-sketch { flex: 1 1 200px; min-height: 140px; max-height: 240px; position: relative; } .talk-cta-wrap > .talk-cta { flex: none; align-items: stretch; gap: 28px; } -.talk-slide .talk-collab { margin: 0; font-size: 30px; line-height: 1.45; padding: 22px 28px; } -.talk-cta-card { background: var(--panel); border-radius: 12px; border-top: 6px solid #2f6db5; padding: 22px 26px; } +.talk-slide .talk-collab { margin: 0; font-size: 27px; line-height: 1.4; padding: 16px 26px; } +.talk-cta-card { background: var(--panel); border-radius: 12px; border-top: 6px solid #2f6db5; padding: 18px 24px; } .talk-cta-card.look { border-top-color: #e8954a; } .talk-cta-card.behavior { border-top-color: #d9534f; } .talk-cta-card h3 { margin: 0 0 14px; } -.talk-cta-card p { font-size: 26px; line-height: 1.45; margin: 0; } +.talk-cta-card p { font-size: 23px; line-height: 1.4; margin: 0; } /* A side-by-side demo stacked for a narrow slot: the chart on top, the table below it. */ .talk-slide .talk-stacked-demo .ig-continent-cohort .it-workspace { grid-template-columns: minmax(0, 1fr); } @@ -196,3 +198,10 @@ box-shadow: 0 8px 22px rgba(0, 40, 90, 0.12); overflow: hidden; } .talk-themes-card:hover { z-index: 20 !important; } + +/* Labels under the use-case sketch: one column per panel, in the deck's own type. */ +.talk-usecases { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; padding: 0 3%; } +.talk-usecases h3 { margin: 0 0 6px; text-align: center; } +.talk-usecases p { margin: 0; font-size: 24px; line-height: 1.4; text-align: center; } +.talk-usecases .on h3 { color: #c0392b; } +.talk-usecases .off { opacity: 0.4; } From f2177495a2a9b5d509cc22b864405139497ecf8b Mon Sep 17 00:00:00 2001 From: Chenglong Wang Date: Wed, 21 Oct 2026 14:03:58 -0700 Subject: [PATCH 2/3] updates --- site/src/talk/data.ts | 2 +- site/src/talk/parts.tsx | 75 +++++++++ site/src/talk/sketch.ts | 4 +- site/src/talk/sketches.ts | 321 +++++++++++++++++++++++++------------- site/src/talk/slides.tsx | 181 +++++++++++---------- site/src/talk/talk.css | 33 +++- 6 files changed, 409 insertions(+), 207 deletions(-) diff --git a/site/src/talk/data.ts b/site/src/talk/data.ts index 0367f0b2..ff4f597d 100644 --- a/site/src/talk/data.ts +++ b/site/src/talk/data.ts @@ -182,7 +182,7 @@ const layoutStep = (): Spec => ({ color: { aggregate: 'sum', field: 'newUsers', type: 'quantitative', title: 'Net new users', scale: { scheme: 'redblue', domainMid: 0 }, - legend: { format: '~s', orient: 'top', direction: 'horizontal', gradientLength: 180 }, + legend: { format: '~s' }, }, }, }); diff --git a/site/src/talk/parts.tsx b/site/src/talk/parts.tsx index fc3bd9a7..a4fd619c 100644 --- a/site/src/talk/parts.tsx +++ b/site/src/talk/parts.tsx @@ -4,6 +4,7 @@ import { FlintChart } from 'flint-chart/react'; import { ScaleToFit } from '../components/ScaleToFit'; import { VegaLiteView } from '../components/VegaLiteView'; import { SKETCHES } from './sketches'; +import { C, ellipse } from './sketch'; import minimaps from './specs/minimaps.json'; /** A live Flint chart laid out for its box: the compiler sizes it to the room, nothing spills. */ @@ -26,6 +27,80 @@ export function VegaLite({ spec }: { spec: unknown }) { ); } +export type Flaw = { role: 'x-axis' | 'y-axis' | 'legend' | 'marks'; label: string }; + +/** + * A Vega-Lite chart with its problems circled in red, hand-drawn over the parts Vega names (an axis, + * the legend, the marks), each with a short label. The rings follow the chart as it scales. + */ +export function FlawedVegaLite({ spec, flaws }: { spec: unknown; flaws: Flaw[] }) { + // Each ring carries its number; the labels are listed as text beside the chart (see FlawList). + const host = useRef(null); + const canvasRef = useRef(null); + useEffect(() => { + const el = host.current, canvas = canvasRef.current; + if (!el || !canvas) return; + let ready = false; + const draw = () => { + const svg = el.querySelector('svg.marks, svg'); + const w = el.clientWidth, h = el.clientHeight; + if (!ready || !svg || !w || !h) return; + const hb = el.getBoundingClientRect(), k = hb.width / w || 1; + const dpr = Math.max(2, window.devicePixelRatio * 1.5); + canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr); + const ctx = canvas.getContext('2d')!; + ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, w, h); + const axes = [...svg.querySelectorAll('.role-axis')].map((g) => g.getBoundingClientRect()); + const pick = (role: Flaw['role']): DOMRect | undefined => { + if (role === 'legend') return svg.querySelector('.role-legend')?.getBoundingClientRect(); + if (role === 'marks') return svg.querySelector('.role-mark')?.getBoundingClientRect(); + // The x axis is the wide one, the y axis the tall one. + const sorted = [...axes].sort((a, b) => (role === 'x-axis' ? b.width / b.height - a.width / a.height : b.height / b.width - a.height / a.width)); + return sorted[0]; + }; + flaws.forEach((flaw, i) => { + const r = pick(flaw.role); + if (!r) return; + const x = (r.left - hb.left) / k, y = (r.top - hb.top) / k, bw = r.width / k, bh = r.height / k; + const cx = x + bw / 2, cy = y + bh / 2; + ellipse(ctx, cx, cy, bw / 2 + 12, bh / 2 + 10, { w: 3, color: C.red, seed: 3000 + i * 7 }); + // A numbered badge on the ring's upper left; the slide lists what each number means. + const rx = bw / 2 + 12, ry = bh / 2 + 10; + const bx = Math.min(Math.max(cx - rx * 0.72, 16), w - 16), by = Math.min(Math.max(cy - ry * 0.72, 16), h - 16); + ctx.save(); + ctx.fillStyle = C.red; ctx.beginPath(); ctx.arc(bx, by, 15, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#fff'; ctx.font = "700 18px Inter, system-ui, sans-serif"; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; + ctx.fillText(String(i + 1), bx, by + 1); + ctx.restore(); + }); + canvas.dataset.drawn = 'true'; + }; + void document.fonts.load("700 20px 'Kalam'").then(() => { ready = true; draw(); }); + const ro = new ResizeObserver(draw); + ro.observe(el); + const mo = new MutationObserver(() => requestAnimationFrame(draw)); + mo.observe(el, { childList: true, subtree: true }); + return () => { ro.disconnect(); mo.disconnect(); }; + }, [flaws]); + return ( +
+ + + + +
+ ); +} + +/** The numbered problems a FlawedVegaLite circles, as readable text. */ +export function FlawList({ flaws }: { flaws: Flaw[] }) { + return ( +
    + {flaws.map((flaw, i) =>
  1. {i + 1}{flaw.label}
  2. )} +
+ ); +} + /** A site demo laid out at `width`, scaled to fit its box. Flint's pointer handling follows the scale. */ export function Demo({ width, children }: { width: number; children: ReactNode }) { return ( diff --git a/site/src/talk/sketch.ts b/site/src/talk/sketch.ts index b35239b9..20ef0bf9 100644 --- a/site/src/talk/sketch.ts +++ b/site/src/talk/sketch.ts @@ -167,9 +167,11 @@ export function card(ctx: Ctx, x: number, y: number, w: number, h: number, o: { rect(ctx, x, y, w, h, { w: o.w ?? 3, color: o.color ?? C.ink, seed: o.seed || 0 }); } -export type FontKind = 'hand' | 'handBold' | 'mono'; +export type FontKind = 'hand' | 'handBold' | 'mono' | 'sans'; export function font(size: number, kind: FontKind = 'hand'): string { if (kind === 'mono') return `500 ${size}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`; + // The deck's own type, for sentences that sit in a sketch but should read as text. + if (kind === 'sans') return `400 ${size}px 'Inter Variable', Inter, system-ui, sans-serif`; return `${kind === 'handBold' ? 700 : 400} ${size}px 'Kalam'`; } diff --git a/site/src/talk/sketches.ts b/site/src/talk/sketches.ts index 03be3e5a..7bf24acb 100644 --- a/site/src/talk/sketches.ts +++ b/site/src/talk/sketches.ts @@ -180,7 +180,7 @@ export const SKETCHES: Record = { // the two limits, shared by every row for (const [x, label] of [[base, 'base size'], [most, 'the most it may stretch']] as [number, string][]) { for (let y = 70; y < 620; y += 26) line(ctx, X(x), Y(y), X(x), Y(y + 12), { w: S(2), color: C.soft, seed: x + y, taper: false }); - text(ctx, label, X(x), Y(52), { size: S(22), color: C.ink2, align: 'center', maxWidth: S(220) }); + text(ctx, label, X(x), Y(52), { size: S(21), kind: 'sans', color: C.ink2, align: 'center', maxWidth: S(220) }); } const rows: { y: number; n: number; wall: number; say: string; extra?: string }[] = [ { y: 110, n: 4, wall: base, say: 'A few items: bands widen, and the plot keeps its size.' }, @@ -188,7 +188,7 @@ export const SKETCHES: Record = { { y: 490, n: 18, wall: most, say: 'Too many: bands at their thinnest, the plot at its limit.', extra: 'the rest scroll into view' }, ]; rows.forEach(({ y, n, wall, say, extra }, r) => { - text(ctx, say, X(20), Y(y + 40), { size: S(26), color: C.ink, maxWidth: S(470), maxLines: 2 }); + text(ctx, say, X(20), Y(y + 40), { size: S(25), kind: 'sans', color: C.ink, maxWidth: S(470), maxLines: 2, lineHeight: 1.3 }); // the axis box rect(ctx, X(x0), Y(y), S(wall - x0), S(100), { w: 3, color: C.ink, seed: 400 + r }); // bands and the springs between them @@ -204,11 +204,11 @@ export const SKETCHES: Record = { } if (r === 1) { arrow(ctx, X(wall + 6), Y(y + 30), X(wall + 76), Y(y + 30), { w: S(3.5), color: C.meaning, seed: 470, head: S(13) }); - text(ctx, 'the data pushes out', X(wall + 84), Y(y + 38), { size: S(22), color: C.meaning, maxWidth: S(1430 - wall - 84) }); + text(ctx, 'the data pushes out', X(wall + 84), Y(y + 38), { size: S(21), kind: 'sans', color: C.meaning, maxWidth: S(1430 - wall - 84) }); arrow(ctx, X(most + 70), Y(y + 78), X(wall + 10), Y(y + 78), { w: S(3.5), color: C.look, seed: 471, head: S(13) }); - text(ctx, 'the canvas pushes back', X(most - 150), Y(y + 128), { size: S(22), color: C.look, maxWidth: S(330) }); + text(ctx, 'the canvas pushes back', X(most - 150), Y(y + 128), { size: S(21), kind: 'sans', color: C.look, maxWidth: S(330) }); } - if (extra) text(ctx, extra, X(most + 16), Y(y + 58), { size: S(21), color: C.ink2, maxWidth: S(1430 - most - 16), maxLines: 3 }); + if (extra) text(ctx, extra, X(most + 16), Y(y + 58), { size: S(20), kind: 'sans', color: C.ink2, maxWidth: S(1430 - most - 16), maxLines: 3 }); }); }, @@ -395,30 +395,54 @@ Object.assign(SKETCHES, { typesHow(ctx: Ctx, w: number, h: number) { pipeline(ctx, w, h, [ { title: 'Data + types', draw: (b, x) => { - mono(ctx, b, 'period newUsers', x + 40, 152, { size: 22, color: C.ink2 }); - line(ctx, b.X(x + 36), b.Y(166), b.X(x + 364), b.Y(166), { w: b.S(2), color: C.soft, seed: 501 }); + // The raw rows, on a soft grey wash: just numbers so far. + washRect(ctx, b.X(x + 26), b.Y(124), b.S(348), b.S(176), C.soft, { alpha: 0.22, seed: 500 }); + rect(ctx, b.X(x + 26), b.Y(124), b.S(348), b.S(176), { w: b.S(1.5), color: C.soft, seed: 504 }); + mono(ctx, b, 'period newUsers', x + 40, 156, { size: 22, color: C.ink2 }); + line(ctx, b.X(x + 36), b.Y(170), b.X(x + 364), b.Y(170), { w: b.S(2), color: C.soft, seed: 501 }); [['202101', '5948'], ['202101', '-1086'], ['…', '…']].forEach(([p, v], i) => { - mono(ctx, b, p, x + 40, 206 + i * 40, { size: 22 }); - mono(ctx, b, v.padStart(8), x + 196, 206 + i * 40, { size: 22, color: v.startsWith('-') ? C.red : C.ink }); + mono(ctx, b, p, x + 40, 210 + i * 36, { size: 22 }); + mono(ctx, b, v.padStart(8), x + 196, 210 + i * 36, { size: 22, color: v.startsWith('-') ? C.red : C.ink }); + }); + ellipse(ctx, b.X(x + 80), b.Y(203), b.S(58), b.S(22), { w: b.S(2.5), color: C.amber, seed: 502 }); + // The semantic types, highlighted in blue: the part the agent adds. + washRect(ctx, b.X(x + 26), b.Y(326), b.S(348), b.S(232), C.meaning, { alpha: 0.2, seed: 505 }); + rect(ctx, b.X(x + 26), b.Y(326), b.S(348), b.S(232), { w: b.S(2.5), color: C.meaning, seed: 506 }); + text(ctx, '+ semantic types', b.X(x + 44), b.Y(370), { size: b.S(28), kind: 'handBold', color: C.meaning, maxWidth: b.S(320), maxLines: 1 }); + [['period', 'YearMonth'], ['game', 'Category'], ['newUsers', 'Profit']].forEach(([f, t], i) => { + const y = 424 + i * 46; + mono(ctx, b, `${f}:`, x + 44, y, { size: 22, color: C.ink2 }); + text(ctx, t, b.X(x + 44 + (f.length + 2) * 13.6), b.Y(y), { size: b.S(23), kind: 'mono', color: C.meaning, maxWidth: b.S(200), maxLines: 1 }); + line(ctx, b.X(x + 44 + (f.length + 2) * 13.6), b.Y(y + 6), b.X(x + 44 + (f.length + 2) * 13.6 + t.length * 13.8), b.Y(y + 6), { w: b.S(2.5), color: C.meaning, seed: 507 + i }); }); - ellipse(ctx, b.X(x + 80), b.Y(199), b.S(58), b.S(22), { w: b.S(2.5), color: C.amber, seed: 502 }); - line(ctx, b.X(x + 30), b.Y(318), b.X(x + 370), b.Y(318), { w: b.S(2), color: C.soft, seed: 503 }); - text(ctx, '+ semantic types', b.X(x + 40), b.Y(366), { size: b.S(28), kind: 'handBold', color: C.meaning, maxWidth: b.S(330), maxLines: 1 }); - ['period: YearMonth', 'game: Category', 'newUsers: Profit'].forEach((m, i) => mono(ctx, b, m, x + 40, 420 + i * 48, { size: 23, color: C.meaning })); } }, - { title: 'Compiler decides', draw: (b, x) => { - chip(ctx, b, x + 24, 180, 'parse', C.blue, '202101 is Jan 2021', 511); - chip(ctx, b, x + 24, 258, 'time axis', C.teal, 'a tick each half year', 513); - chip(ctx, b, x + 24, 336, 'diverge', C.red, 'colors split at 0', 515); - chip(ctx, b, x + 24, 414, 'sum', C.amber, '4 regions, 1 cell', 517); - chip(ctx, b, x + 24, 492, 'fit', C.purple, 'cells sized to fit', 519); + { title: 'What it means', draw: (b, x) => { + chip(ctx, b, x + 24, 200, 'parse', C.blue, '202101 is Jan 2021', 511); + chip(ctx, b, x + 24, 300, 'sum', C.amber, '4 regions, 1 cell', 513); + chip(ctx, b, x + 24, 400, 'diverge', C.red, 'colors split at 0', 515); + chip(ctx, b, x + 24, 500, 'format', C.teal, 'Jan 2021, -1.1k', 517); } }, - { title: 'Chart', draw: (b, x) => { - miniHeatmap(ctx, b.X(x + 40), b.Y(160), b.S(320), b.S(250), { rows: 6, cols: 10, seed: 31, palette: DEFAULT_DIVERGING, frame: false }); - line(ctx, b.X(x + 40), b.Y(430), b.X(x + 360), b.Y(430), { w: b.S(2.5), color: C.ink, seed: 521 }); - ['2021', '2023', '2025'].forEach((t, i) => text(ctx, t, b.X(x + 60 + i * 140), b.Y(474), { size: b.S(26), color: C.ink2, align: 'center', maxWidth: b.S(90) })); + { title: 'Layout', draw: (b, x) => { + // The data pushes the plot out; the canvas pushes back: a dashed canvas around a plot that stretched. + rect(ctx, b.X(x + 30), b.Y(150), b.S(340), b.S(260), { w: b.S(2), color: C.soft, seed: 521 }); + miniHeatmap(ctx, b.X(x + 60), b.Y(176), b.S(290), b.S(170), { rows: 6, cols: 12, seed: 31, palette: DEFAULT_DIVERGING, frame: false }); + arrow(ctx, b.X(x + 205), b.Y(370), b.X(x + 345), b.Y(370), { w: b.S(2.5), color: C.purple, seed: 522, head: b.S(10) }); + arrow(ctx, b.X(x + 205), b.Y(370), b.X(x + 65), b.Y(370), { w: b.S(2.5), color: C.purple, seed: 523, head: b.S(10) }); + ['2021', '2023', '2025'].forEach((t, i) => text(ctx, t, b.X(x + 80 + i * 120), b.Y(398), { size: b.S(20), color: C.ink2, align: 'center', maxWidth: b.S(80) })); + chip(ctx, b, x + 24, 470, 'fit', C.purple, 'cells sized to the canvas', 524); + chip(ctx, b, x + 24, 540, 'ticks', C.teal, 'one label a year', 526); } }, - ], [{ label: 'compiler' }, { label: 'renders' }], [140, 800, 1460]); + { title: 'Any backend', draw: (b, x) => { + const libs: [string, string][] = [['Vega-Lite', C.blue], ['ECharts', C.red], ['Chart.js', C.amber], ['Plotly', C.teal], ['Excel', C.green]]; + libs.forEach(([name, color], i) => { + const y = 150 + i * 84; + washRect(ctx, b.X(x + 30), b.Y(y), b.S(340), b.S(62), color, { alpha: 0.18, seed: 531 + i }); + rect(ctx, b.X(x + 30), b.Y(y), b.S(340), b.S(62), { w: b.S(2), color, seed: 541 + i }); + miniHeatmap(ctx, b.X(x + 42), b.Y(y + 10), b.S(96), b.S(42), { rows: 3, cols: 6, seed: 31 + i, palette: DEFAULT_DIVERGING, frame: false }); + text(ctx, name, b.X(x + 160), b.Y(y + 42), { size: b.S(26), kind: 'handBold', maxWidth: b.S(200), maxLines: 1 }); + }); + } }, + ], [{ label: 'compiler' }, { label: 'compiler' }, { label: 'compiles to' }]); }, /** B, how it works: an unthemed chart, the theme spec, what the compiler decides for this chart, the result. */ @@ -576,117 +600,198 @@ Object.assign(SKETCHES, { }); Object.assign(SKETCHES, { - /** A.1: what each semantic type in the spec sets off, as a small decision tree per field. */ + /** + * A.1: what each semantic type sets off, as a small tree per field. The type boxes and connectors are + * drawn; the branch text is set over them as HTML (see TYPE_TREE in slides.tsx), on the same 1000 × 720 frame. + */ typesTree(ctx: Ctx, w: number, h: number) { const s = Math.min(w / 1000, h / 720); const X = (v: number) => v * s + (w - 1000 * s) / 2, Y = (v: number) => v * s + (h - 720 * s) / 2, S = (v: number) => v * s; - type Leaf = { y: number; text: string; mono?: boolean; color?: string }; - const roots: { cy: number; label: string; leaves: Leaf[] }[] = [ - { cy: 140, label: 'period: YearMonth', leaves: [ - { y: 62, text: 'try the month formats, in order' }, - { y: 112, text: '202101 · 2021-01 · 01/2021 · Jan 2021 · 2021M01', mono: true, color: C.ink2 }, - { y: 168, text: '202101 → Jan 2021', mono: true, color: C.green }, - { y: 226, text: 'draw a time axis, labelled by year' }, - ] }, - { cy: 380, label: 'game: Category', leaves: [ - { y: 338, text: 'no order of its own: keep the data’s order' }, - { y: 410, text: 'one row each, names wrapped to fit' }, - ] }, - { cy: 592, label: 'newUsers: Profit', leaves: [ - { y: 520, text: 'it adds up: sum the four regions' }, - { y: 590, text: 'it can go negative: colors diverge at 0' }, - { y: 660, text: 'same reach on both sides of 0' }, - ] }, - ]; - roots.forEach((r, i) => { + TYPE_TREE.forEach((r, i) => { card(ctx, X(10), Y(r.cy - 40), S(300), S(80), { seed: 1000 + i * 9, color: C.meaning, w: 3 }); text(ctx, r.label, X(160), Y(r.cy + 9), { size: S(25), kind: 'mono', color: C.meaning, align: 'center', maxWidth: S(280), maxLines: 1 }); r.leaves.forEach((l, j) => { - const indent = l.mono ? 40 : 0; if (!l.mono) { - stroke(ctx, [[X(312), Y(r.cy)], [X(345), Y((r.cy + l.y - 8) / 2)], [X(372), Y(l.y - 8)]], { w: S(2.2), color: C.ink2, seed: 1003 + i * 9 + j }); - dot(ctx, X(380), Y(l.y - 8), S(5), C.ink2, { seed: 1030 + i * 9 + j }); + stroke(ctx, [[X(312), Y(r.cy)], [X(345), Y((r.cy + l.y) / 2)], [X(372), Y(l.y)]], { w: S(2.2), color: C.ink2, seed: 1003 + i * 9 + j }); + dot(ctx, X(380), Y(l.y), S(5), C.ink2, { seed: 1030 + i * 9 + j }); } else { - line(ctx, X(398), Y(l.y - 40), X(398), Y(l.y - 8), { w: S(2), color: C.soft, seed: 1050 + i * 9 + j }); - line(ctx, X(398), Y(l.y - 8), X(422), Y(l.y - 8), { w: S(2), color: C.soft, seed: 1060 + i * 9 + j }); + line(ctx, X(398), Y(l.y - 32), X(398), Y(l.y), { w: S(2), color: C.soft, seed: 1050 + i * 9 + j }); + line(ctx, X(398), Y(l.y), X(422), Y(l.y), { w: S(2), color: C.soft, seed: 1060 + i * 9 + j }); } - text(ctx, l.text, X(396 + indent), Y(l.y), l.mono - ? { size: S(21), kind: 'mono', color: l.color, maxWidth: S(560), maxLines: 1 } - : { size: S(29), color: l.color ?? C.ink, maxWidth: S(600), maxLines: 1 }); }); }); }, }); +// What each semantic type sets off; `y` is the middle of a leaf's line on the 1000 × 720 frame. +export type TypeLeaf = { y: number; text: string; mono?: boolean; tone?: 'muted' | 'good' }; +export const TYPE_TREE: { cy: number; label: string; leaves: TypeLeaf[] }[] = [ + { cy: 140, label: 'period: YearMonth', leaves: [ + { y: 54, text: 'Try the month formats, in order' }, + { y: 104, text: '202101 · 2021-01 · 01/2021 · Jan 2021 · 2021M01', mono: true, tone: 'muted' }, + { y: 160, text: '202101 → Jan 2021', mono: true, tone: 'good' }, + { y: 218, text: 'Draw a time axis, labelled by year' }, + ] }, + { cy: 380, label: 'game: Category', leaves: [ + { y: 330, text: "No order of its own: keep the data's order" }, + { y: 402, text: 'One row each, names wrapped to fit' }, + ] }, + { cy: 592, label: 'newUsers: Profit', leaves: [ + { y: 512, text: 'It adds up: sum the four regions' }, + { y: 582, text: 'It can go negative: colors diverge at 0' }, + { y: 652, text: 'Same reach on both sides of 0' }, + ] }, +]; + +// ---------------------------------------------------------------- section A: the vocabulary of semantic types +const TYPE_GROUPS: { group: string; color: string; types: string[]; x: number; y: number; w: number }[] = [ + // Placed by hand on a 1500 × 560 board: three columns, the bigger groups first. + { group: 'Time units', color: C.blue, x: 20, y: 20, w: 470, types: ['Year', 'Quarter', 'Month', 'Week', 'Day', 'Hour', 'YearMonth', 'YearQuarter', 'YearWeek', 'Decade', 'Duration'] }, + { group: 'Points in time', color: C.blue, x: 20, y: 330, w: 470, types: ['DateTime', 'Date', 'Time', 'Timestamp'] }, + { group: 'Measures', color: C.amber, x: 515, y: 20, w: 470, types: ['Quantity', 'Count', 'Amount', 'Price', 'Percentage', 'Temperature'] }, + { group: 'Signed measures', color: C.red, x: 515, y: 255, w: 470, types: ['Profit', 'PercentageChange', 'Sentiment', 'Correlation'] }, + { group: 'Ordered numbers', color: C.green, x: 515, y: 440, w: 470, types: ['Rank', 'Score', 'ID'] }, + { group: 'Places', color: C.teal, x: 1010, y: 20, w: 470, types: ['Country', 'State', 'City', 'Region', 'Address', 'ZipCode', 'Latitude', 'Longitude'] }, + { group: 'Categories', color: C.purple, x: 1010, y: 310, w: 470, types: ['Category', 'Name', 'Status', 'Boolean', 'Direction', 'Range'] }, +]; + +Object.assign(SKETCHES, { + /** The semantic types, each family a hand-drawn group with its types as chips, laid out by hand. */ + typeCloud(ctx: Ctx, w: number, h: number) { + const s = Math.min(w / 1500, h / 560); + const X = (v: number) => v * s + (w - 1500 * s) / 2, Y = (v: number) => v * s + (h - 560 * s) / 2, S = (v: number) => v * s; + const CHIP_H = 40, GAP = 10, PAD = 22, FS = 20; + TYPE_GROUPS.forEach((g, gi) => { + // Lay the chips out in rows first, so the group's outline fits them. + ctx.save(); ctx.font = `500 ${S(FS)}px ui-monospace, 'SF Mono', Menlo, monospace`; + const widths = g.types.map((t) => ctx.measureText(t).width / s + 26); + ctx.restore(); + const rows: { t: string; w: number; x: number }[][] = [[]]; + let cx = 0; + g.types.forEach((t, i) => { + if (cx > 0 && cx + widths[i] > g.w - PAD * 2) { rows.push([]); cx = 0; } + rows[rows.length - 1].push({ t, w: widths[i], x: cx }); + cx += widths[i] + GAP; + }); + const gh = 62 + rows.length * (CHIP_H + GAP) + 8; + washRect(ctx, X(g.x), Y(g.y), S(g.w), S(gh), g.color, { alpha: 0.13, seed: 2000 + gi }); + rect(ctx, X(g.x), Y(g.y), S(g.w), S(gh), { w: S(2.5), color: g.color, seed: 2010 + gi }); + text(ctx, g.group, X(g.x + PAD), Y(g.y + 40), { size: S(27), kind: 'handBold', color: g.color, maxWidth: S(g.w - PAD * 2), maxLines: 1 }); + rows.forEach((row, ri) => row.forEach((c, ci) => { + const x = g.x + PAD + c.x, y = g.y + 58 + ri * (CHIP_H + GAP); + card(ctx, X(x), Y(y), S(c.w), S(CHIP_H), { seed: 2100 + gi * 40 + ri * 10 + ci, color: g.color, fill: '#ffffff', w: 1.6 }); + text(ctx, c.t, X(x + c.w / 2), Y(y + CHIP_H / 2 + 7), { size: S(FS), kind: 'mono', color: C.ink, align: 'center', maxWidth: S(c.w - 8), maxLines: 1 }); + })); + }); + }, +}); + // ---------------------------------------------------------------- act 4: three ways to use Flint -/** The three use cases side by side; with `focus`, that one is circled and spelled out, the others fade back. */ -function useCases(focus?: number): Draw { +type TrioPanel = (ctx: Ctx, b: Board, x: number, py: number) => void; + +/** + * Three hand-drawn windows side by side. With `focus`, the other two fade back and that one is circled + * in `ring`; the slide prints the labels underneath as text. + */ +function trio(panels: TrioPanel[], seed: number, focus?: number, ring: string = C.red): Draw { return (ctx, w, h) => { const s = Math.min(w / 1500, h / 410); - const X = (v: number) => v * s + (w - 1500 * s) / 2, Y = (v: number) => v * s + (h - 410 * s) / 2, S = (v: number) => v * s; + const b: Board = { X: (v) => v * s + (w - 1500 * s) / 2, Y: (v) => v * s + (h - 410 * s) / 2, S: (v) => v * s }; + const { X, Y, S } = b; const PW = 420, PH = 330, xs = [45, 540, 1035], py = 40; - const frame = (x: number, seed: number) => { - card(ctx, X(x), Y(py), S(PW), S(PH), { seed, color: C.ink, fill: C.paper, w: 2.5 }); - line(ctx, X(x), Y(py + 34), X(x + PW), Y(py + 34), { w: S(2), color: C.soft, seed: seed + 1 }); - [0, 1, 2].forEach((i) => dot(ctx, X(x + 20 + i * 18), Y(py + 17), S(5), [C.red, C.amber, C.green][i], { seed: seed + 2 + i })); - }; - - // 1. a chat with a chart card in the reply - { - const x = xs[0]; - frame(x, 1100); - washRect(ctx, X(x + 150), Y(py + 52), S(250), S(46), C.blue, { alpha: 0.22, seed: 1106 }); - line(ctx, X(x + 166), Y(py + 70), X(x + 376), Y(py + 70), { w: S(3), color: C.blue, seed: 1107 }); - line(ctx, X(x + 166), Y(py + 84), X(x + 320), Y(py + 84), { w: S(3), color: C.blue, seed: 1108 }); - dot(ctx, X(x + 32), Y(py + 128), S(12), C.ink, { seed: 1109 }); - card(ctx, X(x + 54), Y(py + 116), S(346), S(196), { seed: 1110, color: C.soft, fill: '#ffffff', w: 2 }); - miniLines(ctx, X(x + 74), Y(py + 140), S(306), S(150), { seed: 1111, series: 3 }); - } - // 2. an app: a table, a chart, and the link between them - { - const x = xs[1]; - frame(x, 1200); - text(ctx, '', X(x + 20), Y(py + 66), { size: S(22), kind: 'mono', color: C.meaning, maxWidth: S(220), maxLines: 1 }); - rect(ctx, X(x + 20), Y(py + 86), S(150), S(220), { w: S(2), color: C.soft, seed: 1201 }); - for (let i = 0; i < 6; i++) { - line(ctx, X(x + 32), Y(py + 112 + i * 32), X(x + 158), Y(py + 112 + i * 32), { w: S(i === 2 ? 4 : 2), color: i === 2 ? C.amber : C.soft, seed: 1202 + i }); - } - card(ctx, X(x + 196), Y(py + 86), S(204), S(220), { seed: 1210, color: C.soft, fill: '#ffffff', w: 2 }); - miniBars(ctx, X(x + 212), Y(py + 110), S(172), S(180), { seed: 1211, bars: 5, color: [C.soft, C.soft, C.amber, C.soft, C.soft] }); - arrow(ctx, X(x + 162), Y(py + 176), X(x + 252), Y(py + 176), { w: S(3), color: C.amber, seed: 1212, head: S(12) }); - } - // 3. a theme: swatches and a typeface, carried onto three charts - { - const x = xs[2]; - frame(x, 1300); - text(ctx, 'Aa', X(x + 28), Y(py + 100), { size: S(48), kind: 'handBold', color: C.ink, maxWidth: S(90), maxLines: 1 }); - ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d'].forEach((c, i) => dot(ctx, X(x + 140 + i * 52), Y(py + 82), S(17), c, { seed: 1301 + i })); - const pal = ['#1f3b73', '#1b998b', '#e3a72f']; - [0, 1, 2].forEach((i) => { - const cx = x + 22 + i * 132; - card(ctx, X(cx), Y(py + 136), S(118), S(170), { seed: 1310 + i * 3, color: C.soft, fill: '#ffffff', w: 2 }); - if (i === 0) miniBars(ctx, X(cx + 12), Y(py + 160), S(94), S(130), { seed: 1320, bars: 4, color: pal[0] }); - if (i === 1) miniLines(ctx, X(cx + 10), Y(py + 160), S(98), S(130), { seed: 1321, series: 2, colors: pal }); - if (i === 2) miniHeatmap(ctx, X(cx + 12), Y(py + 164), S(94), S(118), { rows: 4, cols: 4, seed: 1322, palette: pal, frame: false }); - }); - } - - // the focus: the others fade back, and this one is circled + xs.forEach((x, i) => { + const k = seed + i * 100; + card(ctx, X(x), Y(py), S(PW), S(PH), { seed: k, color: C.ink, fill: C.paper, w: 2.5 }); + line(ctx, X(x), Y(py + 34), X(x + PW), Y(py + 34), { w: S(2), color: C.soft, seed: k + 1 }); + [0, 1, 2].forEach((j) => dot(ctx, X(x + 20 + j * 18), Y(py + 17), S(5), [C.red, C.amber, C.green][j], { seed: k + 2 + j })); + panels[i](ctx, b, x, py); + }); if (focus !== undefined) { ctx.save(); ctx.fillStyle = 'rgba(255, 255, 255, 0.66)'; xs.forEach((x, i) => { if (i !== focus) ctx.fillRect(X(x - 20), Y(0), S(PW + 40), S(410)); }); ctx.restore(); - const cx = xs[focus] + PW / 2; - ellipse(ctx, X(cx), Y(py + PH / 2), S(PW / 2 + 30), S(PH / 2 + 26), { w: S(5), color: C.red, seed: 1400 + focus }); + ellipse(ctx, X(xs[focus] + PW / 2), Y(py + PH / 2), S(PW / 2 + 30), S(PH / 2 + 26), { w: S(5), color: ring, seed: seed + 900 + focus }); } }; } +// The three ways to use Flint: a chat with a chart card in the reply; an app with a table linked to a +// chart; a theme's swatches and typeface carried onto three charts. +const USE_PANELS: TrioPanel[] = [ + (ctx, { X, Y, S }, x, py) => { + washRect(ctx, X(x + 150), Y(py + 52), S(250), S(46), C.blue, { alpha: 0.22, seed: 1106 }); + line(ctx, X(x + 166), Y(py + 70), X(x + 376), Y(py + 70), { w: S(3), color: C.blue, seed: 1107 }); + line(ctx, X(x + 166), Y(py + 84), X(x + 320), Y(py + 84), { w: S(3), color: C.blue, seed: 1108 }); + dot(ctx, X(x + 32), Y(py + 128), S(12), C.ink, { seed: 1109 }); + card(ctx, X(x + 54), Y(py + 116), S(346), S(196), { seed: 1110, color: C.soft, fill: '#ffffff', w: 2 }); + miniLines(ctx, X(x + 74), Y(py + 140), S(306), S(150), { seed: 1111, series: 3 }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, '', X(x + 20), Y(py + 66), { size: S(22), kind: 'mono', color: C.meaning, maxWidth: S(220), maxLines: 1 }); + rect(ctx, X(x + 20), Y(py + 86), S(150), S(220), { w: S(2), color: C.soft, seed: 1201 }); + for (let i = 0; i < 6; i++) { + line(ctx, X(x + 32), Y(py + 112 + i * 32), X(x + 158), Y(py + 112 + i * 32), { w: S(i === 2 ? 4 : 2), color: i === 2 ? C.amber : C.soft, seed: 1202 + i }); + } + card(ctx, X(x + 196), Y(py + 86), S(204), S(220), { seed: 1210, color: C.soft, fill: '#ffffff', w: 2 }); + miniBars(ctx, X(x + 212), Y(py + 110), S(172), S(180), { seed: 1211, bars: 5, color: [C.soft, C.soft, C.amber, C.soft, C.soft] }); + arrow(ctx, X(x + 162), Y(py + 176), X(x + 252), Y(py + 176), { w: S(3), color: C.amber, seed: 1212, head: S(12) }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, 'Aa', X(x + 28), Y(py + 100), { size: S(48), kind: 'handBold', color: C.ink, maxWidth: S(90), maxLines: 1 }); + ['#1f3b73', '#1b998b', '#e3a72f', '#8d99ae', '#c8553d'].forEach((c, i) => dot(ctx, X(x + 140 + i * 52), Y(py + 82), S(17), c, { seed: 1301 + i })); + const pal = ['#1f3b73', '#1b998b', '#e3a72f']; + [0, 1, 2].forEach((i) => { + const cx = x + 22 + i * 132; + card(ctx, X(cx), Y(py + 136), S(118), S(170), { seed: 1310 + i * 3, color: C.soft, fill: '#ffffff', w: 2 }); + if (i === 0) miniBars(ctx, X(cx + 12), Y(py + 160), S(94), S(130), { seed: 1320, bars: 4, color: pal[0] }); + if (i === 1) miniLines(ctx, X(cx + 10), Y(py + 160), S(98), S(130), { seed: 1321, series: 2, colors: pal }); + if (i === 2) miniHeatmap(ctx, X(cx + 12), Y(py + 164), S(94), S(118), { rows: 4, cols: 4, seed: 1322, palette: pal, frame: false }); + }); + }, +]; + +// The three specs: semantic types that become a chart; a theme that turns a plain chart into a house +// chart; a click that arrives as an event naming the data. +const SPEC_PANELS: TrioPanel[] = [ + (ctx, { X, Y, S }, x, py) => { + ['"period": "YearMonth"', '"game": "Category"', '"newUsers": "Profit"'].forEach((t, i) => + text(ctx, t, X(x + 24), Y(py + 72 + i * 32), { size: S(21), kind: 'mono', color: C.meaning, maxWidth: S(370), maxLines: 1 })); + miniHeatmap(ctx, X(x + 40), Y(py + 178), S(340), S(110), { rows: 4, cols: 10, seed: 1511, palette: DEFAULT_DIVERGING, frame: false }); + line(ctx, X(x + 40), Y(py + 298), X(x + 380), Y(py + 298), { w: S(2), color: C.ink, seed: 1512 }); + }, + (ctx, { X, Y, S }, x, py) => { + text(ctx, '"theme_spec": "economist"', X(x + 24), Y(py + 72), { size: S(21), kind: 'mono', color: C.look, maxWidth: S(370), maxLines: 1 }); + card(ctx, X(x + 20), Y(py + 104), S(160), S(200), { seed: 1601, color: C.soft, fill: '#ffffff', w: 2 }); + miniBars(ctx, X(x + 34), Y(py + 140), S(132), S(150), { seed: 1602, bars: 4, color: '#a7adb2' }); + arrow(ctx, X(x + 188), Y(py + 204), X(x + 232), Y(py + 204), { w: S(3), color: C.look, seed: 1603, head: S(12) }); + card(ctx, X(x + 240), Y(py + 104), S(160), S(200), { seed: 1604, color: C.soft, fill: '#ffffff', w: 2 }); + washRect(ctx, X(x + 254), Y(py + 118), S(30), S(9), '#e3120b', { alpha: 0.95, seed: 1605 }); + miniBars(ctx, X(x + 254), Y(py + 140), S(132), S(150), { seed: 1602, bars: 4, color: '#006ba2' }); + }, + (ctx, { X, Y, S }, x, py) => { + const pts: [number, number, number][] = [[50, 250, 9], [80, 200, 12], [110, 230, 8], [140, 150, 14], [170, 180, 10], [200, 110, 11], [120, 280, 8], [60, 120, 9]]; + rect(ctx, X(x + 20), Y(py + 56), S(210), S(250), { w: S(2), color: C.soft, seed: 1701 }); + pts.forEach(([px, pyy, r], i) => dot(ctx, X(x + px), Y(py + pyy), S(r), i === 3 ? C.behavior : C.soft, { seed: 1702 + i })); + ellipse(ctx, X(x + 140), Y(py + 150), S(22), S(22), { w: S(2.5), color: C.amber, seed: 1711 }); + arrow(ctx, X(x + 236), Y(py + 180), X(x + 262), Y(py + 180), { w: S(3), color: C.behavior, seed: 1712, head: S(10) }); + card(ctx, X(x + 268), Y(py + 116), S(136), S(130), { seed: 1713, color: C.behavior, fill: '#ffffff', w: 2.5 }); + text(ctx, 'click', X(x + 280), Y(py + 152), { size: S(19), kind: 'mono', color: C.ink2, maxWidth: S(116), maxLines: 1 }); + text(ctx, 'Country:', X(x + 280), Y(py + 188), { size: S(19), kind: 'mono', color: C.ink, maxWidth: S(116), maxLines: 1 }); + text(ctx, '"Japan"', X(x + 280), Y(py + 222), { size: S(19), kind: 'mono', color: C.behavior, maxWidth: S(116), maxLines: 1 }); + }, +]; + +const SPEC_RINGS = [C.meaning, C.look, C.behavior]; + Object.assign(SKETCHES, { - useCases: useCases(), - useCase1: useCases(0), - useCase2: useCases(1), - useCase3: useCases(2), + useCases: trio(USE_PANELS, 1100), + useCase1: trio(USE_PANELS, 1100, 0), + useCase2: trio(USE_PANELS, 1100, 1), + useCase3: trio(USE_PANELS, 1100, 2), + specs: trio(SPEC_PANELS, 1500), + spec1: trio(SPEC_PANELS, 1500, 0, SPEC_RINGS[0]), + spec2: trio(SPEC_PANELS, 1500, 1, SPEC_RINGS[1]), + spec3: trio(SPEC_PANELS, 1500, 2, SPEC_RINGS[2]), }); diff --git a/site/src/talk/slides.tsx b/site/src/talk/slides.tsx index 43384648..f3b36b30 100644 --- a/site/src/talk/slides.tsx +++ b/site/src/talk/slides.tsx @@ -1,6 +1,7 @@ import type { ReactNode } from 'react'; import type { ChartAssemblyInput, ThemeSpec } from 'flint-chart'; import { THEME_PRESETS } from 'flint-chart'; +import { TYPE_TREE } from './sketches'; import { SizingPlayground } from '../components/SizingPlayground'; import { ThemeExplorer } from './ThemeExplorer'; import { WorldCupScorersDemo } from '../playground/WorldCupScorersDemo'; @@ -16,7 +17,7 @@ import { penguins, picked, withData, type FlintState, } from './data'; import { - Chart, Code, Demo, FitTable, Stable, MINIMAPS, Minimap, Sketch, VegaLite, fullLayout, lineDiff, plainLayout, specLayout, stepLayout, textRows, + Chart, Code, Demo, FitTable, FlawList, FlawedVegaLite, Stable, MINIMAPS, Minimap, Sketch, VegaLite, fullLayout, type Flaw, lineDiff, plainLayout, specLayout, stepLayout, textRows, type CodeRow, type CodeSource, } from './parts'; import glue from './specs/vl-final-glue.txt?raw'; @@ -39,9 +40,9 @@ const Cell = ({ caption, children, framed }: { caption?: string; children: React ); /** One step of the traditional way: the code and chart before, then the code and chart after. */ -const Step = ({ before, beforeSpec, after, afterSpec, note }: { before: CodeSource; beforeSpec: unknown; after: CodeSource; afterSpec: unknown; note?: ReactNode }) => (<> +const Step = ({ before, beforeSpec, after, afterSpec, note, flaws }: { before: CodeSource; beforeSpec: unknown; after: CodeSource; afterSpec: unknown; note?: ReactNode; flaws?: Flaw[] }) => (<>
-
+
{flaws ? : }
→
@@ -64,6 +65,13 @@ const DIFF = { }; const GLUE_LINES = glue.trimEnd().split('\n').length; +/** What is wrong with the raw chart, circled on it. */ +const RAW_FLAWS: Flaw[] = [ + { role: 'marks', label: 'The chart runs far too wide for the page.' }, + { role: 'x-axis', label: 'Months show as raw numbers like 202101.' }, + { role: 'legend', label: 'Losses and gains share one color ramp, with no midpoint at zero.' }, +]; + /** A brand theme an agent might write from a short style guide; the slide shows this exact object. */ const BRAND_THEME = { extends: 'swiss', @@ -109,6 +117,24 @@ const TLDR_SPEC = `{ // After the Flint version: one request at a time, each starting where the last one left off. const FLINT_W = 52; +/** + * The type tree: the drawn boxes and connectors from the sketch, with the branch text set over them in + * the deck's own type. Both sit on the same 1000 × 720 frame, so the text stays on its line at any size. + */ +const TypeTree = () => ( +
+
+ + {TYPE_TREE.flatMap((r) => r.leaves).map((l) => ( + + {l.text} + + ))} +
+
+); + /** The three use cases, labelled under the sketch's three panels. */ const USE_CASES = [ { title: 'Explore data', short: 'A chart or a dashboard, right in your chat.', long: 'Ask, and a live chart or dashboard opens in your chat through the Flint MCP server.' }, @@ -116,20 +142,33 @@ const USE_CASES = [ { title: 'Design', short: 'One theme for every chart.', long: 'Write your house style once as a theme, and every chart in every library follows it.' }, ]; -/** The use-case sketch with readable labels under its panels; `focus` circles one and spells it out. */ -const UseCases = ({ focus }: { focus?: number }) => ( +/** The three specs, labelled under the sketch's three panels, each in its section color. */ +const SPECS = [ + { title: 'The chart spec', short: 'What the data means.', long: 'Semantic types and a layout engine take care of what the data means.', color: '#2f6db5' }, + { title: 'The theme spec', short: 'How it looks.', long: 'A formal specification of style, written once for every chart.', color: '#e8954a' }, + { title: 'The interaction spec', short: 'How it behaves.', long: 'Semantic events and update operators describe how a chart behaves.', color: '#d9534f' }, +]; + +/** + * A three-panel sketch with readable labels under its panels. With `focus`, the sketch circles that + * panel, its label is spelled out, and the other two fade back. + */ +const Trio = ({ sketch, items, focus }: { + sketch: string; items: { title: string; short: string; long: string; color?: string }[]; focus?: number; +}) => (
-
+
- {USE_CASES.map((u, i) => ( + {items.map((u, i) => (
-

{i + 1}. {u.title}

+

{i + 1}. {u.title}

{focus === i ? u.long : u.short}

))}
); +const UseCases = ({ focus }: { focus?: number }) => ; /** The "draw your guess" demo's interaction, condensed: a trigger, and a handler that answers with an update. */ const BESPOKE_ROWS: CodeRow[] = [ @@ -174,16 +213,6 @@ const APP_ROWS: CodeRow[] = [ { text: '' }, ]; -/** The semantic types Flint knows, from its type registry, grouped as the registry groups them. */ -const SEMANTIC_TYPES: [string, string][] = [ - ['Points in time', 'DateTime, Date, Time, Timestamp'], - ['Time units', 'Year, Quarter, Month, Week, Day, Hour, YearMonth, YearQuarter, YearWeek, Decade, Duration'], - ['Measures', 'Quantity, Count, Amount, Price, Percentage, Temperature'], - ['Signed measures', 'Profit, PercentageChange, Sentiment, Correlation'], - ['Ordered numbers', 'Rank, Score, ID'], - ['Places', 'Country, State, City, Region, Address, ZipCode, Latitude, Longitude'], - ['Categories', 'Category, Name, Status, Boolean, Direction, Range'], -]; /** The parts of the real "economist" preset that the theme slides talk about. */ const ECON = (THEME_PRESETS as Record }>).economist.spec; @@ -258,7 +287,7 @@ export const SLIDES: SlideDef[] = [ { id: 'title', kind: 'title', render: () => (<>

Flint: a visualization language for the AI era

-

Chenglong Wang, Yuwei Xiao, Kecheng Lu, Yunhai Wang, Alper Sarikaya, Michel Galley, Chris Quirk, Jianfeng Gao
Deep Learning Group, Microsoft Research

+

microsoft.github.io/flint-chart

@@ -269,7 +298,7 @@ export const SLIDES: SlideDef[] = [ { id: 'tldr', render: () => (<> -

Flint in short

+

Conclusion

Flint is a visualization language for AI agents to reliably create polished data visualizations. The agent writes a short, simple spec, and Flint's compiler takes care of the rest.

@@ -290,15 +319,10 @@ export const SLIDES: SlideDef[] = [ }, // ======================================================== Act 1 - { - id: 'act1', kind: 'section', render: () => (<> -

Authoring a chart the traditional way

-

We'll build one chart with a declarative grammar, Vega-Lite, step by step.

- ), - }, { id: 'ideal', render: () => (<> -

Ideally, a chart is a few lines that are easy to change

+

Authoring with Vega-Lite

+

Ideally, a chart is a few lines that are easy to change.

@@ -316,7 +340,7 @@ export const SLIDES: SlideDef[] = [ }, { id: 'reality', render: () => (<> -

In reality, our charts ask for more

+

Let's try a slightly more complicated example

Task: "Make a heatmap of net new users by game and month for our report page, in The Economist style, and let me click a game to highlight it next to our table."

@@ -324,30 +348,26 @@ export const SLIDES: SlideDef[] = [ rows={LONG_ROWS.map((r) => [r.game, r.region, r.period.replace('-', ''), r.newUsers])} />

Rows: 60 months × 24 games × 4 regions = 5,760.

-
- - -
+
), }, { - id: 'attempt-1', render: () => (<> -

Attempt one: plug the data in, and it breaks

- The same few lines give a valid spec and a wrong chart. To fix it we parse 202101 into a date, sum the four regions in each cell, and centre the colours on zero, adding {DIFF.parse.plus} lines.} - /> + id: 'broken', render: () => (<> +

Plug the data in, and the chart breaks

+
+ + +
), }, { - id: 'attempt-2', render: () => (<> -

Attempt two: five years of months need a new layout

+ id: 'attempt-1', render: () => (<> +

Let's fix parsing and layout

Sixty months crowd the axis with Jan to Dec five times over. We widen the chart, label each year once, give long game names room, and move the legend to the top. That adds {DIFF.layout.plus} lines and changes {DIFF.layout.minus}.} + before={ROWS.raw} beforeSpec={withData(STEPS.raw)} + after={stepLayout(STEPS.layout, STEPS.raw)} afterSpec={withData(STEPS.layout)} + note={<>Parse 202101 into a date, sum the four regions, centre the colours on zero, then widen the chart and label each year once: {lineDiff(STEPS.raw, STEPS.layout).plus} lines.} /> ), }, @@ -355,7 +375,7 @@ export const SLIDES: SlideDef[] = [ id: 'theme-vl', render: () => (<>

Making it look like The Economist is mostly new work

Fonts and axes go into the config, the house colours into the encoding, and the red tab, headline, and source line become extra views placed by hand. The spec grows by {DIFF.theme.plus} lines.} /> @@ -384,7 +404,7 @@ export const SLIDES: SlideDef[] = [
-

A click filters the table and a picker selects a game. These {GLUE_LINES} lines talk in signal names and internal stores, not in terms of the data.

+

{GLUE_LINES} lines, all in signal names.

), }, { @@ -413,16 +433,10 @@ export const SLIDES: SlideDef[] = [ ), }, - // ======================================================== Act 2 - { - id: 'act2', kind: 'section', render: () => (<> -

Just let an AI agent do it?

-

Today we would hand this to an agent. It can do it, but then we notice five problems.

- ), - }, + // Act 1, continued: handing it to an agent { id: 'five-problems', render: () => (<> -

Five problems with letting the agent write it all

+

Just let an AI agent do it? Five problems show up

    @@ -438,23 +452,16 @@ export const SLIDES: SlideDef[] = [ { id: 'root-cause', render: () => (<>

    The root cause is the language

    -
    -
    -

    Low-level configuration ties together what the data means, how the chart looks, and how it behaves. Every change ripples into the others.

    -

    "The logic depends on coordinates, pixels, and SVG paths, all tangled together. So the agent reasons, writes, debugs, and goes around again, and still hands you something fragile."

    -
    -
    -
    +
    ), }, // ======================================================== Act 3 { id: 'lifting', render: () => (<> -

    Flint is a language for AI agents that disentangles visual and interaction logic

    +

    Flint is a language for AI agents that disentangles visual and interaction logic

    -

    You and your agent work with the high-level specs, without losing control. The compiler takes care of data parsing, layout, events, design tokens, and the dependencies between them.

    ), }, @@ -465,7 +472,6 @@ export const SLIDES: SlideDef[] = [
    -

    A few lines on the raw data, with the same look. Click a game to try it.

), @@ -475,34 +481,34 @@ export const SLIDES: SlideDef[] = [ // Section A { - id: 'sec-a', kind: 'section', render: () => (<> -
-

The chart spec

-

Semantic types and a layout engine take care of what the data means.

+ id: 'sec-a', render: () => (<> +

1. The chart spec

+ ), }, + { id: 'a-how', render: () => (<>

Semantic types: say what the data means, and the compiler does the rest

) }, { id: 'a-what', render: () => (<> -

Say what each field means, and the compiler does the rest

+

What each type decides for this chart

-
-
+
+ +

Semantic types decide data processing, axes, and colors, so the compiler can infer the low-level configuration reliably, without heuristics.

+
+
), }, - { id: 'a-how', render: () => (<>

How it works: from what the data means to the chart

) }, { id: 'a-vl', render: () => (<>

And this is what the compiler wrote in Vega-Lite

-

The Flint spec, on the raw rows.

→
-

What the compiler wrote in Vega-Lite because of the three types.

), @@ -511,11 +517,7 @@ export const SLIDES: SlideDef[] = [ id: 'a-types', render: () => (<>

Semantic types: a small vocabulary with a lot behind it

- - - {SEMANTIC_TYPES.map(([family, types]) => )} - -
{family}{types}
+

Agents are really good at this. Saying that a column is a month, a profit, or a country is just reading the data, and it is far easier than writing parsing, scale, and format code.

), @@ -525,7 +527,6 @@ export const SLIDES: SlideDef[] = [

The layout engine: the data pushes out, the canvas pushes back

-

Each item is a spring that wants its own room, and the canvas is a stiffer spring that resists growing. The plot settles where the two balance, never past the most it may stretch.

), }, @@ -546,7 +547,6 @@ export const SLIDES: SlideDef[] = [

One spec, five rendering libraries

-

Each library structures its parameters differently. The same chart spec compiles to all of them.

  • Vega-Lite, with 39 chart types
  • ECharts, with 37
  • @@ -569,10 +569,9 @@ export const SLIDES: SlideDef[] = [ // Section B { - id: 'sec-b', kind: 'section', render: () => (<> -
    -

    The theme spec

    -

    A formal specification of style, written once for every chart.

    + id: 'sec-b', render: () => (<> +

    2. The theme spec

    + ), }, { @@ -582,7 +581,6 @@ export const SLIDES: SlideDef[] = [
    -

    The "economist" definition, from the theme library.

    ), @@ -596,10 +594,9 @@ export const SLIDES: SlideDef[] = [ }, // Section C { - id: 'sec-c', kind: 'section', render: () => (<> -
    -

    The interaction spec

    -

    Semantic events and update operators describe how a chart behaves.

    + id: 'sec-c', render: () => (<> +

    3. The interaction spec

    + ), }, { @@ -641,7 +638,7 @@ export const SLIDES: SlideDef[] = [ // ======================================================== Act 4 { id: 'act4', render: () => (<> -

    What you can build with it

    +

    Applications: what can you build with Flint?

    ), }, @@ -744,7 +741,7 @@ export const SLIDES: SlideDef[] = [ // ======================================================== Act 5 { id: 'recap', render: () => (<> -

    Flint: a visualization language for AI agents

    +

    Flint: a visualization language for AI agents

    Open source, MIT license. flint-chart on npm and PyPI, and the flint-chart-mcp server for your agent, at github.com/microsoft/flint-chart.

    diff --git a/site/src/talk/talk.css b/site/src/talk/talk.css index 9970d929..4b74233d 100644 --- a/site/src/talk/talk.css +++ b/site/src/talk/talk.css @@ -42,7 +42,6 @@ .talk-slide strong { color: var(--ink); font-weight: 650; } .talk-slide code { font: 500 0.86em/1.3 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; color: var(--ink); background: var(--panel); padding: 0.06em 0.3em; border-radius: 6px; } .talk-lead { font-size: 34px !important; line-height: 1.4; color: var(--ink) !important; } -.talk-quote { font-size: 32px; line-height: 1.45; color: var(--ink); font-style: italic; } .c-meaning { color: var(--meaning); } .c-look { color: var(--look); } .c-behavior { color: var(--behavior); } @@ -110,10 +109,6 @@ .talk-slide.is-title h1 { font-size: 80px; max-width: 1300px; margin-bottom: 16px; } .talk-slide.is-section h1 { font-size: 76px; } .talk-slide.is-statement h1 { font-size: 64px; max-width: 1300px; } -.talk-bar { width: 120px; height: 10px; border-radius: 5px; margin-bottom: 32px; flex: none; } -.talk-bar.meaning { background: var(--meaning); } -.talk-bar.look { background: var(--look); } -.talk-bar.behavior { background: var(--behavior); } /* A chat, as an agent client shows it. */ .talk-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 16px; background: var(--panel); border-radius: 16px; padding: 22px; } @@ -205,3 +200,31 @@ .talk-usecases p { margin: 0; font-size: 24px; line-height: 1.4; text-align: center; } .talk-usecases .on h3 { color: #c0392b; } .talk-usecases .off { opacity: 0.4; } + +/* The first slide of each act: its title leads with a mark, in place of a separate divider slide. */ +.talk-slide h2.is-act::before { + content: ''; display: inline-block; width: 0.42em; height: 0.42em; margin: 0 0.5em 0 0.06em; + background: #0067b8; border-radius: 3px; transform: rotate(45deg); vertical-align: 0.14em; +} + +/* A callout that floats over the slide like a sticky note, out of the layout's flow. */ +.talk-slide .talk-callout { + position: absolute; top: 46px; right: 64px; z-index: 5; max-width: 420px; margin: 0; + padding: 18px 22px; border-radius: 10px; background: #fff7d6; border: 1.5px solid #e8c766; + color: var(--ink); font-size: 27px; line-height: 1.35; font-weight: 550; + box-shadow: 0 12px 28px rgba(60, 45, 0, 0.18); transform: rotate(1.6deg); +} + +/* The problems circled on a chart, numbered to match its red badges. */ +.talk-flaws { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; margin: 8px 0 0; padding: 0; list-style: none; } +.talk-flaws li { display: flex; align-items: flex-start; gap: 12px; margin: 0; font-size: 26px; line-height: 1.35; color: var(--ink); } +.talk-flaws span { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #e4572e; color: #fff; font-weight: 700; font-size: 20px; display: grid; place-items: center; } + +/* A sketch with text laid over it: the frame keeps the sketch's aspect, so text and lines stay aligned. */ +.talk-frame { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; container-type: size; } +.talk-frame .talk-sketch { position: absolute; inset: 0; } +.talk-leaf { position: absolute; transform: translateY(-50%); white-space: nowrap; font-size: 2.9cqw; color: var(--ink); line-height: 1.2; } +.talk-leaf.mono { font: 500 1.9cqw/1.2 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; } +.talk-leaf.muted { color: var(--ink-3); } +.talk-leaf.good { color: #3d7a27; } +.talk-slide .talk-callout.talk-callout-inline { position: relative; top: auto; right: auto; flex: none; max-width: none; margin: 0 8px 8px; transform: rotate(-1deg); } From 16f567ddc61364a38898c659e5c219e6c231c324 Mon Sep 17 00:00:00 2001 From: Chenglong Wang Date: Wed, 21 Oct 2026 14:19:04 -0700 Subject: [PATCH 3/3] fixes --- packages/flint-mcp/ui/src/BoardView.tsx | 11 +----- packages/flint-mcp/ui/src/ChartView.tsx | 12 ++---- packages/flint-mcp/ui/src/page-scroll.ts | 49 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 packages/flint-mcp/ui/src/page-scroll.ts diff --git a/packages/flint-mcp/ui/src/BoardView.tsx b/packages/flint-mcp/ui/src/BoardView.tsx index 0b7871e7..627da14b 100644 --- a/packages/flint-mcp/ui/src/BoardView.tsx +++ b/packages/flint-mcp/ui/src/BoardView.tsx @@ -44,6 +44,7 @@ import { boardPng } from './board-export'; import { SelectionChips, chipText, impliedParts, partText } from './selection-chips'; import { ViewSwitch, useCellViews, useChartTable, type CellView } from './chart-table-view'; import { ActionButton, ThemeControl } from './controls'; +import { usePageScroll } from './page-scroll'; import { LINK_LAYER, conditionUpdates, gestureParts, shownFields, type ChartLink, type LinkCondition, type LinkSpec } from 'flint-chart/interactive'; export interface BoardChart { @@ -733,16 +734,8 @@ export function BoardView({ app, initial, hostContext }: { app: App; initial: Bo document.documentElement.style.background = style.background; document.body.style.background = style.background; }, [style.background]); - // Inline, the card is sized to the board, so the page never scrolls. A scrollbar would appear while the - // host catches up with a new height, narrow the board, lay every chart out again, and change the height - // again. In a pane the host sets the height, so a taller board scrolls, with its gutter kept so the - // scrollbar never narrows it. const paned = hostContext?.displayMode === 'fullscreen' || hostContext?.displayMode === 'pip'; - useEffect(() => { - document.documentElement.style.overflow = paned ? 'hidden auto' : 'hidden'; - document.documentElement.style.scrollbarGutter = paned ? 'stable' : ''; - document.body.style.overflow = paned ? 'visible' : 'hidden'; - }, [paned]); + usePageScroll(hostContext, paned); const byId = useMemo(() => new Map(charts.map((chart) => [chart.id, chart])), [charts]); const grid = draft ?? board.grid; diff --git a/packages/flint-mcp/ui/src/ChartView.tsx b/packages/flint-mcp/ui/src/ChartView.tsx index 90e8da11..80107d9a 100644 --- a/packages/flint-mcp/ui/src/ChartView.tsx +++ b/packages/flint-mcp/ui/src/ChartView.tsx @@ -25,6 +25,7 @@ import { chartIconFor } from './chart-icons'; import { SelectionChips, chipText, impliedParts, partText, type SelectionChip } from './selection-chips'; import { VIEW_SWITCH_LABEL, ViewSwitchIcon, useChartTable, type CellView } from './chart-table-view'; import { tablePng } from './table-export'; +import { usePageScroll } from './page-scroll'; import { conditionUpdates, selectionParts, type LinkCondition } from 'flint-chart/interactive'; import { chartContext, chartView, type ChartGesture } from '../../src/chart-context'; import { @@ -611,16 +612,9 @@ export function ChartView({ app, shown, hostContext }: { app: App; shown: Board; }, []); useEffect(() => () => chartBoxObserver.current?.disconnect(), []); - // Inline, the card is sized to the chart, so the page never scrolls: a scrollbar shown while the host - // catches up with a new height would narrow the chart and lay it out again. In a pane the host sets - // the height and the chart is laid out for what the pane leaves it; the page scrolls only past that, - // with its gutter kept so the scrollbar never narrows the chart. + // In a pane the host sets the height and the chart is laid out for what the pane leaves it. const paned = hostContext?.displayMode === 'fullscreen' || hostContext?.displayMode === 'pip'; - useEffect(() => { - document.documentElement.style.overflow = paned ? 'hidden auto' : 'hidden'; - document.documentElement.style.scrollbarGutter = paned ? 'stable' : ''; - document.body.style.overflow = paned ? 'visible' : 'hidden'; - }, [paned]); + usePageScroll(hostContext, paned); // Re-seed when a new tool input arrives from the host. useEffect(() => setCurrent(input), [input]); diff --git a/packages/flint-mcp/ui/src/page-scroll.ts b/packages/flint-mcp/ui/src/page-scroll.ts new file mode 100644 index 00000000..c46c41eb --- /dev/null +++ b/packages/flint-mcp/ui/src/page-scroll.ts @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { useEffect, useState } from 'react'; +import type { McpUiHostContext } from '@modelcontextprotocol/ext-apps'; + +/** The tallest the host will draw the card inline, if it says. */ +function hostMaxHeight(hostContext?: McpUiHostContext): number | undefined { + const dims = hostContext?.containerDimensions as { height?: number; maxHeight?: number } | undefined; + const cap = dims?.maxHeight ?? dims?.height; + return typeof cap === 'number' && Number.isFinite(cap) && cap > 0 ? cap : undefined; +} + +/** How far a scrolling page must shrink below the cap before it stops scrolling, so the gutter cannot flip it back and forth. */ +const HYSTERESIS = 16; + +/** + * Whether the page scrolls. Inline, the card is sized to the page, so it never does: a scrollbar would + * appear while the host catches up with a new height, narrow the content, lay it out again, and change + * the height again. A host that stops growing the card at a height (VS Code: 75% of its window) says so + * in `containerDimensions.maxHeight`; a page taller than that scrolls, or its bottom is cut off. In a pane + * the host sets the height, so the page scrolls past it. A scrolling page keeps its gutter so the + * scrollbar never narrows it. + */ +export function usePageScroll(hostContext: McpUiHostContext | undefined, paned: boolean): void { + const cap = paned ? undefined : hostMaxHeight(hostContext); + const [over, setOver] = useState(false); + useEffect(() => { + if (cap === undefined || typeof ResizeObserver === 'undefined') { + setOver(false); + return; + } + const read = () => { + const height = document.body.scrollHeight; + setOver((prev) => (prev ? height > cap - HYSTERESIS : height > cap + 1)); + }; + read(); + const observer = new ResizeObserver(read); + observer.observe(document.body); + return () => observer.disconnect(); + }, [cap]); + + const scrolls = paned || over; + useEffect(() => { + document.documentElement.style.overflow = scrolls ? 'hidden auto' : 'hidden'; + document.documentElement.style.scrollbarGutter = scrolls ? 'stable' : ''; + document.body.style.overflow = scrolls ? 'visible' : 'hidden'; + }, [scrolls]); +}