본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)41k · #6839

building-html-canvases

하는 일

이 스킬은 보고서, 다이어그램, 그림 같은 문서형이나 그래픽 캔버스를 단순한 웹 코드로 만듭니다. 완전한 앱이 아니라 PostHog 안에서 읽기 쉬운 페이지나 시각 작품이 필요한 사람을 위한 것입니다.

사용하는 경우

  • ✓글로 된 보고서나 기사를 캔버스로 보여 주고 싶을 때.
  • ✓PostHog 안에 다이어그램, 그림, 생성된 그래픽을 넣고 싶을 때.
  • ✓캔버스가 대부분 정적이고 많은 대화형 컨트롤이 필요하지 않을 때.

스킬 링크

https://github.com/PostHog/posthog/blob/master/products/canvas/skills/building-html-canvases/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/PostHog/posthog/blob/master/products/canvas/skills/building-html-canvases/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 분기 조사 결과를 깔끔하고 읽기 쉬운 보고서와 간단한 차트로 보여 주는 캔버스를 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 PostHog가 요구하는 작은 React 래퍼로 감싼 시맨틱 HTML, 스타일, 브라우저 그래픽 코드를 작성합니다. 또한 테마가 바뀔 때 캔버스가 잘 작동하도록 애니메이션과 리스너를 정리합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Building HTML canvases

Some canvases are documents or graphics programs, not applications: a written report, a diagram, a generative-art piece, a WebGL scene. For these, semantic HTML, CSS, and direct browser APIs are the right tools — don't force Quill components or React state onto a static page.

The wrapper the current runtime requires

Every canvas keeps src/canvas.tsx as its mounted React entry component (default export, no props). Keep the React layer as a thin shell and write the experience in HTML/CSS/browser APIs inside it:

  • A document is JSX that is effectively semantic HTML — <article>, headings, lists, tables, figures — with a <style> block for typography and layout. Write real, specific copy.
  • A drawing/WebGL program renders a <canvas> element and drives it imperatively from a useEffect via a ref: get the 2D/WebGL context, run the setup and render loop there.
  • Clean up in the effect's return: cancel requestAnimationFrame loops, remove listeners, and release contexts, so theme switches and remounts don't leak or double-run.
  • Mixing tiers is fine: a mostly static page can mount one interactive island, and a data board can hand a chart's <canvas> to imperative code while React owns the chrome.

The import allowlist still applies (react, react-dom, @posthog/quill, recharts, lucide-react, dayjs) — browser globals (document, CanvasRenderingContext2D, WebGLRenderingContext, requestAnimationFrame, IntersectionObserver, Web Audio, etc.) need no import. Three.js and other npm graphics libraries are not yet loadable; write against raw WebGL or 2D canvas until the build pipeline's dependency admission ships.

Styling and theme without Quill

  • Size the outermost JSX/HTML element to the iframe viewport with min-h-screen or min-height: 100vh, so it fills the viewport and grows past it as content demands. Do not use h-screen or height: 100vh there: a fixed viewport height caps a flex column, so tall children shrink and clip instead of scrolling. Do not use h-full or height: 100% on that root either: a published canvas's artifact shell gives its html, body, and #root elements no explicit height, so percentage height collapses to the content height. A min-height root is not a definite height, so a descendant's percentage height still collapses; give an intermediate wrapper an explicit height when a child must fill a box.
  • Use Tailwind utilities and/or a <style> block (keyframes and complex selectors are fine).
  • The host toggles a .dark class on the document root when the user's PostHog theme changes. Define your colors as CSS variables under :root { … } with overrides under html.dark { … }, or use theme token utilities (bg-background, text-foreground, border-border) — never a light-only hardcoded color.
  • Give your own CSS variables a prefix (--doc-bg, --doc-muted). Never reuse a platform token name: the bundled Quill stylesheet sets --background, --border, --card, --chrome, --input, --muted, --primary, and --fill-* on every element, so a :root or html.dark value with one of those names never reaches any element. A page that colors its text with its own --muted then renders unreadable (pale text on a pale page). Validation rejects such a declaration with platform_token_redeclared.
  • For canvas/WebGL drawing colors, read the resolved token at runtime (getComputedStyle(document.documentElement).getPropertyValue("--primary")) or your own CSS variables, and re-read on theme change if the scene is long-lived.

Rules that still apply

  • PostHog data comes only through the ph bridge (see querying-canvas-data), including ph.capture for interaction analytics. Other requests and external styles, images, fonts, media, or frames require their exact public HTTPS origins in capabilities.network.origins and work only after publishing. Remote scripts and dynamic imports remain blocked.
  • A document that states PostHog numbers must make each one verifiable: an insight-backed number links its saved insight through ph.openExternal (URL from the generate-app-url MCP tool, from a click); an ad-hoc ph.query number discloses the exact query that ran in a <details> element beside the claim — see "Verifiability" in querying-canvas-data.
  • External links go through ph.openExternal(url) (posthog.com origins only), from a user interaction.
  • Validate and publish through the c
자주 묻는 질문

React를 알아야 하나요?

많이 필요하지 않습니다. React 부분은 얇은 래퍼이고, 나머지는 일반 HTML, CSS, 브라우저 코드입니다.

PostHog의 데이터를 보여 줄 수 있나요?

네. 캔버스가 선언해야 하는 PostHog 데이터 브리지를 통해 가능합니다.

이 방식이 맞지 않는 경우는 언제인가요?

컨트롤이 많은 대화형 앱에는 React와 Quill 방식이 더 잘 맞습니다.

상세 정보

작성자의 원본 설명

Author a PostHog canvas with semantic HTML, CSS, and direct browser APIs — documents, articles, generative graphics, 2D canvas and WebGL experiences, and focused experiments where React components add no useful structure. Use after building-canvases has routed a canvas request to a plain-HTML/browser-API implementation. Covers the thin component wrapper the current runtime requires, styling and theming without Quill, drawing surfaces, and animation/cleanup patterns.

repo: PostHog/posthog

인기도

GitHub 스타
41k
순위
#6839
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬