From 8d4a9d5141c780f259ce567bd0e30cfc4a8ae397 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 9 Nov 2023 13:36:56 -0400 Subject: [PATCH] Add status css for unpublished. --- web/modules/custom/.gitkeep | 0 .../custom/islandlives/css/islandlives.css | 3 +++ .../custom/islandlives/islandlives.libraries.yml | 6 ++++++ .../custom/islandlives/islandlives.module | 16 ++++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 web/modules/custom/.gitkeep create mode 100644 web/modules/custom/islandlives/css/islandlives.css create mode 100644 web/modules/custom/islandlives/islandlives.libraries.yml diff --git a/web/modules/custom/.gitkeep b/web/modules/custom/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/web/modules/custom/islandlives/css/islandlives.css b/web/modules/custom/islandlives/css/islandlives.css new file mode 100644 index 0000000..43a3109 --- /dev/null +++ b/web/modules/custom/islandlives/css/islandlives.css @@ -0,0 +1,3 @@ +tr.Unpublished { + background-color: #FFF4F4; +} \ No newline at end of file diff --git a/web/modules/custom/islandlives/islandlives.libraries.yml b/web/modules/custom/islandlives/islandlives.libraries.yml new file mode 100644 index 0000000..e3c92ee --- /dev/null +++ b/web/modules/custom/islandlives/islandlives.libraries.yml @@ -0,0 +1,6 @@ +unpublished: + version: 1.x + css: + theme: + css/islandlives.css: {} + \ No newline at end of file diff --git a/web/modules/custom/islandlives/islandlives.module b/web/modules/custom/islandlives/islandlives.module index 5faefbc..e6071ee 100644 --- a/web/modules/custom/islandlives/islandlives.module +++ b/web/modules/custom/islandlives/islandlives.module @@ -6,6 +6,7 @@ */ use Drupal\pathauto\PathautoPatternInterface; +use Drupal\views\ViewExecutable; /** * Implements hook_pathauto_pattern_alter(). @@ -23,3 +24,18 @@ function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, a } } } + +/** + * Implements hook_views_pre_render(). + */ +function islandlives_views_pre_render(ViewExecutable $view) { + $applicable_views = [ + 'content', + 'media', + 'manage_members', + 'media_of', + ]; + if (isset($view) && (in_array($view->storage->id(), $applicable_views))) { + $view->element['#attached']['library'][] = 'islandlives/unpublished'; + } +}