Skip to content

Commit

Permalink
removed tertiary, danger, warning, info, success colors & refactor se…
Browse files Browse the repository at this point in the history
…rvice provider
  • Loading branch information
developermithu committed Aug 9, 2024
1 parent 9b47390 commit 9651183
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 186 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# TallCraftUi

TallCraftUI is a versatile and customizable UI package for the TALL stack **(Tailwind CSS, Alpine.js, Laravel, and Livewire)**. It provides a set of components to simplify livewire application development and seamlessly integrate with **TALL stack** projects.
# [TallCraftUi](https://tallcraftui.developermithu.com)

Laravel blade UI component library built on TALL stack ([TailwindCSS](https://tailwindcss.com), [Alpine.js](https://alpinejs.dev), [Laravel](https://laravel.com), [Livewire](https://livewire.laravel.com)).

<p align="center">
<a href="https://packagist.org/packages/developermithu/tallcraftui"><img src="https://img.shields.io/packagist/v/developermithu/tallcraftui?style=flat-square" alt="Latest Version on Packagist"></a>
Expand Down Expand Up @@ -31,7 +30,7 @@ Error will be automatically displayed after submitting the form if it exists. Yo

```php
if($errors->any())
<x-alert :errors="$errors->all()" danger />
<x-alert :errors="$errors->all()" red />
@endif
```

Expand All @@ -51,11 +50,6 @@ php artisan install:tallcraftui
colors: {
primary: "#6d28d9",
secondary: "#a21caf",
tertiary: "#00BBC9",
danger: "#b91c1c",
warning: "#a16207",
success: "#15803d",
info: "#1d4ed8",
},
},
},
Expand All @@ -80,7 +74,7 @@ return [
*
* Examples:
* prefix => '' // <x-input />
* prefix => 'tall-' // <x-tall-input />
* prefix => 'tc-' // <x-tc-input />
*
*/
'prefix' => '',
Expand Down
4 changes: 2 additions & 2 deletions config/tallcraftui.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* using `php artisan view:clear`
*
* Examples:
* prefix => '' // <x-input />
* prefix => 'tall-' // <x-tall-input />
* prefix => '' // <x-input />
* prefix => 'tc-' // <x-tc-input />
*/
'prefix' => '',

Expand Down
8 changes: 4 additions & 4 deletions src/Console/Commands/InstallTallcraftuiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function renameComponentPrefix()
$path = base_path('config/tallcraftui.php');
$config = File::get($path);

// Replaces existing prefix with 'tall-' in the tallcraftui.php configuration file.
$contents = str($config)->replace("'prefix' => ''", "'prefix' => 'tall-'");
// Replaces existing prefix with 'tc-' in the tallcraftui.php configuration file.
$contents = str($config)->replace("'prefix' => ''", "'prefix' => 'tc-'");
File::put($path, $contents);

$this->info("\n");
$this->warn("Added 'tall-' prefix to tallcraftuiUI components to avoid conflicts with `$target` 🚨");
$this->warn('* Examples: <x-tall-button />, <x-tall-input />');
$this->warn("Added 'tc-' prefix to tallcraftuiUI components to avoid conflicts with `$target` 🚨");
$this->warn('* Examples: <x-tc-button />, <x-tc-input />');
$this->warn('* See config/tallcraftui.php for details.');
}
});
Expand Down
74 changes: 41 additions & 33 deletions src/TallCraftUiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
namespace Developermithu\Tallcraftui;

use Developermithu\Tallcraftui\Console\Commands\InstallTallcraftuiCommand;
use Developermithu\Tallcraftui\View\Components\Alert;
use Developermithu\Tallcraftui\View\Components\Badge;
use Developermithu\Tallcraftui\View\Components\Breadcrumb;
use Developermithu\Tallcraftui\View\Components\BreadcrumbItem;
use Developermithu\Tallcraftui\View\Components\Button;
use Developermithu\Tallcraftui\View\Components\Checkbox;
use Developermithu\Tallcraftui\View\Components\Dropdown;
use Developermithu\Tallcraftui\View\Components\DropdownItem;
use Developermithu\Tallcraftui\View\Components\Hint;
use Developermithu\Tallcraftui\View\Components\Icon;
use Developermithu\Tallcraftui\View\Components\Input;
use Developermithu\Tallcraftui\View\Components\Label;
use Developermithu\Tallcraftui\View\Components\Modal;
use Developermithu\Tallcraftui\View\Components\Radio;
use Developermithu\Tallcraftui\View\Components\Select;
use Developermithu\Tallcraftui\View\Components\Textarea;
use Developermithu\Tallcraftui\View\Components\Toggle;
use Developermithu\Tallcraftui\View\Components\{
Alert,
Badge,
Breadcrumb,
BreadcrumbItem,
Button,
Checkbox,
Dropdown,
DropdownItem,
Hint,
Icon,
Input,
Label,
Modal,
Radio,
Select,
Textarea,
Toggle
};
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

Expand All @@ -32,7 +34,7 @@ public function boot(): void
$this->registerComponents();

$this->publishes([
__DIR__.'/../config/tallcraftui.php' => config_path('tallcraftui.php'),
__DIR__ . '/../config/tallcraftui.php' => config_path('tallcraftui.php'),
], 'tallcraftui-config');

// Register the application's commands.
Expand All @@ -47,21 +49,27 @@ private function registerComponents(): void
{
$prefix = config('tallcraftui.prefix');

Blade::component($prefix.'button', Button::class);
Blade::component($prefix.'badge', Badge::class);
Blade::component($prefix.'input', Input::class);
Blade::component($prefix.'icon', Icon::class);
Blade::component($prefix.'textarea', Textarea::class);
Blade::component($prefix.'toggle', Toggle::class);
Blade::component($prefix.'select', Select::class);
Blade::component($prefix.'checkbox', Checkbox::class);
Blade::component($prefix.'radio', Radio::class);
Blade::component($prefix.'alert', Alert::class);
Blade::component($prefix.'breadcrumb', Breadcrumb::class);
Blade::component($prefix.'breadcrumb-item', BreadcrumbItem::class);
Blade::component($prefix.'modal', Modal::class);
Blade::component($prefix.'dropdown', Dropdown::class);
Blade::component($prefix.'dropdown-item', DropdownItem::class);
$components = [
'button' => Button::class,
'badge' => Badge::class,
'input' => Input::class,
'icon' => Icon::class,
'textarea' => Textarea::class,
'toggle' => Toggle::class,
'select' => Select::class,
'checkbox' => Checkbox::class,
'radio' => Radio::class,
'alert' => Alert::class,
'breadcrumb' => Breadcrumb::class,
'breadcrumb-item' => BreadcrumbItem::class,
'modal' => Modal::class,
'dropdown' => Dropdown::class,
'dropdown-item' => DropdownItem::class,
];

foreach ($components as $name => $class) {
Blade::component($prefix . $name, $class);
}

// TallCraftUI internal components
Blade::component('tc-icon', Icon::class);
Expand Down
39 changes: 6 additions & 33 deletions src/View/Components/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ public function __construct(
// Alert types
public bool $primary = true,
public bool $secondary = false,
public bool $tertiary = false,
public bool $warning = false,
public bool $info = false,
public bool $success = false,
public bool $danger = false,

// Tailwind Colors
public bool $black = false,
public bool $white = false,
public bool $slate = false,
Expand Down Expand Up @@ -56,9 +49,9 @@ public function __construct(
public function alertIcon(): string
{
return $this->icon ?: match (true) {
$this->warning => 'exclamation-triangle',
$this->info || $this->secondary => 'information-circle',
$this->danger => 'x-circle',
$this->yellow || $this->orange || $this->amber => 'exclamation-triangle',
$this->blue || $this->secondary => 'information-circle',
$this->red => 'x-circle',
default => 'check-circle',
};
}
Expand All @@ -67,13 +60,6 @@ public function alertClasses(): string
{
return match (true) {
$this->secondary => 'text-secondary border-secondary/20 bg-secondary/10 dark:bg-secondary/15 dark:border-secondary/50 dark:text-secondary',
$this->tertiary => 'text-tertiary border-tertiary/20 bg-tertiary/10 dark:bg-tertiary/15 dark:border-tertiary/50 dark:text-tertiary',
$this->warning => 'text-warning border-warning/20 bg-warning/10 dark:bg-warning/15 dark:border-warning/50 dark:text-warning',
$this->info => 'text-info border-info/20 bg-info/10 dark:bg-info/15 dark:border-info/50 dark:text-info',
$this->danger => 'text-danger border-danger/20 bg-danger/10 dark:bg-danger/15 dark:border-danger/50 dark:text-danger',
$this->success => 'text-success border-success/20 bg-success/10 dark:bg-success/15 dark:border-success/50 dark:text-success',

// Tailwind Colors
$this->black => 'text-black-800 border-black-200 bg-black-50 dark:bg-black-800/20 dark:border-black-900 dark:text-black-500',
$this->white => 'text-white-800 border-white-200 bg-white-50 dark:bg-white-800/20 dark:border-white-900 dark:text-white-500',
$this->slate => 'text-slate-800 border-slate-200 bg-slate-50 dark:bg-slate-800/20 dark:border-slate-900 dark:text-slate-500',
Expand Down Expand Up @@ -106,13 +92,6 @@ public function descriptionClasses(): string
{
return match (true) {
$this->secondary => 'text-secondary/80 dark:text-secondary/80',
$this->tertiary => 'text-tertiary/80 dark:text-tertiary/80',
$this->warning => 'text-warning/80 dark:text-warning/80',
$this->info => 'text-info/80 dark:text-info/80',
$this->danger => 'text-danger/80 dark:text-danger/80',
$this->success => 'text-success/80 dark:text-success/80',

// Tailwind Colors
$this->black => 'text-black-700 dark:text-black-400',
$this->white => 'text-white-700 dark:text-white-400',
$this->slate => 'text-slate-700 dark:text-slate-400',
Expand All @@ -137,7 +116,7 @@ public function descriptionClasses(): string
$this->fuchsia => 'text-fuchsia-700 dark:text-fuchsia-400',
$this->pink => 'text-pink-700 dark:text-pink-400',
$this->rose => 'text-rose-700 dark:text-rose-400',
default => 'text-primary/80 dark:text-primary/80',
default => 'text-primary/80 dark:text-primary/80', // primary
};
}

Expand All @@ -160,12 +139,6 @@ public function actionColors(): string
{
return match (true) {
$this->secondary => 'text-secondary hover:bg-secondary/10 focus:bg-secondary/15 focus:ring-secondary/70',
$this->tertiary => 'text-tertiary hover:bg-tertiary/10 focus:bg-tertiary/15 focus:ring-tertiary/70',
$this->warning => 'text-warning hover:bg-warning/10 focus:bg-warning/15 focus:ring-warning/70',
$this->info => 'text-info hover:bg-info/10 focus:bg-info/15 focus:ring-info/70',
$this->danger => 'text-danger hover:bg-danger/10 focus:bg-danger/15 focus:ring-danger/70',
$this->success => 'text-success hover:bg-success/10 focus:bg-success/15 focus:ring-success/70',

$this->black => 'text-black-600 hover:bg-black-500/10 focus:bg-black-500/15 focus:ring-black-500',
$this->white => 'text-white-600 hover:bg-white-500/10 focus:bg-white-500/15 focus:ring-white-500',
$this->slate => 'text-slate-600 hover:bg-slate-500/10 focus:bg-slate-500/15 focus:ring-slate-500',
Expand All @@ -190,7 +163,7 @@ public function actionColors(): string
$this->fuchsia => 'text-fuchsia-600 hover:bg-fuchsia-500/10 focus:bg-fuchsia-500/15 focus:ring-fuchsia-500',
$this->pink => 'text-pink-600 hover:bg-pink-500/10 focus:bg-pink-500/15 focus:ring-pink-500',
$this->rose => 'text-rose-600 hover:bg-rose-500/10 focus:bg-rose-500/15 focus:ring-rose-500',
default => 'text-primary hover:bg-primary/10 focus:bg-primary/15 focus:ring-primary/70',
default => 'text-primary hover:bg-primary/10 focus:bg-primary/15 focus:ring-primary/70', // primary
};
}

Expand All @@ -215,7 +188,7 @@ public function render(): View|Closure|string
>
<div class="flex items-start">
<div class="flex-shrink-0">
<x-tc-icon :name="$alertIcon()" class="{{ $errors ? '!text-danger/80': '' }}" />
<x-tc-icon :name="$alertIcon()" class="{{ $errors ? 'text-red-500': '' }}" />
</div>
<div @class(["ms-2","ms-4" => $description])>
Expand Down
28 changes: 1 addition & 27 deletions src/View/Components/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ public function __construct(
public ?string $iconLeft = null,
public ?string $iconRight = null,

// Badge colors
// Badge types
public bool $primary = true,
public bool $secondary = false,
public bool $tertiary = false,
public bool $warning = false,
public bool $info = false,
public bool $success = false,
public bool $danger = false,

// Tailwind Colors
public bool $black = false,
public bool $white = false,
public bool $slate = false,
Expand Down Expand Up @@ -57,12 +50,6 @@ private function isPrimaryWithoutOthers(): bool
{
return $this->primary
&& ! $this->secondary
&& ! $this->tertiary
&& ! $this->danger
&& ! $this->warning
&& ! $this->info
&& ! $this->success

&& ! $this->black
&& ! $this->white
&& ! $this->slate
Expand Down Expand Up @@ -96,13 +83,6 @@ public function colorClasses(): string
return match (true) {
$this->isPrimaryWithoutOthers() && $notOtherStyle => 'bg-primary/10 text-primary',
$this->secondary && $notOtherStyle => 'bg-secondary/10 text-secondary',
$this->tertiary && $notOtherStyle => 'bg-tertiary/10 text-tertiary',
$this->warning && $notOtherStyle => 'bg-warning/10 text-warning',
$this->info && $notOtherStyle => 'bg-info/10 text-info',
$this->danger && $notOtherStyle => 'bg-danger/10 text-danger',
$this->success && $notOtherStyle => 'bg-success/10 text-success',

// Tailwind Colors
$this->black && $notOtherStyle => 'bg-black text-white',
$this->white && $notOtherStyle => 'bg-gray-50 text-gray-700',
$this->slate && $notOtherStyle => 'bg-slate-100 dark:bg-slate-800/50 dark:text-slate-400 text-slate-800',
Expand Down Expand Up @@ -136,12 +116,6 @@ public function outlineClasses(): string
return match (true) {
$this->outline && $this->isPrimaryWithoutOthers() => 'bg-transparent text-primary border border-primary',
$this->outline && $this->secondary => 'bg-transparent text-secondary border border-secondary',
$this->outline && $this->tertiary => 'bg-transparent text-tertiary border border-tertiary',
$this->outline && $this->warning => 'bg-transparent text-warning border border-warning',
$this->outline && $this->success => 'bg-transparent text-success border border-success',
$this->outline && $this->danger => 'bg-transparent text-danger border border-danger',
$this->outline && $this->info => 'bg-transparent text-info border border-info',

$this->outline && $this->black => 'bg-transparent text-black border border-black',
$this->outline && $this->white => 'bg-transparent text-gray-500 border border-gray-200',
$this->outline && $this->slate => 'bg-transparent text-slate-500 border border-slate-500',
Expand Down
Loading

0 comments on commit 9651183

Please sign in to comment.