2.1.0 • Published 11 months ago

style-factory v2.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months 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

11 months ago

2.0.2

11 months ago

2.0.5

11 months ago

2.0.4

11 months ago

2.0.6

11 months ago

2.1.0

11 months ago

2.0.0-next.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

3.0.0-next.2

1 year ago

3.0.0-next.1

1 year ago

3.0.0-next.4

1 year ago

3.0.0-next.3

1 year ago

3.0.0-next.0

1 year ago

3.0.0-next.6

1 year ago

3.0.0-next.5

1 year ago

2.0.0-next.0

2 years ago

2.0.0-next.1

2 years ago

1.0.0-next.0

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago