From 2040d745c9ae15af8fdcf95a6e7542bf5bf56e41 Mon Sep 17 00:00:00 2001 From: Alessandro Ferro <49845537+xfarrow@users.noreply.github.com> Date: Tue, 15 Mar 2022 22:35:48 +0100 Subject: [PATCH] dropdown --- phpxpress/examples/dropdown.php | 18 +++++++++ phpxpress/phpxpress/dropdown.php | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 phpxpress/examples/dropdown.php create mode 100644 phpxpress/phpxpress/dropdown.php diff --git a/phpxpress/examples/dropdown.php b/phpxpress/examples/dropdown.php new file mode 100644 index 0000000..12215d1 --- /dev/null +++ b/phpxpress/examples/dropdown.php @@ -0,0 +1,18 @@ + + + Dropdown example + + + + setTitle("Title"); + $dropdown->setDataSource(array("AA" => "#" , "BB" => "#")); + $dropdown->setSize("large"); + $dropdown->draw(); + ?> + + \ No newline at end of file diff --git a/phpxpress/phpxpress/dropdown.php b/phpxpress/phpxpress/dropdown.php new file mode 100644 index 0000000..032e927 --- /dev/null +++ b/phpxpress/phpxpress/dropdown.php @@ -0,0 +1,64 @@ + + link + public function setDataSource(Array $datasource){ + $this->datasource = $datasource; + } + + public function setTitle($title){ + $this->title = $title; + } + + public function setColor($color){ + $this->color = Code::bootstrapColors($color); + } + + public function setSize($size){ + if($size == "default") + $this->size = NULL; + + else if($size == "large") + $this->size = "btn-lg"; + + else if($size == "small") + $this->size = "btn-sm"; + + else + throw new InvalidArgumentException('Parameter size must be either default, large or small.'); + + + } + + public function draw(){ + + $btnClass = 'btn btn-' . $this->color . ' dropdown-toggle'; + if(isset($this->size)){ + $btnClass .= ' ' . $this->size; + } + + echo ''; + } + } +?> \ No newline at end of file