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

quantum

v1.0.0-alpha.12

Published

Lowest-level React components for responsive, accessible, cross-platform app development

Downloads

170

Readme

🔬 Quantum

quan·tum: any of the very small increments or parcels into which many forms of energy are subdivided

Quantum contains low-level components for building cross-platform applications in React and React Native. It aims to speed up development and allow for writing concise code.

Installation

npm install quantum@latest

Usage

import { Flex, Center, Text, Spacer, Circle, Input, QuantumProvider } from 'quantum'

const theme = {
  colors: {
    primary: '#448aff',
    secondary: '#1a1a1a'
  },
  fonts: {
    mono: 'Menlo, monospace'
  }
}

const App = () => (
  <QuantumProvider theme={theme}>
    <Flex p={8}>
      <Center w={64} h={32} p={8} bg="primary" radius={4}>
        <Text size={12} color="white">
          Testing
        </Text>
      </Center>
      <Spacer h={32} />
      <Flex dir="row">
        <Circle bg="primary" />
        <Spacer w={8} />
        <Input placeholder="test" color="secondary" fontFamily="mono" />
      </Flex>
    </Flex>
  </QuantumProvider>
)

Base Props

All Quantum components inherit the following base props: (aliases displayed in parenthesis)

  • display
  • flex
  • alignSelf
  • justifySelf
  • width (w)
  • height (h)
  • maxWidth (maxW)
  • maxHeight (maxH)
  • position (pos)
  • top (t)
  • right (r)
  • bottom (b)
  • left (l)
  • margin (m)
  • marginTop (mt)
  • marginRight (mr)
  • marginBottom (mb)
  • marginLeft (ml)
  • marginHorizontal (mx)
  • marginVertical (my)
  • padding (p)
  • paddingTop (pt)
  • paddingRight (pr)
  • paddingBottom (pb)
  • paddingLeft (pl)
  • paddingHorizontal (px)
  • paddingVertical (py)
  • color
  • background (bg)
  • backgroundColor (bgColor)
  • border
  • borderColor
  • borderRadius (radius)
  • boxShadow (shadow)
  • lineHeight
  • characterSpacing (charSpacing)

Components

<Box />

The most basic component; essentially a standard div.

<Box></Box>

Defaults:

{
  display: 'block'
}

Additional props/aliases: None

<Flex />

A basic box with flexbox styling.

<Flex dir="column" align="center" justify="space-between"></Flex>

Defaults:

{
  display: 'flex'
}

Additional props/aliases:

  • flexDirection (dir)
  • alignItems (align)
  • justifyContent (justify)

<Center />

A flexbox with defaults for aligning and justifying center.

<Center>
  <Text>I'm centered!</Text>
</Center>

Defaults:

{
  display: 'flex',
  alignItems: 'center',
  justifyContent: 'center'
}

Additional props/aliases:

  • flexDirection (dir)
  • alignItems (align)
  • justifyContent (justify)

Theming

Quantum provides theming support out of the box, through React Context.

First, create a theme file like so:

// theme.js
export default {
  colors: {
    text: '#1a1a1a',
    background: '#fff',
    primary: '#07c',
    secondary: '#05a',
    accent: '#609',
    muted: '#f6f6f6',
  },
  fonts: {
    body: 'system-ui, sans-serif',
    heading: 'system-ui, sans-serif',
    monospace: 'Menlo, monospace',
  },
  fontWeights: {
    body: 400,
    heading: 700,
    bold: 700,
  },
  lineHeights: {
    body: 1.5,
    heading: 1.125,
  },
}

Next, import QuantumProvider from Quantum, along with your theme, high up in your application:

// App.jsx
import { QuantumProvider } from 'quantum'
import theme from './theme' // the theme file you created

export default function App() {
  return (
    <QuantumProvider theme={theme}>
      // The rest of your app
    </QuantumProvider>
  )
}

To use theme values in Quantum components, just use the theme item name as a style value:

<Box bg="primary">
  <Text family="body" color="secondary" weight="heading">
    Hello Quantum!
  </Text>
</Box>

You can also access the theme object directly with the useTheme hook:

import { useTheme } from 'quantum'

export default function MyComponent() {
  const theme = useTheme()

  console.log(theme)

  return (
    <Box color={theme.colors.primary} />
  )
}

Responsiveness

Quantum adds support for responsive styling out of the box. First, make sure your theme (see Theming) has a "breakpoints" array, like so:

export default {
  breakpoints: [640, 832, 1024],
  colors: {
    // .....

With breakpoints defined in the theme, you can now pass arrays as values to style props. The value displayed will match the index of the breakpoints array based on screen size.

// 64px on <640px screens,
// 128px on <832px screens,
// 256px on <1024px screens,
// 512px on >=1024px screens
<Box w={[64, 128, 256, 512]}>