<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[10952] sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns: Pattern Directory: Sync with git WordPress/pattern-directory@7241d0ba9cc511723b3f850a5f241d1c13d29a43</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/10952">10952</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/10952","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>ryelle</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-05-05 20:13:22 +0000 (Wed, 05 May 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Pattern Directory: Sync with git WordPress/pattern-directory@7241d0ba9cc511723b3f850a5f241d1c13d29a43</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsbuildindexassetphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.asset.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsbuildindexjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsindexphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/index.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternspackagejson">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/package.json</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssinglewporgpatternphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/single-wporg-pattern.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrccomponentscopypatternbuttonindexjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/copy-pattern-button/index.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrccomponentspatternthumbnailindexjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/pattern-thumbnail/index.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrcutilsindexjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/index.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternstemplatepartscontentgridphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/template-parts/content-grid.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrcutilscopytoclipboardjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/copy-to-clipboard.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsbuildindexassetphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.asset.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.asset.php 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.asset.php 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1 +1 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '51d417961bbb5e88ef5cc17bcdd3e65e');
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php return array('dependencies' => array('react', 'wp-a11y', 'wp-components', 'wp-compose', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '6cc4550be1812ff312e84305d20a109c');
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsbuildindexjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.js 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.js 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11072,6 +11072,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils */ "./src/utils/index.js");
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11080,27 +11081,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
- *
- * @param {string} stringToCopy A string that will be copied to the clipboard
- * @return {boolean} Whether the copy function succeeded
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Internal dependencies
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-var copyToClipboard = function copyToClipboard(stringToCopy) {
- var element = document.createElement('textarea'); // We don't want the text area to be selected since it's temporary.
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- element.setAttribute('readonly', ''); // We don't want the text area to be visible since it's temporary.
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- element.style.position = 'absolute';
- element.style.left = '-9999px';
- element.value = stringToCopy;
- document.body.appendChild(element);
- element.select();
- var success = document.execCommand('copy');
- document.body.removeChild(element);
- return success;
-};
-
</del><span class="cx" style="display: block; padding: 0 10px"> var CopyPatternButton = function CopyPatternButton(_ref) {
</span><span class="cx" style="display: block; padding: 0 10px"> var onSuccess = _ref.onSuccess;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11109,7 +11094,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Grab the pattern markup from hidden input
</span><span class="cx" style="display: block; padding: 0 10px"> var blockData = document.getElementById('block-data');
</span><span class="cx" style="display: block; padding: 0 10px"> var blockPattern = JSON.parse(decodeURIComponent(blockData.value));
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var success = copyToClipboard(blockPattern); // Make sure we reset focus in case it was lost in the 'copy' command.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var success = Object(_utils__WEBPACK_IMPORTED_MODULE_3__["copyToClipboard"])(blockPattern); // Make sure we reset focus in case it was lost in the 'copy' command.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> target.focus();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12047,13 +12032,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
-/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
-/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__);
-/* harmony import */ var _icons_heart_outline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../icons/heart-outline */ "./src/components/icons/heart-outline.js");
-/* harmony import */ var _icons_heart_filled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons/heart-filled */ "./src/components/icons/heart-filled.js");
-/* harmony import */ var _canvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./canvas */ "./src/components/pattern-thumbnail/canvas.js");
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* harmony import */ var _wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/a11y */ "@wordpress/a11y");
+/* harmony import */ var _wordpress_a11y__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__);
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__);
+/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
+/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__);
+/* harmony import */ var _icons_heart_outline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons/heart-outline */ "./src/components/icons/heart-outline.js");
+/* harmony import */ var _icons_heart_filled__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../icons/heart-filled */ "./src/components/icons/heart-filled.js");
+/* harmony import */ var _canvas__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./canvas */ "./src/components/pattern-thumbnail/canvas.js");
+/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils */ "./src/utils/index.js");
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12063,6 +12051,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Internal dependencies
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12071,6 +12060,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> function PatternThumbnail(_ref) {
</span><span class="cx" style="display: block; padding: 0 10px"> var pattern = _ref.pattern;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12080,6 +12070,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> isFavorite = _useState2[0],
</span><span class="cx" style="display: block; padding: 0 10px"> setFavorite = _useState2[1];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var _useState3 = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useState"])(false),
+ _useState4 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_useState3, 2),
+ copied = _useState4[0],
+ setCopied = _useState4[1];
+
+ var handleCopy = function handleCopy() {
+ var result = Object(_utils__WEBPACK_IMPORTED_MODULE_8__["copyToClipboard"])(pattern.pattern_content);
+ setCopied(result);
+ };
+
+ Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useEffect"])(function () {
+ if (!copied) {
+ return;
+ }
+
+ Object(_wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__["speak"])(Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["sprintf"])(
+ /* translators: %s: pattern title. */
+ Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copied %s pattern to clipboard.', 'wporg-patterns'), pattern.title.rendered));
+ var timer = setTimeout(function () {
+ return setCopied(false);
+ }, 20000);
+ return function () {
+ clearTimeout(timer);
+ };
+ }, [copied]);
</ins><span class="cx" style="display: block; padding: 0 10px"> return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("div", {
</span><span class="cx" style="display: block; padding: 0 10px"> className: "pattern-grid__pattern"
</span><span class="cx" style="display: block; padding: 0 10px"> }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("a", {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12087,7 +12102,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> rel: "bookmark"
</span><span class="cx" style="display: block; padding: 0 10px"> }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("span", {
</span><span class="cx" style="display: block; padding: 0 10px"> className: "screen-reader-text"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Disabled"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_canvas__WEBPACK_IMPORTED_MODULE_6__["default"], {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["Disabled"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_canvas__WEBPACK_IMPORTED_MODULE_7__["default"], {
</ins><span class="cx" style="display: block; padding: 0 10px"> className: "pattern-grid__preview",
</span><span class="cx" style="display: block; padding: 0 10px"> html: pattern.content.rendered
</span><span class="cx" style="display: block; padding: 0 10px"> }))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("div", {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12094,21 +12109,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> className: "pattern-grid__actions"
</span><span class="cx" style="display: block; padding: 0 10px"> }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("h2", {
</span><span class="cx" style="display: block; padding: 0 10px"> className: "pattern-grid__title"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Tooltip"], {
- text: isFavorite ? Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Remove pattern from favorites', 'wporg-patterns') : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Favorite pattern', 'wporg-patterns')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["Tooltip"], {
+ text: isFavorite ? Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Remove pattern from favorites', 'wporg-patterns') : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Favorite pattern', 'wporg-patterns')
</ins><span class="cx" style="display: block; padding: 0 10px"> }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("button", {
</span><span class="cx" style="display: block; padding: 0 10px"> className: 'button button-link pattern__favorite-button' + (isFavorite ? ' is-favorited' : ''),
</span><span class="cx" style="display: block; padding: 0 10px"> onClick: function onClick() {
</span><span class="cx" style="display: block; padding: 0 10px"> return setFavorite(!isFavorite);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_filled__WEBPACK_IMPORTED_MODULE_5__["default"], {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_filled__WEBPACK_IMPORTED_MODULE_6__["default"], {
</ins><span class="cx" style="display: block; padding: 0 10px"> className: "pattern__favorite-filled"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_outline__WEBPACK_IMPORTED_MODULE_4__["default"], {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_outline__WEBPACK_IMPORTED_MODULE_5__["default"], {
</ins><span class="cx" style="display: block; padding: 0 10px"> className: "pattern__favorite-outline"
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["Button"], {
</ins><span class="cx" style="display: block; padding: 0 10px"> className: "pattern__copy-button is-small",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- isPrimary: true
- }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Copy', 'wporg-patterns'))));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ isPrimary: true,
+ onClick: handleCopy
+ }, copied ? Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copied!', 'wporg-patterns') : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copy', 'wporg-patterns'))));
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony default export */ __webpack_exports__["default"] = (PatternThumbnail);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13112,11 +13128,46 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /***/ }),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/***/ "./src/utils/copy-to-clipboard.js":
+/*!****************************************!*\
+ !*** ./src/utils/copy-to-clipboard.js ***!
+ \****************************************/
+/*! exports provided: copyToClipboard */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return copyToClipboard; });
+/**
+ * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
+ *
+ * @param {string} stringToCopy A string that will be copied to the clipboard
+ * @return {boolean} Whether the copy function succeeded
+ */
+var copyToClipboard = function copyToClipboard(stringToCopy) {
+ var element = document.createElement('textarea'); // We don't want the text area to be selected since it's temporary.
+
+ element.setAttribute('readonly', ''); // We don't want screen readers to read the content since it's pattern markup
+
+ element.setAttribute('aria-hidden', 'true'); // We don't want the text area to be visible since it's temporary.
+
+ element.style.position = 'absolute';
+ element.style.left = '-9999px';
+ element.value = stringToCopy;
+ document.body.appendChild(element);
+ element.select();
+ var success = document.execCommand('copy');
+ document.body.removeChild(element);
+ return success;
+};
+
+/***/ }),
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /***/ "./src/utils/index.js":
</span><span class="cx" style="display: block; padding: 0 10px"> /*!****************************!*\
</span><span class="cx" style="display: block; padding: 0 10px"> !*** ./src/utils/index.js ***!
</span><span class="cx" style="display: block; padding: 0 10px"> \****************************/
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/*! exports provided: getCategoryFromPath, removeQueryString, removeEmptyArgs */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*! exports provided: getCategoryFromPath, removeQueryString, removeEmptyArgs, copyToClipboard */
</ins><span class="cx" style="display: block; padding: 0 10px"> /***/ (function(module, __webpack_exports__, __webpack_require__) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> "use strict";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13128,8 +13179,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeEmptyArgs", function() { return _category__WEBPACK_IMPORTED_MODULE_0__["removeEmptyArgs"]; });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* harmony import */ var _copy_to_clipboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./copy-to-clipboard */ "./src/utils/copy-to-clipboard.js");
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return _copy_to_clipboard__WEBPACK_IMPORTED_MODULE_1__["copyToClipboard"]; });
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /***/ }),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /***/ "@babel/runtime/regenerator":
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13143,6 +13198,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /***/ }),
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/***/ "@wordpress/a11y":
+/*!******************************!*\
+ !*** external ["wp","a11y"] ***!
+ \******************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+(function() { module.exports = window["wp"]["a11y"]; }());
+
+/***/ }),
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /***/ "@wordpress/components":
</span><span class="cx" style="display: block; padding: 0 10px"> /*!************************************!*\
</span><span class="cx" style="display: block; padding: 0 10px"> !*** external ["wp","components"] ***!
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternsindexphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/index.php 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/index.php 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,10 +9,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @link https://codex.wordpress.org/Template_Hierarchy
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @package WordPressdotorg\Theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @package WordPressdotorg\Pattern_Directory\Theme
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-namespace WordPressdotorg\Theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+namespace WordPressdotorg\Pattern_Directory\Theme;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_header();
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternspackagejson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/package.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/package.json 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/package.json 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,6 +25,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "extends @wordpress/browserslist-config"
</span><span class="cx" style="display: block; padding: 0 10px"> ],
</span><span class="cx" style="display: block; padding: 0 10px"> "devDependencies": {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "@wordpress/a11y": "2.15.2",
</ins><span class="cx" style="display: block; padding: 0 10px"> "@wordpress/block-editor": "5.3.0",
</span><span class="cx" style="display: block; padding: 0 10px"> "@wordpress/browserslist-config": "3.0.1",
</span><span class="cx" style="display: block; padding: 0 10px"> "@wordpress/components": "13.0.0",
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssinglewporgpatternphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/single-wporg-pattern.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/single-wporg-pattern.php 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/single-wporg-pattern.php 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,10 +4,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @package WordPressdotorg\Theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @package WordPressdotorg\Pattern_Directory\Theme
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-namespace WordPressdotorg\Theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+namespace WordPressdotorg\Pattern_Directory\Theme;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_header();
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrccomponentscopypatternbuttonindexjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/copy-pattern-button/index.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/copy-pattern-button/index.js 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/copy-pattern-button/index.js 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,32 +5,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> import { Button } from '@wordpress/components';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
- *
- * @param {string} stringToCopy A string that will be copied to the clipboard
- * @return {boolean} Whether the copy function succeeded
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Internal dependencies
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-const copyToClipboard = ( stringToCopy ) => {
- const element = document.createElement( 'textarea' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+import { copyToClipboard } from '../../utils';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We don't want the text area to be selected since it's temporary.
- element.setAttribute( 'readonly', '' );
-
- // We don't want the text area to be visible since it's temporary.
- element.style.position = 'absolute';
- element.style.left = '-9999px';
-
- element.value = stringToCopy;
-
- document.body.appendChild( element );
- element.select();
-
- const success = document.execCommand( 'copy' );
- document.body.removeChild( element );
-
- return success;
-};
-
</del><span class="cx" style="display: block; padding: 0 10px"> const CopyPatternButton = ( { onSuccess } ) => {
</span><span class="cx" style="display: block; padding: 0 10px"> const handleClick = ( { target } ) => {
</span><span class="cx" style="display: block; padding: 0 10px"> // Grab the pattern markup from hidden input
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrccomponentspatternthumbnailindexjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/pattern-thumbnail/index.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/pattern-thumbnail/index.js 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/pattern-thumbnail/index.js 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,9 +1,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * WordPress dependencies
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-import { __ } from '@wordpress/i18n';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+import { speak } from '@wordpress/a11y';
+import { __, sprintf } from '@wordpress/i18n';
</ins><span class="cx" style="display: block; padding: 0 10px"> import { Button, Disabled, Tooltip } from '@wordpress/components';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-import { useState } from '@wordpress/element';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+import { useEffect, useState } from '@wordpress/element';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Internal dependencies
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,11 +12,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> import IconHeartOutline from '../icons/heart-outline';
</span><span class="cx" style="display: block; padding: 0 10px"> import IconHeartFilled from '../icons/heart-filled';
</span><span class="cx" style="display: block; padding: 0 10px"> import Canvas from './canvas';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+import { copyToClipboard } from '../../utils';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function PatternThumbnail( { pattern } ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // @todo Implement a real favoriting process.
</span><span class="cx" style="display: block; padding: 0 10px"> const [ isFavorite, setFavorite ] = useState( Math.random() < 0.3 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const [ copied, setCopied ] = useState( false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const handleCopy = () => {
+ const result = copyToClipboard( pattern.pattern_content );
+
+ setCopied( result );
+ };
+
+ useEffect( () => {
+ if ( ! copied ) {
+ return;
+ }
+
+ speak(
+ sprintf(
+ /* translators: %s: pattern title. */
+ __( 'Copied %s pattern to clipboard.', 'wporg-patterns' ),
+ pattern.title.rendered
+ )
+ );
+
+ const timer = setTimeout( () => setCopied( false ), 20000 );
+ return () => {
+ clearTimeout( timer );
+ };
+ }, [ copied ] );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return (
</span><span class="cx" style="display: block; padding: 0 10px"> <div className="pattern-grid__pattern">
</span><span class="cx" style="display: block; padding: 0 10px"> <a href={ pattern.link } rel="bookmark">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,8 +71,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <IconHeartOutline className="pattern__favorite-outline" />
</span><span class="cx" style="display: block; padding: 0 10px"> </button>
</span><span class="cx" style="display: block; padding: 0 10px"> </Tooltip>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <Button className="pattern__copy-button is-small" isPrimary>
- { __( 'Copy', 'wporg-patterns' ) }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <Button className="pattern__copy-button is-small" isPrimary onClick={ handleCopy }>
+ { copied ? __( 'Copied!', 'wporg-patterns' ) : __( 'Copy', 'wporg-patterns' ) }
</ins><span class="cx" style="display: block; padding: 0 10px"> </Button>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrcutilscopytoclipboardjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/copy-to-clipboard.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/copy-to-clipboard.js (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/copy-to-clipboard.js 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,29 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
+ *
+ * @param {string} stringToCopy A string that will be copied to the clipboard
+ * @return {boolean} Whether the copy function succeeded
+ */
+export const copyToClipboard = ( stringToCopy ) => {
+ const element = document.createElement( 'textarea' );
+
+ // We don't want the text area to be selected since it's temporary.
+ element.setAttribute( 'readonly', '' );
+
+ // We don't want screen readers to read the content since it's pattern markup
+ element.setAttribute( 'aria-hidden', 'true' );
+
+ // We don't want the text area to be visible since it's temporary.
+ element.style.position = 'absolute';
+ element.style.left = '-9999px';
+
+ element.value = stringToCopy;
+
+ document.body.appendChild( element );
+ element.select();
+
+ const success = document.execCommand( 'copy' );
+ document.body.removeChild( element );
+
+ return success;
+};
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternssrcutilsindexjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/index.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/index.js 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/index.js 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1 +1,2 @@
</span><span class="cx" style="display: block; padding: 0 10px"> export { getCategoryFromPath, removeQueryString, removeEmptyArgs } from './category';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+export { copyToClipboard } from './copy-to-clipboard';
</ins></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpatternstemplatepartscontentgridphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/template-parts/content-grid.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/template-parts/content-grid.php 2021-05-05 17:38:07 UTC (rev 10951)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/template-parts/content-grid.php 2021-05-05 20:13:22 UTC (rev 10952)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,10 +2,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The template part for displaying content
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @package WordPressdotorg\Theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @package WordPressdotorg\Pattern_Directory\Theme;
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-namespace WordPressdotorg\Theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+namespace WordPressdotorg\Pattern_Directory\Theme;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>