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

carden

v4.0.0

Published

Create cards in the terminal

Downloads

69

Readme

carden Build Status

Create cards in the terminal. Forked from sindresorhus/boxen. Options are the same, but can be configured independently for the header or content.

screenshot

Install

$ npm install carden

Usage

const carden = require('carden');

console.log(carden('unicorn', 'unicorn', {padding: 1}));
/*
┌─────────────┐
│             │
│   unicorn   │
│             │
│             │
│   unicorn   │
│             │
└─────────────┘
*/

console.log(carden('unicorn', 'unicorn', {padding: 1, margin: 1, borderStyle: 'double'}));
/*
   ╔═════════════╗
   ║             ║
   ║   unicorn   ║
   ║             ║
   ║             ║
   ║   unicorn   ║
   ║             ║
   ╚═════════════╝
*/

API

carden(header, content, [options])

header

Type: string

Text inside the header area.

content

Type: string

Text inside the content area.

options

Type: object

The same options object used for boxen, but the header and content can also be configured with their own options object.

Examples

// card with blue background for header
console.log(carden('Chidi',
  'You put the Peeps in the chili \npot and it makes it taste bad.', {
  header: {
    backgroundColor: 'blue'
  }
}));

Chidi card

// card with different padding, border colors, and border styles
console.log(carden('Tahani',
  `It's not about who you know. Enlightenment comes from within.

The Dalai Lama texted me that.`, {
  margin: 2, // margin can only be set globally
  header: {
    backgroundColor: 'blue',
    padding: 1
  },
  content: {
    borderStyle: 'classic',
    borderColor: 'yellow'
  }
}));

Tahani card

// card with green double border all around
console.log(carden('Eleanor',
  `That Eleanor is a better Eleanor than this one. And
that is not easy for me to say.

"You're not better than me" was my yearbook quote.`, {
  borderStyle: 'double',
  borderColor: 'green',
  header: {
    backgroundColor: 'blue',
    padding: 1
  }
}));

Eleanor card

// very customized card
console.log(carden('Jason',
  chalk.black(`I always trust dudes in bow ties. Once, this guy
in a bow tie came up to me at the gun range in a
Jacksonville bus station and said he'd give me
$600 if I put these weird turtles in my duffle
bag and brought them to Daytona Beach.

So I hotwired a swamp boat to Daytona and the guy
paid me the $600. My point is, you always trust
dudes in bow ties.`), {
  padding: 1,
  header: {
    backgroundColor: 'blue',
    borderStyle: 'classic',
    borderColor: 'cyan',
  },
  content: {
    backgroundColor: 'white',
    borderStyle: 'round',
    borderColor: 'yellow'
  }
}));

Jason card

Borders

Borders are the same as sindresorhus/cli-boxes, with two additions (subtractions?):

  • blank - replaces border characters with spaces, so the card lines up with cards that have borders

  • none - border is completely removed, no characters in its place

// single
console.log(carden('Janet',
  `Is it an error to act unpredictably and behave in
ways that run counter to how you were programmed
to behave?`, {
  borderStyle: 'single',
  padding: 1,
  header: {
    backgroundColor: 'green'
  },
  content: {
    backgroundColor: 'blue'
  }
}));

// blank
console.log(carden('Janet',
  `Is it an error to act unpredictably and behave in
ways that run counter to how you were programmed
to behave?`, {
  borderStyle: 'blank',
  padding: 1,
  header: {
    backgroundColor: 'green'
 },
  content: {
    backgroundColor: 'blue'
  }
}));

// none
console.log(carden('Janet',
  `Is it an error to act unpredictably and behave in
ways that run counter to how you were programmed
to behave?`, {
  borderStyle: 'none',
  padding: 1,
  header: {
    backgroundColor: 'green'
  },
  content: {
    backgroundColor: 'blue'
  }
}));

Janet