diff --git a/core/lib/Drupal/Core/Render/Element/BulkOperations.php b/core/lib/Drupal/Core/Render/Element/BulkOperations.php new file mode 100644 index 0000000..fefaf13 --- /dev/null +++ b/core/lib/Drupal/Core/Render/Element/BulkOperations.php @@ -0,0 +1,11 @@ + 'details', - '#title' => $this->t('Update options'), - '#open' => TRUE, - '#attributes' => array('class' => array('container-inline')), + '#type' => 'bulk_operations', ); if ($type == 'approval') { @@ -117,7 +114,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' $form['options']['operation'] = array( '#type' => 'select', '#title' => $this->t('Action'), - '#title_display' => 'invisible', '#options' => $options, '#default_value' => 'publish', ); diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index 8e38c2b..f264ac6 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -275,7 +275,7 @@ public function viewsForm(&$form, FormStateInterface $form_state) { // Ensure a consistent container for filters/operations in the view header. $form['header'] = array( - '#type' => 'container', + '#type' => 'bulk_operations', '#weight' => -100, ); diff --git a/core/themes/seven/css/components/container-inline.css b/core/themes/seven/css/components/container-inline.css new file mode 100644 index 0000000..f17f77e --- /dev/null +++ b/core/themes/seven/css/components/container-inline.css @@ -0,0 +1,40 @@ +/** + * @file + * Inline items. + */ + +.container-inline div, +.container-inline label { + display: inline-block; +} +div.container-inline { + /* All space top and bottom comes from contents. */ + padding-top: 0; + padding-bottom: 0; +} +.container-inline .form-item { + margin-top: 0.75em; + margin-left: 2px; + margin-bottom: .25em; + margin-right: 2px; +} +.container-inline.form-actions, +.container-inline input[type="submit"], +.container-inline.form-wrapper input[type="submit"], +.container-inline.form-wrapper input[type="submit"]:first-child { + margin-top: 0.25em; + margin-right: 2px; + margin-bottom: 0.75em; + margin-left: 2px; +} +/* Override container-inline width for narrow viewports. */ +@media screen and (max-width: 600px) { + .container-inline .form-item, + .container-inline input[type="submit"], + .container-inline.form-actions, + .container-inline .form-actions { + margin-right: 0; + margin-left: 0; + width: 100%; + } +} diff --git a/core/themes/seven/css/components/form.css b/core/themes/seven/css/components/form.css index f3acc2c..d9d8bdb 100644 --- a/core/themes/seven/css/components/form.css +++ b/core/themes/seven/css/components/form.css @@ -127,7 +127,6 @@ label[for] { padding: 0.25em 0.666em 0; } - /* Filter */ ul.tips, div.description, @@ -222,6 +221,16 @@ textarea.form-textarea { } /** + * Styles the bulk operations form. + */ + +.panel.form-wrapper--bulk-form { + margin-bottom: 10px; + border-left: 0; + border-right: 0; +} + +/** * Limits extra long instances of select elements to the max width allowed * to avoid breaking layouts. */ diff --git a/core/themes/seven/seven.libraries.yml b/core/themes/seven/seven.libraries.yml index 424e7f5..c9eea21 100644 --- a/core/themes/seven/seven.libraries.yml +++ b/core/themes/seven/seven.libraries.yml @@ -8,6 +8,7 @@ global-styling: component: css/components/admin-list.css: {} css/components/content-header.css: {} + css/components/container-inline.css: {} css/components/breadcrumb.css: {} css/components/buttons.css: {} css/components/colors.css: {} diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 64ee724..fa51bbe 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -126,6 +126,10 @@ function seven_element_info_alter(&$type) { if (isset($type['button'])) { $type['button']['#attached']['library'][] = 'core/modernizr'; } + + if (isset($type['bulk_operations'])) { + $type['bulk_operations']['#pre_render'][] = 'seven_bulk_operations_pre_render'; + } } /** @@ -186,3 +190,12 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { $form['revision_information']['#type'] = 'container'; $form['revision_information']['#group'] = 'meta'; } + +/** + * #pre_render callback: Sets a variation class for bulk form form wrapper. + */ +function seven_bulk_operations_pre_render($element) { + $element['#attributes']['class'] = ['form-wrapper--bulk-form', 'panel', 'container-inline']; + + return $element; +}