Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unlimited user actions support in Card #1977

Merged
merged 9 commits into from
Jan 23, 2023
Next Next commit
Fix Card fluid rendering for unlimited items
mvorisek committed Jan 23, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
commit 581bc12d34eaec2ad82c92de38874b865d7a150c
22 changes: 4 additions & 18 deletions src/Card.php
Original file line number Diff line number Diff line change
@@ -71,15 +71,6 @@ class Card extends View
/** @var string Default executor class. */
public $executor = UserAction\ModalExecutor::class;

/** @var array Columns CSS wide classes */
protected $words = [
'', 'fluid', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve',
'thirteen', 'fourteen', 'fifteen', 'sixteen',
];

/** @var int The number of buttons */
private $btnCount = 0;

protected function init(): void
{
parent::init();
@@ -153,6 +144,10 @@ public function getButtonContainer()
{
if (!$this->btnContainer) {
$this->btnContainer = $this->addExtraContent(new View(['ui' => 'buttons']));
$this->getButtonContainer()->addClass('wrapping');
if ($this->hasFluidButton) {
$this->getButtonContainer()->addClass('fluid');
}
}

return $this->btnContainer;
@@ -317,20 +312,11 @@ public function addImage($img)
*/
public function addButton($seed)
{
if ($this->hasFluidButton && $this->btnCount > 0) {
$this->getButtonContainer()->removeClass($this->words[$this->btnCount]);
}

if (!is_object($seed)) {
$seed = Factory::factory([Button::class], $seed);
}

$btn = $this->getButtonContainer()->add($seed);
++$this->btnCount;

if ($this->hasFluidButton && $this->btnCount > 0) {
$this->getButtonContainer()->addClass($this->words[$this->btnCount]);
}

return $btn;
}