An open API service indexing awesome lists of open source software.

https://github.com/ud-ud/layout

Generate UI given a set of configuration and render it in HTML ,SVG or CANVAS
https://github.com/ud-ud/layout

Last synced: 23 days ago
JSON representation

Generate UI given a set of configuration and render it in HTML ,SVG or CANVAS

Awesome Lists containing this project

README

        

# Layout

Creates a html layout from a given configuration

### Prerequisites

```
node
```

### Installing

Clone the repository and run the following command

```
npm install
```
After the installation all necessary library will be ready for you to directly start your developement

## Build you app
```
npm run build
```

## Running the tests

```
npm run test
```

## Show Test Coverage

```
npm run cover
```

## Usage
```
const {
Layout,
DummyComponent
} = layout

const width = 600
const height = 600
const skeletonType = 'html'

const component1 = new DummyComponent(10, {
width: width / 2,
height: width / 2
})

const component2 = new DummyComponent(10, {
width: width / 2,
height: width / 2
})

const component3 = new DummyComponent(10, {
width: width / 2,
height: width / 2
})

const component4 = new DummyComponent(10, {
width: width / 2,
height: width / 2
})

const layoutDefinition = {
host: null,
cut: 'v',
ratioWeight: 1,
lanes: [{
host: null,
cut: 'h',
ratioWeight: 1,
preferred: true,
lanes: [
{
host: component1,
cut: null,
ratioWeight: 1,
preferred: true,
lanes: []
},
{
host: component2,
cut: null,
ratioWeight: 1,
lanes: []
}
]
},
{
host: null,
cut: 'h',
ratioWeight: 1,
lanes: [
{
host: component3,
cut: null,
ratioWeight: 1,
lanes: []
},
{
host: component4,
cut: null,
ratioWeight: 1,
preferred: true,
lanes: []
}
]
}
]
}

const renderAt = 'board'

const fancyGridLayout = new Layout({
renderAt,
layoutDefinition,
width,
height,
skeletonType
})

fancyGridLayout.compute()

// draw all components
component1.draw()
component2.draw()
component3.draw()
component4.draw()

```