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

doxastic

v0.0.10

Published

Document your React component library, in React

Downloads

2

Readme

Doxastic is a component documentation system that aims to ease component implementation and iteration, taking you from install to fully customizable, interactive, and self-documenting component library/playground in a few easy steps.

Storybook is the classic and almost ubiquitous React component library documentation system, and React Styleguidist is another excellent project in this field. Both have many features that allow your component docs to thrive! But both require new types of files that are built with a whole new build process - Doxastic lets you document and render documentation with an ergonomic and well-typed interface of React components. At a high level, Doxastic should be able to provide all the features you want without additional overhead!

Getting Started

To get started, you just need to install from npm:

npm i doxastic

Doxastic has additional peer-dependencies on React, React-DOM, and styled-components. This being a React documentation library, hopefully you have react, but styled-components is a handy library for including CSS styles in your React components that you may also need to install:

npm i styled-components

Document a Component

Lets walk through a straightforward Checkbox component documentation:

import {Document, bool, callback} from "doxastic";
import Checkbox from "my-checkbox-component";

<Document
  _a={Checkbox}
  _defaultView='grid'
  checked={bool({ trinary: true })`
    This is documentation about the checked prop
  `}
  disabled={bool()}
  onClick={callback()}
/>

Easy enough to see, this will render documentation on our Checkbox component. The _defaultView here says that we will by default see a grid of permutations of the component, automatically chosen based on the potential and example values of the props of the component.

The most important part of documenting a component is documenting the props - and for this, the Document component from doxastic takes in property meta values, easily created through a variety of helpers. Here we demonstrate 2 boolean properties, with the checked property behaving as a trinary boolean (where unknown is significantly distinct from false), and disabled being self-explanatory. All of the docType helpers can additionally act as a tagged template string, where the final string is arbitrary documentation of the prop. The onClick prop takes a callback, with the callback helper instantiating a quick method that logs when the callback is triggered.

Documenting a set of components

Sometimes, you may want to document a set of related components together:


import {Document, colors, str} from "doxastic";
import {H1, H2, H3, H4, H5, H6} from "my-text-components";

<Document
  _a={H1}
  _examples={[
    [
      { _overrideComponent: H1 },
      { _overrideComponent: H2 },
      { _overrideComponent: H3 },
      { _overrideComponent: H4 },
      { _overrideComponent: H5 },
      { _overrideComponent: H6 },
    ],
  ]}
  _defaultView='examples'
  color={colors({default: '#000', example: '#000'})}
  children={str({ example: "The quick brown fox etc" })}
/>

Here we group together our various text components, rendering a set of examples with different component. We also introduce the colors and str docType helpers, which render basic input elements. With this, we can see all of the components together, and quickly try out new colors and contents on all of them: