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

rich-log

v1.2.0

Published

JSX + console.log = RichLog

Downloads

2

Readme

Rich Log

Get started

yarn add rich-log

Try it on CodeSandbox

import RichLog from 'rich-log';

RichLog.log(
  <RichLog.Fragment>
    <RichLog.Text>This is </RichLog.Text>
    <RichLog.Text
      color="white"
      background="linear-gradient(#555, #333)"
      padding="2px 6px"
      borderRadius="4px 0 0 4px"
      fontFamily="monospace"
    >
      rich-log
    </RichLog.Text>
    <RichLog.Text
      color="white"
      background="linear-gradient(#222, #090909)"
      padding="2px 6px"
      borderRadius="0 4px 4px 0"
      fontWeight="bold"
      fontFamily="monospace"
    >
      v1.0.0
    </RichLog.Text>
  </RichLog.Fragment>,
);

Output:

Thats it!

Benefits ✨

  • JSX in console.log
  • Styling with props (like styled-component)
  • Lightweight
  • Written in Typescript
  • Works with React and Preact

Components

<RichLog.Text />

A component for displaying styled text.

RichLog.log(
  <RichLog.Text fontSize="12px" color="green">
    Hello world
  </RichLog.Text>,
);

Output:

<RichLog.Fragment />

If you want to display several components at once, you can nest them in a fragment.

RichLog.log(
  <RichLog.Fragment>
    <RichLog.Text>My name is: </RichLog.Text>
    <RichLog.Text fontWeight="bold">Slim Shady</RichLog.Text>
  </RichLog.Fragment>,
);

Output:

If you want to separate text lines, you use the separate-prop:

RichLog.log(
  <RichLog.Fragment>
    <RichLog.Text separate>First line</RichLog.Text>
    <RichLog.Text fontWeight="bold">Second line</RichLog.Text>
  </RichLog.Fragment>,
);

Output:

<RichLog.Table />

Component for rendering data to table.

RichLog.log(<RichLog.Table data={{ foo: true, bar: 1 }} />);

Output:

<RichLog.Group />

Component for grouping logs.

RichLog.log(
  <RichLog.Group
    header={
      <RichLog.Text fontSize="20px" fontFamily="monospace" background="black" color="white">
        Collapsed group
      </RichLog.Text>
    }
  >
    <RichLog.Text>I'am a text inside group</RichLog.Text>
  </RichLog.Group>,
);

Output:

<RichLog.Img />

Component for rendering images and gifs.

RichLog.log(
  <RichLog.Fragment>
    <RichLog.Img height="60px" width="60px" src="https://c.tenor.com/fFntTHJYFPMAAAAC/random.gif" marginRight="8px" />
    <RichLog.Img height="60px" width="60px" src="https://picsum.photos/120/120" />
  </RichLog.Fragment>,
);

Output:

<RichLog.SVG />

Component for rendering svg icons.

RichLog.log(
  <RichLog.SVG height="60px" width="60px">
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 24 24"
      width="24"
      height="24"
      stroke="white"
      strokeWidth="2"
      fill="none"
      strokeLinecap="round"
      strokeLinejoin="round"
    >
      <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
      <line x1="12" y1="9" x2="12" y2="13"></line>
      <line x1="12" y1="17" x2="12.01" y2="17"></line>
    </svg>
  </RichLog.SVG>,
);

Output:

<RichLog.Box />

Component for rendering boxes.

RichLog.log(
  <RichLog.Fragment>
    <RichLog.Box background="red" borderRadius="50%" width="20px" height="20px" marginRight="4px" />
    <RichLog.Box background="yellow" borderRadius="50%" width="20px" height="20px" marginRight="4px" />
    <RichLog.Box background="green" borderRadius="50%" width="20px" height="20px" />
  </RichLog.Fragment>,
);

TODO

  • [ ] Safari support
  • [ ] Styled tables

License

rich-log is WTFPL licensed.