From f046e3a4d3445d5ddb3da637bf71424c331342e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 7 Mar 2022 11:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20InfoBox=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Widgets/InfoBox.php | 110 ++++++++++++++++++ .../vendor/admin/widgets/info-box.blade.php | 31 +++++ 2 files changed, 141 insertions(+) create mode 100644 app/Admin/Widgets/InfoBox.php create mode 100644 resources/views/vendor/admin/widgets/info-box.blade.php diff --git a/app/Admin/Widgets/InfoBox.php b/app/Admin/Widgets/InfoBox.php new file mode 100644 index 00000000..32cc3db9 --- /dev/null +++ b/app/Admin/Widgets/InfoBox.php @@ -0,0 +1,110 @@ +title($title); + $this->content($content); + $this->icon($icon); + } + + /** + * Info Box 图标 + * + * @param string $icon + * @return $this + */ + public function icon(string $icon = null) + { + $this->icon = $icon; + + return $this; + } + + /** + * Info Box 内容 + * + * @param string $content + * @return $this + */ + public function content($content) + { + $this->content = $content; + + return $this; + } + + /** + * Info Box 标题 + * + * @param string $title + * @return $this + */ + public function title($title) + { + $this->title = $title; + + return $this; + } + + /** + * Add style. + * + * @param string $style + * @return $this + */ + public function style($style = 'info') + { + $this->style = $style; + + return $this; + } + + /** + * Variables in view. + * + * @return array + */ + public function defaultVariables() + { + $this->class('info-box'); + + return [ + 'title' => $this->title, + 'content' => $this->content, + 'icon' => $this->icon, + 'style' => $this->style, + 'attributes' => $this->formatHtmlAttributes(), + ]; + } +} diff --git a/resources/views/vendor/admin/widgets/info-box.blade.php b/resources/views/vendor/admin/widgets/info-box.blade.php new file mode 100644 index 00000000..639dbe5b --- /dev/null +++ b/resources/views/vendor/admin/widgets/info-box.blade.php @@ -0,0 +1,31 @@ + + +
+ @if($icon) + + + + @endif + +
+ {{ $title }} + {!! $content !!} +
+