mirror of https://github.com/xfarrow/phpxpress.git
dropdown
This commit is contained in:
parent
363503d953
commit
2a4a8bf8f3
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
$dropdown = new Dropdown;
|
$dropdown = new Dropdown;
|
||||||
|
|
||||||
$dropdown->setTitle("Title");
|
$dropdown->setTitle("Bank Account");
|
||||||
$dropdown->setDataSource(array("AA" => "#" , "BB" => "#"));
|
$dropdown->setDataSource(array("Unicredit" => "#" , "United Bank" => "#" , "National Bank" => "#"));
|
||||||
$dropdown->setSize("large");
|
|
||||||
$dropdown->draw();
|
$dropdown->draw();
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
private $locations;
|
private $locations;
|
||||||
|
|
||||||
// unless otherwise specified via stating 'setActiveLocation(-1)'
|
// unless otherwise specified via stating 'setActiveLocation()'
|
||||||
// the active location will be the last element
|
// the active location will be the last element
|
||||||
private $activeLocation;
|
private $activeLocation;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
private $datasource;
|
private $datasource;
|
||||||
private $color = 'secondary';
|
private $color = 'secondary';
|
||||||
private $size;
|
private $size;
|
||||||
|
private $darkTheme = false;
|
||||||
|
|
||||||
// Associative array name => link
|
// Associative array name => link
|
||||||
public function setDataSource(Array $datasource){
|
public function setDataSource(Array $datasource){
|
||||||
|
@ -34,7 +35,13 @@
|
||||||
|
|
||||||
else
|
else
|
||||||
throw new InvalidArgumentException('Parameter size must be either default, large or small.');
|
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 $this->title;
|
||||||
echo '</button>';
|
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){
|
foreach($this->datasource as $name => $link){
|
||||||
echo '<li><a class="dropdown-item" href="' . $link . '">' . $name . '</a></li>';
|
echo '<li><a class="dropdown-item" href="' . $link . '">' . $name . '</a></li>';
|
||||||
|
|
Loading…
Reference in New Issue