-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Form row component experiment #17921
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great - I love stripping out all of that repetitive boilerplate HTML and simplifying it so much - I think that's going to be awesome! I had a few notes I added, but I don't think anything fatal - this looks like a great start to componentizing us in more and more places! Can't wait to see what the next one brings :)
]) | ||
|
||
<label {{ $attributes->merge(['class' => 'control-label']) }}> | ||
{{ $label }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a stylistic thing, but you could use $slot
here - making your labels look something like:
<x-label.whatever blah="blah" blah="blah">
This is the actual Label
</x-label.whatever>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way to ensure that we have control-label
and whatever other styles might be needed. Possible I'm misunderstanding though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means removing @props
and swapping {{ $label }}
for {{ $slot }}
. The attributes will still be merged (class="control-label"
will still render) and the calling syntax would change from
<x-form-label
:$label
:for="$name"
:style="$label_style ?? null"
class="{{ $label_class }}"
/>
to
<x-form-label
:for="$name"
:style="$label_style ?? null"
class="{{ $label_class }}"
>
{{ $label }}
</x-form-label>
It's not a big difference but it's worth noting the attributes are still merged using that syntax.
Personally, I like the "content" to be passed via $slot
because it feels more natural than passing it as an attribute but either way works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That gives me Undefined variable $label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I swap it for {{ $slot }}
, it works, but for such a simple blade, I'm not really sure how that helps us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$slot
feels more natural to me in this scenario but either way works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but that screws up the flexibility I just built into the checkboxes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I hadn't gotten that far into my review 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have more files to check out but here are some readability improvements.
Overall this looks pretty good and is a big step in the right direction 😄
]) | ||
|
||
<label {{ $attributes->merge(['class' => 'control-label']) }}> | ||
{{ $label }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I hadn't gotten that far into my review 😅
<div {{ $attributes->merge(['class' => 'input-group date']) }} data-provide="datepicker" data-date-today-highlight="true" data-date-language="{{ auth()->user()->locale }}" data-date-locale="{{ auth()->user()->locale }}" data-date-format="yyyy-mm-dd" data-date-autoclose="true" data-date-clear-btn="true"{{ $end_date ? ' data-date-end-date=' . $end_date : '' }}> | ||
<input type="text" {{ $attributes->merge(['class' => 'form-control']) }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a $attributes->merge(['class' =>
on the parent div
and the input
makes me 🤔
I noticed the same on form-row
itself. I'm side-eyeing it but it seems to work fine.
Co-authored-by: Marcus Moore <[email protected]>
Co-authored-by: Marcus Moore <[email protected]>
As a side note, I need to revisit https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/ to determine if we really want to use the |
This is a bit of an experiment on my part, an attempt to solve a few problems at once:
We have several spots in the (huge) codebase where forms look slightly different. Sometimes the labels are aligned to the left, sometimes to the right, sometimes they're bold, sometimes they're not, etc.
By abstracting this out into cascading blade components, we would be able to change the classes (assuming we have very few overrides) for all forms very quickly.
In the example in the image below:
That blade component code would look like this:
The HTML rendered from that is:
I've tried to account for all of the "extras" we might run into (styles, placeholders, error text, help text, etc). A few more bits to handle, but I did want to see if I was going in a direction the team feels makes sense.
Oh, also, if the style passed is null, I'm still seeing that stupid
style=";"
being injected. Not sure how to fix that one. It doesn't actually hurt anything, it's just dumb.Remaining