@hunchcloud/live-element
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

<live-element>

npm

A custom element to live edit other custom elements. Like react-live, but for web components (custom elements).

💫️ Demos

demo.gif

Usage

Install by

yarn add @hunchcloud/live-element

Insert the following HTML

<live-element>
  <textarea>
    <your-custom-element></your-custom-element>
  </textarea>
<live-element>

Then you will get a playground to live edit <your-custom-element>.

Notice the <textarea> wrapper is required to prevent <your-custom-element> rendering before being passed to <live-element>.

Customize editor styles

Use style-template-id to pass in customized styles.

<template id="prism-solarized">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/themes/prism-solarizedlight.min.css" />
  <style>
    #live-editor {
      color: #657b83;
      background: #073642;
    }
    ::slotted(*) {
      background: lightcyan;
    }
  </style>
</template>

<live-element style-template-id="prism-solarized">
  <textarea>
    <your-custom-element></your-custom-element>
  </textarea>
<live-element>

Development

parcel example/demo.md

Package Sidebar

Install

npm i @hunchcloud/live-element

Weekly Downloads

1

Version

0.3.2

License

BSD-3-Clause

Unpacked Size

9.11 kB

Total Files

7

Last publish

Collaborators

  • rnons