I'd like to continue to follow a pattern i'm implementing for alerts. The problem with buttons there are many varying options. Button options include size, color and a few other things.
#my Alert structure
/Alerts
/Default
index.blade.php
primary.blade.php
secondary.blade.php
/Dismissing
index.blade.php
primary.blade.php
secondary.blade.php
/Custom
...
...
#heres some examples how I call my alerts. I like doing it this way for a few reason. One making it easy for other devs to see what quick color options are avaliable to use.
<x-alerts.default.primary text="foo"/>
<x-alerts.default.secondary text="foo"/>
<x-alerts.default.warning text="foo"/>
<x-alerts.default.danger text="foo"/>
<x-alerts.dismissing.primary text="foo"/>
<x-alerts.dismissing.secondarytext="foo"/>
#.. list goes on....
#example of my one of my alert comps. They are all the same except classes have been added to chagge text color and background color etc... They will call their respective folder index.blade.php file
default/primary.blade.php ->calling index.blade.php
<x-alerts.default class="alert-primary" {{ $attributes }} />
#index.blade.php example
#you can see im sort of just wrapping and extending or decorating with more classes
@props([
'text'=>'add your text'
,'id'=>null
])
<div {{ $attributes->merge(
['class' => 'alert'
,'id' => $id ?? uniqid()
]) }} {{ $attributes }} role="alert">
{{ $text }}
</div>
#so the problem i run into with buttons is there is more than just a couple options. I'd like to be able to render my buttons using something like without having to have a directory tree
#dont want a folder struture like this for buttons
/Buttons
/Default
index.blade.php
sm.primary.blade.php
md.primary.blade.php
sm.secondary.blade.php
md.secondary.blade.php
/Outline
index.blade.php
sm.primary.blade.php
md.primary.blade.php
sm.secondary.blade.php
md.secondary.blade.php
<x-buttons.sm.default.primary text="foo"/>
<x-buttons.sm.default.secondary text="foo"/>
<x-buttons.sm.default.warning text="foo"/>
<x-buttons.md.default.primary text="foo"/>
<x-buttons.md.default.secondary text="foo"/>
<x-buttons.md.default.warning text="foo"/>
<x-buttons.sm.outline.primary text="foo"/>
<x-buttons.sm.outline.secondary text="foo"/>
<x-buttons.sm.outline.warning text="foo"/>
<x-buttons.md.outline.primary text="foo"/>
<x-buttons.md.outline.secondary text="foo"/>
<x-buttons.md.outline.warning text="foo"/>
#Im trying to avoid passing in the options like this
@props([
color=>"primary"
,base=>"default"
,size=>"size"
])
@php
//having look up array for classes here
@endphp
Anyways does anyone have suggestion on this or how they create components like this? Thanks