Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Make it much more customizable #129

Closed
bernhardh opened this issue Dec 11, 2020 · 2 comments
Closed

RFC: Make it much more customizable #129

bernhardh opened this issue Dec 11, 2020 · 2 comments

Comments

@bernhardh
Copy link
Contributor

bernhardh commented Dec 11, 2020

I know this was part of the cleanup / make it easier some time ago (v1 I think), but why not work (optionally) with an objects instead of plain array structure? It would make customization (like in #127, #79, #72, #58) much easier. Something like this:

Tab::make("Tabs", [
    TabItem::make("My title", [
        ...Fields...    
    ]),    
])

where TabItem would be a new class of this package, holding the fields. To keep it backward compatible, you could also allow to use the "old" syntax with array key-values.

Why? The benefit of this would be, that you can extend and chain methods to each single tab. Please let me show you some examples:

#127 "How to customize a tab name in a URL?"

Tab::make("Tabs", [
    TabItem::make("My title (4711)", [
        // ...Fields...    
    ])->name("my-title"),    
    TabItem::make("Photos (2)", [
        // ...Fields...    
    ])->name("photos"),    
])

#79, #72 Icons

Or you could even implement a couple of other features, like icons:

Tab::make("Tabs", [
    TabItem::make("My title (4711)", [
        // ...Fields...    
    ])->icon("<svg....>"),    
])

But this isn't necessary to make it as a seperate method, if you don't want it. Just make the "title" html able and since we can now set the name seperatly, we could do it like so:

Tab::make("Tabs", [
    TabItem::make("<svg ...> My title (4711)", [
        // ...Fields...    
    ])->name("my-title"),    
])

#58 Conditionally show tabs

Only show tabs, if a condition is met. For example with the help of a callback:

Tab::make("Tabs", [
    TabItem::make("Show only if...", [
        // ...Fields...    
    ])->showIf(function() {
        // ....
    })
])

Style each tab separatly

Or even give the tab extra css classes, to have different colors for tabs, for example if you wanna make a tab red, because its a very important one or has some things to do on it:

Tab::make("Tabs", [
    TabItem::make("My title (4711)", [
        // ...Fields...    
    ])->cssBodyClass('my-cool-class make-it-red mx-5')->cssTabClass('make-it-red')
])

And many more ...

... the nice thing is, that you should or could make the TabItem macroable, so that each user of the package could extend it, if needed, by themself.

To keep it backward compatible

... you could allow also the "old" syntax and allow mixing:

```php
Tab::make("Tabs", [
    "Basic Fields" => [
        // ...Fields...    
    ],
    TabItem::make("Show only if...", [
        // ...Fields...    
    ])->showIf(function() {
        // ....
    })
])
@RVxLab
Copy link
Collaborator

RVxLab commented Dec 11, 2020

I actually really love this idea. It would take a bit to implement and needless to say this will not be possible without actually adding some unit tests (which are also planned). I'll look into this.

@bernhardh
Copy link
Contributor Author

If you need any help, don't hesitate to ask.

@RVxLab RVxLab changed the title Make it much more customizable RFC: Make it much more customizable Dec 13, 2020
@RVxLab RVxLab mentioned this issue Jan 30, 2021
@RVxLab RVxLab closed this as completed Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants