2.1.0 • Published 2 years ago

style-factory v2.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

style-factory

npm version License: MIT issues downloads Code Coverage Node.js Package

将 style 文本内容转化为 function 函数,可附加 prefix、换算 rpx、:host 选择符的操作。

作为小程序样式转换使用

Usage

import styleFactory from 'style-factory';

const code = styleFactory(css);

Input

/* 注释 */
.foo {
  color: red;
  height: 100rpx;
}

Output

function styleFactory(options) {
  const prefix = options.prefix || '';
  const rpx = options.rpx;
  const host = options.host || 'host-placeholder';
  return (
    '/* 注释 */\n.' +
    prefix +
    'foo{\n    color: red;\n    height: ' +
    rpx(100) +
    'px' +
    ';\n}'
  );
}

调用该方法

styleFactory({
  prefix: 'foo--',
  rpx: function (size) {
    return size * 0.5;
  },
});

输出以下内容

/* 注释 */
.foo--foo {
  color: red;
  height: 50px;
}
2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.6

2 years ago

2.1.0

2 years ago

2.0.0-next.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

3.0.0-next.2

2 years ago

3.0.0-next.1

2 years ago

3.0.0-next.4

2 years ago

3.0.0-next.3

2 years ago

3.0.0-next.0

2 years ago

3.0.0-next.6

2 years ago

3.0.0-next.5

2 years ago

2.0.0-next.0

3 years ago

2.0.0-next.1

3 years ago

1.0.0-next.0

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

4 years ago