npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@parsons/ti-preview

v0.0.22

Published

Mini HTML/CSS editor / preview for the Typography & Interaction class at Parsons

Downloads

245

Readme

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

| Attribute | Description | Default | | ------------- | ------------------------------------ | ------- | | base | Pass a different Document Base URL | null | | readonly | Prevent the code from being changed | false | | hide-tabs | Don't render the file selection tabs | false | | hide-output | Don't render the output preview | false | | dedent | Automatically dedent code snippets | false |

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.