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

@siteimprove/alfa-css

v0.93.8

Published

Implementations of the core CSS syntax and value types

Downloads

3,318

Readme

Package @siteimprove/alfa-css

Description

This package implements support for CSS syntax and values.

Package organisation

(all paths are relative to src/)

  • syntax: Support for the CSS syntax and parsers for the basic tokens.
  • unit: Model of CSS units. We currently only support angle and length.
  • calculation: Model of CSS calculations. This contains base (non calculated) numeric types, and calculations themselves.
  • value: Model for the CSS values themselves. This includes another copy of the numeric types, but this time including potential calculation. Most of the actual work is likely to involve this directory. It is further split into the various types.

Value structure

The Value type contains the shared structure of CSS values. Most notably:

  • Value have a type string parameter that can be used as a discriminating union field (e.g. in a switch statement). However, it may sometimes be more convenient to use the Foo.isFoo type predicates, notably in combination with a Selective construct.
  • Value have a CALC type parameter that indicates whether they may contain calculations (i.e. if CALC is false, we guarantee there is no calculation, but if CALC is true, we do not guarantee the presence of a calculation). This parameter can be accessed programmatically with the Value#hasCalculation() type predicate.
  • Value have a Foo.Canonical subtype representing the canonical form of the value. This includes resolving calculations, converting units to their canonical units (e.g. px for lengths), and otherwise converting formats (e.g. canonical colors are in RGB format).
  • Value have a #resolve() method to resolve calculations and provide the same value in its canonical form. These may need a resolver to help with some types (mostly lengths and percentages). The type system should ensure that #resolve() is always called with the correct resolver. Value that need a resolver also have a Foo.Resolver type to declare it.
  • For many Value, percentage resolution depends on data Alfa does not always have (usually, size of boxes). These also have a Foo.PartiallyResolved type, and a Foo.partiallyResolve() function (with its Foo.PartialResolver interface). Note that partially resolved values will possibly include calculations, including mixed ones (length-percentage) and that needs to be handled downstream (e.g. with the computed values of the CSS properties using these).
  • Value implement the Resolvable interface, which state into what they resolve, and which resolver they need.