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

hyperscript-adapter-modules

v1.2.2

Published

A package for modules that use hyperscript-adapter. Supports CSS modules and various CSS in JS tools.

Downloads

9

Readme

Hyperscript-Adapter-Modules

This library is a utility for having components and modules in JavaScript with less boilerplate and support for CSS Modules / JSS.

Install

Simpily run:

npm install --save hyperscript-adapter-modules

hyperscript-adapter will have to be installed for this to work.

Loading

Once this library is installed, load the file using a script or requirejs.

Script loading:

<script src="path/to/hyperscript-adapter-modules/index.min.js"></script>

Requirejs loading:

requirejs(['path/to/hyperscript-adapter-modules/index.min.js'], HTMLModuleCreator => {
    /* Do stuff with HTML */
});

If requirejs is loaded before the script, then HTML is exported:

requirejs(['hyperscript-adapter-modules'], HTMLModuleCreator => {
    /* Do stuff with HTML */
});

Settings

Settings can be applied as the second argument to HTMLModuleCreator. For example:

HTMLModuleCreator(HTML, {
    fallbackClasses: true,
});

The HTML instance can also have settings applied to it. HTMLModuleCreator will override the classResolver and tagResolver though.

fallbackClasses: false

This setting controls whether to make $.foo go to the global class foo if it is not within one of the modules loaded. While this may be useful if there are important globals, this is disabled by default as it can be the cause of bugs.

partialApply: false

This setting controls whether the function input should be partially applied. If this setting is activated, the component function is partially applied. For example:

modWithPartialApplyTrue('name', (css, mod, $, argOne, argTwo) => doStuff());
// Would be equivalent to
mod('name', (css, mod, $) => (argOne, argTwo) => doStuff());

hyphenatedComponents: false

This setting controls whether component creation is hyphenated. If this is activated, $.fooBar would reference the component with name foo-bar instead of the component with name fooBar.

hyphenatedClasses: true

This setting controls whether to hyphenate classes loaded with css. If true, it will query based on the hyphenated version of the input class. For example, fooBar would become foo-bar.

useDefault: false

This setting controls whether to use the default property of the css stylesheets passed in. Activate this if you are using commonjs in a webpack project.

Initialization

The exported HTMLModuleCreator is a function that takes in the current HTML instance and an object of settings and outputs the actual module creator function.

The simplest way to initialize it is:

const mod = HTMLModuleCreator(HTML);

Usage

const stylesheet = {
    foo: 'foo-hash',
    bar: 'bar-hash',
};
const SomeComponent = mod('SomeComponent', (css, use, $) => {
    css(stylesheet);
    return $.div.foo($.div.bar());
});
const OtherComponent = mod('OtherComponent', (css, use, $) => {
    use(SomeComponent);
    return $.SomeComponent();
});

The css function allows the importing of stylesheets. The use function allows the importing of other components.

Each call to mod returns an object, with two keys: the name of the component (the first argument), and the component (the return value of the function). The component is paired up in this way as to allow use to pick up the name as well.

The mod function also has an addGlobal method which adds a global component, which can be seen by all component declarations.

The full usage can be seen in tests.js.