climate icon indicating copy to clipboard operation
climate copied to clipboard

Proposal: center or right-align table columns?

Open tomkyle opened this issue 6 years ago • 2 comments

Hey there, what do you think of centering column contents, or aligning (numbers) to the right?

As far as I can see, there is a buildCell method that calls another pad method and also already knows the column width. Roughly outline as use example:

<?php
$climate->table($data, [
    // STR_PAD_RIGHT or null is default anyway
    // 'name' => STR_PAD_RIGHT,
    'age' => STR_PAD_LEFT,
    'centered' => STR_PAD_BOTH
]);

And inside the Table class, I imagine:

protected function buildCell($key, $column)
{
    $align = $this->column_aligns[$key];
    $width = $this->column_widths[$key];
    return  $this->pad($column, $width, $align);
}

Regards

tomkyle avatar Jun 28 '18 07:06 tomkyle

Hi @tomkyle, that sounds like an interesting idea, I'll take a look when I get a minute

duncan3dc avatar Jun 28 '18 07:06 duncan3dc

Would be nice if this were to be implemented

rotexdegba avatar Mar 12 '24 23:03 rotexdegba