Experiments >

Code animation: Screen editor component

Experiment #14922nd April, 2021by Joshua Nussbaum

This integrates the previous experiment where I researched creating a DSL for defining property editor components.

ScreenEditor Component

The <ScreenEditor> component is responsible for modify screen related data.

The component looks something like this:

  import { document } from '$lib/document'
  import { Section, TextField, ColorField, CheckboxField, SelectField, CodeField, PositionField, Fieldset } from '$lib/components/properties'

  const presets = []
  const languages = []

<Section title="Title">
  <TextField bind:value={$document.window.title}/>

<Section title="Dimension">
  <Fieldset orientation="horizontal">
    <TextField type="number" label="H" orientation="horizontal" bind:value={$document.window.height} min=0/>
    <TextField type="number" label="W" orientation="horizontal" bind:value={$document.window.width} min=0/>

<Section title="Style">
  <SelectField label="Preset" bind:value={$document.window.preset} options={presets}/>
  <ColorField label="Color" bind:value={$document.window.color}/>
  <ColorField label="Background" bind:value={$document.window.background}/>

  <Fieldset orientation="horizontal">
    <TextField type="number" label="Border" bind:value={$document.window.border.size} min=0/>
    <ColorField bind:value={$document.window.border.color}/>

<Section title="Options">
  <CheckboxField label="Controls" bind:value={$document.window.controls}/>

<Section title="Code Editor">
  <SelectField label="Language" bind:value={$document.window.language} options={languages}/>
  <CheckboxField label="Line Numbers" bind:value={$document.window.lineNumbers}/>
  <CodeField label="Initial" language={$document.window.language} lineNumbers={$document.window.lineNumbers} bind:code={$document.window.initial}/>





  • It only supports a code editor screen for now, I may expand it later to support multiple screen types. ie editor, browser, phone
  • Bug: Fix layout for property fields when there are multiple fields per fieldset
  • Bug: Databading between CodeField and CodeMirror not working
  • Bug: JSON editor height doesn’t scale properly
  • Bug: Header disapears when timeline is too tall. I don’t think the outer layout should use flexbox. The <header>, <Timeline> and sidebar should probably be position: fixed
view all experiments

Stay tuned in

Learn how to add more experimentation to your workflow