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

@xtayr/corner-label

v1.0.0

Published

Responsive labels appearing as ribbons around the corner of their parent

Downloads

3

Readme

Corner label

from 360 bytes minified & gzipped

Attention-seeking labels for when generic, horizontal titles just aren't enough.

<span class="corner-label-container">
  <span class="corner-label">
    I'm a default label!
  </span>
  
  <span class="corner-label corner-label--top-right">
    I'm up on the top right!
  </span>
</span>

<span class="corner-label-container corner-label-container--tight">
  <span class="corner-label corner-label--dark">
    I'm all dark and tight…
  </span>
</span>

Why 2 divs for this simple little label, you ask?

Well, the first, containing span crops the corners off've the labels, making them look that awesome labely shape and not like big blocks clawing onto your container. That's why.

Notice that, because the container is the one controlling the cropping, you can have as many of the same tightness labels inside of a single container as you'd like! Neato… right? right? right?

Using your own colours in your own CSS files

Make sure the parent of the labels is position: relative | absolute | fixed;.

Use the css/corner-labels.css file directly for instant super-yellow and garish-red (--dark) labels.

Or, better still, set the $corner-label-x variables to your hearts' desire and then use:

@import "path/to/tools/_print-all-label-styles";

$corner-label-colors: (
  default: (
    color: black,
    background-color: yellow,
    hover-background-color: orange,
    shadow-color: darkorange,
  ),

  dark: (
    color: white,
    background-color: blue,
    hover-background-color: darkblue,
    shadow-color: navy,
  ),
);

@include print-all-label-styles;

Customisation

Colours

$corner-label-colors

Often you won't want to use bright yellow and medium blue banners. (We get it. Managers can be super uptight about branding an all that. It's cool, we've got ya back!)

This accepts an object which describes all the colours of label you'll want to use in your app.

For example, if you only have one label colour:

$corner-label-colors: (
  colour-class-suffix: (
    color: $color,
    background-color: $background-color,
    hover-background-color: $hover-background-color,
    shadow-color: $shadow-color,
  ),
);

colour-class-suffix is the secondary class you would use on your label in the HTML.
ie. <span class="corner-label corner-label--colour-class-suffix">

  • color is the text colour of the label
  • background-color the base background colour of the label
  • hover-background-color the background colour of the label when hovered - ignored if $corner-label-change-background-on-hover is false
  • shadow-color the background colour of label folds

Selectors

$corner-label-label-selector
$corner-label-container-selector

I heard you came to us to fix your styles, not dirty up your beautiful HTML with our dirty, dirty classes. That's ok. we can help! …maybe …at least a little.

You'll still need both of the elements, but at least you can change the base classes to better fit the rest of your code.

Try something like:

For example, if you only have one label colour:

@import "path/to/tools/_print-all-label-styles";

$corner-ribbon-ribbon-selector: "i";
$corner-ribbon-container-selector: "b";

@include print-all-label-styles;

And you can cut your markup down to as little as:

<b><i>Look at my ribbons!</i></b>

However, please bear in mind that in order to use colours and tightnesses other than the default you'll need to use .classes as the selectors.

plus, disregaring that fact, this markup is horribly unreadable…

Alignment

You don't like your labels on the top left? Oh, come on. … ok, fine. We'll allow you to move it to the top right.

Use this markup instead:

<span class="corner-label-container">
  <span class="corner-label corner-label--dark  corner-label--top-right">
    Look at my labels!
  </span>
</span>

What's that you say? Your labels are mostly top-right, so you don't want to type all of that? Ok, cool, then revert your markup back to the default and add this variable to your sass:

@import "path/to/tools/_print-all-label-styles";

$default-alignment: top-right;

@include print-all-label-styles;

You what? Your labels are ALWAYS top-right, so you don't even want to include the (5 lines of) CSS for the top left? I'm still with ya! Do this instead:

@import "path/to/tools/_print-all-label-styles";

@include print-label-styles-for(top-right);

On the bottom, you say? Well… do WE have a solution for you?!

… no. No is the answer there. If enough requests come in, I'll look into it, though!

MHOAR OPTIONS!!!

Whoa! Ha… you're getting a little excited there… and just a tad scary… could you brush your teeth before you do that again, please?

There actually ARE more options… but I'll let you find them for yourself as they're all quite edge case and, hopefully, quite easy to decipher.

Look through the files in scss/settings and you should be flying.

License

Copyright © 2018 Brook Jordan Licensed under the MIT license.