Skip to content

Proposal: center or right-align table columns?  #123

@tomkyle

Description

@tomkyle

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions