Giter VIP home page Giter VIP logo

evoluteur / isomorphic-table-cards Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 180 KB

Isomorphic Table and Cards views with animated transitions on sorting, changing view, and browser resizing (using Vanilla Javascript, CSS, and HTML).

Home Page: https://evoluteur.github.io/isomorphic-table-cards/

License: MIT License

CSS 19.70% HTML 34.80% JavaScript 45.50%
card cards cardview table table-view transition transition-animation animation animation-css transformation

isomorphic-table-cards's Introduction

Isomorphic-Table-Cards · GitHub license

Isomorphic-Table-Cards is a Javascript class for Table and Cards views with animated transitions on sorting, view toggle, and browser resizing.

Check out the live demo.

screenshot

Usage

The code is just Vanilla Javascript, CSS, and HTML.

Importing the code

In the "head" section your html page, import the Javascript and CSS:

<link href="css/isomorphic-table-cards.css" rel="stylesheet" />
<script src="js/isomorphic-table-cards.js" charset="utf-8"></script>

Config options

Isomorphic-Table-Cards is a Javascript class with configuration options for re-use.

data: data to display (JSON array).

selector: CSS selector for the root element which will hold the cards or table.

rowHeight: Row height (in pixels).

cardHeight: Card height (in pixels).

cardWidth: Card width (in pixels).

itemTemplate: HTML template to display an item. It is the same for both table and cards views, only the CSS changes.

sort: Function for sorting the data (arguments: data, key, direction).

Methods

render(): Initial rendering method.

redraw(style): Redraw method (style="table" or "cards").

sort(key): Sort method (key=data attribute to sort by).

Example

const tableCards = new IsomorphicTableCards({
  data: <yourData>,
  selector: ".holder",
  // row and card dimensions
  rowHeight: 30,
  cardHeight: 100,
  cardWidth: 250,
  // item template
  itemTemplate: d => `<div class="item" id="${d.name}">
      <div class="c1">
        ${d.name}
      </div>
      <div class="c2">
        ${d.descriptionn}
      </div>
    </div>
  `,
  // sort function
  sort: (data, key, direction) => data.sort((a, b) => direction*a[key].localeCompare(b[key]))   }
});

tableCards.render()

The same animations can also be done using D3.js.

License

Isomorphic-Table-Cards is open source at GitHub with MIT license.

(c) 2024 Olivier Giulieri.

isomorphic-table-cards's People

Contributors

evoluteur avatar

Stargazers

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