Skip to content

Библиотека для конвертирования CSS в объект JS.

License

Notifications You must be signed in to change notification settings

sedlab/css-to-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jul 11, 2023
3dd6dc0 · Jul 11, 2023

History

22 Commits
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023
Jul 11, 2023

Repository files navigation

css-to-object

Библиотека для конвертирования CSS в объект JS.

Установка

npm install sedlab/css-to-object#latest --save или yarn add sedlab/css-to-object#latest

Использование

ES6

import { cssToObject } from "css-to-object";

ES5

const { cssToObject } = require("css-to-object");

Пример

cssToObject(`
  height: 800px;
  background-color: #f6f4e6;
  #1233 .class-name {
    height: 800px;
    background-color: #f6f4e6;
  }
  @media screen and (max-width: 1199px) {
    #1233 .class-name {
      height: 800px;
      background-color: #f6f4e6;
    }
  }
  @media screen and (max-width: 1199px) {
    #1234 .class-name {
      height: 800px;
      background-color: #f6f4e6;
    }
    #1234 .class-name {
      width: 100%;
    }
  }
`, { numbers: true, camel: true });

Результат:

{
  "height": 800,
  "backgroundColor": "#f6f4e6",
  "#1233 .class-name": { "height": 800, "backgroundColor": "#f6f4e6" },
  "@media screen and (max-width: 1199px)": {
    "#1233 .class-name": { "height": 800, "backgroundColor": "#f6f4e6" },
    "#1234 .class-name": { "height": 800, "backgroundColor": "#f6f4e6", "width": 100 }
  }
}

About

Библиотека для конвертирования CSS в объект JS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published