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

display-primitives

v0.0.10

Published

The missing `display` primitives (`<flex>`, `<grid>`, etc)

Downloads

3

Readme

Display Primitives

Tasks To Do:

  • [ ] Build new design that uses grid and an image, too. Start with Mobile.
  • [ ] Add examples for Next and Gatsby
  • [ ] Finish this readme
  • [ ] Add Social Preview in Github settings

Tasks I Might Do:

  • [ ] Consider <flex.row> and <flex.col>
  • [ ] Make importable <Flex> components with derived $- props
    • Auto-import or grobally available in tsconfig?
  • [ ] SWC plugin? https://swc.rs/docs/usage/plugins

What is this?

The browser gives us <div/> for display: block; and <span/> for display: inline;, but what about the other display values like flex and grid? This babel transform adds these missing tags/elements.e

NOTE: could also show before and after screenshots of code editor with red underlines for <flex> and such.

Before

  <div /> // display: block;
  <span /> // display: inline;
  <table /> // display: table;

  // ❌ These don't exist (notice the red squiglies)
  <flex /> // display: flex;
  <grid /> // display: grid;

After

  <div /> // display: block;
  <span /> // display: inline;
  <table /> // display: table;

  // ✅ But we can make up their existence with a Babel Transform :smile: (notice absence of red squiglies)
  <flex /> // display: flex;
  <grid /> // display: grid;

| display= | html | Display Elements | | ---------------- | --------- | ---------------- | | "block" | <div> | <block> | | "inline" | <span> | <inline> | | "flex" | :x: | <flex> | | "grid" | :x: | <grid> | | "table" | <table> | | | "inline-block" | :x: | <inlineblock> | | "inline-flex" | :x: | <inlineflex> | | "inline-grid" | :x: | <inlinegrid> |

Also added for convenience: row and column. See The Case for Row and Col for more.

| css | html | Display Elements | | ---------------------------------------- | ---- | ---------------- | | display: flex; flex-direction: row; | :x: | <row> | | display: flex; flex-direction: column; | :x: | <column> |

For convenience, we've also added <block> and <inline>, even though div and span already exist.

Getting Started

Install...

API

| Prop | Type | Description | | ---- | ------------------------------------------------------ | ------------------------------------------------------------ | | $ | "div" \| "aside" \| "main" ...etc (Default: "div") | The html tag that this element will become (at compile time) |

Limitations

$ prop is used at compile time, so it can not be a variable. I.e. you can't have a wrapper component that passes in $={props.as}.

Questions/Answers

Why Babel? Why not just make components like <Flex>?

  1. runtime perf (I assume)
  2. no import needed
  3. editor treats it (and colors it) like a normal html tag, which I like.
    1. I also like that the lowercase name (e.g. <flex>) denotes it as a leaf node in the render tree (not a compound component)