diff --git a/modules/custom/az_card/az_card.module b/modules/custom/az_card/az_card.module index fc1c155e4c..02ac81eddc 100644 --- a/modules/custom/az_card/az_card.module +++ b/modules/custom/az_card/az_card.module @@ -35,6 +35,7 @@ function az_card_theme($existing, $type, $theme, $path) { 'title' => NULL, 'body' => NULL, 'link' => NULL, + 'link_url' => NULL, 'title_style' => 'default', 'title_alignment' => 'text-left', 'title_level' => 'h3', diff --git a/modules/custom/az_card/css/az-card-title-hover.css b/modules/custom/az_card/css/az-card-title-hover.css index de19828e2e..ca654eba8a 100644 --- a/modules/custom/az_card/css/az-card-title-hover.css +++ b/modules/custom/az_card/css/az-card-title-hover.css @@ -6,3 +6,21 @@ transform: scale(1.03); transition: ease .25s; } + +h2.card-title>a, +h3.card-title>a, +h4.card-title>a, +h5.card-title>a, +h6.card-title>a { + color: inherit; + text-decoration: inherit; + font-weight: inherit; +} + +h2.card-title>a:hover, +h3.card-title>a:hover, +h4.card-title>a:hover, +h5.card-title>a:hover, +h6.card-title>a:hover { + text-decoration: underline; +} diff --git a/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php b/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php index 6c2d757cca..da319d8516 100644 --- a/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php +++ b/modules/custom/az_card/src/Plugin/Field/FieldFormatter/AZCardDefaultFormatter.php @@ -123,6 +123,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // Link. $link_render_array = []; + $link_url = ''; if ($item->link_title || $item->link_uri) { if (str_starts_with($item->link_uri ?? '', '/' . PublicStream::basePath())) { // Link to public file: use fromUri() to get the URL. @@ -213,9 +214,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { if (isset($card_defaults['card_title_display'])) { $title_display = $card_defaults['card_title_display']; } - } - } // Handle class keys that contained multiple classes. @@ -239,6 +238,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { '#langcode' => $item->getLangcode(), ], '#link' => $link_render_array, + '#link_url' => $link_url, '#title_style' => $title_style ?? 'default', '#title_level' => $title_level ?? 'h3', '#title_alignment' => $title_alignment ?? 'text-left', diff --git a/modules/custom/az_card/src/Plugin/Field/FieldWidget/AZCardWidget.php b/modules/custom/az_card/src/Plugin/Field/FieldWidget/AZCardWidget.php index fe3a034aea..5ff3bbd9c2 100644 --- a/modules/custom/az_card/src/Plugin/Field/FieldWidget/AZCardWidget.php +++ b/modules/custom/az_card/src/Plugin/Field/FieldWidget/AZCardWidget.php @@ -263,6 +263,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#type' => 'textfield', '#title' => $this->t('Card Link Title'), '#default_value' => $item->link_title ?? NULL, + '#description' => $this->t('Make each link title unique for best accessibility of this content. Use the pattern "verb" "noun" to create helpful links. For example, "Explore Undergraduate Programs".'), ]; $element['link_uri'] = [ @@ -292,7 +293,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen ]; if (!$item->isEmpty()) { - $button_name = implode('-', array_merge($field_parents, + $button_name = implode('-', array_merge( + $field_parents, [$field_name, $delta, 'toggle'] )); // Extra card_actions wrapper needed for core delete ajax submit nesting. @@ -432,8 +434,10 @@ public function validateCardLink(&$element, FormStateInterface $form_state, &$co // Url is valid, no conversion required. return; } - if (str_starts_with($element['#value'], '/' . PublicStream::basePath()) && - file_exists('public:' . urldecode(str_replace(PublicStream::basePath(), '', $element['#value'])))) { + if ( + str_starts_with($element['#value'], '/' . PublicStream::basePath()) && + file_exists('public:' . urldecode(str_replace(PublicStream::basePath(), '', $element['#value']))) + ) { // Link to a public file which is confirmed to exist. return; } diff --git a/modules/custom/az_card/templates/az-card.html.twig b/modules/custom/az_card/templates/az-card.html.twig index a9bbffdf31..b3f26e19ef 100644 --- a/modules/custom/az_card/templates/az-card.html.twig +++ b/modules/custom/az_card/templates/az-card.html.twig @@ -9,6 +9,7 @@ * - title: The title field of a card. * - body: The body field of a card. * - link: The link field on a card. + * - link_url: The link URL only. * - title_style: The title style to use. * - title_alignment: The title alignment to use. * - title_level: The heading level to use. @@ -26,7 +27,13 @@ {{ media }} {% if title and title_style == 'title-on-image' %}
{% endif %} @@ -40,7 +47,13 @@ {% else %}