Code Window

greet.ts
export function greet(name: string) {
return `Hello, ${name}!`;
}
 
// Ship it
About this piece

Code Window

Theme-adaptive editor window with traffic-light header, filename, and a tokenized code body.

Usage

The import and the props worth knowing about, in one place.

import { Editor1 } from "@/components/beste/piece/editor1";

<Editor1
  surface="card"
  bordered={false}
  inverted={false}
  filename="greet.ts"
  lines={[
    {
      "tokens": [
        {
          "text": "export",
          "kind": "keyword"
        },
        {
          "text": " "
        },
        {
          "text": "function",
          "kind": "keyword"
        },
        {
          "text": " "
        },
        {
          "text": "greet",
          "kind": "fn"
        },
        {
          "text": "(name: string) {"
        }
      ]
    },
    {
      "tokens": [
        {
          "text": "  "
        },
        {
          "text": "return",
          "kind": "keyword"
        },
        {
          "text": " "
        },
        {
          "text": "`Hello, ${name}!`",
          "kind": "string"
        },
        {
          "text": ";"
        }
      ]
    },
    {
      "tokens": [
        {
          "text": "}"
        }
      ]
    },
    {
      "tokens": []
    },
    {
      "tokens": [
        {
          "text": "// Ship it",
          "kind": "comment"
        }
      ]
    }
  ]}
/>

More Editor pieces

View all Editor
Theme
for (let $1:i = 0; $1 < $2:arr.length; $1++) {}
format
  • Format Document
  • Format Selection
  • Reveal in File Explorer
1// TODO migrate to server components
2// FIXME handles null state poorly
3// NOTE revisit once design lock lands
  • Dashboard
  • state
  • render
  • computeStats