diff --git a/composer.json b/composer.json
index fda09f196..3b2315bec 100644
--- a/composer.json
+++ b/composer.json
@@ -71,10 +71,12 @@
"drupal/smart_trim": "^2.1",
"drupal/stage_file_proxy": "^2.1",
"drupal/tfa": "^1.0",
+ "drupal/tooltip": "^1.1",
"drupal/upgrade_status": "^4.0",
"drupal/username_enumeration_prevention": "^1.3",
"drush/drush": "^11",
"longwave/laminas-diactoros": "^2.14",
+ "mglaman/composer-drupal-lenient": "^1",
"npm-asset/anchor-js": "^5.0",
"npm-asset/select2": "^4.0",
"npm-asset/slick-carousel": "^1.8",
@@ -121,7 +123,8 @@
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
- "oomphinc/composer-installers-extender": true
+ "oomphinc/composer-installers-extender": true,
+ "mglaman/composer-drupal-lenient": true
},
"platform": {
"php": "8.1"
@@ -156,6 +159,9 @@
},
"npm-asset/anchor-js": {
"remove font-face": "patches/remove-anchorjs-fontface.patch"
+ },
+ "drupal/tooltip": {
+ "Remove hard dependency on CKEditor": "patches/tooltip.patch"
}
},
"drupal-scaffold": {
@@ -202,9 +208,13 @@
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
+ },
+ "drupal-lenient": {
+ "allowed-list": ["drupal/tooltip"]
}
},
"replace": {
- "drupal/ctools": "*"
+ "drupal/ctools": "*",
+ "drupal/ckeditor": "*"
}
}
diff --git a/composer.lock b/composer.lock
index 18a7097ec..8ac3615cc 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "57c53f87ffc0afbbd3bf347e79892e7f",
+ "content-hash": "f9295c8d777218a6a45a3f980fbeb433",
"packages": [
{
"name": "asm89/stack-cors",
@@ -5180,6 +5180,59 @@
"source": "https://git.drupalcode.org/project/token"
}
},
+ {
+ "name": "drupal/tooltip",
+ "version": "1.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://git.drupalcode.org/project/tooltip.git",
+ "reference": "1.1.1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://ftp.drupal.org/files/projects/tooltip-1.1.1.zip",
+ "reference": "1.1.1",
+ "shasum": "cc0bfe1aeebb54700ef8b8e2e7adbf563dcc9704"
+ },
+ "require": {
+ "drupal/ckeditor": "^1.0",
+ "drupal/core": "^8 || ^9 || ^10"
+ },
+ "type": "drupal-module",
+ "extra": {
+ "drupal": {
+ "version": "1.1.1",
+ "datestamp": "1691397408",
+ "security-coverage": {
+ "status": "covered",
+ "message": "Covered by Drupal's security advisory policy"
+ }
+ }
+ },
+ "notification-url": "https://packages.drupal.org/8/downloads",
+ "license": [
+ "GPL-2.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "googletorp",
+ "homepage": "https://www.drupal.org/user/386230"
+ },
+ {
+ "name": "matthieuscarset",
+ "homepage": "https://www.drupal.org/user/3471281"
+ },
+ {
+ "name": "mikl",
+ "homepage": "https://www.drupal.org/user/58679"
+ }
+ ],
+ "description": "Display anything you want in a tooltip on your Drupal site.",
+ "homepage": "https://www.drupal.org/project/tooltip",
+ "support": {
+ "source": "https://git.drupalcode.org/project/tooltip"
+ }
+ },
{
"name": "drupal/upgrade_status",
"version": "4.0.0",
@@ -6816,6 +6869,64 @@
},
"time": "2023-08-03T13:14:11+00:00"
},
+ {
+ "name": "mglaman/composer-drupal-lenient",
+ "version": "1.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mglaman/composer-drupal-lenient.git",
+ "reference": "9d9271499d86ceb1431de80f876800fadf10a9e1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mglaman/composer-drupal-lenient/zipball/9d9271499d86ceb1431de80f876800fadf10a9e1",
+ "reference": "9d9271499d86ceb1431de80f876800fadf10a9e1",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^2.0",
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "composer/composer": "^2.3",
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^1.6",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.2",
+ "phpunit/phpunit": "^9.5",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "ComposerDrupalLenient\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "ComposerDrupalLenient\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-2.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Matt Glaman",
+ "email": "nmd.matt@gmail.com"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/mglaman/composer-drupal-lenient/issues",
+ "source": "https://github.com/mglaman/composer-drupal-lenient/tree/1.0.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/mglaman",
+ "type": "github"
+ }
+ ],
+ "time": "2023-03-21T19:06:37+00:00"
+ },
{
"name": "mglaman/phpstan-drupal",
"version": "1.1.10",
diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml
index 6bc632df6..8ea098063 100644
--- a/config/sync/core.extension.yml
+++ b/config/sync/core.extension.yml
@@ -82,6 +82,7 @@ module:
tfa: 0
token: 0
toolbar: 0
+ tooltip: 0
update: 0
user: 0
username_enumeration_prevention: 0
diff --git a/patches/tooltip.patch b/patches/tooltip.patch
new file mode 100644
index 000000000..f84eff515
--- /dev/null
+++ b/patches/tooltip.patch
@@ -0,0 +1,23 @@
+diff --git a/tooltip.info.yml b/tooltip.info.yml
+index 60a5f91..b848e21 100644
+--- a/tooltip.info.yml
++++ b/tooltip.info.yml
+@@ -3,9 +3,6 @@ type: module
+ description: Provides advanced HTML tooltip with PopperJS library.
+ core: 8.x
+ core_version_requirement: ^8 || ^9 || ^10
+-dependencies:
+- - drupal:editor
+- - drupal:ckeditor
+
+ # Information added by Drupal.org packaging script on 2023-08-07
+ version: '1.1.1'
+diff --git a/tooltip.routing.yml b/tooltip.routing.yml
+index 07aab50..234cb19 100644
+--- a/tooltip.routing.yml
++++ b/tooltip.routing.yml
+@@ -17,3 +17,4 @@ tooltip.editor_dialog:
+ type: entity:editor
+ requirements:
+ _entity_access: 'editor.use'
++ _module_dependencies: 'editor + ckeditor'
diff --git a/web/modules/custom/server_general/src/ListTrait.php b/web/modules/custom/server_general/src/ListTrait.php
new file mode 100644
index 000000000..9adf7b443
--- /dev/null
+++ b/web/modules/custom/server_general/src/ListTrait.php
@@ -0,0 +1,46 @@
+ 'item_list',
+ '#list_type' => 'ul',
+ '#items' => $items,
+ ];
+ }
+
+ /**
+ * Build an ordered list.
+ *
+ * @param array $items
+ * The items of the list.
+ *
+ * @return array
+ * The render array of the list.
+ */
+ protected function buildElementOrderedList(array $items): array {
+ return [
+ '#theme' => 'item_list',
+ '#list_type' => 'ol',
+ '#items' => $items,
+ ];
+ }
+
+}
diff --git a/web/modules/custom/server_general/src/TooltipTrait.php b/web/modules/custom/server_general/src/TooltipTrait.php
new file mode 100644
index 000000000..7aeed6735
--- /dev/null
+++ b/web/modules/custom/server_general/src/TooltipTrait.php
@@ -0,0 +1,73 @@
+renderer->render($content);
+ $settings = array_merge($default_settings, $settings);
+
+ // Create the tooltip element now.
+ return [
+ '#theme' => 'server_theme_element__tooltip_span',
+ '#text' => $text,
+ '#settings' => json::encode($settings),
+ ];
+ }
+
+ /**
+ * Build a link with a tooltip. This trait depends on the tooltip module.
+ *
+ * @param string $text
+ * The text to generate the link with the tooltip.
+ * @param string $href
+ * The href of the link.
+ * @param array $content
+ * Items to render inside the tooltip.
+ * @param array $settings
+ * Additional settings to pass to render the tooltip.
+ *
+ * @return array
+ * The render array.
+ */
+ protected function buildElementLinkWithTooltip(string|\Stringable $text, string $href, array $content, array $settings = []): array {
+ $default_settings = [];
+ $default_settings['placement'] = 'bottom';
+ $default_settings['content'] = $this->renderer->render($content);
+ $settings = array_merge($default_settings, $settings);
+
+ // Create the tooltip element now.
+ return [
+ '#theme' => 'server_theme_element__tooltip_link',
+ '#href' => $href,
+ '#text' => $text,
+ '#settings' => Json::encode($settings),
+ ];
+ }
+
+}
diff --git a/web/modules/custom/server_style_guide/src/Controller/StyleGuideController.php b/web/modules/custom/server_style_guide/src/Controller/StyleGuideController.php
index 8b1189f94..fcda7d668 100644
--- a/web/modules/custom/server_style_guide/src/Controller/StyleGuideController.php
+++ b/web/modules/custom/server_style_guide/src/Controller/StyleGuideController.php
@@ -17,9 +17,11 @@
use Drupal\server_general\ElementWrapTrait;
use Drupal\server_general\InnerElementTrait;
use Drupal\server_general\LinkTrait;
+use Drupal\server_general\ListTrait;
use Drupal\server_general\SocialShareTrait;
use Drupal\server_general\TagTrait;
use Drupal\server_general\TitleAndLabelsTrait;
+use Drupal\server_general\TooltipTrait;
use Drupal\server_style_guide\StyleGuideElementWrapTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -37,10 +39,12 @@ class StyleGuideController extends ControllerBase {
use ElementWrapTrait;
use InnerElementTrait;
use LinkTrait;
+ use ListTrait;
use SocialShareTrait;
use StyleGuideElementWrapTrait;
use TagTrait;
use TitleAndLabelsTrait;
+ use TooltipTrait;
/**
@@ -180,6 +184,9 @@ protected function getAllElements() : array {
$element = $this->getNodeNews();
$build[] = $this->wrapElementNoContainer($element, 'Node view: News');
+ $element = $this->getTooltip();
+ $build[] = $this->wrapElementWideContainer($element, 'Element: Tooltip');
+
return $build;
}
@@ -848,4 +855,20 @@ protected function getRelatedContent(int $num = 5, bool $is_featured = FALSE): a
return $elements;
}
+ /**
+ * Renders a tooltip.
+ *
+ * @return array
+ * A render array.
+ */
+ protected function getTooltip() : array {
+ $content = $this->getMediaImageWithCreditOverlay();
+ $elements[] = $this->buildElementSpanWithTooltip('This element has a tooltip', $content, ['placement' => 'top']);
+
+ $content = ['#markup' => 'An example site'];
+ $elements[] = $this->buildElementLinkWithTooltip('This element is a link with tooltip', 'https://example.com', $content, ['placement' => 'top']);
+
+ return $this->buildElementUnorderedList($elements);
+ }
+
}
diff --git a/web/themes/custom/server_theme/server_theme.theme b/web/themes/custom/server_theme/server_theme.theme
index 59bd931f6..0df4d313a 100644
--- a/web/themes/custom/server_theme/server_theme.theme
+++ b/web/themes/custom/server_theme/server_theme.theme
@@ -458,6 +458,28 @@ function server_theme_theme() {
],
];
+ // The "Tooltip span" element.
+ $info['server_theme_element__tooltip_span'] = [
+ 'variables' => [
+ // The text inside the span.
+ 'text' => '',
+ // The settings to render the tooltip. Json encoded.
+ 'settings' => '',
+ ],
+ ];
+
+ // The "Tooltip link" element.
+ $info['server_theme_element__tooltip_link'] = [
+ 'variables' => [
+ // The url of the link.
+ 'href' => '',
+ // The text inside the link.
+ 'text' => '',
+ // The settings to render the tooltip. Json encoded.
+ 'settings' => '',
+ ],
+ ];
+
// A card that is linkable.
$info['server_theme_inner_element__quick_link_item'] = [
'variables' => [
diff --git a/web/themes/custom/server_theme/templates/server-theme-element--tooltip-link.html.twig b/web/themes/custom/server_theme/templates/server-theme-element--tooltip-link.html.twig
new file mode 100644
index 000000000..c65b706d5
--- /dev/null
+++ b/web/themes/custom/server_theme/templates/server-theme-element--tooltip-link.html.twig
@@ -0,0 +1,4 @@
+{{ attach_library('tooltip/tooltip') }}
+
+{{ text }}
+
diff --git a/web/themes/custom/server_theme/templates/server-theme-element--tooltip-span.html.twig b/web/themes/custom/server_theme/templates/server-theme-element--tooltip-span.html.twig
new file mode 100644
index 000000000..70102575c
--- /dev/null
+++ b/web/themes/custom/server_theme/templates/server-theme-element--tooltip-span.html.twig
@@ -0,0 +1,3 @@
+{{ attach_library('tooltip/tooltip') }}
+
+{{ text }}