1.0.1 • Published 8 months ago

unitless v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

unitless

This package provides the list of unitless CSS properties (accepts a number but is not a distance). The list of properties that match this criteria is from react-dom-bindings's isUnitlessNumber.js.

As of 1.0.0, the list is from 18.2.0 of react-dom-bindings.

Usage

unitless has two names exports: unitlessNumbers and isUnitlessNumber.

// unitlessNumbers is a Set
import { unitlessNumbers, isUnitlessNumber } from "unitless";

const property = "property";
const value = 1;

if (unitlessNumbers.has(property)) {
  return value;
} else {
  return value + "px";
}

// or more succinctly

return unitlessNumbers.has(property) ? value : value + "px";

// alternatively, using isUnitlessNumber

return isUnitlessNumber(property) ? value : value + "px";

Versioning

Any breaking changes to the API will constitute a major version.

Updates to the properties list will constitute a minor version.

Contributing

To install bun:

https://bun.sh/docs/installation

To install dependencies:

bun install

To build:

bun run build

License

Copyright © 2023 Alexander Liu, Meta Platforms, Inc. and affiliates

MIT License

0.0.1

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

8.0.11

1 year ago

99.10.9

2 years ago