How to use the @tarojs/taro.pxTransform function in @tarojs/taro

To help you get started, we’ve selected a few @tarojs/taro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qit-team / taro-yanxuan / src / pages / item / item.js View on Github external
render () {
    const { itemInfo } = this.props
    const { itemDetail = {} } = itemInfo
    const gallery = [
      itemInfo.listPicUrl,
      itemDetail.picUrl1, itemDetail.picUrl2, itemDetail.picUrl3, itemDetail.picUrl4
    ].filter(i => i)
    const height = getWindowHeight(false)
    // XXX RN 的 transform 写法不同,这块可以统一放到 @utils/style 的 postcss() 中处理
    const popupStyle = process.env.TARO_ENV === 'rn' ?
      { transform: [{ translateY: Taro.pxTransform(-100) }] } :
      { transform: `translateY(${Taro.pxTransform(-100)})` }

    if (!this.state.loaded) {
      return 
    }

    return (
github qit-team / taro-yanxuan / src / pages / user-login / user-login.js View on Github external
render () {
    const BUTTON = {
      marginTop: Taro.pxTransform(30)
    }

    return (
github NervJS / taro-ui / src / components / divider / index.js View on Github external
render () {
    const {
      className,
      customStyle,
      content,
      height,
      fontColor,
      fontSize,
      lineColor,
    } = this.props

    const rootStyle = {
      height: height ? `${Taro.pxTransform(height)}` : ''
    }

    const fontStyle = {
      'color': fontColor,
      'font-size': fontSize ? `${Taro.pxTransform(fontSize)}` : ''
    }

    const lineStyle = {
      'background-color': lineColor
    }

    return (
github apersonw / taro-mall / client / src / components / CustomImage.js View on Github external
render() {
    let { src, width = 0, height = 0, className, mode = 'scaleToFill', onClick, style } = this.props;
    width = width && Taro.pxTransform(width);
    height = height && Taro.pxTransform(height);

    if (style == null || typeof style === 'undefined') {
      style = '';
    }
    return (
      <img src="{src}" height="" style="{'display:" mode="{mode}">
    );
  }
}
github NervJS / taro-ui / src / components / indexes / index.js View on Github external
const {
      className,
      customStyle,
      animation,
      topKey,
      list,
    } = this.props
    const {
      _scrollTop,
      _scrollIntoView,
      _tipText,
      _isShowToast,
      isWEB
    } = this.state

    const toastStyle = { minWidth: Taro.pxTransform(100) }
    const rootCls = classNames('at-indexes', className)

    const menuList = list.map((dataList, i) =&gt; {
      const { key } = dataList
      const targetView = `at-indexes__list-${key}`
      return 
    })

    const indexesList = list.map(dataList =&gt; (
github qit-team / taro-yanxuan / src / pages / cart / cart.js View on Github external
if (!this.state.loaded) {
      return 
    }

    if (!this.state.login) {
      return (
        
      )
    }

    return (
github NervJS / taro-ui / src / components / divider / index.js View on Github external
className,
      customStyle,
      content,
      height,
      fontColor,
      fontSize,
      lineColor,
    } = this.props

    const rootStyle = {
      height: height ? `${Taro.pxTransform(height)}` : ''
    }

    const fontStyle = {
      'color': fontColor,
      'font-size': fontSize ? `${Taro.pxTransform(fontSize)}` : ''
    }

    const lineStyle = {
      'background-color': lineColor
    }

    return (
github NervJS / taro-ui / src / components / float-button / index.js View on Github external
constructor () {
    super(...arguments)
    const isWEAPP = Taro.getEnv() === Taro.ENV_TYPE.WEAPP
    const offset = isWEAPP ? parseInt(Taro.pxTransform(this.props.size).replace('rpx')) : this.props.size
    const windowWidth = isWEAPP ? Taro.getSystemInfoSync().windowWidth : window.innerWidth
    const windowHeight = isWEAPP ? Taro.getSystemInfoSync().windowHeight : window.innerHeight
    this.state = {
      position: {
        left: `${(windowWidth * 0.85) - offset}px`,
        top: `${(windowHeight * 0.90) - offset}px`
      },
      offset,
      movableRangeWidth: (windowWidth * 0.95) - (2 * offset),
      movableRangeHeight: (windowHeight * 0.95) - (2 * offset),
      backgroundColor: this.props.backgroundColor,
      isWEAPP,
    }
  }
github NervJS / taro-ui / src / components / icon / index.js View on Github external
render () {
    const {
      customStyle,
      className,
      prefixClass,
      value,
      size,
      color
    } = this.props

    const rootStyle = {
      fontSize: `${Taro.pxTransform(parseInt(size) * 2)}`,
      color
    }

    const iconName = value ? `${prefixClass}-${value}` : ''
    return (
      
    )