浮動介面
浮在頁面上的介面:對話框、抽屜、浮動內容與提示文字。
INFO
所有元件都能用共用方法(key、visible、class、attributes、view…)。
Drawer
drawer側邊抽屜。用 openButton() 產生開啟按鈕,抽屜本身也要放進頁面。
php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Drawer\Drawer;
use Cg\ComponentFramework\Component\Select\Select;
use Cg\ComponentFramework\Component\Stack\Stack;
$drawer = Drawer::make('filters', '篩選條件', 'right')
->body(Select::make('status', '狀態')->options(['open' => '進行中', 'done' => '已完成']))
->footer([
Button::make('套用')->color('primary')->closesModal('filters'),
]);
Stack::make([$drawer->openButton('開啟篩選'), $drawer]);建構:Drawer::make(string $name, Htmlable|Closure|string|null $title = null, string $side = 'right')
方法一覽 (10)
side(string $side)variant(string $variant)body(mixed $body)footer(Actions|Traversable|array $actions)description(Closure|string|null $description)label(?string $label)static(bool $condition = true)autofocus(?string $selector)closeButton(bool $condition = true)openButton(Htmlable|Closure|string $label)
Modal
modal dialog對話框。開關是純前端狀態、不發請求;用 openButton() 產生開啟按鈕。
php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Modal\Modal;
use Cg\ComponentFramework\Component\Stack\Stack;
$modal = Modal::make('confirm-delete', '確定要刪除?')
->description('刪除後無法復原。')
->footer([
Button::make('取消')->variant('ghost')->closesModal('confirm-delete'),
Button::make('刪除')->color('danger'),
]);
Stack::make([$modal->openButton('刪除'), $modal]);建構:Modal::make(string $name, Htmlable|Closure|string|null $title = null)
方法一覽 (9)
body(mixed $body)footer(Actions|Traversable|array $actions)description(Closure|string|null $description)label(?string $label)variant(string $variant)static(bool $condition = true)autofocus(?string $selector)closeButton(bool $condition = true)openButton(Htmlable|Closure|string $label)
Popover
popover點擊後出現的浮動內容,可放任何元件。
php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Popover\Popover;
Popover::make(
Button::make('說明')->variant('ghost'),
'這個欄位會顯示在公開頁面。',
)->title('提示')->placement('bottom');建構:Popover::make(Component $trigger, mixed $content = null)
可用選項
placement():top·right·bottom·leftalign():start·center·endwidth():sm·md·lg
方法一覽 (10)
id(string $id)content(mixed $content)title(Htmlable|Closure|string|null $title)label(?string $label)placement(string $placement, string $align = 'start')width(string $width)offset(int $pixels)open(bool $condition = true)dismissible(bool $condition = true, string $label = '關閉浮動內容')stateKey(string $key)
Tooltip
tooltip滑過或聚焦時出現的簡短提示文字。
php
use Cg\ComponentFramework\Component\Button\Button;
use Cg\ComponentFramework\Component\Tooltip\Tooltip;
Tooltip::make(
Button::make('複製')->icon('file'),
'複製分享連結',
)->placement('top');建構:Tooltip::make(Component $trigger, Closure|string $content)
可用選項
placement():top·right·bottom·left
方法一覽 (4)
id(string $id)placement(string $placement)delay(int $milliseconds)offset(int $pixels)
這一頁由 scripts/wiki-components/generate.php 依原始碼產生,範例都經過實際渲染驗證。