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

Allow additional attributes to be passed to component on registration #80

Closed
faustbrian opened this issue Aug 7, 2019 · 1 comment

Comments

@faustbrian
Copy link

commented Aug 7, 2019

Currently it seems very tedious to create components that are all based on a single generic and determine their behaviour based on a handful of properties.

I would propose something like below code as a solution to that issue. I've used inputs as an example as that is where I noticed the most duplication in a medium sized application.

Old

// Provider
BladeX::component('components.form.input.date')->tag('input-date');
BladeX::component('components.form.input.date-time')->tag('input-date-time');
BladeX::component('components.form.input.email')->tag('input-email');
BladeX::component('components.form.input.number')->tag('input-number');
BladeX::component('components.form.input.text')->tag('input-text');
BladeX::component('components.form.input.password')->tag('input-password');
BladeX::component('components.form.input.textarea')->tag('input-textarea');

// Generic Input
<input type="{{ $type }}" />

// Components
@include('components.form.input._input', ['type' => 'text'])
@include('components.form.input._input', ['type' => 'email'])
@include('components.form.input._input', ['type' => 'password'])
...

New

BladeX::component('components.form.input', 'input-password', ['type' => "password"])
BladeX::component('components.form.input', 'input-date', ['type' => "date"]);
BladeX::component('components.form.input', 'input-date-time', ['type' => "datetime-local"]);
BladeX::component('components.form.input', 'input-email', ['type' => "email"]);
BladeX::component('components.form.input', 'input-number', ['type' => "number"]);
BladeX::component('components.form.input', 'input-text', ['type' => "text"]);
BladeX::component('components.form.input', 'input-password', ['type' => "password"]);
BladeX::component('components.form.input', 'input-textarea', ['type' => "textarea"]);
@freekmurze

This comment has been minimized.

Copy link
Member

commented Aug 7, 2019

We will consider this when creating a new major version of the package.

@freekmurze freekmurze closed this Aug 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.