@seanchas116/cssvalue
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@seanchas116/cssvalue

A CSS value parser & serializer

TODO: detailed description

Usage

import {
  cssParser,
  Background,
  BackgroundLayer,
  URL,
  Position,
  Dimension,
  HexColor,
} from "@seanchas116/cssvalue";

const background = cssParser.background.tryParse(
  'center / contain no-repeat url("foo.svg"), #eee 35% url("bar.png")'
);

const expected = new Background({
  layers: [
    new BackgroundLayer({
      position: new Position("center", "center"),
      size: "contain",
      repeatStyle: ["no-repeat"],
      image: new URL("foo.svg"),
    }),
    new BackgroundLayer({
      position: new Position(
        { from: "left", offset: new Dimension(35, "%") },
        "center"
      ),
      image: new URL("bar.png"),
    }),
  ],
  color: new HexColor("#eee"),
});

expect(background).toEqual(expected);

background.toString(); // => the original string

Readme

Keywords

none

Package Sidebar

Install

npm i @seanchas116/cssvalue

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

76.3 kB

Total Files

59

Last publish

Collaborators

  • seanchas116