Elixir's UI (design)
Design (UI) components
Code

Code Component

Simple code editor to handle YAML, JSON and multiline text input.

Preview

,

Imports

import EccUtilDesignCode from '@elixir-cloud/design/dist/react/code/index';

Example

EccUtilsDesignCode
import React from 'react';
import EccUtilDesignCode from '@elixir-cloud/design/dist/react/code/index';
 
export default function Code() {
  return <EccUtilDesignCode />
}

Properties

PropertyRequiredDefaultTypeDescription
codefalseStringSpecifies the code to be rendered in the editor during initialization.
labelCodeStringLabel for code editor input field.
languagefalseStringSpecifies the language interpreter for syntax highlighting.
indentationfalse2NumberSpecifies number of spaces that should be considered for 1 Tab space.
blurDelayfalse150NumberTime in ms between 2 Tab key presses that should move the focus.
requiredfalsetrueBooleanMakes the code area a required field.
disabledfalsefalseBooleanDisables the code area.

Events

Event NameReact Event NameDescription
ecc-utils-changeEccUtilsChangeEventThis event is triggered when there is a change in the code within the editor. The event details include the language set by the package author, the code as value, and an error attribute indicating whether the entered code is valid based on the specified language.

Methods

Method NameArgumentsDescription
getCode()Returns the input.

Slots

👷‍♀️
Come back soon, huh!

Parts

👩‍🏭
Hold on! We are working here.

Examples

JSON

Control the language, the first tag shows the language the app-author defaulted for this component, so this means users are supposed to input JSON (in this case), but if they put something else the first badge will turn red.

,
😎

Try, putting valid YAML!

codeWithJson
import React from 'react';
export default function CodeWithJson() {
  return <EccUtilsDesignCode language='JSON' />;
}

Indentation

This has a default indentation of 8 spaces.

,
codeWithIndents
import React from 'react';
export default function CodeWithIndents() {
  return <EccUtilsDesignCode indentation={8} />;
}
;