Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions config/alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,80 +27,80 @@
'themes' => [
'classic' => [
'components' => 'Digitlimit\Alert\View\Components\Themes\Classic',
'types' => [
'types' => [
'message' => [
'view' => 'alert-message',
'alert' => Types\Message::class,
'view' => 'alert-message',
'alert' => Types\Message::class,
'component' => Themes\Classic\Message::class,
],

'field' => [
'view' => 'alert-field',
'alert' => Types\Field::class,
'view' => 'alert-field',
'alert' => Types\Field::class,
'component' => Themes\Classic\Field::class,
],

'bag' => [
'view' => 'alert-field',
'alert' => Types\FieldBag::class,
'view' => 'alert-field',
'alert' => Types\FieldBag::class,
'component' => Themes\Classic\Field::class,
],

'modal' => [
'view' => 'alert-modal',
'alert' => Types\Modal::class,
'view' => 'alert-modal',
'alert' => Types\Modal::class,
'component' => Themes\Classic\Modal::class,
],

'notify' => [
'view' => 'alert-notify',
'alert' => Types\Notify::class,
'view' => 'alert-notify',
'alert' => Types\Notify::class,
'component' => Themes\Classic\Notify::class,
],

'sticky' => [
'view' => 'alert-sticky',
'alert' => Types\Sticky::class,
'view' => 'alert-sticky',
'alert' => Types\Sticky::class,
'component' => Themes\Classic\Sticky::class,
],
],
],
'bootstrap5' => [
'components' => 'Digitlimit\Alert\View\Components\Themes\Bootstrap5',
'types' => [
'types' => [
'message' => [
'view' => 'alert-message',
'alert' => Types\Message::class,
'view' => 'alert-message',
'alert' => Types\Message::class,
'component' => Themes\Bootstrap5\Message::class,
],

'field' => [
'view' => 'alert-field',
'alert' => Types\Field::class,
'view' => 'alert-field',
'alert' => Types\Field::class,
'component' => Themes\Bootstrap5\Field::class,
],

'bag' => [
'view' => 'alert-field',
'alert' => Types\FieldBag::class,
'view' => 'alert-field',
'alert' => Types\FieldBag::class,
'component' => Themes\Bootstrap5\Field::class,
],

'modal' => [
'view' => 'alert-modal',
'alert' => Types\Modal::class,
'view' => 'alert-modal',
'alert' => Types\Modal::class,
'component' => Themes\Bootstrap5\Modal::class,
],

'notify' => [
'view' => 'alert-notify',
'alert' => Types\Notify::class,
'view' => 'alert-notify',
'alert' => Types\Notify::class,
'component' => Themes\Bootstrap5\Notify::class,
],

'sticky' => [
'view' => 'alert-sticky',
'alert' => Types\Sticky::class,
'view' => 'alert-sticky',
'alert' => Types\Sticky::class,
'component' => Themes\Bootstrap5\Sticky::class,
],
],
Expand Down
9 changes: 5 additions & 4 deletions src/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Alert
*/
public function __construct(
protected SessionInterface $session
) {}
) {
}

/**
* Fetch an alert based on the default tag.
Expand All @@ -43,7 +44,7 @@ public function named(
string $name,
?string $tag = null
): ?MessageInterface {
if (! Type::exists($type)) {
if (!Type::exists($type)) {
throw new Exception("Invalid alert type '$type'. Check the alert config");
}

Expand All @@ -61,7 +62,7 @@ public function tagged(
string $type,
string $tag
): ?MessageInterface {
if (! Type::exists($type)) {
if (!Type::exists($type)) {
throw new Exception("Invalid alert type '$type'. Check the alert config");
}

Expand Down Expand Up @@ -141,7 +142,7 @@ public function from(
string $type,
...$args
): MessageInterface {
if (! Type::exists($type)) {
if (!Type::exists($type)) {
throw new Exception("Invalid alert type '$type'. Check the alert config");
}

Expand Down
3 changes: 2 additions & 1 deletion src/Component/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public function __construct(
public ?string $label = null,
public ?string $link = null,
public array $attributes = []
) {}
) {
}

/**
* Set the button label.
Expand Down
14 changes: 7 additions & 7 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Validator;

if (! function_exists('alert')) {
if (!function_exists('alert')) {
function alert(string $message, ?string $title = null): mixed
{
$alert = app('alert')
Expand All @@ -18,7 +18,7 @@ function alert(string $message, ?string $title = null): mixed
}
}

if (! function_exists('field')) {
if (!function_exists('field')) {
function field(string $name, string $message, ?string $tag = null): mixed
{
$alert = app('alert')->field($name, $message);
Expand All @@ -31,15 +31,15 @@ function field(string $name, string $message, ?string $tag = null): mixed
}
}

if (! function_exists('fieldBag')) {
if (!function_exists('fieldBag')) {
function fieldBag(Validator|MessageBag $bag): mixed
{
return app('alert')
->fieldBag($bag);
}
}

if (! function_exists('modal')) {
if (!function_exists('modal')) {
function modal(string $message, ?string $title = null): mixed
{
$alert = app('alert')->modal($message);
Expand All @@ -52,7 +52,7 @@ function modal(string $message, ?string $title = null): mixed
}
}

if (! function_exists('notify')) {
if (!function_exists('notify')) {
function notify(string $message, ?string $title = null): mixed
{
$alert = app('alert')->notify($message);
Expand All @@ -65,7 +65,7 @@ function notify(string $message, ?string $title = null): mixed
}
}

if (! function_exists('sticky')) {
if (!function_exists('sticky')) {
function sticky(string $message, ?string $title = null): mixed
{
$alert = app('alert')->sticky($message);
Expand All @@ -78,7 +78,7 @@ function sticky(string $message, ?string $title = null): mixed
}
}

if (! function_exists('forgetSticky')) {
if (!function_exists('forgetSticky')) {
function forgetSticky(?string $name = null): void
{
app('alert')->stickForget($name);
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function type(string $type): array
*/
public static function classname(string $type): string
{
if (! self::exists($type)) {
if (!self::exists($type)) {
throw new Exception("The alert type '$type' does not exist in config");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Message/MessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function make(SessionInterface $session, string $type, ...$args):
{
$class = Type::classname($type);

if (! class_exists($class)) {
if (!class_exists($class)) {
throw new Exception("Alert type '$class' class not found ");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Types/FieldBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
} elseif (is_a($bag, MessageBag::class)) {
$this->messages($bag);
} else {
$this->messages = new MessageBag;
$this->messages = new MessageBag();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Types/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function __construct(
public ?string $message
) {
$this->id($this->key().'-'.Helper::randomString());
$this->action = new Button;
$this->cancel = new Button;
$this->action = new Button();
$this->cancel = new Button();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Sticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
public ?string $message
) {
$this->id($this->key().'-'.Helper::randomString());
$this->action = new Button;
$this->action = new Button();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/View/Components/Themes/Bootstrap5/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class Modal extends Component
* Default action button attributes.
*/
public array $actionAttributes = [
'type' => 'button',
'type' => 'button',
'class' => 'btn btn-primary',
];

/**
* Default cancel button attributes.
*/
public array $cancelAttributes = [
'type' => 'button',
'class' => 'btn btn-secondary',
'type' => 'button',
'class' => 'btn btn-secondary',
'data-bs-dismiss' => 'modal',
];

Expand Down
2 changes: 1 addition & 1 deletion src/View/Components/Themes/Bootstrap5/Sticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Sticky extends Component
* Default action button.
*/
public array $actionAttributes = [
'type' => 'button',
'type' => 'button',
'class' => 'btn btn-sm btn-primary float-end',
];

Expand Down
6 changes: 3 additions & 3 deletions src/View/Components/Themes/Classic/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class Modal extends Component
* Default action button attributes.
*/
public array $actionAttributes = [
'type' => 'button',
'type' => 'button',
'class' => 'btn btn-primary',
];

/**
* Default cancel button attributes.
*/
public array $cancelAttributes = [
'type' => 'button',
'class' => 'btn btn-secondary',
'type' => 'button',
'class' => 'btn btn-secondary',
'data-bs-dismiss' => 'modal',
];

Expand Down
2 changes: 1 addition & 1 deletion src/View/Components/Themes/Classic/Sticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Sticky extends Component
* Default action button.
*/
public array $actionAttributes = [
'type' => 'button',
'type' => 'button',
'class' => 'btn btn-sm btn-primary float-end',
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Components/FieldBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
['firstname' => '', 'lastname' => ''],
[
'firstname' => 'required',
'lastname' => 'required',
'lastname' => 'required',
]
);

Expand Down
3 changes: 0 additions & 3 deletions tests/Feature/Components/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
$view
->assertSee('class="form-text text-success"', false)
->assertSee('Username is available');

})->group('view-component', 'view-component-field-default');

it('can render a tagged field view component', function () {
Expand All @@ -26,7 +25,6 @@
$view
->assertSee('class="form-text text-warning"', false)
->assertSee('Please select a country');

})->group('view-component', 'view-component-field-tagged');

it('can render a named field view component', function () {
Expand All @@ -45,5 +43,4 @@
->assertSee('class="form-text text-success"', false)
->assertSee('Good, you chose a valid country')
->assertDontSee('Good, you chose a valid state');

})->group('view-component', 'view-component-field-named-tagged');
1 change: 0 additions & 1 deletion tests/Feature/Helpers/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Field::class)
->and($default->message)
->toEqual('Invalid firstname');

})->group('types', 'types-field');
1 change: 0 additions & 1 deletion tests/Feature/Helpers/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Message::class)
->and($default->message)
->toEqual('Thank you!');

})->group('types', 'types-default', 'types-message');
1 change: 0 additions & 1 deletion tests/Feature/Helpers/ModalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Modal::class)
->and($default->message)
->toEqual('Thank you!');

})->group('types', 'types-modal', 'types-modal');
1 change: 0 additions & 1 deletion tests/Feature/Helpers/NotifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
->toEqual('Thank you!')
->and($default->key())
->toEqual('notify');

})->group('types', 'types-notify', 'types-notify');
1 change: 0 additions & 1 deletion tests/Feature/Helpers/StickyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Sticky::class)
->and($default->message)
->toEqual('Thank you!');

})->group('types', 'types-sticky', 'types-sticky-message');
1 change: 0 additions & 1 deletion tests/Feature/Types/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Field::class)
->and($default->message)
->toEqual('Invalid firstname');

})->group('types', 'types-field', 'types-field');
1 change: 0 additions & 1 deletion tests/Feature/Types/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
->toBeInstanceOf(Message::class)
->and($default->message)
->toEqual('Thank you!');

})->group('types', 'types-default', 'types-message');
Loading