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

web-foundation

v1.28.1

Published

reusable web components for making interfaces

Downloads

7

Readme

web-foundation

reusable web components for making interfaces within postmates

How to start a frontend package

There's a lot of moving pieces required to get you programming with components before an official spec drops from the W3C, but don't fret, we've created some copypasta to help jumpstart the adventure and placed them all in the examples directory here.

First thing first, the webpack.config.js file has been abstracted out to a point where you shouldn't have to edit it at all. Just copy it into your new project. All of the configuration is consolidated into the project.config.js.

It's a little specific to how frontend projects get built within django here at postmates, but to set up your static files correctly, edit the project name to match your app name. This will make the compiled output available at /static/(js|css|img)/{project}/[entry].[ext].

Next, set up your aliases. These allow you to replace ../../../files/config.js with files/config. As code starts to morph and abstractions break down, not having your modules tied to a relative directory structure is a huge time saver.

Lastly, you have to set up your bundles, or what actually compiles. The format is loosely bundlename: path/to/kickoff.js. By adding this and running webpack, you'll find bundlename.min.js, bundlename.min.css, and [ img-file-hash ].[ext] in their respective static folders.

To make sure that the project is as universal and deployable as the next frontend project in these repos, a package.json file is also included. Mostly it's just a collection of script commands we're working to normalize around.

Creating Atoms & Components

An Atom is a base level interaction element (checkbox, switch, textarea), whereas a Component is a smashing together of atoms (address, user profile). In practice, components usually are data driven (filling out a form or something), where an atom is state driven (this component is on or off).

All components/atoms should have:

  • A unique name (enforced by directory structure)
  • A less file with the same name as the component
  • An index.js file that exports the appropriate View(s) and/or Model(s)

Things to note:

  • Filenames should be slugs. i.e. a component calld TextInput would have a folder and filename "text-input"
  • Atoms should have a named export matching the name of the React component (i.e. TextInput)
  • Components should have:
    • the View as default export (this will be re-exported at the root level as MyComponentView)
    • two named exports Model and View (these will be re-exported at the root level as MyComponent.Model and MyComponent.View)
    • Any additional named exports will be re-exported as properties of MyComponent (similar to Model and View)

Transforms

Transforms are functions that add additional functionality to our Atoms and Components. They partially serve the purpose that mixins, decorators, or component inheritance might have served. If you find yourself adding functionality to your react component that you've added before and expect to add again - consider creating a transform.

Example Usage:

import FormValidation from 'web-foundation/transforms';

// in constructor of react component
constructor(props) {
    super(props);

    FormValidation(this, /* arguments */);
}