diff --git a/claro.theme b/claro.theme index 4798963..1bcb25f 100644 --- a/claro.theme +++ b/claro.theme @@ -65,10 +65,22 @@ function claro_preprocess_menu_local_tasks(&$variables) { * Implements hook_preprocess_HOOK() for menu-local-task templates. */ function claro_preprocess_menu_local_task(&$variables) { - $variables['attributes']['class'][] = 'tabs__tab'; $variables['link']['#options']['attributes']['class'][] = 'tabs__link'; - $variables['level'] = $variables['element']['#level']; + if (isset($variables['element']['#level'])) { + $variables['level'] = $variables['element']['#level']; + } +} + +/** + * Implements hook_preprocess_HOOK() for menu-local-task Views UI templates. + */ +function claro_preprocess_menu_local_task__views_ui(&$variables) { + // Remove 'tabs__link' without adding a new class because it couldn't be used + // reliably. + // @see https://www.drupal.org/node/3051605 + $link_class_index = array_search('tabs__link', $variables['link']['#options']['attributes']['class']); + unset($variables['link']['#options']['attributes']['class'][$link_class_index]); } /** @@ -321,6 +333,18 @@ function claro_form_media_form_alter(&$form, FormStateInterface $form_state) { } } +/** + * Implements hook_form_FORM_ID_alter() for view_edit_form. + */ +function claro_form_view_edit_form_alter(&$form, FormStateInterface $form_state) { + // @todo remove this after https://www.drupal.org/node/3051605 has been + // solved. + $form['displays']['top']['tabs']['#prefix'] = str_replace('class="tabs secondary"', 'class="views-tabs views-tabs--secondary"', $form['displays']['top']['tabs']['#prefix']); + foreach (Element::children($form['displays']['top']['tabs']) as $tab) { + $form['displays']['top']['tabs'][$tab]['#theme'] = 'menu_local_task__views_ui'; + } +} + /** * Implements hook_preprocess_form_element(). */ diff --git a/css/src/components/views-ui.css b/css/src/components/views-ui.css index 1998475..3772cc1 100644 --- a/css/src/components/views-ui.css +++ b/css/src/components/views-ui.css @@ -163,46 +163,183 @@ details.fieldset-no-legend { * The tabs that switch between sections */ -.views-displays .secondary { +.views-tabs { + overflow: visible; + margin: 0 200px 0 0; /* LTR */ + padding: 0; + border-bottom: 0 none; + list-style: none; text-align: left; /* LTR */ } -[dir="rtl"] .views-displays .secondary { +[dir="rtl"] .views-tabs { text-align: right; + margin-right: 0; + margin-left: 200px } - -.views-admin .icon.add { - background-position: center 3px; +.views-tabs > li { + float: left; /* LTR */ + padding: 0; + border-right: 0 none; /* LTR */ +} +[dir="rtl"] .views-tabs > li { + float: right; + border-right: 1px solid #bfbfbf; + border-left: 0 none; +} +.views-tabs .open > a { + position: relative; + z-index: 51; +} +.views-tabs .views-display-deleted-link { + text-decoration: line-through; +} +.views-tabs .add { + position: relative; +} +.views-tabs .action-list { + position: absolute; + z-index: 50; + top: 23px; + left: 0; /* LTR */ + margin: 0; +} +[dir="rtl"] .views-tabs .action-list { + right: 0; + left: auto; +} +.views-tabs .action-list li { + display: block; } -.views-displays .secondary a:hover > .icon.add { +.views-tab a:hover > .icon.add { background-position: center -25px; } -.views-displays .secondary .open > a { +.views-tab .open > a { border-radius: 7px 7px 0 0; } -.views-displays .secondary .open > a:hover, -.views-displays .secondary .open > a:focus { +.views-tab .open > a:hover, +.views-tab .open > a:focus { background-color: #f1f1f1; color: #008bcb; } -.views-displays .secondary .action-list li:first-child { +.views-tab .action-list li:first-child { border-radius: 0 7px 0 0; /* LTR */ } -[dir="rtl"] .views-displays .secondary .action-list li:first-child { +[dir="rtl"] .views-tab .action-list li:first-child { border-radius: 7px 0 0 0; } -.views-displays .secondary .action-list li:last-child { +.views-tab .action-list li:last-child { border-radius: 0 0 7px 7px; } -.views-displays .secondary .action-list input.form-submit { +.views-tab .action-list input.form-submit { color: #008bcb; } +.views-tabs li, +.views-tabs li.is-active { + width: auto; + padding: 0; + border: 0; + background: transparent; +} +.views-tabs li.add ul.action-list li { + margin: 0; +} +.views-tabs li { + margin: 0 5px 5px 6px; /* LTR */ +} +[dir="rtl"] .views-tabs li { + margin-right: 6px; + margin-left: 5px; +} +.views-tabs li + li { + border-top: 0; +} +.views-tabs li:hover { + padding-left: 0; /* LTR */ + border: 0; +} +[dir="rtl"] .views-tabs li:hover { + padding-right: 0; +} +.views-tabs a { + display: inline-block; + padding: 3px 7px; + border: 1px solid #cbcbcb; + border-radius: 7px; + font-size: small; + line-height: 1.3333; +} + +/* Display a red border if the display doesn't validate. */ +.views-tabs li.is-active a.is-active.error, +.views-tabs .error { + padding: 1px 6px; + border: 2px solid #ed541d; +} +.views-tabs a:focus { + text-decoration: underline; + outline: none; +} +.views-tabs li a { + background-color: #fff; +} +.views-tabs li a:hover, +.views-tabs li.is-active a, +.views-tabs li.is-active a.is-active { + color: #fff; + background-color: #555; +} +.views-tabs .open > a { + position: relative; + border-bottom: 1px solid transparent; + background-color: #f1f1f1; +} +.views-tabs .open > a:hover { + color: #0074bd; + background-color: #f1f1f1; +} +.views-tabs .action-list li { + padding: 2px 9px; + border-width: 0 1px; + border-style: solid; + border-color: #cbcbcb; + background-color: #f1f1f1; +} +.views-tabs .action-list li:first-child { + border-width: 1px 1px 0; +} +.views-displays .action-list li:last-child { + border-width: 0 1px 1px; +} +.views-tabs .action-list li:last-child { + border-width: 0 1px 1px; +} +.views-tabs .action-list input.form-submit { + margin: 0; + padding: 0; + border: medium none; + background: none repeat scroll 0 0 transparent; +} +.views-tabs .action-list input.form-submit:hover { + box-shadow: none; +} +.views-tabs .action-list li:hover { + background-color: #ddd; +} + +.views-tabs a:hover > .icon.add { + background-position: center -25px; +} +.views-tabs .open a:hover > .icon.add { + background-position: center 3px; +} + /* @end */ /* @group Attachment buckets diff --git a/templates/menu-local-task.html.twig b/templates/menu-local-task.html.twig index b855981..b1d11d5 100644 --- a/templates/menu-local-task.html.twig +++ b/templates/menu-local-task.html.twig @@ -14,4 +14,4 @@ * @see template_preprocess_menu_local_task() */ #} -