Skip to content

Commit 62cdf0c

Browse files
committed
docs
1 parent dbfe551 commit 62cdf0c

File tree

15 files changed

+93
-59
lines changed

15 files changed

+93
-59
lines changed

docs-assets/app/app/Livewire/PrimesDemo.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function primes(Schema $schema): Schema
6262
->copyable()
6363
->copyMessage('Copied')
6464
->fontFamily(FontFamily::Mono)
65-
->size('xs')
65+
->size(TextSize::ExtraSmall)
6666
->color('neutral'),
6767
[
6868
'tYRnCqNLUx-3QOLNKyDiV',
@@ -75,7 +75,7 @@ public function primes(Schema $schema): Schema
7575
'cO0dJYqmee-S9ubJHpRFR',
7676
],
7777
))
78-
->size('xs'),
78+
->size(TextSize::ExtraSmall),
7979
])
8080
->compact()
8181
->secondary(),

packages/panels/src/Auth/MultiFactor/GoogleTwoFactor/Actions/SetUpGoogleTwoFactorAuthenticationAction.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Filament\Schemas\Components\UnorderedList;
2121
use Filament\Support\Enums\FontFamily;
2222
use Filament\Support\Enums\FontWeight;
23+
use Filament\Support\Enums\TextSize;
2324
use Filament\Support\Enums\Width;
2425
use Filament\Support\Icons\Heroicon;
2526
use Illuminate\Contracts\Auth\Authenticatable;
@@ -86,11 +87,11 @@ public static function make(GoogleTwoFactorAuthentication $googleTwoFactorAuthen
8687
->copyable()
8788
->copyMessage(__('filament-panels::auth/multi-factor/recovery-codes-modal-content.messages.copied'))
8889
->fontFamily(FontFamily::Mono)
89-
->size('xs')
90+
->size(TextSize::ExtraSmall)
9091
->color('neutral'),
9192
decrypt($action->getArguments()['encrypted'] ?? encrypt([]))['recoveryCodes'] ?? [],
9293
))
93-
->size('xs'),
94+
->size(TextSize::ExtraSmall),
9495
Text::make(function () use ($action): Htmlable {
9596
$recoveryCodes = decrypt($action->getArguments()['encrypted'])['recoveryCodes'];
9697

packages/schemas/docs/04-layouts/01-overview.md

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ By default, calling `extraAttributes()` multiple times will overwrite the previo
5454
The vast majority of methods used to configure entries accept functions as parameters instead of hardcoded values:
5555

5656
```php
57-
use App\Models\User;
5857
use Filament\Schemas\Components\Grid;
5958
use Filament\Schemas\Components\Section;
6059

packages/schemas/docs/05-primes/01-overview.md

+32-42
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use Filament\Schemas\Components\Image;
1919
use Filament\Schemas\Components\Section;
2020
use Filament\Schemas\Components\Text;
2121
use Filament\Schemas\Components\UnorderedList;
22+
use Filament\Support\Enums\FontWeight;
23+
use Filament\Support\Enums\TextSize;
2224

2325
$schema
2426
->components([
@@ -39,11 +41,11 @@ $schema
3941
fn (string $recoveryCode): Text => Text::make($recoveryCode)
4042
->copyable()
4143
->fontFamily(FontFamily::Mono)
42-
->size('xs')
44+
->size(TextSize::ExtraSmall)
4345
->color('neutral'),
4446
['tYRnCqNLUx-3QOLNKyDiV', 'cKok2eImKc-oWHHH4VhNe', 'C0ZstEcSSB-nrbyk2pv8z', '49EXLRQ8MI-FpWywpSDHE', 'TXjHnvkUrr-KuiVJENPmJ', 'BB574ookll-uI20yxP6oa', 'BbgScF2egu-VOfHrMtsCl', 'cO0dJYqmee-S9ubJHpRFR'],
4547
))
46-
->size('xs'),
48+
->size(TextSize::ExtraSmall),
4749
])
4850
->compact()
4951
->secondary(),
@@ -52,40 +54,31 @@ $schema
5254
])
5355
```
5456

55-
In these examples, the prime components are not associated with any other components in the schema, they are standalone.
57+
Although text can be rendered in a schema using an [infolist text entry](../infolists/text), entries are intended to render a label-value detail about an entity (like an Eloquent model), and not to render arbitrary text. Prime components are more suitable for this purpose. Infolists can be considered more similar to [description lists](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl) in HTML.
5658

5759
Prime component classes can be found in the `Filament\Schemas\Components` namespace. They reside within the schema array of components.
5860

59-
Components may be created using the static `make()` method. Usually, you will then define the child component `schema()` to display inside:
60-
61-
```php
62-
use Filament\Schemas\Components\Text;
63-
64-
Text::make()
65-
```
66-
6761
## Available prime components
6862

6963
Filament ships with some prime components, suitable for arranging your components depending on your needs:
7064

71-
- [Grid](grid)
72-
- [Section](section)
73-
- [Tabs](tabs)
74-
- [Wizard](wizard)
75-
- [Fieldset](fieldset)
76-
- [Split](split)
65+
- [Text](text)
66+
- [Icon](icon)
67+
- [Image](image)
68+
- [Unordered list](unordered-list)
69+
- [Action](action)
7770

78-
You may also [create your own custom prime components](custom) to organize schemas however you wish.
71+
You may also [create your own custom prime components](custom) to add your own arbitrary content to a schema.
7972

8073
## Adding extra HTML attributes to a prime component
8174

8275
You can pass extra HTML attributes to the component via the `extraAttributes()` method, which will be merged onto its outer HTML element. The attributes should be represented by an array, where the key is the attribute name and the value is the attribute value:
8376

8477
```php
85-
use Filament\Schemas\Components\Section;
78+
use Filament\Schemas\Components\Text;
8679

87-
Section::make()
88-
->extraAttributes(['class' => 'custom-section-style'])
80+
Text::make()
81+
->extraAttributes(['class' => 'custom-text-style'])
8982
```
9083

9184
<UtilityInjection set="formFields" version="4.x">As well as allowing a static value, the `extraAttributes()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
@@ -97,21 +90,18 @@ By default, calling `extraAttributes()` multiple times will overwrite the previo
9790
The vast majority of methods used to configure entries accept functions as parameters instead of hardcoded values:
9891

9992
```php
100-
use App\Models\User;
101-
use Filament\Schemas\Components\Grid;
102-
use Filament\Schemas\Components\Section;
93+
use Filament\Schemas\Components\Image;
94+
use Filament\Schemas\Components\Text;
10395

104-
Grid::make(fn (): array => [
105-
'lg' => auth()->user()->isAdmin() ? 4 : 6,
106-
])->schema([
107-
// ...
108-
])
96+
Text::make(fn (): string => auth()->user()->isAdmin()
97+
? 'Admin users modify the settings'
98+
: 'Non-admin users view but not change the settings.')
10999

110-
Section::make()
111-
->heading(fn (): string => auth()->user()->isAdmin() ? 'Admin Dashboard' : 'User Dashboard')
112-
->schema([
113-
// ...
114-
])
100+
Image::make(
101+
url: fn (): string => auth()->user()->isAdmin() ? asset('images/admin.jpg') : asset('images/non-admin.jpg'),
102+
alt: fn (): string => auth()->user()->isAdmin() ? 'Admin user' : 'Non-admin user',
103+
)
104+
->imageHeight(fn (): string => auth()->user()->isAdmin() ? '12rem' : '8rem')
115105
```
116106

117107
This alone unlocks many customization possibilities.
@@ -212,22 +202,22 @@ function (Request $request, Set $set) {
212202

213203
## Global settings
214204

215-
If you wish to change the default behavior of a component globally, then you can call the static `configureUsing()` method inside a service provider's `boot()` method, to which you pass a Closure to modify the component using. For example, if you wish to make all section components have [2 columns](grid) by default, you can do it like so:
205+
If you wish to change the default behavior of a component globally, then you can call the static `configureUsing()` method inside a service provider's `boot()` method, to which you pass a Closure to modify the component using. For example, if you wish to make all images have a height of 12rem by default:
216206

217207
```php
218-
use Filament\Schemas\Components\Section;
208+
use Filament\Schemas\Components\Image;
219209

220-
Section::configureUsing(function (Section $section): void {
221-
$section
222-
->columns(2);
210+
Image::configureUsing(function (Image $image): void {
211+
$image
212+
->imageHeight('12rem');
223213
});
224214
```
225215

226216
Of course, you are still able to overwrite this on each component individually:
227217

228218
```php
229-
use Filament\Schemas\Components\Section;
219+
use Filament\Schemas\Components\Image;
230220

231-
Section::make()
232-
->columns(1)
221+
Image::make()
222+
->imageHeight('8rem')
233223
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Text
3+
---
4+
import Aside from "@components/Aside.astro"
5+
import AutoScreenshot from "@components/AutoScreenshot.astro"
6+
import UtilityInjection from "@components/UtilityInjection.astro"
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Icon
3+
---
4+
import Aside from "@components/Aside.astro"
5+
import AutoScreenshot from "@components/AutoScreenshot.astro"
6+
import UtilityInjection from "@components/UtilityInjection.astro"
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Image
3+
---
4+
import Aside from "@components/Aside.astro"
5+
import AutoScreenshot from "@components/AutoScreenshot.astro"
6+
import UtilityInjection from "@components/UtilityInjection.astro"
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Unordered list
3+
---
4+
import Aside from "@components/Aside.astro"
5+
import AutoScreenshot from "@components/AutoScreenshot.astro"
6+
import UtilityInjection from "@components/UtilityInjection.astro"
7+

packages/schemas/docs/05-primes/02-actions.md packages/schemas/docs/05-primes/06-action.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Actions
2+
title: Action
33
---
44
import AutoScreenshot from "@components/AutoScreenshot.astro"
55

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Custom
3+
---
4+
import Aside from "@components/Aside.astro"
5+
import AutoScreenshot from "@components/AutoScreenshot.astro"
6+
import UtilityInjection from "@components/UtilityInjection.astro"
7+
8+
render hook
9+
livewire
10+
view
11+
custom component

packages/schemas/resources/views/components/image.blade.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
@if (filled($tooltip))
1818
x-tooltip="{ content: @js($tooltip), theme: $store.theme }"
1919
@endif
20-
@class([
21-
'fi-sc-icon',
22-
($alignment instanceof Alignment) ? "fi-align-{$alignment->value}" : $alignment,
23-
])
24-
@style([
25-
"height: {$height}" => $height,
26-
"width: {$width}" => $width,
27-
])
20+
{{
21+
$getExtraAttributeBag()
22+
->class([
23+
'fi-sc-icon',
24+
($alignment instanceof Alignment) ? "fi-align-{$alignment->value}" : $alignment,
25+
])
26+
->style([
27+
"height: {$height}" => $height,
28+
"width: {$width}" => $width,
29+
])
30+
}}
2831
/>

packages/schemas/resources/views/components/text.blade.php

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
' : null
3737
"
3838
:tag="$isCopyable ? 'button' : 'span'"
39+
:attributes="\Filament\Support\prepare_inherited_attributes($getExtraAttributeBag())"
3940
>
4041
{{ $content }}
4142
</x-filament::badge>
@@ -60,6 +61,7 @@
6061
($weight instanceof FontWeight) ? "fi-font-{$weight->value}" : $weight,
6162
($fontFamily instanceof FontFamily) ? "fi-font-{$fontFamily->value}" : $fontFamily,
6263
])
64+
->merge($getExtraAttributes(), escape: false)
6365
}}
6466
>
6567
{{ $content }}

packages/schemas/resources/views/components/unordered-list.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<ul
2-
@class([
2+
{{ $getExtraAttributeBag()->class([
33
'fi-sc-unordered-list',
44
(($size = $getSize()) instanceof \Filament\Support\Enums\TextSize) ? "fi-size-{$size->value}" : $size,
5-
])
5+
]) }}
66
>
77
@foreach ($getChildSchema()->getComponents() as $component)
88
<li>

packages/support/resources/views/components/icon.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'icon' => null,
44
])
55

6-
{{ \Filament\Support\generate_icon_html($icon, $alias, $attributes) }}
6+
{{ \Filament\Support\generate_icon_html($icon, $alias, $attributes->merge($getExtraAttributes(), escape: false)) }}

0 commit comments

Comments
 (0)