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

acoru

v0.0.3

Published

To make an accordion UI

Downloads

7

Readme

Acoru

XO code style

screenshot

To make an accordion UI.

Install or Download

yarn add acoru
npm i -S acoru

Or access to releases page. Then, download the latest version.

Usage

HTML

if you read as a separate file.

<script src="https://unpkg.com/acoru/dist/acoru.js"></script>
<!-- or -->
<script src="/path/tp/acoru.js"></script>

Markup and script are like this.

<div id="vertical" data-acoru-axis="vertical" data-acoru-mode="single">
  <div data-acoru-for="name1">name1</div>
  <div data-acoru-id="name1" style="display:none">...</div>
  <div data-acoru-for="name2">name2</div>
  <div data-acoru-id="name2" style="display:none">...</div>
</div>

Special attributes are as follows.

data-acoru-for, data-acoru-id

Like label[for] and input[id], for example click on [data-acoru-for=name] to open [data-acoru-id=name].

[data-acoru-id] is first hidden by [style='display:none'].

data-acoru-axis (default: vertical)

Whether to open vertically or horizontally.

data-acoru-mode (default: single)

Try to open only one, Do you want to open multiple.

data-acoru-parent (option)

If an ancestor has an element that has this element, it is considered a parent. Otherwise, we consider the next higher element as parent.

About class

The following classes come with timing.

  • open Before opening, open element
  • opened After opening, open the element
  • close After closing, close element

Especially in the case of markup like this, I think that it will be necessary to control the style using classes.

<div id="vertical">
  <!-- One deep -->
  <div>
    <div data-acoru-for="name1">name1</div>
    <div data-acoru-id="name1" style="display:none">...</div>
  </div>
  <div>
    <div data-acoru-for="name2">name2</div>
    <div data-acoru-id="name2" style="display:none">...</div>
  </div>
</div>

About overflow

When the parent ([data-acoru-parent]) element is in overflow:hidden state, the size of each accordion item is adjusted so that it does not jump out of parent.

JavaScript

Example

// For es
// import Acoru from 'acoru';

const acoru = new Acoru(document.getElementById('vertical'));
acoru.init();
acoru.on('opened', collection => console.log('opened ' + collection.name));
new Acoru(baseElement = document)

Process elements below baseElement.

acoru.init()

Initial processing.

acoru.on(type, cb)

Register a function to be executed at a certain timing. It has the following.

  • open Before opening any
  • opened After opening any
  • close Before closing any
  • closedAfter closing any

acoru.open(name)

Open the name item.

acoru.close(name)

Close the name item.

acoru.teardown()

Discard processing related to Acoru

Example

  • test/fixtures/
  • example/webpack/

LICENSE

The MIT License (MIT)

Copyright (c) 2017 nju33 [email protected]