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

riccio

v1.1.0

Published

Adaptive grid view with expanding info box.

Downloads

6

Readme

Riccio

Adaptive grid view whith expanding info box.

Have you ever seen the iTunes Album view or the Google Image grid? With this little JavaScript you can implement those view in no time.

Quick Start

Start using Riccio in three steps.

  1. Download latest Riccio package from Github. Add dist/riccio.min.js and dist/riccio.min.css to your web page.
<link href="/path/to/riccio/dist/riccio.min.css" rel="stylesheet" media="screen">
<script src="/path/to/riccio/dist/riccio.min.js"></script>
  1. Set your grid layout in CSS. Using the ::before selector you can set the number of items to print in a row. Change the layout using the media queries.
@media (max-width: 560px) {
  .album-view::before {
    content: '2';
  }
}

@media (min-width: 561px) {
  .album-view::before {
    content: '5';
  }
}
  1. Initialize Riccio in a custom script.
var element = document.querySelector( '.album-view' );
// Initialize Riccio.
var riccio = new Riccio( element, {
  itemSelector: '.album',
  popSelector: '.album__track-list',
} );

That's it. You’re all set to start using Riccio.

Options

Riccio accepts an object of options. itemSelector and popSelector are required, while mediaQueries and perRow will be calculated from your CSS.

// Default options.
var riccio = new Riccio( element, {
  itemSelector: '', // A valid CSS selector.
  popSelector: '', // A valid CSS selector.
  perRow: true, // This value will be calculated from your CSS.
  mediaQueries: true // True, false or an array of string representing the media queries.
} );
<div class="album-view"> <!-- The Riccio's element -->
  <div class="album"> <!-- The item selector -->
    <img src="#">
    <h3 class="album__title">Album title</h3>
    <ul class="album__track-list"> <!-- The pop selector -->
      <li>Track #1</li>
      <li>Track #2</li>
      <li>Track #3</li>
    </ul>
  </div>
</div>
  • itemSelector - It's a valid CSS selector of your grid items. Riccio cuts this elements and print them into the grid item rows. The items number and pops number must be the same, otherwise Riccio returns an error.

  • popSelector - It's a valid CSS selector of your grid pops. Riccio cuts this elements and print them into the grid pop rows.

  • perRow - If set to true Riccio gets this options from your CSS. This way you can change the layout of your grid in CSS using the media queries. If you're not using media queries set this option to the number of items you want to display in a row.

  • mediaQueries - If you set this option to true, Riccio try to get media queries from your CSS. However we know that this function doesn't play nice with at-rules, such as @import or @charset. If this is your case, you can set this option to an array of media queries, or to false to completly disable the function.

// Media queries array.
var riccio = new Riccio( element, {
  mediaQueries: [
    '(max-width: 560px)',
    '(min-width: 561px)'
  ]
} );

Methods

Methods are actions done by Riccio instances.

// Instantiate new Riccio object.
var riccio = new Riccio( element, {
  itemSelector: '.album',
  popSelector: '.album__track-list'
} );

init()

Initialize a Riccio object. This function is called when a new Riccio object is instantiate, or when a breakpoint is triggered.

// Init Riccio object.
riccio.init();

buildLayout()

Builds the Riccio layout. This function is called when a Riccio instance is initialized and when a breakpoint is triggered.

// Build the layout.
riccio.buildLayout();

~~needs()~~

DEPRECATED - Will be removed in v2.0.0, buildLayout() function take cares of building your layout.

Return the number of rows you have and the number of rows you need to wrap the items. As other functions, it counts an item row and the relative pop row as a single element. So if you need two rows, it means that you need two item rows and two pop rows.

// Get the number of row you have and the number of row you need.
riccio.needs();

~~setItems( fragment )~~

DEPRECATED - Will be removed in v2.0.0, buildLayout() function take cares of building your layout.

Takes items and pops and appends them to the given fragment. The function doesn't check if there are enough rows, it's up to you provide the correct number of rows. Check setRows() function.

// Appends pop and item element to the relative rows.
riccio.setItems( fragment )

~~setRows( fragment )~~

DEPRECATED - Will be removed in v2.0.0, buildLayout() function take cares of building your layout.

Ask to needs() function how many pop rows and item rows we have. Then append the rigth number of rows to the given fragment.

// Set the rigth number of rows.
riccio.setRows( fragment );

toggle( index )

Open or close the element corresponding to the given index.

riccio.toggle( index );