Giter Site home page Giter Site logo

jupiterrr / column-view-component Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 1.0 3.08 MB

Web Component for Miller columns (aka. Column View)

Home Page: http://jupiterrr.github.io/column-view-component

License: MIT License

JavaScript 5.57% CSS 42.49% HTML 51.94%

column-view-component's Introduction

<column-view>

A Polymer Web Component for Miller columns (aka. Column View) with keyboard navigation.

screenshot

demo page only

Install

Install the component using Bower:

bower install column-view --save

Usage

  1. Import Web Components' polyfill:

    <script src="bower_components/platform/platform.js"></script>
  2. Import Custom Element:

    <link rel="import" href="bower_components/column-view/dist/column-view.html">
  3. Insert Custom Element

    <column-view ondata="sourceFn"></column-view>
  4. Set up your data source

    Example:

    <script type="text/javascript">
      var data = {
        0: {name: "root", childIDs: [1,2]}, // not vissible
        1: {name: "Item 1", childIDs: [3,4,5]},
        2: {name: "Item 2"},
        3: {name: "Item 3"},
        4: {name: "Item 4"},
        5: {name: "Item 5"}
      };
    
      function getChildren(selectedItem) {
        var children = selectedItem.childIDs.map(function(id) {
          var item = data[id];
          return {name: item.name, value: id};
        });
        return children;
      }
    
      function sourceFn(ID, cb) {
        if (!ID) ID = 0;
        var selectedItem = data[ID];
        if (selectedItem.childIDs) {
          cb({items: getChildren(selectedItem)});
        } else {
          cb({dom: document.createTextNode("Preview: " + selectedItem.name)})
        }
      }
    </script>

<column-view>

Attributes

Attribute Options Default Description
ondata Function(String value, Function callback) None. A function to be called for each selected item. This function can either pass child items or an HTML element to the callback function.

Callback:
callback({dom: <HTMLElement>})
callback({items: [{name: <String>, value: <String, Number>}, ...]})
data JSON None. *work in progress*
{"fruits": {"apple": "<b>Apple</b>", "grape": "<b>Grape</b>"}}
path String "" Defines the path of items the column-view is initialized with. When the element is ready the ondata method is called with each item ID. Each call results in a new column.

IDs are speareated by /.

Example: path="1/2/3"

Methods

Method Parameters Returns Description
back() None. Nothing. Deselects last selected item

Properties

Method Returns Description
canMoveBack Boolean ...

Events

Event Description
change Fires when selection changes.

<button is="column-view-back">

With is="column-view-back" you can extend a button so that when you click it you move the selection one column to the left.

<button is="column-view-back" for="columnViewID">back</button>
<column-view id="columnViewID"></column-view>

Attributes

Attribute Options Default Description
for ID None. The ID of a column-view

Setup (run it locally)

  1. Install dependencies: bower install

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License

column-view-component's People

Contributors

jupiterrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sherryhuangus

column-view-component's Issues

Add headers

It would be great if you could provide an API / attributes to add headers to columns

Fixed number of columns

Hello, is there a way to initialize column-view with fixed number of columns? I have six levels of data, and I want to show all levels.

Upgrade to Polymer 1.0

In order to make it easier to use with other Web Components it would be great if you could upgrade to Polymer 1.0

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.