Skip to content

Commit f4cf520

Browse files
authored
snowflakes: Remove enabled switch & Translate (#54)
* snowflakes: Remove enabled switch * snowflakes: Translate
1 parent 9b38b94 commit f4cf520

4 files changed

Lines changed: 26 additions & 40 deletions

File tree

snowflakes/config/snowflakes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
return [
4-
'enabled' => env('SNOWFLAKES_ENABLED', true),
54
'size' => env('SNOWFLAKES_SIZE', 1),
65
'speed' => env('SNOWFLAKES_SPEED', 3),
76
'opacity' => env('SNOWFLAKES_OPACITY', 0.5),

snowflakes/lang/en/strings.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
return [
4+
'size' => 'Size',
5+
'size_help' => 'Size of the snowflakes.',
6+
'speed' => 'Speed',
7+
'speed_help' => 'Speed of the snowflakes falling.',
8+
'opacity' => 'Opacity',
9+
'opacity_help' => 'How well can you see through the snowflakes.',
10+
'density' => 'Density',
11+
'density_help' => 'Page density of the snowflakes. More density, more snowflakes.',
12+
'quality' => 'Quality',
13+
'quality_help' => 'Higher quality may impact performance on some devices.',
14+
];

snowflakes/src/Providers/SnowflakesPluginProvider.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@ class SnowflakesPluginProvider extends ServiceProvider
1111
{
1212
public function boot(): void
1313
{
14-
$enabled = config('snowflakes.enabled');
15-
$size = config('snowflakes.size');
16-
$speed = config('snowflakes.speed');
17-
$opacity = config('snowflakes.opacity');
18-
$density = config('snowflakes.density');
19-
$quality = config('snowflakes.quality');
20-
2114
FilamentView::registerRenderHook(
2215
PanelsRenderHook::PAGE_START,
2316
fn () => Blade::render(<<<'HTML'
2417
<script>
2518
window.SnowflakeConfig = {
26-
start: {{ $enabled }},
2719
size: {{ $size }},
2820
speed: {{ $speed }},
2921
opacity: {{ $opacity }},
@@ -34,14 +26,7 @@ public function boot(): void
3426
};
3527
</script>
3628
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/snowflake@master/snowflake.min.js"></script>
37-
HTML, [
38-
'enabled' => $enabled,
39-
'size' => $size,
40-
'speed' => $speed,
41-
'opacity' => $opacity,
42-
'density' => $density,
43-
'quality' => $quality,
44-
])
29+
HTML, config('snowflakes'))
4530
);
4631
}
4732
}

snowflakes/src/SnowflakesPlugin.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use App\Traits\EnvironmentWriterTrait;
77
use Filament\Contracts\Plugin;
88
use Filament\Forms\Components\Slider;
9-
use Filament\Forms\Components\Toggle;
109
use Filament\Notifications\Notification;
1110
use Filament\Panel;
1211
use Filament\Schemas\Components\Group;
@@ -27,60 +26,50 @@ public function boot(Panel $panel): void {}
2726
public function getSettingsForm(): array
2827
{
2928
$schema = [
30-
Toggle::make('SNOWFLAKES_ENABLED')
31-
->label('Enable Snowflakes')
32-
->columnSpanFull()
33-
->live()
34-
->default(fn () => config('snowflakes.enabled')),
3529
Slider::make('SNOWFLAKES_SIZE')
30+
->label(trans('snowflakes::strings.size'))
3631
->range(minValue: 0.5, maxValue: 4)
3732
->decimalPlaces(1)
3833
->step(0.1)
39-
->label('Size')
4034
->tooltips()
4135
->hintIcon('tabler-question-mark')
42-
->hintIconTooltip('Size of the snowflakes.')
43-
->disabled(fn ($get) => !$get('SNOWFLAKES_ENABLED'))
36+
->hintIconTooltip(trans('snowflakes::strings.size_help'))
4437
->default(fn () => config('snowflakes.size')),
4538
Slider::make('SNOWFLAKES_SPEED')
46-
->label('Speed')
39+
->label(trans('snowflakes::strings.speed'))
4740
->range(minValue: 0.5, maxValue: 3)
4841
->decimalPlaces(1)
4942
->step(0.1)
5043
->tooltips()
5144
->hintIcon('tabler-question-mark')
52-
->hintIconTooltip('Speed of the snowflakes falling.')
53-
->disabled(fn ($get) => !$get('SNOWFLAKES_ENABLED'))
45+
->hintIconTooltip(trans('snowflakes::strings.speed_help'))
5446
->default(fn () => config('snowflakes.speed')),
5547
Slider::make('SNOWFLAKES_OPACITY')
56-
->label('Opacity')
48+
->label(trans('snowflakes::strings.opacity'))
5749
->range(minValue: 0.1, maxValue: 1)
5850
->decimalPlaces(1)
5951
->step(0.1)
6052
->tooltips()
6153
->hintIcon('tabler-question-mark')
62-
->hintIconTooltip('How well can you see through the snowflakes.')
63-
->disabled(fn ($get) => !$get('SNOWFLAKES_ENABLED'))
54+
->hintIconTooltip(trans('snowflakes::strings.opacity_help'))
6455
->default(fn () => config('snowflakes.opacity')),
6556
Slider::make('SNOWFLAKES_DENSITY')
66-
->label('Density')
57+
->label(trans('snowflakes::strings.density'))
6758
->range(minValue: 0.5, maxValue: 10)
6859
->decimalPlaces(1)
6960
->step(0.1)
7061
->tooltips()
7162
->hintIcon('tabler-question-mark')
72-
->hintIconTooltip('Page density of the snowflakes. More density, more snowflakes.')
73-
->disabled(fn ($get) => !$get('SNOWFLAKES_ENABLED'))
63+
->hintIconTooltip(trans('snowflakes::strings.density_help'))
7464
->default(fn () => config('snowflakes.density')),
7565
Slider::make('SNOWFLAKES_QUALITY')
76-
->label('Quality')
66+
->label(trans('snowflakes::strings.quality'))
7767
->range(minValue: 0.1, maxValue: 1)
7868
->decimalPlaces(1)
7969
->step(0.1)
8070
->tooltips()
8171
->hintIcon('tabler-question-mark')
82-
->hintIconTooltip('Higher quality may impact performance on some devices.')
83-
->disabled(fn ($get) => !$get('SNOWFLAKES_ENABLED'))
72+
->hintIconTooltip(trans('snowflakes::strings.quality_help'))
8473
->default(fn () => config('snowflakes.quality')),
8574
];
8675

@@ -93,11 +82,10 @@ public function getSettingsForm(): array
9382

9483
public function saveSettings(array $data): void
9584
{
96-
$data['SNOWFLAKES_ENABLED'] = $data['SNOWFLAKES_ENABLED'] ? 'true' : 'false';
9785
$this->writeToEnvironment($data);
9886

9987
Notification::make()
100-
->title('Settings saved')
88+
->title(trans('admin/setting.save_success'))
10189
->success()
10290
->send();
10391
}

0 commit comments

Comments
 (0)