npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

table-fits

v1.2.0

Published

Responsive table

Downloads

9

Readme

TableFits

Full doc | Example | Demo

npm

Responsive table into a responsive site. Or adaptive?

Easy

Support colspan

npm install table-fits
<script src="js/table-fits.js"></script>
// Create own style or take ours — for test
<link rel="stylesheet" href="css/table-fits.css">
<table id="id-table">
    <thead>
        <tr>
            <td>Title 1</td>
            <td>Title 2</td>
            ...
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Value 1</td>
            <td>Value 2</td>
            ...
        </tr>
        ...
    </tbody>
</table>
TableFits.make('#id-table');

Now, you have the responsive table

How it works?

The script looks for a table and if the data in the table do not fit, the script will show them in cute look

The script will keep watch, if the structure of the table has changed or added a new line. And modify data in new blocks.

And callback on resize

Some options

TableFits.make('#id-table',{
   mainClass: 'table-fits',
   width: null,
   resize: true,
   watch: true
})

Option | Description ------ | ----------- mainClass|Class name prefix, default: table-fits and all children has class table-fits__... width|Sets the width of the table when it will converted into blocks, default null resize|Enable resize, if width of window will change, default true watch|Enable watch, if the structure of the table has changed or added a new line, default true

Inline options

Skip the table data-table-fits="no"

If you give the script all tables in a row, this option will be useful

<table id="id-table" data-table-fits="no">
...
</table>

Width of the table data-table-fits-width="700"

Sets the width of the table when it will converted into blocks.

<table id="id-table" data-table-fits-width="700">
...
</table>

Similar to the option

TableFits.make('#id-table',{
   width: 700
});

Title of block data-table-fits="title"

The block is tag <tr> like <div>, and this block may have headings (titles). You need to add data-table-fits="title" in the right column in the tag <td> in the <thead>

P.S. Supports multiple headers

<table id="id-table">
    <thead>
        <tr>
            <td data-table-fits="title">Title 1</td>
            <td data-table-fits="title">Title 2</td>
            <td>Title 3</td>
            ...
        </tr>
    </thead>
    <tbody>
        ...
    </tbody>
</table>

Now, the headers that have the option, the "headers's data" will be in the top of block like a header

Combine headers data-table-fits-group="My group"

You can combine columns using colspan or use the option data-table-fits-group="My group"

<table id="id-table">
    <thead>
        <tr>
            <td data-table-fits-group="My group">Title 1</td>
            <td data-table-fits-group="My group">Title 2</td>
            <td>Title 3</td>
            ...
        </tr>
    </thead>
    <tbody>
        ...
    </tbody>
</table>

or

<table id="id-table">
    <thead>
        <tr>
            <td colspan="2">My Group</td>
            <td rowspan="2">Title 3</td>
            ...
        </tr>
        <tr>
            <td>Title 1</td>
            <td>Title 2</td>
            <td>Title 3</td>
            ...
        </tr>
    </thead>
    <tbody>
        ...
    </tbody>
</table>

Full doc | Example | Demo