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

@typestyled/core

v0.2.0

Published

Typestyled core CSS properties.

Downloads

1

Readme

@typestyled/core

Configurable core library to preserve spacing and font line heights aligned to a baseline grid.

@typestyled/core solves the problem of manually creating (global) variables to be shared across typed styles in order to preserve spacing and font line heights aligned to a baseline grid. Instead, @typestyled/core provides a configuration object that can be passed around. In addition, it also provides a few helper functions to compute line height and spacing units.

Look how easy it is to use:

import { configure } from '@typestyled/core'

const coreConfig = configure()

Features

  • Default configuration
  • Adjustable settings for custom configuration
  • Baseline grid
  • Spacing units
  • Font alignment to baseline grid
  • Line height computation function
  • Spacing unit computation function

Quick Start

The easiest way to get started with @typestyled/core is to follow along as we go through the examples.

Installing @typestyled/core

We recommend using Yarn or npm for managing front-end dependencies. If you are new to package managers, the Yarn documentation is a good place to start.

To install @typestyled/core with Yarn, run:

yarn init
yarn add @typestyled/core

To install @typestyled/core with npm, run:

npm init
npm install --save @typestyled/core

Both Yarn and npm download packages directly from the npm registry.

Enable TypeScript and Typestyle

We recommend using @typestyled libraries with TypeScript. TypeScript is a strict syntatical superset of JavaScript and adds optional static typing to the JavaScript language, and TypeStyle is a type-safe CSS-in-JS framework that works nicely with Typestyled libraries.

Hello World with TypeScript and TypeStyle

We recommend using a bundler like webpack or Browserify, so you can write modular code and bundle it together into small packages to optimize load time.

A small @typestyled/core example looks like this:

import { configure } from '@typestyled/core'
import { style } from 'typestyle'

const {
  fontSize, // 16px
  lineHeight, // 24px
  piSpacingUnit, // 2px
  omicronSpacingUnit, // 4px
  xiSpacingUnit, // 8px
  nuSpacingUnit, // 16px
  lambdaSpacingUnit, // 32px
} = configure()

const helloClass = style({
  fontSize,
  lineHeight,
  margin: `${lambdaSpacingUnit} auto`,
  padding: `${xiSpacingUnit} ${nuSpacingUnit}`,
  backgroundColor: `yellow`,
  border: `${piSpacingUnit} solid red`,
  borderRadius: xiSpacingUnit,
  boxShadow: `${xiSpacingUnit} ${xiSpacingUnit} ${omicronSpacingUnit} #888`,
  width: `300px`
})

const element = document.createElement('div')
element.innerHtml = 'Hello World!'
element.classList.add(helloClass)
document.body.appendChild(element)

This code gets the default configuration, and uses the spacing units to make a CSS class with TypeStyle's style function.

Contribute

  • Issue tracker: https://github.com/typestyled/core/issues
  • Source code: https://github.com/typestyled/core

License

Copyright © 2017 The Typestyled Authors.

Licensed under the MIT license. See LICENSE.txt in the project root for complete license information.