Problem/Motivation

The styling for exposed forms looks like this:

.views-exposed-form .form-item {
  /* Display exposed form elements horizontally. */
  float: left; /* LTR */
  margin-right: .25em; /* LTR */
}

It's simple styling that could be used elsewhere in the admin interface. We should abstract this out into a more generic class. This is also useful if we want to make the form responsive, so we don't have to do it again elsewhere.

Proposed resolution

.form--inline .form-item {
  /* Display form elements horizontally. */
  float: left; /* LTR */
  margin-right: .25em; /* LTR */
}

Remaining tasks

Write a patch
Review

User interface changes

None

API changes

A new reusable CSS class

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it will require less styling to reuse this behaviour in core and contrib.
Issue priority Not critical because it is not a major DX issue
Unfrozen changes Unfrozen because it only changes CSS
CommentFileSizeAuthor
#48 interdiff-48-35.txt3.55 KBidebr
#48 2333719-48.patch5.98 KBidebr
#48 2333719-48-views-preview-rtl-before.png182.09 KBidebr
#48 2333719-48-views-preview-rtl-after.png233.13 KBidebr
#48 2333719-48-views-rtl-before-large.png69.94 KBidebr
#48 2333719-48-views-rtl-after-large.png107.91 KBidebr
#48 2333719-48-views-after-large.png93.97 KBidebr
#48 2333719-48-views-before-large.png55.25 KBidebr
#48 2333719-48-after-large.png50.71 KBidebr
#48 2333719-48-before-large.png51.88 KBidebr
#48 2333719-48-before-small.png25 KBidebr
#48 2333719-48-after-small.png22.08 KBidebr
#35 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-35.patch2.97 KBalvar0hurtad0
#35 Captura de pantalla 2014-12-12 a la(s) 20.55.21.png38.43 KBalvar0hurtad0
#35 Captura de pantalla 2014-12-12 a la(s) 20.55.37.png37.11 KBalvar0hurtad0
#30 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-30.patch3.07 KBalvar0hurtad0
#30 interdiff.txt638 bytesalvar0hurtad0
#28 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-28.patch3.3 KBlewisnyman
#28 interdiff.txt2.3 KBlewisnyman
#28 Screen Shot 2014-11-09 at 16.18.47.jpg600.06 KBlewisnyman
#24 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-24.patch1.92 KBalvar0hurtad0
#21 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-21.patch1.86 KBalvar0hurtad0
#20 scsht.png32.23 KBalvar0hurtad0
#20 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-20.patch1.88 KBalvar0hurtad0
#13 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-13.patch2.3 KBalvar0hurtad0
#13 Captura de pantalla 2014-10-07 a la(s) 09.47.42.png21.97 KBalvar0hurtad0
#11 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-11.patch876 bytesalvar0hurtad0
#6 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-6.patch479 bytesalvar0hurtad0
#6 abstract_views_exposed_form_styling_out_into_reusable_class-2333719-6.patch479 bytesalvar0hurtad0
#3 views-abstract_views_exposed_css_class-2333719-3.patch666 bytesmsankhala

Comments

dawehner’s picture

No idea what this means but +1 for making things consistent and good looking out of the box.

msankhala’s picture

We can do simply like

.views-exposed-form .form-item, .ltr-inline-item {
  /* Display exposed form elements horizontally. */
  float: left; /* LTR */
  margin-right: .25em; /* LTR */
}

[dir="rtl"] .views-exposed-form .form-item, .rtl-inline-item {
  float: right;
  margin-left: .25em;
}

By doing this we will not have to change the code where ever we using the .form-item class under .views-exposed-form and use ltr-inline-item and rtl-inline-item class where we want inline item left to right and right to left respectively.

msankhala’s picture

Adding patch.

lewisnyman’s picture

But then to create this visual you'll have to add this class to every form item in the form? It feels a lot easier just to add one class to the wrapper like we do with container-inline

alvar0hurtad0’s picture

Assigned: Unassigned » alvar0hurtad0

I'm going to add the class :D

alvar0hurtad0’s picture

alvar0hurtad0’s picture

Status: Active » Needs review

Sorry for uploading twice the patch...

lewisnyman’s picture

Status: Needs review » Needs work

Thanks for the patch. I think it's possible to use the container-inline class here so I'm not against it. I'm not sure if this is the right approach as this will add the container-inline to all form elements, we want to add it to only the views exposed filter form. We should be able to delete all the CSS for the views exposed filter form and it could look the same.

alvar0hurtad0’s picture

Assigned: alvar0hurtad0 » Unassigned

As i'm not really sure what does the previous comment means I prefer release the issue. If I can understand better comment #8I'll try to afford the patch.

lewisnyman’s picture

Sorry I'll emphasise the important part:

This will add the container-inline to all form elements, we want to add it to only the views exposed filter form.

alvar0hurtad0’s picture

Status: Needs work » Needs review
StatusFileSize
new876 bytes

Ok, I think I got it.

Thank You so much for be so patiente.

:D

lewisnyman’s picture

Status: Needs review » Needs work

Ok, awesome. This looks like the right direction. Now, we should be able to delete all the CSS in views.exposed_form.css and it should look the same as before. I'm not sure that' will happen right now.

alvar0hurtad0’s picture

It's probably a bit brave, but It's the best solution I could find.

As margins don't affect to inline elements, the form was too much close to the view content:
https://www.drupal.org/files/issues/Captura%20de%20pantalla%202014-10-07%20a%20la%28s%29%2009.47.42.png

So I was looking for any reusable class that adds vertical margins to the wrapper. I couldn't find it so I created one at core/modules/system/css/system.module.css

vertical-margin{
 margin: 1em 0;
}

To be honest I'm not really sure if it's the best name for the class and if it's a good idea define new classes at system.module.css.

Status: Needs review » Needs work

lewisnyman’s picture

As margins don't affect to inline elements, the form was too much close to the view content:

Aha that's true but if we get #2226317: Divs in the container-inline wrapper should be inline-block instead of inline in first then it should look a lot better?

Status: Needs review » Needs work
alvar0hurtad0’s picture

Yes, if We use inline-block it looks better, but there is not a "inline-block-container" class (almost I didn't find it).

lewisnyman’s picture

Not yet, but once #2226317: Divs in the container-inline wrapper should be inline-block instead of inline is in then container-inline will be inline-block

alvar0hurtad0’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB
new32.23 KB

Awesome!!!

After applying the patch on #2226317: Divs in the container-inline wrapper should be inline-block instead of inline and the patch on this comment, the form looks like this:

screenshot

alvar0hurtad0’s picture

Sorry,

my previous patch has a mistake.

Status: Needs review » Needs work
alvar0hurtad0’s picture

Status: Needs work » Needs review
StatusFileSize
new1.92 KB

Trying to pass the test, I think now the views.libraries.yml is ok.

lewisnyman’s picture

amateescu’s picture

Lewis point me to this issue while we were discussing #1963340: Change field UI so that adding a field is a separate task. The current patch there copies the CSS from views exposed filters and would benefit a lot from the reusable class introduced here :)

lewisnyman’s picture

Status: Postponed » Needs work

Now that #2226317: Divs in the container-inline wrapper should be inline-block instead of inline is a no go for 8.0.x, we should really add a new class that can handle this well. I think it's ok to have classes that are really generic rather than try to do too much with one class.

Let's move back in the direction of the issue summary.

lewisnyman’s picture

amateescu’s picture

I realize this problem already exists, but the inlined form items look really crammed into each other. Should we increase the margin-right spacing a bit to 0.5em? I used 1em in #1963340: Change field UI so that adding a field is a separate task but that's because I have an element in between which contains only text (actually, two letters) so it might be too much for the default.

alvar0hurtad0’s picture

Patch #28 works fine this patch adds also the margin sugested by #29

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Assuming that everyone agrees with the 0.5em spacing, I think this is ready.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots

Can we get a screenshot to compare the .25em with the .5em.

Also

  // Include basic theming for exposed forms.
  $form['#attached']['library'][] = 'views/views.exposed-form';

Is still in template_preprocess_views_exposed_form() even though the library does not exist with this patch.

lewisnyman’s picture

Issue tags: +Novice

Thanks Alex, looks like a novice task.

alexpott’s picture

This issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary. This will be allowed because it is in the unfrozen category (CSS).

alvar0hurtad0’s picture

Here are the screenshots and the patch rerolled and with the #32 modification.

margin right 0.25em

screenshot 0.25em margin right

margin right 0.5em

screenshot 0.5em margin right

amateescu’s picture

The new 0.5em spacing looks better to me but I'll let @LewisNyman make the final call :)

lewisnyman’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots, -Needs issue summary update

I like it! I'm glad we can polish this kind of stuff and other developers can just reuse it :). I've added the beta evaluation to the summary.

Status: Reviewed & tested by the community » Needs work

Status: Needs review » Needs work

Status: Needs work » Needs review
lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Back to RTBC

idebr’s picture

Status: Reviewed & tested by the community » Needs work

Now, we should be able to delete all the CSS in views.exposed_form.css and it should look the same as before. I'm not sure that' will happen right now.

It seems this change got lost along the way. The library declaration for views/views.exposed-form.css is deleted in views.libraries.yml, but the file is still there.

Also, there is an issue about the css for exposed filters in the Views preview section that overlaps with this patch and should probably be merged: #2396465: Views UI: Exposed Filter css is not applied

alexpott’s picture

Issue tags: +Needs screenshots

Can someone test that we've not broken #2396465: Views UI: Exposed Filter css is not applied now that that has landed :)

amateescu’s picture

Further to #46, #1963340: Change field UI so that adding a field is a separate task landed some time ago so the patch needs to be updated to make FieldStorageAddForm use this new styling class.

idebr’s picture

@amateescu Thanks for the heads up, I updated the 'Field: add field' form with the new form--inline class.

I have added some screenshots in the attachments. For the sake of brevity I have not embedded them in the comment.

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community

Great work! Thanks for all the screenshots. I think we're good to go here.

amateescu’s picture

It looks perfect! RTBC++

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c741d42 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed c741d42 on 8.0.x
    Issue #2333719 by alvar0hurtad0, idebr, LewisNyman, msankhala: Abstract...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.