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

tts-table

v1.4.2

Published

A performant grid / table webcomponent.

Downloads

5

Readme

Built With Stencil

tts-table

Using this component

You need tts-table component and paper-tooltip element. Please check https://webcomponents.org for paper-tooltip.

Include the paper-tooltip element in your index.html. Then put a script tag similar to this for tts-table:

<script src='https://unpkg.com/tts-table/dist/ttstable.js'></script>

or versioned:

<script src='https://unpkg.com/[email protected]/dist/ttstable.js'></script>

or node with node modules run:

yarn add tts-table

and add:

<script src='node_modules/my-name/dist/myname.js></script>

...in the head of your index.html. Then you can use the element anywhere in your template, JSX, html etc. Note that some js frameworks might require additional steps to the ones below. Polyfills might also be needed for webcomponents.

Documentation

Properties

// Things you can set as props to the component
@Prop() tableData: TableData;

// One table items datamodel
export interface TableItem {
  startTime: Date | number;
  endTime: Date | number;
  row: number;
  title?: string;
  tooltipData?: Tooltip[];
  highlighted?: boolean;
  disabled?: boolean;
  selected?: boolean;
}

// tooltip datamodel
export interface Tooltip {
  type: string;
  value: string;
}

// A column consists of several items
export type TableColumn = TableItem[];

// A table consists of several columns
export type TableData = TableColumn[];

Events

// you should listen to tableItemSelected event if you want to change the selected item.
@Event() tableItemSelected: EventEmitter;

Please note that you should handle the logic of selecting / adding highlighted / unavailbling the items in the parent component. The logic is delegated because of multi / single selection possibilities. Maybe someone does not want selections at all.

// Here is an example of single seleciton
function setSelectedItem(tableData, selectedItem) {
  return tableData.map(
    columnData => columnData.map(
      tableItem => {
        if (
          tableItem.startTime === selectedItem.startTime &&
          tableItem.endTime === selectedItem.endTime &&
          tableItem.row === selectedItem.row
        ) {
          return Object.assign({}, tableItem, {selected: true})
        }
        return Object.assign({}, tableItem, {selected: false})
      }
    )
  )
}

Styles

tts-table {
  --tts-table-font-family: 'Courier New', monospace;

  --tts-table-column-title-font-size: 16px;
  --tts-table-column-title-font-weight: bold;
  --tts-table-column-width: 240px;
  --tts-table-column-title-padding: 6px;

  --tts-side-column-padding-top: 30px;
  --tts-side-column-font-weight: bold;

  --tts-side-item-color: rgba(16, 16, 16, 0.95);
  --tts-side-item-background-color: transparent;
  --tts-side-item-font-size: 16px;
  --tts-side-item-height: 34px;
  --tts-side-item-margin: 4px 2px;
  --tts-side-item-padding: 9px 0;
  --tts-side-item-border-radius: 2px;

  --tts-table-item-color: rgba(16, 16, 16, 0.95);
  --tts-table-item-background-color: #fafafa;
  --tts-table-item-hover-background-color: #ea80fc;
  --tts-table-item-disabled-background-color: rgba(168, 168, 168, 0.7);
  --tts-table-item-disabled-hover-background-color: rgba(168, 168, 168, 0.7);
  --tts-table-item-selected-background-color: #40c4ff;
  --tts-table-item-highlighted-background-color: #ffea00;
  --tts-table-item-font-size: 14px;
  --tts-table-item-height: 34px;
  --tts-table-item-margin: 4px 2px;
  --tts-table-item-padding: 10px;
  --tts-table-item-border-radius: 2px;

  --tts-tooltip-text-align: center;
  --tts-tooltip-top: 100%;
  --tts-tooltip-cursor: default;
  --tts-tooltip-left: 5%;
  --tts-tooltip-width: 90%;
  --tts-tooltip-padding: 8px;
  --tts-tooltip-z-index: 1;
  --tts-tooltip-font-weight: bold;
  --tts-tooltip-background-color: rgba(222, 222, 222, 0.8);
  --tts-tooltip-border-radius: 0 0 4px 4px;
}

Getting Started with hacking

  1. Send cool ideas
  2. Fork this repo
  3. Run yarn install
  4. Run yarn start
  5. Hack on
  6. Pull request
  7. (Run yarn build for building)