New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-virtual-dom

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-virtual-dom

convert json to react html layout(virtual DOM)

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

r-layout

row

set horizontal layout
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},gap:12,
          row:[ //see here
            {html:'a',flex:1,attrs:{className:'panel'}},
            {html:'b',flex:1,attrs:{className:'panel'}},
            {html:'c',flex:1,attrs:{className:'panel'}}, 
          ]
        }}
      />
    )
  }
}

[alt text]

column

set vertical layout
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          column:[ // see here
            {html:'a',flex:1,attrs:{className:'panel'}},
            {html:'b',flex:1,attrs:{className:'panel'}},
            {html:'c',flex:1,attrs:{className:'panel'}}, 
          ]
        }}
      />
    )
  }
}

[alt text]

childsAttrs

set childsAttrs in parent as set attrs property of childs
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          childsAttrs:{className:'panel'},//see here
          row:[
            {html:'a',flex:1},
            {html:'b',flex:1},
            {html:'c',flex:1}, 
          ]
        }}
      />
    )
  }
}

[alt text]

childsProps

set childsProps in parent as set props of childs
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          childsAttrs:{className:'panel'},//see here
          childsProps:{flex:1},//see here
          row:[
            {html:'a'},
            {html:'b'},
            {html:'c'}, 
          ]
        }}
      />
    )
  }
}

[alt text]

size

set specific size on childs
import React,{Component} from "react";
import RLayout from './r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          childsAttrs:{className:'panel'},
          row:[
            {html:'a',size:48},//see here
            {html:'b',flex:1},
            {html:'c',flex:1}, 
          ]
        }}
      />
    )
  }
}

[alt text]

flex

set specific flex on childs
default is 1
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          childsAttrs:{className:'panel'},
          row:[
            {html:'a',flex:2},//see here
            {html:'b',flex:1},
            {html:'c',flex:1}, 
          ]
        }}
      />
    )
  }
}

[alt text]

set size of child as fit content

just sdont set flex and size
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          childsAttrs:{className:'panel'},
          row:[
            {html:'abcdefg'},//see here
            {html:'b',flex:1},
            {html:'c',flex:1}, 
          ]
        }}
      />
    )
  }
}

[alt text]

nested layout

each child can get own layout
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          row:[
            {
              gap:12,
              flex:1,
              childsAttrs:{className:'panel'},
              column:[
                {html:'a1',flex:1},
                {html:'a2',flex:1},
                {html:'a3',flex:1},
              ]
            },
            {
              flex:1,
              attrs:{className:'panel'},
              html:'b'
            },
            {
              gap:12,
              flex:1,
              childsAttrs:{className:'panel'},
              column:[
                {html:'c1',flex:1},
                {html:'c2',flex:1},
                {html:'c3',flex:1},
              ]
            },
          ]
        }}
      />
    )
  }
}


[alt text]

gap

space between childs
default is 12
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:24,
          attrs:{className:'container'},
          row:[
            {
              flex:1,
              gap:24,
              childsAttrs:{className:'panel'},
              column:[
                {html:'a1',flex:1},
                {html:'a2',flex:1},
                {html:'a3',flex:1},
              ]
            },
            {html:'b',flex:1,attrs:{className:'panel'}},
            {
              childsAttrs:{className:'panel'},flex:1,
              gap:24, // see here
              column:[
                {html:'c1',flex:1},
                {html:'c2',flex:1},
                {html:'c3',flex:1},
              ]
            },
          ]
        }}
      />
    )
  }
}


[alt text]

onResize

resize child by mouse
in this case size of child should store in state and onResize function change it
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  state = {size1:100};
  render(){
    let {size1} = this.state;
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          row:[
            {
              gap:12,
              size:size1, // see here
              onResize:(value)=>this.setState({size1:value}), //see here
              childsAttrs:{className:'panel'},
              column:[
                {html:'a1',flex:1},
                {html:'a2',flex:1},
                {html:'a3',flex:1},
              ]
            },
            {
              attrs:{className:'panel'},
              flex:1,
              html:'b',
            },
            {
              childsAttrs:{className:'panel'},
              flex:1,
              gap:12,
              column:[
                {html:'c1',flex:1},
                {html:'c2',flex:1},
                {html:'c3',flex:1}, 
              ]
            },
          ]
        }}
      />
    )
  }
}

[alt text]

show

set false to prevent show child
boolean or function that return boolean
import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  render(){
    return (
      <RLayout
        layout={{
          gap:12,
          attrs:{className:'container'},
          row:[
            {
              gap:12,
              flex:1,
              childsAttrs:{className:'panel'},
              column:[
                {html:'a1',flex:1},
                {html:'a2',flex:1,show:false},//see here . show type function
                {html:'a3',flex:1},
              ]
            },
            {html:'b',flex:1,attrs:{className:'panel'}},
            {
              gap:12,
              flex:1,
              childsAttrs:{className:'panel'},
              column:[
                {html:'c1',flex:1},
                {html:'c2',flex:1,show:false}, // see here . show type boolean
                {html:'c3',flex:1}, 
              ]
            },
          ]
        }}
      />
    )
  }
}

[alt text]

handle Complexity by get child from functions

import React,{Component} from "react";
import RLayout from 'r-layout';
import './style.css'
export default class app extends Component {
  state = {
    list1:[
      {title:'item1'},
      {title:'item2'},
      {title:'item3'},
      {title:'item4'},
      {title:'item5'},
      {title:'item6'},
      {title:'item7'},
      {title:'item8'},
      {title:'item9'},
      {title:'item10'},
      {title:'item11'},
      {title:'item12'},
      {title:'item13'},
      {title:'item14'},
      {title:'item15'},
      {title:'item16'},
      {title:'item17'},
      {title:'item18'},
      {title:'item19'},
    ],
    list2:[]
  }
  getList(listName){
    return {
      gap:0,attrs:{className:'panel',},
      column:this.state[listName].map((o,index)=>{
        return {
          html:o.title,size:36,
          attrs:{
            className:'item',
            onClick:()=>{
              let currentList = this.state[listName];
              let otherList = this.state[listName === 'list1'?'list2':'list1'];
              otherList.push(o);
              currentList.splice(index,1);
              this.setState({[listName]:currentList});
            }
          }
        }
      })
    }
  }
  render(){
    return (
      <RLayout
        layout={{
          attrs:{className:'container',style:{padding:12,boxSizing:'border-box'}},
          column:[ 
            {
              size:72,
              childsAttrs:{className:'panel'},
              row:[
                {html:'a'},
                {html:'b'},
                {html:'c'},
              ]
            },
            {
              row:[
                this.getList('list1'),
                this.getList('list2'),
              ]
            }
          ]
        }}
      />
    )
  }
}


[alt text]

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc