Code Monkey home page Code Monkey logo

vue-leader-line's Introduction

A Very Simple Leader Line Component of Vue2

npm

WIP

Features

  • Vertical Leader Line
  • Horizontal Leader Line
  • One to One
  • One to Many

preview_0

Usage

Binds Elements

import LeaderLine from "vue-leader-line-nz";

// ...

mounted() {
  const ref = this.$refs.leaderLine;

  // one to one
  ref.binds(this.$refs.start, this.$refs.end);

  // one to many
  ref.binds(this.$refs.start, [
    this.$refs.end2,
    this.$refs.end3,
    this.$refs.end4,
  ]);
}
Demo Code
<template>
  <div id="app">
    <div class="end" ref="end">END</div>

    <div class="start" ref="start">START</div>

    <div class="end" ref="end2">END1</div>
    <div class="end" ref="end3">END2</div>
    <div class="end" ref="end4">END3</div>

    <leader-line constraint align="start" :padding="[16]" ref="z" />

    <leader-line :constraint="false" ref="z1" />
  </div>
</template>

<script>
  import LeaderLine from "./";

  export default {
    name: "App",
    components: {
      LeaderLine,
    },
    mounted() {
      // one to one
      this.$refs.z.binds(this.$refs.start, this.$refs.end);

      // one to many
      this.$refs.z1.binds(this.$refs.start, [
        this.$refs.end2,
        this.$refs.end3,
        this.$refs.end4,
      ]);
    },
  };
</script>

<style>
  .start,
  .end {
    border: 1px solid #000;
    height: 2em;
    justify-content: center;
    align-items: center;
    display: flex;
  }
  .start {
    width: 4em;
    margin-top: 80px;
    margin-left: 30px;
  }
  .end {
    width: 3.2em;
    margin-top: 20px;
    margin-left: 160px;
  }
</style>

Props

interface Props {
  // default: "currentColor"
  color: string;

  // default: 2
  thickness: number;

  // If true, the line will be constrained to the two ends of vertical line.
  // default: true
  constraint: boolean;

  // default: [0, 0]
  padding: [number, number];

  // default: "center"
  align: "start" | "end" | "center";
}

Methods

interface Methods {
  // if EndRef is an array, draw multiple lines
  binds(StartRef: HTMLElement, EndRef: HTMLElement | HTMLElement[]): void;
}

Development

# build lib
npm run build:lib

# serve demo and access http://localhost:8080
npm run serve

vue-leader-line's People

Watchers

Clord Weel 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.