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

Implementation for Tab object #130

Closed
RVxLab opened this issue Dec 14, 2020 · 4 comments
Closed

Implementation for Tab object #130

RVxLab opened this issue Dec 14, 2020 · 4 comments
Assignees

Comments

@RVxLab
Copy link
Collaborator

RVxLab commented Dec 14, 2020

Branch: https://github.com/eminiarts/nova-tabs/tree/feature/tabs-object

Implementation for the proposal in #129

To implement a Tab object I propose the following interface:

interface TabContract
{
    // Through the Makeable trait
    public static function make(string $title, array $fields, array $options = []): self;

    public function name(string $name): self;

    public function showIf(bool | callable $condition): self;

    public function showUnless(bool | callable $condition): self;

    public function titleAsHtml(bool $titleAsHtml = true): self;

    public function beforeIcon(string $iconAsHtml): self;

    public function afterIcon(string $iconAsHtml): self;

    public function tabClass(string | array $classes): self;

    public function bodyClass(string | array $classes): self;
}

Macroable

The Tab class would implement the Illuminate\Support\Traits\Macroable trait to implement macros.

However, if deeper adjustments are required, it would be better to extend the Tab class or make a custom implementation based on the TabContract interface.

Backwards compatibility

The current way to define tabs would remain a valid way to define them, but seeing that the Tab class would provide more flexibility, the array method could be considered obsolete or even deprecated.

If chosen for deprecation, I vote to remove the feature in a 2.0 release.

Implementation plan

The plan to implement this feature would be as follows:

  1. Create tests to ensure the current functionality does not break (PHPUnit with possibly Pest).
  2. Implement the newly planned features and add tests for them on the backend
  3. Implement these changes in the frontend

Additionally, as this feature would add quite a few new things to the frontend, this would be a good time to do some clean up these.

  1. Split components for better re-usability
  2. Add ESLint and/or Prettier for code quality
  3. Ideally, use Jest to test these components

Finally, I'd like to start making use of GitHub Actions for some automation.

@RVxLab RVxLab self-assigned this Dec 14, 2020
@bernhardh
Copy link
Contributor

bernhardh commented Dec 16, 2020

As requested in #129 I would also add a tabClass and a bodyClass, so that you can give each tab and tab-body an individual style (for example background color) if needed.

interface TabContract
{
    // Through the Makeable trait
    public static function make(string $title, array $fields, array $options = []): self;

    public function name(string $name): self;

    public function showIf(bool | callable $condition): self;

    public function showUnless(bool | callable $condition): self;

    public function titleAsHtml(bool $titleAsHtml = true): self;

    public function icon(string $iconAsHtml): self;

    public function tabClass(string $iconAsHtml): self;

    public function bodyClass(string $iconAsHtml): self;
}

@RVxLab RVxLab changed the title WIP: Implementation for Tab object Implementation for Tab object Jan 6, 2021
@RVxLab RVxLab pinned this issue Jan 6, 2021
@RVxLab
Copy link
Collaborator Author

RVxLab commented Jan 6, 2021

@bernhardh Those requests have been added to the interface above.

This was referenced Jan 7, 2021
@RVxLab
Copy link
Collaborator Author

RVxLab commented Jan 26, 2021

The new Tab class has been implemented into the Tabs class and can now be used.

For those willing to try it out, you can use the feature/tabs-object branch. Mind you that at this time only the following fields are functional:

  • showIf
  • showUnless
  • name

I will add the new properties to the Vue side soon.

@RVxLab RVxLab mentioned this issue Jan 30, 2021
@RVxLab
Copy link
Collaborator Author

RVxLab commented Jan 30, 2021

This is now available in master.

@RVxLab RVxLab closed this as completed Jan 30, 2021
@RVxLab RVxLab unpinned this issue Mar 26, 2022
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