Giter VIP home page Giter VIP logo

vue-json-component's Introduction

Vue JSON Component

npm version TypeScript npm bundle size License: MIT code style: prettier

Demo

A collapsable tree view for JSON. This package is loosely based on vue-json-tree-view with a series of upgrades. I'm not contributing this back to that package because it would require breaking API changes, and there are some features I'm not planning on adding unless people need them. Contributions welcome!

demo image

Philosophy

This package has two major improvements over predecessors: builds and customization. For builds, this package ships CommonJS, Module, and Minified builds with limited external dependencies. vue-json-tree-view bundles in lots of dependencies. I also export global Vue imports, local Vue imports, and TypeScript declarations. The code itself is also only two files with most of the functions being helpers for custom styles.

The styles in this package are all scoped, with key colors still being customizable. There are no extra margins or overflow rules and text properties are all inherited from the page. This makes the view much easier to integrate anywhere you need it.

Usage

Install

npm i vue-json-component
yarn add vue-json-component

Import Locally

import { JSONView } from "vue-json-component";
export default Vue.extend({
  components: { "json-view": JSONView }
});

Import Globally

import JSONView from "vue-json-component";
Vue.use(JSONView)

Use

<template>
  <json-view :data="data" />
</template>

Customize

The font size and font family are inherited from the page.

Props

  • data (JSON): The valid JSON object you want rendered as a tree.
  • rootKey (String): The name of the top level root key; defaults to root.
  • maxDepth (Number): Depth of the tree that is open at first render; defaults to 1.
  • styles (Object): Override the color styles. Defaults shown below.
const defaultStyles = {
  key: "#002b36",
  valueKey: "#073642",
  string: "#268bd2",
  number: "#2aa198",
  boolean: "#cb4b16",
  null: "#6c71c4",
  arrowSize: "6px"
};

Example

<template>
  <json-view
    :data="data"
    rootKey="view"
    :maxDepth="1"
    :styles="{ key: '#0977e6' }"
  />
</template>

Development

Install

yarn

Hot-Reload Hostapp

yarn serve

Build Component

yarn build

Lints and fixes files

yarn lint

vue-json-component's People

Contributors

tylerkrupicka avatar

Watchers

 avatar  avatar  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.