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

react-manhattan

v0.2.2

Published

Atomic react elements for quick prototyping. This is probably a terrible idea.

Downloads

52

Readme

manhattan

Atomic react elements for styling and quick prototyping. This is probably a terrible idea.

Build Status Code Climate NPM Dependencies Status npm version GitHub license

install

$ npm i react-manhattan

quick example

import React from 'react'
import { Flex, TextCentered, TextRight } from 'react-manhattan'

const MyComponent = () =>
  <Flex>
    <TextCentered>Heya!</TextCentered>
    <TextRight>This text is so right aligned!</TextRight>
  </Flex>

export default MyComponent

intro

Manhattan asks the question "can simple styling needs be easily fulfilled by importing and using a component rather than writing new CSS or styles in JS?"

Under the hood, Manhattan is really just a simple map between an atomic styling declaration and a React component. In general it follows the form

for a CSS declaration:

 position: 'absolute'

we get a React component

<Absolute>
  Heya. Look at me, I'm an absolutely positioned element
</Absolute>

which results in a DOM node that looks like

<div style="position: 'absolute'">
  Heya. Look at me, I'm an absolutely positioned element
</div>

Components generally take the name of the css property value, but for clarity sometimes part of the css property is included like in the case of <TextCentered>Text</TextCentered>

props

Manhattan components can also accept other styling props. These get merged with the originating styles. This is mostly for convenience. If you find yourself adding a ton of style properties to a Manhattan element then maybe reconsider using the element. Or not. It's your app, you do you.

<Flex alignItems='center'>
  <div>Heya</div>
</Flex>

why?

if you're familiar with atomic classnames in css, they help a ton with keeping your css maintainable and make quick prototyping without side effects really easy.

a quick atomic classnames example:

.flex { display: flex; }
/* a simple class for adding a level of margin on the x axis */
.mx1 {
  marginLeft: 1em;
  marginRight: 1em;
}
<div class="flex">
  <div class="mx1">
    My very good content with left and right margin
  </div>
  <div>Some additional very good content</div>
</div>

avaliable components

  • Border
    • <Bordered />
    • <BorderTop />
    • <BorderBottom />
  • Display
    • <Block />
    • <Flex />
    • <None />
  • Margin
    • <M1 />
    • <Mx1 />
    • <My1 />
  • Position
    • <Relative />
    • <Absolute />
    • <Fixed />
  • TextAlignment
    • <TextLeft />
    • <TextCentered />
    • <TextRight />

open questions

  • Are there enough cases where a single style property (or just one or two classes) is used that using a Manhattan component is worth it. (Positioning contexts seem like a good example of when its particularly useful?)

  • Since React is built for composition it feels natural to try and nest Manhattan components to achieve a desired style. But obviously this results in un-necessary DOM to achieve the equivelant class based style. Do styling props provide enough of an escape hatch without adding too much complexity?

  • How can we allow for customization of things like colors and text sizes on a global level?

  • How much of this is really just a desire to make JSX look nicer by removing styling and className props?

inspiration

A lot of this is inspired by the work of Brent Jackson, Adam Morse, and Pete Hunt and their projects basscss, tachyons, and jsxtyle respectively.

hello yes I'm looking for more badges?

js-standard-style

why is it named Manhattan?

Its a not so clever reference to the Manhattan project. (You probably already knew that)