Giter Site home page Giter Site logo

wxsshup's Introduction

Hotupdate WXSS

A tool for generating .wxmlfile inline styles, improve the efficiency of adjusting the UI.

Like this

<view class='deom-class'>data</view>
<!-- add inline style -->
<view class='deom-class' style='{{cloudStyle["deom-class"]}} '>data</view>

Feature

  • Automatically generate attribute style according to class, support ? : && || and other expression.
  • WebSocket serve to update UI

Installation

 npm install -g wxsshup

How to use

step 1.

Automatically generate styles

hotwxss <input path> [options]

output:

Success:  文件 [dome.wxml path]
Output File Path:

output file path
[WebSocket SERVER] ws://localhost:3003/updater

If there is -w option then automatically open wxsshup/backend/admin.html in the browser

step 2.

wxapp end ready to work

add style update var

Page({
  data: {
    cloudStyle:{}
  }
})

add SocketMessage function

connectStyleService() {
    wx.connectSocket({
        url: 'ws://localhost:3003/listener',
        method:"GET"
    })
    wx.onSocketMessage(this.updateStyle.bind(this))
}

updateStyle(style) {
    if (!style) return
    try {
        const s = JSON.parse((style.data || {}))

        this.setData({
            cloudStyle:s
        })

    } catch (error) {
        console.error(error);
    }
}

step 3.

update style on admin.html, enjoy.

Options

  • -o {String} Output file path (default STDOUT), support folder directory.
  • -s {String} Hotupdate Object var (default cloudStyle).
  • -c {Boolean} Cover input file (The same as -o [input file path]; -c first).
  • -c {Number} WebSocket serve listener port (default 3000).
  • -w {{Boolean}} Automatically start WebSocket serve

wxsshup's People

Contributors

leon2xiaowu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.