Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithDennis committed Jun 27, 2024
1 parent 5080630 commit 958acc4
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 245 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) CodeWithDennis <personal.elsinga@gmail.com>
Copyright (c) CodeWithDennis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
97 changes: 67 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# A plugin for adding straightforward alerts to your filament pages
# Filament Simple Alert

[![Latest Version on Packagist](https://img.shields.io/packagist/v/codewithdennis/filament-simple-alert.svg?style=flat-square)](https://packagist.org/packages/codewithdennis/filament-simple-alert)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/codewithdennis/filament-simple-alert/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/codewithdennis/filament-simple-alert/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/codewithdennis/filament-simple-alert/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/codewithdennis/filament-simple-alert/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/codewithdennis/filament-simple-alert.svg?style=flat-square)](https://packagist.org/packages/codewithdennis/filament-simple-alert)



This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
This package provides a simple alert component for Filament.

## Installation

Expand All @@ -17,56 +14,96 @@ You can install the package via composer:
composer require codewithdennis/filament-simple-alert
```

You can publish and run the migrations with:
## Usage

```bash
php artisan vendor:publish --tag="filament-simple-alert-migrations"
php artisan migrate
### Simple Alerts

```php
SimpleAlertEntry::make()
->danger()
->info()
->success()
->warning()
```

You can publish the config file with:
If you would like to use a [different color](https://filamentphp.com/docs/3.x/support/colors), you can use the `color` method:

```bash
php artisan vendor:publish --tag="filament-simple-alert-config"
```php
SimpleAlertEntry::make()
->color('purple')
```

Optionally, you can publish the views using
### Title

```bash
php artisan vendor:publish --tag="filament-simple-alert-views"
You can add a title to the alert by using the `title` method:

```php
SimpleAlertEntry::make()
->title('This is the title')
```

This is the contents of the published config file:
### Description

You can add a description to the alert by using the `description` method:

```php
return [
];
SimpleAlertEntry::make()
->description('This is the description')
```

## Usage
### Icon

By default, all simple alerts will have an icon. If you would like to change the icon, you can use the `icon` method:

```php
$simpleAlert = new CodeWithDennis\SimpleAlert();
echo $simpleAlert->echoPhrase('Hello, CodeWithDennis!');
SimpleAlertEntry::make()
->color('purple')
->icon('heroicon-s-users')
```

## Testing
### Link

```bash
composer test
You can also add a link to the alert by using the `link` method:

```php
SimpleAlertEntry::make()
->info()
->link('https://filamentphp.com'),
```

## Changelog
If you would like the link to customize the link label, you can use the `linkLabel` method:

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
```php
SimpleAlertEntry::make()
->info()
->link('https://filamentphp.com')
->linkLabel('Read more!'),
```

## Contributing
If you would like the link to open in a new tab, you can use the `blank` method:

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
```php
SimpleAlertEntry::make()
->info()
->link('https://filamentphp.com')
->linkBlank(),
```

### Example

## Security Vulnerabilities
```php
SimpleAlertEntry::make()
->success()
->title(new HtmlString('<strong>Hoorraayy! Your request has been approved! 🎉</strong>'))
->description('Lorem ipsum dolor sit amet consectetur adipisicing elit.')
->link('https://filamentphp.com')
->linkLabel('Read more!')
->linkBlank(),
```

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

## Credits

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.16",
"nunomaduro/collision": "^7.9",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.1",
Expand Down Expand Up @@ -65,4 +66,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
6 changes: 0 additions & 6 deletions config/simple-alert.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/migrations/create_simple_alert_table.php.stub

This file was deleted.

6 changes: 0 additions & 6 deletions resources/lang/en/simple-alert.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Commands/SimpleAlertCommand.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Components/SimpleAlertEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ public function getIcon(): ?string
{
return $this->evaluate($this->icon);
}
}
}
122 changes: 1 addition & 121 deletions src/SimpleAlertServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace CodeWithDennis\SimpleAlert;

use CodeWithDennis\SimpleAlert\Commands\SimpleAlertCommand;
use CodeWithDennis\SimpleAlert\Testing\TestsSimpleAlert;
use Filament\Support\Assets\Asset;
use Filament\Support\Facades\FilamentAsset;
use Filament\Support\Facades\FilamentIcon;
use Illuminate\Filesystem\Filesystem;
use Livewire\Features\SupportTesting\Testable;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand All @@ -21,131 +14,18 @@ class SimpleAlertServiceProvider extends PackageServiceProvider

public function configurePackage(Package $package): void
{
/*
* This class is a Package Service Provider
*
* More info: https://github.com/spatie/laravel-package-tools
*/
$package->name(static::$name)
->hasCommands($this->getCommands())
->hasInstallCommand(function (InstallCommand $command) {
$command
->publishConfigFile()
->publishMigrations()
->askToRunMigrations()
->askToStarRepoOnGitHub('codewithdennis/filament-simple-alert');
$command->askToStarRepoOnGitHub('codewithdennis/filament-simple-alert');
});

$configFileName = $package->shortName();

if (file_exists($package->basePath("/../config/{$configFileName}.php"))) {
$package->hasConfigFile();
}

if (file_exists($package->basePath('/../database/migrations'))) {
$package->hasMigrations($this->getMigrations());
}

if (file_exists($package->basePath('/../resources/lang'))) {
$package->hasTranslations();
}

if (file_exists($package->basePath('/../resources/views'))) {
$package->hasViews(static::$viewNamespace);
}
}

public function packageRegistered(): void
{
}

public function packageBooted(): void
{
// Asset Registration
FilamentAsset::register(
$this->getAssets(),
$this->getAssetPackageName()
);

FilamentAsset::registerScriptData(
$this->getScriptData(),
$this->getAssetPackageName()
);

// Icon Registration
FilamentIcon::register($this->getIcons());

// Handle Stubs
if (app()->runningInConsole()) {
foreach (app(Filesystem::class)->files(__DIR__.'/../stubs/') as $file) {
$this->publishes([
$file->getRealPath() => base_path("stubs/filament-simple-alert/{$file->getFilename()}"),
], 'filament-simple-alert-stubs');
}
}

// Testing
Testable::mixin(new TestsSimpleAlert());
}

protected function getAssetPackageName(): ?string
{
return 'codewithdennis/filament-simple-alert';
}

/**
* @return array<Asset>
*/
protected function getAssets(): array
{
return [
// AlpineComponent::make('filament-simple-alert', __DIR__ . '/../resources/dist/components/filament-simple-alert.js'),
// Css::make('filament-simple-alert', __DIR__.'/../resources/dist/filament-simple-alert.css'),
// Js::make('filament-simple-alert-scripts', __DIR__ . '/../resources/dist/filament-simple-alert.js'),
];
}

/**
* @return array<class-string>
*/
protected function getCommands(): array
{
return [
SimpleAlertCommand::class,
];
}

/**
* @return array<string>
*/
protected function getIcons(): array
{
return [];
}

/**
* @return array<string>
*/
protected function getRoutes(): array
{
return [];
}

/**
* @return array<string, mixed>
*/
protected function getScriptData(): array
{
return [];
}

/**
* @return array<string>
*/
protected function getMigrations(): array
{
return [
'create_filament-simple-alert_table',
];
}
}
Loading

0 comments on commit 958acc4

Please sign in to comment.