1.1.5 • Published 5 years ago

@iceland/intelligent-code v1.1.5

Weekly downloads
22
License
MIT
Repository
github
Last release
5 years ago

Intelligent Code

将 json 转化为代码,使用方式参考 test.

Usage

Source Data(see /lib/interfaces.d.ts):

const sourceData = {
    id: 'div-1',
    type: 'div',
    children: [
        {
            id: 'spn-1',
            type: 'span',
            children: '你的名字:'
        },
        {
            id: 'Input-2',
            type: 'Input',
            npmName: '@icedesign/base',
            props: {
                style: {
                    fontSize: 28,
                    fontWeight: 'bold'
                },
                value: '阿里巴巴'
            }
        }
    ]
};

Use intelligent-code:

const intelligentCode = require('@ali/iceland-intelligent-code');
const result = intelligentCode(sourceData);

/*
{
  codeFileTree: {
    'index.jsx': ``,
    'stores': {},
    'actions': {}
  },
  entryFileName: 'index.jsx'
  deps: []
}
*/

The expected output:

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Input } from '@icedesign/base';

class div1 extends Component {

    render() {
        return (
            <div>
                <span>
                    你的名字:
                </span>
                <Input style={styles.yourNameInput} value="阿里巴巴" />
            </div>
        );
    }
}

const styles = {
    "yourNameInput": {
        "fontSize": 28,
        "fontWeight": "bold"
    }
};


ReactDOM.render(<div1 />, mountNode);
1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.20-alpha.1

5 years ago

1.0.20-alpha.0

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.9

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago