Coder Social home page Coder Social logo

wc-sortable-table's Introduction

<wc-sortable-table> A HTML Table with Sort

GitHub Releases NPM Releases Bundlephobia Latest Status Release Status

Discord Published on WebComponents.org

Installation

Installation

npm i @vanillawc/wc-sortable-table

Import from NPM

<script type="module" src="node_modules/@vanillawc/wc-sortable-table/index.js"></script>

Import from CDN

<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-sortable-table@1/index.js"></script>

Demo

Try it on WebComponents.dev

Usage

Attributes

  • src - load an external source file
  • theme - an external theme file

Properties

  • value - get/set the table data

Basic Usage

<wc-sortable-table src="sample.json"></wc-sortable-table>

Styling

By default, <wc-sortable-table> contains an un-styled <table> element in the lightDOM. That means, it will inherit any global CSS styles present on the site and can be styled directly using CSS.

When a sort is applied, the <th> element selected receives either a .asc or .desc class depending on the direction of the sort.

Theming

Alternatively, a theme for <wc-sortable-table> can be specified. This will encapsulate the element in a shadowDOM -- to prevent style bleed -- and apply the style provided.

<wc-sortable-table src="sample.json" theme="assets/example-theme.html"></wc-sortable-table>

Creating Themes

A theme contains a <style> element with the CSS that will be applied to the element.

example-theme.html

<style>
  table, th, td {
    border: 1px solid black;
  }
  
  .asc:after {
    content: "▲";
    color: red;
    font-size: .75rem;
    vertical-align: text-top;
    text-align:right;
  }
  
  .desc:after {
    content: "▼";
    color: red;
    font-size: .75rem;
    vertical-align: text-top;
    text-align: right;
  }
</style>

Contributing

See CONTRIBUTING.md

wc-sortable-table's People

Contributors

evanplaice avatar dereknongeneric avatar

Watchers

 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.