Giter Club home page Giter Club logo

vue-panel's Introduction

#vue-panel

This plugin aims to provide your Vue application with a handful of light, composable, Flexbox-powered components.

###Installation

Just bower or npm install ericmcdaniel/vue-panel. The package is exposed as a UMD module so you can require it with Browserify/Webpack/etc. or include it in your page via script tag.

To use this plugin with Vue, simply call Vue.use(require('vue-panel')), or Vue.use(window.VuePanel) if including in a script tag.

###Components

####VPanel <v-panel> responds to a variety of Flexbox parameters and is useable as both a display: flex element and a flex-item:

<v-panel grow="1" shrink="0"></v-panel>

<v-panel> will display any content inside of the element as it's own transclusion content:

<v-panel basis="200px">
    <h3>Foo</h3>
    <p>Lorem ipsum dolor sit amet...</p>
</v-panel>

<v-panel> responds to

  • align-items,
  • align-self,
  • order,
  • direction (flex-direction),
  • flex,
  • grow (flex-grow),
  • shrink (flex-shrink),
  • basis (flex-basis),
  • and justify (justify-content).

The plugin provides two more components: <v-panel-bar> and <v-panel-content>.

####VPanelBar <v-panel-bar> responds to

  • align-items,
  • direction,
  • justify,
  • and size (flex-basis).

The bar is 30px wide by default. When the direction value changes, the component will broadcast the event v-panel-bar:direction (with it's $data.direction value) to child components so they can respond to it's flex-direction.

####VPanelContent <v-panel-content> is a simple flex-item that responds to flex, grow and shrink.

<v-panel>
    <v-panel-bar>
        <button on="click: updateContent">Click</button>
    </v-panel-bar>
    <v-panel-content v-ref="content">Foo</v-panel-content>
</v-panel>

###Directives

Each of the included components are also provided as directives. These directives can take parameters in the form of attributes, not to be confused with component props. These params follow the same naming conventions as the props documented above.

<section v-panel grow="1" shrink="0">
  <div v-panel-bar size="90px"></div>
  <div v-panel-content></div>
</section>

The directives share common defaults with the components, but you will have to manually declare bindings using the v-bind directive if you want to hook up ViewModel data to the params. For example:

<my-nav v-panel-bar v-bind:size="myBarSize"></my-component>

###Configuration

Each of the vue-panel components can be globally configured to initialize with additional data values via an object literal where the key is the property name and the value is the initial value. This is done by passing an object as the second parameter to the Vue.use function like so:

Vue.use(VuePanel, {
  // either hyphenated
  'v-panel': {
    class: 'Panel',
    style: {
      color: 'red',
      backgroundColor: '#ccc'
    }
  },
  // or camel case:
  'vPanelBar': {
    class: 'Panel-bar'
  },
  'vPanelContent': {
    class: 'Panel-content'
  }
});

class and style are currently the only options that have any built-in effect. The value from class will be merged with the class list of each component instance via the v-bind:class directive. The value(s) from style will be merged with the inline styles of each component instance via the v-bind:style directive.

Note: This feature does not work with the bundled directives. Directives are designed to provide the bare-minimum Flexbox parameters that you can integrate with any component or element.

###Example

Open example/index.html for a straightforward example.

###Tests

The plugin ships with Jasmine specs in the test folder if installing from NPM or GitHub. npm install to pull down the Vue dependency, then open test/index.html to run the specs.

vue-panel's People

Contributors

3mcd avatar

Watchers

James Cloos avatar Abishek R Srikaanth 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.