This commit is contained in:
Alessandro Ferro 2022-03-16 19:14:17 +01:00
parent 363503d953
commit 2a4a8bf8f3
3 changed files with 16 additions and 5 deletions

View File

@ -9,9 +9,8 @@
$dropdown = new Dropdown;
$dropdown->setTitle("Title");
$dropdown->setDataSource(array("AA" => "#" , "BB" => "#"));
$dropdown->setSize("large");
$dropdown->setTitle("Bank Account");
$dropdown->setDataSource(array("Unicredit" => "#" , "United Bank" => "#" , "National Bank" => "#"));
$dropdown->draw();
?>
</body>

View File

@ -6,7 +6,7 @@
private $locations;
// unless otherwise specified via stating 'setActiveLocation(-1)'
// unless otherwise specified via stating 'setActiveLocation()'
// the active location will be the last element
private $activeLocation;

View File

@ -8,6 +8,7 @@
private $datasource;
private $color = 'secondary';
private $size;
private $darkTheme = false;
// Associative array name => link
public function setDataSource(Array $datasource){
@ -34,7 +35,13 @@
else
throw new InvalidArgumentException('Parameter size must be either default, large or small.');
}
public function setDarkTheme($bool){
if(!is_bool($bool))
throw new InvalidArgumentException('Parameter must be a bool.');
$this->darkTheme = $bool;
}
@ -52,7 +59,12 @@
echo $this->title;
echo '</button>';
echo '<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">';
$ulClass = "dropdown-menu";
if($this->darkTheme){
$ulClass .= " dropdown-menu-dark";
}
echo '<ul class="' . $ulClass . '" aria-labelledby="dropdownMenuButton1">';
foreach($this->datasource as $name => $link){
echo '<li><a class="dropdown-item" href="' . $link . '">' . $name . '</a></li>';