JSPM

slack-table

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4387
  • Score
    100M100P100Q118407F
  • License MIT

generates slack markdown text which looks like table

Package Exports

  • slack-table

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (slack-table) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

slack-table

generates slack markdown text which looks like table

install

npm install slack-table

usage

import slackTable from 'slack-table';

const table = slackTable({
    title: 'Marketing Summary',
    columns: [
        { width: 20, title: 'Campaign', dataIndex: 'campaign' },
        { width: 10, title: 'Install', dataIndex: 'install', align: 'right' },
        { width: 12, title: 'Cost', dataIndex: 'cost', align: 'right' },
    ],
    dataSource: [
        '-',
        { campaign: 'Google CPC', install: '12', cost: '$ 400' },
        { campaign: 'Facebook CPC', install: '3', cost: '$ 60' },
        { campaign: 'Youtube Video', install: '131', cost: '$ 1,230' },
        '-',
        { campaign: 'Total', install: '146', cost: '$ 1,690' },
    ],
});

When I build a slack slash command, I wanted to format the command results look like table. However, I could not find a simple way to do that, and decided to build a table-like view using code. Use the result string in slack markdown text, and you can get the following view.

Warning: CJK characters will break the table layout

slack-table