0.1.8 • Published 3 years ago

vue-family-tree v0.1.8

Weekly downloads
48
License
-
Repository
-
Last release
3 years ago

Vue component to display family tree.

Installation

npm

npm install vue-family-tree --save

Demo

https://walkerz88.github.io/vue-family-tree/

Usage

<template>
  <div id="app">
    <VueFamilyTree
      :tree="tree"
      @card-click="cardClick"
    />
  </div>
</template>
<script>
import VueFamilyTree from 'vue-family-tree';

export default {
  name: 'App',
  components: {
    VueFamilyTree
  },
  data () {
    return {
      tree: [{
        firstPerson: {
          name: 'John Walker',
          image: 'https://picsum.photos/300/300?random=1'
        },
        secondPerson: {
          name: 'Jannet Grem',
          image: 'https://picsum.photos/300/300?random=2'
        },
        children: [{
          firstPerson: {
            name: 'Katia'
          },
          secondPerson: {
            name: 'Oleg'
          },
          children: [{
            firstPerson: {
              name: 'Gleb'
            },
            secondPerson: {
              name: 'Viktoriya'
            },
            children: [{
              firstPerson: {
                name: 'Rim'
              },
              secondPerson: {
                name: 'Natasha'
              }
            },
            {
              firstPerson: {
                name: 'Leonid'
              }
            }]
          },
          {
            firstPerson: {
              name: 'Olga'
            },
            secondPerson: {
              name: 'Nikita'
            }
          }]
        },
        {
          firstPerson: {
            name: 'Vitia'
          },
          secondPerson: {
            name: 'Dasha'
          }
        },
        {
          firstPerson: {
            name: 'Antonio Wild',
            image: 'https://picsum.photos/300/300?random=3'
          },
          secondPerson: {
            name: 'Olivia Olson'
          },
          children: [{
            firstPerson: {
              name: 'Kristina Wild'
            }
          },
          {
            firstPerson: {
              name: 'Alexey Wild'
            }
          },
          {
            firstPerson: {
              name: 'Viktor Wild'
            }
          }]
        }]
      }]
    }
  },
  methods: {
    cardClick (item) {
      console.log(item);
    }
  }
}
</script>

Props

PropTypeDefaultDescription
treeArray[]JSON of your tree
enable-dragBooleantrueEnable or disable drag
wrapper-stylesObjectIf enable-drag is true: {position: 'relative', width: '100%', height: '600px'} else nullWrapper css parameters
drag-cursorStringgrabbingCSS cursor name when drag is active
mouse-change-diffNumber2How many pixels mouse should move, to change cursor and prevent mouse events

Events

EventDescription
card-clickClick on card (You will receive full data from card object)

Slots

Card

Your custom card template. Please use fixed width in your card styles (will be fixed in feature)

<VueFamilyTree :tree="tree">
  <template v-slot:card="{item}">
    {{ item.name }}
  </template>
</VueFamilyTree>
0.1.8

3 years ago

0.1.7

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago