diff --git a/assets/scss/homepage.scss b/assets/scss/homepage.scss index 65e06ff..6fb6196 100644 --- a/assets/scss/homepage.scss +++ b/assets/scss/homepage.scss @@ -225,8 +225,11 @@ display: block; } - & h4#{&}__title { + & p#{&}__title { margin-top: 0; + font-size: 1.125em; + font-family: bca6d3310b5c9dae1dae416e8abc8405,helvetica,arial,sans-serif; + line-height: 1.2; } p:last-child { diff --git a/layouts/shortcodes/blocks/card.html b/layouts/shortcodes/blocks/card.html index aab43f8..3571d6f 100644 --- a/layouts/shortcodes/blocks/card.html +++ b/layouts/shortcodes/blocks/card.html @@ -35,7 +35,7 @@ {{ $modifiedSvg := replaceRE `()` "$1 aria-hidden=\"true\"$2" $svgContent 1 }} {{ $modifiedSvg | safeHTML }} -

{{ .Title }}

+

{{ .Title }}

{{ if $description }}

{{ $description }}

{{ else }} @@ -56,7 +56,7 @@

{{ .Title }}

{{ end }} {{ end }} -

{{ $title }}

+

{{ $title }}

{{ if eq .Page.File.Ext "md" }} {{ .Inner | .Page.RenderString }} diff --git a/static/js/prism-accessibility.js b/static/js/prism-accessibility.js index c0f2e5f..50e74e8 100644 --- a/static/js/prism-accessibility.js +++ b/static/js/prism-accessibility.js @@ -1,114 +1,134 @@ // (C) 2023 GoodData Corporation (function ($) { - $(document).ready(function () { - // Set initial ARIA attributes and variables - var $codeBlock = $('.code-toolbar'); - var $codeBlockToolBar = $('.toolbar'); - var $codeBlockContent = $('pre'); - var $accordionOptions = $('.accordion-options'); - var $defaultThreshold = 200; - - $codeBlock.attr('aria-expanded', 'false'); - - // Find all copy buttons - $('.copy-to-clipboard-button').each(function() { - var button = $(this); - - // Add ARIA attributes for better accessibility - button.attr('aria-label', 'Copy code to clipboard'); - }); - - // Expand buttons and expand code block options - $codeBlockToolBar.each(function() { - var nearestCodeBlock = $(this).closest($codeBlock); - var nearestCodeBlockContent = nearestCodeBlock.find($codeBlockContent); - var nearestAccordionOptions = nearestCodeBlock.closest($accordionOptions); - var threshold = nearestAccordionOptions.data('threshold') ? nearestAccordionOptions.data('threshold') : $defaultThreshold; - - var expandButton = $(''); - if (nearestCodeBlockContent.outerHeight(true) > threshold && !nearestAccordionOptions.hasClass('accordion-options--not-collapsible')) { - $(this).prepend(expandButton); - nearestCodeBlock.css('max-height', threshold + 'px'); - nearestCodeBlock.addClass('overflowing'); - expandButton.attr('aria-label', 'Expand code block'); - expandButton.wrap('
'); - } - }); - - var $expandButton = $('.expand-button'); - - $expandButton.on('click', function() { - var nearestCodeBlock = $(this).closest($codeBlock); - var nearestCodeBlockContent = $(this).closest($codeBlock).find($codeBlockContent); - var nearestAccordionOptions = nearestCodeBlock.closest($accordionOptions); - var threshold = nearestAccordionOptions.data('threshold') ? nearestAccordionOptions.data('threshold') : $defaultThreshold; - - // Toggle expanded state - nearestCodeBlock.toggleClass('expanded'); - nearestCodeBlock.attr('aria-expanded', nearestCodeBlock.hasClass('expanded')); - $(this).attr('aria-expanded', nearestCodeBlock.hasClass('expanded')); - $(this).attr('aria-label', nearestCodeBlock.hasClass('expanded') ? 'Collapse code block' : 'Expand code block'); - $(this).text(nearestCodeBlock.hasClass('expanded') ? 'Collapse' : 'Expand'); - $(this).toggleClass('expand-button--expanded'); - - // Adjust max-height based on expanded state - if (nearestCodeBlock.hasClass('expanded')) { - nearestCodeBlock.css('max-height', nearestCodeBlockContent.outerHeight(true) + 'px'); - } else { - nearestCodeBlock.css('max-height', threshold + 'px'); - $('html, body').animate({ - scrollTop: nearestCodeBlock.offset().top - 300 - }, 300); - nearestCodeBlockContent.animate({ - scrollLeft: 0 - }, 300); - } - }); - - // Add global escape key handler for code blocks - $(document).on('keydown', function(e) { - if (e.key === 'Escape') { - // Find any focused copy buttons and blur them - $('.copy-to-clipboard-button:focus').blur(); - } - }); - - // Accessibility for buttons - $codeBlockToolBar.find('button').each(function() { - var button = $(this); - - button.attr('tabindex', '0'); - - button.on('keydown', function(e) { - // Allow Escape key to dismiss the button - if (e.key === 'Escape') { - button.blur(); - e.preventDefault(); - } - - // Allow Enter or Space to activate the button - if (e.key === 'Enter' || e.key === ' ') { - button.click(); - e.preventDefault(); - } - }); - }); - - // Make the toolbar stay visible when tabbing into it - $('div.code-toolbar > .toolbar').each(function() { - var toolbar = $(this); - - toolbar.on('focusin', function() { - toolbar.css('opacity', '1'); - }); - - toolbar.on('focusout', function(e) { - // Only hide if focus moved outside the toolbar - if (!$.contains(toolbar[0], e.relatedTarget)) { - toolbar.css('opacity', ''); - } - }); - }); + $(document).ready(function () { + // Set initial ARIA attributes and variables + var $codeBlock = $(".code-toolbar"); + var $codeBlockToolBar = $(".toolbar"); + var $codeBlockContent = $("pre"); + var $accordionOptions = $(".accordion-options"); + var $defaultThreshold = 200; + + $codeBlock.attr("aria-expanded", "false"); + + // Expand buttons and expand code block options + $codeBlockToolBar.each(function () { + var nearestCodeBlock = $(this).closest($codeBlock); + var nearestCodeBlockContent = nearestCodeBlock.find($codeBlockContent); + var nearestAccordionOptions = nearestCodeBlock.closest($accordionOptions); + var threshold = nearestAccordionOptions.data("threshold") + ? nearestAccordionOptions.data("threshold") + : $defaultThreshold; + + var expandButton = $(''); + if ( + nearestCodeBlockContent.outerHeight(true) > threshold && + !nearestAccordionOptions.hasClass("accordion-options--not-collapsible") + ) { + $(this).prepend(expandButton); + nearestCodeBlock.css("max-height", threshold + "px"); + nearestCodeBlock.addClass("overflowing"); + expandButton.attr("aria-label", "Expand code block"); + expandButton.wrap('
'); + } + }); + + var $expandButton = $(".expand-button"); + + $expandButton.on("click", function () { + var nearestCodeBlock = $(this).closest($codeBlock); + var nearestCodeBlockContent = $(this) + .closest($codeBlock) + .find($codeBlockContent); + var nearestAccordionOptions = nearestCodeBlock.closest($accordionOptions); + var threshold = nearestAccordionOptions.data("threshold") + ? nearestAccordionOptions.data("threshold") + : $defaultThreshold; + + // Toggle expanded state + nearestCodeBlock.toggleClass("expanded"); + nearestCodeBlock.attr( + "aria-expanded", + nearestCodeBlock.hasClass("expanded"), + ); + $(this).attr("aria-expanded", nearestCodeBlock.hasClass("expanded")); + $(this).attr( + "aria-label", + nearestCodeBlock.hasClass("expanded") + ? "Collapse code block" + : "Expand code block", + ); + $(this).text( + nearestCodeBlock.hasClass("expanded") ? "Collapse" : "Expand", + ); + $(this).toggleClass("expand-button--expanded"); + + // Adjust max-height based on expanded state + if (nearestCodeBlock.hasClass("expanded")) { + nearestCodeBlock.css( + "max-height", + nearestCodeBlockContent.outerHeight(true) + "px", + ); + } else { + nearestCodeBlock.css("max-height", threshold + "px"); + $("html, body").animate( + { + scrollTop: nearestCodeBlock.offset().top - 300, + }, + 300, + ); + nearestCodeBlockContent.animate( + { + scrollLeft: 0, + }, + 300, + ); + } + }); + + // Add global escape key handler for code blocks + $(document).on("keydown", function (e) { + if (e.key === "Escape") { + // Find any focused copy buttons and blur them + $(".copy-to-clipboard-button:focus").blur(); + } + }); + + // Accessibility for buttons + $codeBlockToolBar.find("button").each(function () { + var button = $(this); + + button.attr("tabindex", "0"); + + button.on("keydown", function (e) { + // Allow Escape key to dismiss the button + if (e.key === "Escape") { + button.blur(); + e.preventDefault(); + } + + // Allow Enter or Space to activate the button + if (e.key === "Enter" || e.key === " ") { + button.click(); + e.preventDefault(); + } + }); + }); + + // Make the toolbar stay visible when tabbing into it + $("div.code-toolbar > .toolbar").each(function () { + var toolbar = $(this); + + toolbar.on("focusin", function () { + toolbar.css("opacity", "1"); + }); + + toolbar.on("focusout", function (e) { + // Only hide if focus moved outside the toolbar + if (!$.contains(toolbar[0], e.relatedTarget)) { + toolbar.css("opacity", ""); + } + }); }); -})(jQuery); \ No newline at end of file + }); +})(jQuery);