0.1.0 • Published 7 years ago

weex-style-validator v0.1.0

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
7 years ago

Weex Style Validator

Check if weex components support the specific styles.

API

  • configure: Function config the validator
  • validateStyles: Function validate component styles

Usage

Validate styles

const validator = require('weex-style-validator')

/**
 * Validate style object.
 * @param {Object} style map
 */
validator.validateStyles(styles)

/**
 * Validate styles for specific component.
 * @param {String} componentName
 * @param {Object} style map
 */
validator.validateStyles(componentName, styles)

Config the validator

const validator = require('weex-style-validator')

/**
 * Config the validator.
 * @param {Object} configure
 */
validator.configure({
  // Whether to suppress the warnings in the console.
  // Default is false, will print warnings in the console by default.
  silent: true,

  // Executed when an illegal style is encountered
  onfail: function (message) {
    // do something ...
  }
})

Common Error Output

Weex use display: flex; by default:

[Style Validator] Not support to use the "display" style property.

Weex doesn't support short-hand properties currently:

[Style Validator] Not support to use the "margin" style property.
[Style Validator] Not support to use the "border" style property.
[Style Validator] <div> is not support to use the "margin" style property.
[Style Validator] <image> is not support to use the "padding" style property.