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

redliner

v0.1.3

Published

redliner is a Mocha test utility that determines if an element is obeying style guide requirements

Downloads

4

Readme

redliner

redliner is a Mocha test utility that determines if an element is obeying style requirements set by a design guide when it's rendered by a browser. This is still very much a work in progress, so if you run into any issues, please submit them.

Requirements

Node 0.12+

Dependencies

How does it work?

  1. Usage of PhantomJS to "headlessly" load a local resource that contains a full list of HTML elements*
  2. Performs a scan of the computedStyles for that element
  3. Compare the computedStyles to the properties set in .yml files and spit out any discrepancies

* This HTML page should contain all the elements you want to redline that will also use the CSS you want to test. For instance, if you have a redline for .btn and .btn-sm, then the HTML page should have an element with a .btn class and an element with a .btn-sm.

How to use redliner

Quick

  • npm install redliner --save-dev
  • Create .yml redlines in /test/ (see .yml example below)
  • Create a test file in /test/ (see redliner-test.js example below)
  • Create HTML page with elements (see HTML example below)
  • mocha test/redliner-test.js

Details

Creating redlines

In order to use redliner, you'll need at least one .yml file that is structured like the example below (filename is unimportant):

Example: btn.yml

formalName: Default Buttons
className: .btn
tests:
  - testGroup:
      testName: Padding
      paddingTop: 12px
      paddingRight: 35px
      paddingBottom: 12px
      paddingLeft: 35px
  - testGroup:
      testName: Fonts
      fontSize: 14px
      fontWeight: bold
  - testGroup:
      testName: Colors
      color: 'rgb(255, 255, 255)'
      backgroundColor: '#5596E6'

Each testGroup is a group of tests that will be run by Mocha. testGroup is composed of a testName and CSS properties that match the DOM API properties.

Requirements for testGroup:

  • testName must be set (this will be the describe of your test)
  • There must be at least one CSS property to test

Creating the test file

All .yml files should be placed inside a dedicated folder which will then be referenced in your test file. A common way to do this is to place a redlines folder in the test folder within the root directory of your app.

Example: redliner-test.js

var redliner = require('redliner'),
    path = require('path');

var config = {
  redlines: path.resolve(__dirname, 'redlines/'),
  resource: path.resolve(__dirname, '../all-elements.html')
};

redliner(config);

The config object has two properties:

  • redlines is the resolved path to where the .yml files are located
  • resource is the resolved path to where the local HTML file is located

Example directory structure of test folder:

app.js
node_modules
...
test
├── index.js
├── redliner-test.js
└── redlines
    ├── btn.yml
    ├── btnExtraSmall.yml
    └── btnSmall.yml

Creating the HTML page

Create an HTML page that contains the elements you want to redline. This page can be located anywhere in the project, but must be properly resolved in the config object.

Example: all-elements.html

<!DOCTYPE html>
<html>
  <head>
    ...
    <link rel="stylesheet" type="text/css" href="path/to/main.css">
    ...
  </head>
  <body>
    <button class="btn">Default Button</button>
    <button class="btn btn-sm">Small Button</button>
  </body>
</html>

TODOs

  • Add unit tests
  • Work on making things more modular