導覽
在頁面之間移動:麵包屑、導覽選單與分頁。
INFO
所有元件都能用共用方法(key、visible、class、attributes、view…)。
Breadcrumbs
breadcrumbs麵包屑導覽,最後一項用 current() 標示目前頁面。
php
use Cg\ComponentFramework\Component\Breadcrumbs\BreadcrumbItem;
use Cg\ComponentFramework\Component\Breadcrumbs\Breadcrumbs;
Breadcrumbs::make([
BreadcrumbItem::make('home', '首頁')->url('/'),
BreadcrumbItem::make('orders', '訂單')->url('/orders'),
BreadcrumbItem::make('detail', '#1024')->current(),
]);建構:Breadcrumbs::make(iterable $items = [])
方法一覽 (4)
items(iterable $items)push(BreadcrumbItem $item)label(string $label)separator(Htmlable|string $separator)
Navigation
navigation menu導覽選單,支援巢狀項目、徽章與水平/垂直排列。
php
use Cg\ComponentFramework\Component\Navigation\Navigation;
use Cg\ComponentFramework\Component\Navigation\NavigationItem;
Navigation::make([
NavigationItem::make('dashboard', '儀表板')->url('/dashboard')->current(),
NavigationItem::make('settings', '設定')->children([
NavigationItem::make('profile', '個人資料')->url('/settings/profile'),
NavigationItem::make('billing', '帳單')->url('/settings/billing'),
]),
])->orientation('vertical');建構:Navigation::make(iterable $items = [])
可用選項
orientation():horizontal·vertical
方法一覽 (5)
items(iterable $items)push(NavigationItem $item)label(string $label)orientation(string $orientation)single(bool $condition = true)
Pagination
pagination pager分頁導覽,直接吃 Laravel 的 Paginator。
php
use App\Models\User;
use Cg\ComponentFramework\Component\Pagination\Pagination;
Pagination::make(User::query()->paginate(15))
->onEachSide(1)
->showSummary();建構:Pagination::make(Paginator|CursorPaginator|Closure $paginator)
方法一覽 (6)
onEachSide(int $pages)label(string $label)showSummary(bool $condition = true)hideWhenSinglePage(bool $condition = true)renderPagesWith(string $controller, string $target, string $method = 'components', array $params = [], array $extra = [])linkerPaginate(string $method, array $extra = [])
這一頁由 scripts/wiki-components/generate.php 依原始碼產生,範例都經過實際渲染驗證。