0.0.22 • Published 8 months ago

@parsons/ti-preview v0.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TI Editor

Installation

  • Install the Web Component npm install @parsons/ti-preview

  • Either import / bundle it in your JS:

import "@parsons/ti-preview";
  • Or use the pre-bundled static file directly in your HTML:
<script src="./node_modules/@parsons/ti-preview/dist/bundled/index.js" type="module" />

Usage

Wrap code snippets in a figure inside of ti-preview:

<ti-preview>
	<figure>
		<pre>body { background-color: red; }</pre>
		<figcaption>style.css</figcaption>
	</figure>
</ti-preview>

Properties

AttributeDescriptionDefault
basePass a different Document Base URLnull
readonlyPrevent the code from being changedfalse
hide-tabsDon't render the file selection tabsfalse
hide-outputDon't render the output previewfalse
dedentAutomatically dedent code snippetsfalse

Theming

The following CSS variables can be overridden on ti-preview:

--container-border-radius: 4px;

--tab-bar-active-background: var(--editor-background);
--tab-bar-active-border-radius: initial;
--tab-bar-active-foreground: var(--tab-bar-foreground);
--tab-bar-active-highlight: #dcc193;
--tab-bar-active-inset: calc(100% - 2px) 0 0;
--tab-bar-active-weight: normal;
--tab-bar-background: var(--output-background);
--tab-bar-filter: none;
--tab-bar-font-family: system-ui, sans-serif;
--tab-bar-font-size: 12px;
--tab-bar-foreground: #acb2be;
--tab-bar-margin: initial;
--tab-bar-padding: 8px 12px;

--output-background: #22252a;
--output-border: 2px solid var(--editor-background);

--editor-width: 60%;
--editor-height: 50%;

--editor-background: #292c33;
--editor-caret-color: #acb2be;
--editor-font-family: monospace;
--editor-font-size: 1rem;
--editor-line-height: 1.2;
--editor-padding: 8px;
--editor-selection-background: #343841;

--syntax-text: #acb2be;
--syntax-link: #c678dd;
--syntax-heading: #e06c75;
--syntax-emphasis: #acb2be;
--syntax-strong: #acb2be;
--syntax-keyword: #c678dd;
--syntax-atom: #d19a66;
--syntax-bool: #d19a66;
--syntax-url: #56b6c2;
--syntax-labelName: #61afef;
--syntax-inserted: #98c379;
--syntax-deleted: #e06c75;
--syntax-literal: #acb2be;
--syntax-string: #98c379;
--syntax-number: #e5c07b;
--syntax-variableName: #61afef;
--syntax-definition: #61afef;
--syntax-typeName: #e5c07b;
--syntax-namespace: #e5c07b;
--syntax-className: #e5c07b;
--syntax-macroName: #e06c75;
--syntax-propertyName: #e06c75;
--syntax-operator: #56b6c2;
--syntax-comment: #7d8799;
--syntax-meta: #7d8799;
--syntax-punctuation: #acb2be;
--syntax-invalid: #ffffff;
--syntax-whitespace: transparent;

Filenames / Syntax highlighting

When using the <figure><pre/><figcaption/></figure> structure, the component will use the contents of the figcaption to determine the language to highlight the code in.

When using a <pre/> directly, you can either set the filename through the data-filename attribute, or omit the filename and control the highlighting through a language class class="language-css".

Currently only HTML and CSS are supported as languages.

Examples

See the demo folder for various examples of how to use this.

Development

You can use pnpm build:watch to create new dist builds whenever something changes, and pnpm start to render the demos live.

0.0.22

8 months ago

0.0.20

9 months ago

0.0.21

9 months ago

0.0.18

9 months ago

0.0.19

9 months ago

0.0.12

10 months ago

0.0.13

9 months ago

0.0.14

9 months ago

0.0.15

9 months ago

0.0.16

9 months ago

0.0.17

9 months ago

0.0.10

10 months ago

0.0.11

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.1

10 months ago