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

picto-graph-x

v0.0.28

Published

Preview, develop and document StencilJS components

Downloads

2

Readme

Warning! This is a modified fork, please don't use this version. Instead go to the real project.


Getting started

Stencil provides the tooling, picto brings the ui and conventions that allow you to rapidly and attractively document, display and develop your component libraries.

You'll only need to do a few things to get it up and running for local development:

  • Create an index.html file
  • Create an additional stencil config
  • Add a script in package.json

Once you've got the basics up and running you can create preconfigured examples for your components using slots, props and custom markdown documentation (we'll get to that later.)

src/index.html

<!doctype html>
<html lang=en>

<head>
  <meta charset=utf-8>
  <title>My Component Library</title>
  <!-- Make sure you replace your-namespace with your namespace ;) -->
  <script src=/build/your-namespace.js></script>
  <link rel=stylesheet href=/build/your-namespace.css>
  <script src=https://unpkg.com/@snaptopixel/picto/dist/picto.js></script>
  <link rel=stylesheet href=https://unpkg.com/@snaptopixel/picto/dist/themes/default.css>
</head>

<body>
  <picto-graph>
    # Markdown to display as the home/index page
  </picto-graph>
</body>

</html>

stencil.dev.ts

This should be a duplicate of your stencil.config.ts replacing your dist outputTarget with the following:

outputTargets: [{
  type: 'www',
  dir: 'docs'
}],

package.json

Add the following to the scripts portion (you can name it whatever you'd like):

"picto": "stencil build --config stencil.dev.ts --dev --watch --serve --docs-json docs/components.json"

Run it!

Use your preferred package manager to run the newly added script yarn picto or npm run picto. Your browser will launch once compiled and you'll be able to preview and play with your components with hot-reloading etc.

⚠️  After running, you'll notice a new docs directory, you can add this to .gitignore or even deploy it to your repo and host on github for an auto-updating docs site.

Documenting components

After running for the first time you'll notice that readme.md files have been created next to your components (via Stencil). This is your entry point for documenting and configuring your example components.

Any markdown you add above the auto-generated content will be rendered below your component preview. You can use standard markdown and will also get syntax-highlighting with code blocks.

Configuring component previews

You configure your previews using YAML "frontmatter" at the top of your markdown files. In its most basic form it looks like this:

---
props:
  propString: Hello World
  propNumber: 123
  propBoolean: true
  propArray:
    - Hello
    - World
  propObj:
    message: Hi
    name: Bob 
---

Markdown here…

All supported options

  • props
    Optional hash containing prop name/value pairs that will be pre-populated
  • background
    css background value for the component preview, dark or light is also supported for predefined values
  • innerHTML
    HTML that will be inserted inside the component, useful for testing slots etc.
  • title
    When creating multiple usage examples will be used as the title in the sub-navigation menu
  • controls
    Customize the ui control used in the prop inspector, current supported values are
    • string: input[type=text]
    • boolean: checkbox
    • number: input[type=number]
    • (any value): textarea *parsed as javascript

Specifying additional configurations

There may be instances where you want to show additional or optional usages of a single-component.

picto also supports markdown files that are placed in a component's usage directory. Simply add a markdown file following the conventions already mentioned and it will appear in a sub-menu under the component's main navigation item.