Skip to content

Commit 6eac273

Browse files
committed
docs
1 parent 4d4278a commit 6eac273

File tree

9 files changed

+118
-48
lines changed

9 files changed

+118
-48
lines changed

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

+19-12
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,18 @@
33
namespace App\Livewire;
44

55
use Filament\Actions\Action;
6-
use Filament\Infolists\Components\ColorEntry;
7-
use Filament\Infolists\Components\IconEntry;
8-
use Filament\Infolists\Components\ImageEntry;
9-
use Filament\Infolists\Components\KeyValueEntry;
10-
use Filament\Infolists\Components\RepeatableEntry;
11-
use Filament\Infolists\Components\TextEntry;
126
use Filament\Schemas\Components\Group;
137
use Filament\Schemas\Components\Image;
148
use Filament\Schemas\Components\Section;
15-
use Filament\Schemas\Components\Split;
169
use Filament\Schemas\Components\Text;
1710
use Filament\Schemas\Components\UnorderedList;
1811
use Filament\Schemas\Concerns\InteractsWithSchemas;
1912
use Filament\Schemas\Contracts\HasSchemas;
2013
use Filament\Schemas\Schema;
2114
use Filament\Support\Enums\FontFamily;
2215
use Filament\Support\Enums\FontWeight;
23-
use Filament\Support\Enums\IconPosition;
24-
use Filament\Support\Enums\IconSize;
2516
use Filament\Support\Enums\TextSize;
26-
use Filament\Support\Icons\Heroicon;
27-
use Illuminate\Contracts\Support\Htmlable;
2817
use Illuminate\Support\HtmlString;
29-
use Illuminate\Support\Js;
3018
use Livewire\Component;
3119

3220
class PrimesDemo extends Component implements HasSchemas
@@ -98,6 +86,25 @@ public function primes(Schema $schema): Schema
9886
->schema([
9987
Text::make(new HtmlString('<strong>Warning:</strong> Modifying these permissions may give users access to sensitive information.')),
10088
]),
89+
Group::make()
90+
->id('textColor')
91+
->extraAttributes([
92+
'class' => 'p-16 max-w-xl',
93+
])
94+
->schema([
95+
Text::make('Information')
96+
->color('info'),
97+
]),
98+
Group::make()
99+
->id('textBadge')
100+
->extraAttributes([
101+
'class' => 'p-16 max-w-xl',
102+
])
103+
->schema([
104+
Text::make('Warning')
105+
->color('warning')
106+
->badge(),
107+
]),
101108
]);
102109
}
103110

Loading
Loading
Loading
Loading

docs-assets/screenshots/schema.js

+18
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,24 @@ export default {
18471847
deviceScaleFactor: 3,
18481848
},
18491849
},
1850+
'primes/text/color': {
1851+
url: 'primes',
1852+
selector: '#textColor',
1853+
viewport: {
1854+
width: 1920,
1855+
height: 640,
1856+
deviceScaleFactor: 3,
1857+
},
1858+
},
1859+
'primes/text/badge': {
1860+
url: 'primes',
1861+
selector: '#textBadge',
1862+
viewport: {
1863+
width: 1920,
1864+
height: 640,
1865+
deviceScaleFactor: 3,
1866+
},
1867+
},
18501868
'tables/example': {
18511869
url: 'tables?table=example',
18521870
selector: 'body',

packages/schemas/docs/03-infolists/02-text.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,6 @@ TextEntry::make('title')
1717

1818
<AutoScreenshot name="infolists/entries/text/simple" alt="Text entry" version="4.x" />
1919

20-
## Displaying as a "badge"
21-
22-
By default, text is quite plain and has no background color. You can make it appear as a "badge" instead using the `badge()` method. A great use case for this is with statuses, where may want to display a badge with a [color](#customizing-the-color) that matches the status:
23-
24-
```php
25-
use Filament\Infolists\Components\TextEntry;
26-
27-
TextEntry::make('status')
28-
->badge()
29-
->color(fn (string $state): string => match ($state) {
30-
'draft' => 'gray',
31-
'reviewing' => 'warning',
32-
'published' => 'success',
33-
'rejected' => 'danger',
34-
})
35-
```
36-
37-
<AutoScreenshot name="infolists/entries/text/badge" alt="Text entry as badge" version="4.x" />
38-
39-
You may add other things to the badge, like an [icon](#adding-an-icon).
40-
41-
Optionally, you may pass a boolean value to control if the text should be in a badge or not:
42-
43-
```php
44-
use Filament\Infolists\Components\TextEntry;
45-
46-
TextEntry::make('status')
47-
->badge(FeatureFlag::active())
48-
```
49-
50-
<UtilityInjection set="infolistEntries" version="4.x">As well as allowing a static value, the `badge()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
51-
5220
## Customizing the color
5321

5422
You may set a [color](../../styling/colors) for the text:
@@ -111,6 +79,38 @@ TextEntry::make('email')
11179

11280
<AutoScreenshot name="infolists/entries/text/icon-color" alt="Text entry with icon in the primary color" version="4.x" />
11381

82+
## Displaying as a "badge"
83+
84+
By default, text is quite plain and has no background color. You can make it appear as a "badge" instead using the `badge()` method. A great use case for this is with statuses, where may want to display a badge with a [color](#customizing-the-color) that matches the status:
85+
86+
```php
87+
use Filament\Infolists\Components\TextEntry;
88+
89+
TextEntry::make('status')
90+
->badge()
91+
->color(fn (string $state): string => match ($state) {
92+
'draft' => 'gray',
93+
'reviewing' => 'warning',
94+
'published' => 'success',
95+
'rejected' => 'danger',
96+
})
97+
```
98+
99+
<AutoScreenshot name="infolists/entries/text/badge" alt="Text entry as badge" version="4.x" />
100+
101+
You may add other things to the badge, like an [icon](#adding-an-icon).
102+
103+
Optionally, you may pass a boolean value to control if the text should be in a badge or not:
104+
105+
```php
106+
use Filament\Infolists\Components\TextEntry;
107+
108+
TextEntry::make('status')
109+
->badge(FeatureFlag::active())
110+
```
111+
112+
<UtilityInjection set="infolistEntries" version="4.x">As well as allowing a static value, the `badge()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
113+
114114
## Formatting
115115

116116
When using a text entry, you may want the actual outputted text in the UI to differ from the raw [state](overview#entry-content-state) of the entry, which is often automatically retrieved from an Eloquent model. Formatting the state allows you to preserve the integrity of the raw data while also allowing it to be presented in a more user-friendly way.

packages/schemas/docs/05-primes/02-text.md

+43
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,46 @@ Text::make(
4343
```
4444

4545
<UtilityInjection set="primeComponents" version="4.x">As well as allowing a static value, the `make()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
46+
47+
## Customizing the color
48+
49+
You may set a [color](../../styling/colors) for the text:
50+
51+
```php
52+
use Filament\Schemas\Components\Text;
53+
54+
Text::make('Information')
55+
->color('info')
56+
```
57+
58+
<UtilityInjection set="infolistEntries" version="4.x">As well as allowing a static value, the `color()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
59+
60+
<AutoScreenshot name="primes/text/color" alt="Text in the info color" version="4.x" />
61+
62+
## Displaying as a "badge"
63+
64+
By default, text is quite plain and has no background color. You can make it appear as a "badge" instead using the `badge()` method. A great use case for this is with statuses, where may want to display a badge with a [color](#customizing-the-color) that matches the status:
65+
66+
```php
67+
use Filament\Schemas\Components\Text;
68+
69+
Text::make('Warning')
70+
->color('warning')
71+
->badge()
72+
```
73+
74+
<AutoScreenshot name="primes/text/badge" alt="Text as badge" version="4.x" />
75+
76+
You may add other things to the badge, like an [icon](../../styling/icons).
77+
78+
Optionally, you may pass a boolean value to control if the text should be in a badge or not:
79+
80+
```php
81+
use Filament\Schemas\Components\Text;
82+
83+
Text::make('Warning')
84+
->color('warning')
85+
->badge(FeatureFlag::active())
86+
```
87+
88+
<UtilityInjection set="infolistEntries" version="4.x">As well as allowing a static value, the `badge()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<ul
2-
{{ $getExtraAttributeBag()->class([
3-
'fi-sc-unordered-list',
4-
(($size = $getSize()) instanceof \Filament\Support\Enums\TextSize) ? "fi-size-{$size->value}" : $size,
5-
]) }}
2+
{{
3+
$getExtraAttributeBag()->class([
4+
'fi-sc-unordered-list',
5+
(($size = $getSize()) instanceof \Filament\Support\Enums\TextSize) ? "fi-size-{$size->value}" : $size,
6+
])
7+
}}
68
>
79
@foreach ($getChildSchema()->getComponents() as $component)
810
<li>

0 commit comments

Comments
 (0)