Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
portico: Polish UI for portico pages copy-codeblock button.
Wladimir Ramosb80a205dbe8f
diff --git a/web/src/portico/help.js b/web/src/portico/help.jsindex a80171e4719..6c39044f69f 100644--- a/web/src/portico/help.js+++ b/web/src/portico/help.js@@ -9,9 +9,9 @@ import * as common from "../common";import * as google_analytics from "./google-analytics";import {activate_correct_tab} from "./tabbed-instructions";-function registerCodeSection($codeSection) {- const $li = $codeSection.find("ul.nav li");- const $blocks = $codeSection.find(".blocks div");+function register_code_section($code_section) {+ const $li = $code_section.find("ul.nav li");+ const $blocks = $code_section.find(".blocks div");$li.on("click", function () {const tab_key = this.dataset.tabKey;@@ -46,19 +46,33 @@ function add_copy_to_clipboard_element($codehilite) {},});+ // Show a tippy tooltip when the button is hovered+ const tooltip_copy = tippy($copy_button[0], {+ content: "Copy code",+ trigger: "mouseenter",+ placement: "top",+ });+// Show a tippy tooltip when the code is copied- clipboard.on("success", () => {- const tooltip = tippy($copy_button[0], {- content: "Copied!",- trigger: "manual",- placement: "top",- });+ const tooltip_copied = tippy($copy_button[0], {+ content: "Copied!",+ trigger: "manual",+ placement: "top",+ });++ // Copy code on button click+ $copy_button.on("click", () => {+ clipboard.onClick({currentTarget: $copy_button[0]});+ });- tooltip.show();+ // Show "Copied!" tooltip when code is successfully copied+ clipboard.on("success", () => {+ tooltip_copy.hide();+ tooltip_copied.show();- // Show the tooltip for 1s+ // Hide the "Copied!" tooltip after 1 secondsetTimeout(() => {- tooltip.hide();+ tooltip_copied.hide();}, 1000);});}@@ -89,7 +103,7 @@ function highlight_current_article() {function render_code_sections() {$(".code-section").each(function () {activate_correct_tab($(this));- registerCodeSection($(this));+ register_code_section($(this));});// Add a copy-to-clipboard button for each .codehilite elementdiff --git a/web/styles/portico/markdown.css b/web/styles/portico/markdown.cssindex 67ed07c8bdc..083f0379548 100644--- a/web/styles/portico/markdown.css+++ b/web/styles/portico/markdown.css@@ -399,6 +399,7 @@}.copy-codeblock {+ cursor: pointer;/* Invisible default button */background: none;border: none;@@ -413,6 +414,10 @@outline-offset: -1px;outline-color: hsl(176deg 46% 41%);}++ &:hover svg path {+ fill: hsl(200deg 100% 40%);+ }}.code-section {