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

mad-separator

v1.0.0

Published

Utility to separate item vertically or horizontally.

Downloads

3

Readme

This creates separators between items with some configurations. It takes elements with display:none into consideration to ignore them and don't add extra separators.

Making An Instance

horizontal_separator = Separator.factory(
{
    mode: "horizontal",
    class: "big red"
})

horizontal_separator.separate("some_container")

vertical_separator = Separator.factory(
{
    mode: "vertical",
    class: "shiny blue"
})

vertical_separator.separate("some_other_container")

Usage

The basic workflow is creating one or several configured Separator instances to use them many times.

The typical structure of a container could be:

<div id='my_container' class='flex_row'>
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
</div>

Then to create the separators:

horizontal_separator.separate("my_container")

It could look like:

This can be ran any time, but it won't run automatically, if the content changes you must run the separate function again.

Why?

A lot of this may be done with CSS, but from personal experience I've found that route lacking for some cases, so I created my own separator mechanism. It might or might not be useful to you.

Methods

instance.separate(id or element, options:optional)

It removes any previous separators and rebuilds them. It takes items with display:none into account to not add extra separators. If an options object is received, options included there will override provided options from instantiation, but only for that execution.

instance.remove_separators(id or element)

Removes all separators.

Options

mode

Either horizontal or vertical.

html

The html inside the separators. If nothing is defined it uses a default html stucture. The default could be enough for some cases.

class

The class or classes to add to the separator element.

height

The height of the separator item. Only applicable for horizontal mode.

width

The width of the separator item. Only applicable for vertical mode.

margin_top

The margin-top of the separator item. Only applicable for vertical mode.

margin_bottom

The margin-bottom of the separator item. Only applicable for vertical mode.

margin_left

The margin-left of the separator item. Only applicable for horizontal mode.

margin_right

The margin-right of the separator item. Only applicable for horizontal mode.

font_size

The font-size of the separator item.

line_height

The line-height of the separator item.

Defaults

if(options.mode === undefined)
{
    options.mode = "horizontal"
}

if(options.html === undefined)
{
    if(options.mode === "horizontal")
    {
        options.html =  `
        <div class="separator-horizontal-container">
            <div class="separator-horizontal-line"></div>
        </div>`
    }

    else if(options.mode === "vertical")
    {
        options.html = `
        <div class="separator-vertical-container">
            <div class="separator-vertical-line"></div>
        </div>`
    }
}

if(options.class === undefined)
{
    options.class = ""
}

if(options.height === undefined)
{
    options.height = "1em"
}

if(options.width === undefined)
{
    options.width = "1em"
}

if(options.margin_top === undefined)
{
    options.margin_top = "1em"
}

if(options.margin_bottom === undefined)
{
    options.margin_bottom = "1em"
}

if(options.margin_left === undefined)
{
    options.margin_left = "1em"
}

if(options.margin_right === undefined)
{
    options.margin_right = "1em"
}

if(options.font_size === undefined)
{
    options.font_size = "1em"
}

if(options.line_height === undefined)
{
    options.line_height = "1em"
}