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

calamari

v0.1.6

Published

A core package for developing user interfaces in [React](https://github.com/facebook/react). Calamari used other calamari packages as adapters for different environments.

Downloads

8

Readme

Calamari

A core package for developing user interfaces in React. Calamari used other calamari packages as adapters for different environments.

Why calamari?

Nowdays there are a lot of ways to styling user interfaces in React. Basicly you can use only css for styling your component like this.

const Button = () => (
	<button className="button" />
);

This way have many disadvantages . Let's imagine that your interface has a lot of buttons with different color themes. Commonly it resolves like this.

const Button = ({theme}) => (
	<button className={`button button_theme_${theme}`} />
);

Button.defaultProps = {
	theme: 'white',
};

Hmm maybe add a little bit more modificators...

import React from 'react';

import 'button.css';

const Button = ({theme, size, rounded}) => (
	<button className={`
			button button_theme_${theme}
			button_size_${size}
			${rounded ? button_rounded : ''}`
		}
	/>
);

Button.defaultProps = {
	theme: 'white',
	size: 'medium',
};

I think each of you has seen something like this. We can bring classnames package or its clone to automate className generation like this.

import classnames from 'classnames';

const Button = ({theme}) => (
	<button className={classnames('button', {[`button_theme_${theme}`: true]})} />
)

Or use classnames/bind with css-modules. But also you can use Calamari like this:

import Calamari from 'calamari-web';

const Button = Calamari({class: 'button', component: 'button', mods: ['theme']});

More difficult case:

import Calamari from 'calamari-web';

const Button = Calamari({
    class: 'button',
    component: 'button',
    mods: [['theme', 'white'], 'rounded', ['size', 'medium']],
});

I think that's a good improvement, but calamari can do more things.

Feautures

For good understanding the main Calamari concepts you shoud know the main agreements of BEM: Block, Element, Modifier, Mixin. I highly recommended to look at quick start of it before we can continue.

  • Creating blocks with simple function call.
  • Add elements for it.
  • Inheritance of components via decoration components by each other.

Examples

Create common component

import Calamari from 'calamari-web';

const Button = Calamari({
    class: 'button',
    component: 'button',
    mods: [['theme', 'white'], 'rounded', ['size', 'medium']],
});

Create component with elements

import Calamari from 'calamari-web';

const ButtonBlock = Calamari({
    class: 'button',
    component: 'button',
    mods: [['theme', 'white'], 'rounded', ['size', 'medium']],
}, {
	Text: {component: 'span', mods: [['color']]},
});

And use it:

const Button = ({text, children, ...rest}) => (
	<ButtonBlock {...rest} >
		<ButtonBlock.Text {...text} >{children}</ButtonBlock.Text>
	</ButtonBlock>
);

...
render() {
	return (
		<Button theme="black" rounded text={{color: 'black'}}>
			Hello world button
		</Button>
	)
}

It will return to us smth like this

<button className="button button_theme_black button_rounded button_size_medium">
	<span className="button__text button__text_color_black">Hello world button</span>
</button>

Inherit uniq button from project button

const LoginButton = Calamari({class: 'login-button', component: Button});

render() {
	return <LoginButton color="black" />
}

It will return to us smth like this:

<button className="login-button button button_size_medium" />

So you can style common button and restyle it in LoginPage css via login-button selector.

Docs

Detail docs will appear soon...

Adapters

Contribute

Calamari is under active development, if you have any idea to improve or if you found a bug, you can create an issue.

Ideas

  • Write full docs for Calamari, Calamari Web and Calamari Native.
  • Fix the text documentation
  • Css modules adapter