eladnava/mailgen

Align price value to the right.

lipis opened this issue · 4 comments

lipis commented
Align price value to the right.

Hi @lipis, good idea!

I'm thinking it could be an optional value passed in via body.table.columns.align, e.g.:

table: {
            data: [
                {
                    item: 'Node.js',
                    description: 'Event-driven I/O server-side JavaScript environment based on V8.',
                    price: '$10.99'
                },
            ],
            columns: {
                  align: {
                       price: 'right'
                  }
            }
}

Would you like to submit a PR with this improvement?

lipis commented

I would not overcomplicate it.. the numbers are usually on the right.. and the titles should be center aligned.. the rest on the left.. too lazy for the PR.. sorry :)

I think we should strive to allow as much configurability as possible, no reason to limit it to numbers only. Also, we should support center alignment as well.

Will add this soon.

@lipis done, implemented as follows:

      table: {
            data: [
                {
                    item: 'Node.js',
                    description: 'Event-driven I/O server-side JavaScript environment based on V8.',
                    price: '$10.99'
                },
                {
                    item: 'Mailgen',
                    description: 'Programmatically create beautiful e-mails using plain old JavaScript.',
                    price: '$1.99'
                }
            ],
            columns: {
                // Optionally, customize the column widths
                customWidth: {
                    item: '20%',
                    price: '15%'
                },
                // Optionally, change column text alignment
                customAlignment: {
                    price: 'right'
                }
            }
        },