tty-table icon indicating copy to clipboard operation
tty-table copied to clipboard

Footer align does not work

Open muuvmuuv opened this issue 4 years ago • 1 comments

Problem Summary

I am trying to align a footer cell to right.

Expected Result (screen shot if possible)

Actual Result (screen shot if possible)

Bildschirmfoto 2020-07-02 um 11 14 41

Environment Information

  • OS: latest public macOS

  • Terminal Emulator: iTerm2 with zsh and zprezto plugin

  • Node Version: LTS

Steps to Reproduce

  const header = [
    {
      value: 'Test',
      align: 'left',
      headerAlign: 'left',
      footerAlign: 'right',
    },
    {
      value: 'Score',
      align: 'left',
      headerAlign: 'left',
      footerAlign: 'left',
      formatter: (cellValue) => {
        return cellValue > 60 ? green(cellValue) : red(cellValue)
      },
    },
  ]
  const rows = [
    ['Performance', 64],
    ['Accessibility', 70],
    ['Best Practices', 30],
    ['SEO', 60],
    ['PWA', 100],
  ]
  const footer = [
    'Total',
    (cellValue, columnIndex, rowIndex, rowData) => {
      const total = Math.round(rowData.map((i) => i[1]).reduce((p, c) => p + c) / 5)
      return italic(total)
    },
  ]
  const renderedTable = Table(header, rows, footer).render()
  console.log(renderedTable)

muuvmuuv avatar Jul 02 '20 09:07 muuvmuuv

Thanks for reporting. Feel free to send me in a PR, otherwise it will be a little while before I get to this.

tecfu avatar Dec 10 '20 18:12 tecfu