Making WordPress.org

Changeset 10952


Ignore:
Timestamp:
05/05/2021 08:13:22 PM (3 years ago)
Author:
ryelle
Message:

Pattern Directory: Sync with git WordPress/pattern-directory@7241d0ba9cc511723b3f850a5f241d1c13d29a43

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.asset.php

    r10930 r10952  
    1 <?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');
     1<?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');
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/build/index.js

    r10930 r10952  
    1107311073/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
    1107411074/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__);
     11075/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils */ "./src/utils/index.js");
    1107511076
    1107611077
     
    1108111082
    1108211083/**
    11083  * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
    11084  *
    11085  * @param {string} stringToCopy A string that will be copied to the clipboard
    11086  * @return {boolean} Whether the copy function succeeded
    11087  */
    11088 
    11089 var copyToClipboard = function copyToClipboard(stringToCopy) {
    11090   var element = document.createElement('textarea'); // We don't want the text area to be selected since it's temporary.
    11091 
    11092   element.setAttribute('readonly', ''); // We don't want the text area to be visible since it's temporary.
    11093 
    11094   element.style.position = 'absolute';
    11095   element.style.left = '-9999px';
    11096   element.value = stringToCopy;
    11097   document.body.appendChild(element);
    11098   element.select();
    11099   var success = document.execCommand('copy');
    11100   document.body.removeChild(element);
    11101   return success;
    11102 };
     11084 * Internal dependencies
     11085 */
     11086
     11087
    1110311088
    1110411089var CopyPatternButton = function CopyPatternButton(_ref) {
     
    1111011095    var blockData = document.getElementById('block-data');
    1111111096    var blockPattern = JSON.parse(decodeURIComponent(blockData.value));
    11112     var success = copyToClipboard(blockPattern); // Make sure we reset focus in case it was lost in the 'copy' command.
     11097    var success = Object(_utils__WEBPACK_IMPORTED_MODULE_3__["copyToClipboard"])(blockPattern); // Make sure we reset focus in case it was lost in the 'copy' command.
    1111311098
    1111411099    target.focus();
     
    1204812033/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
    1204912034/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
    12050 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
    12051 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
    12052 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
    12053 /* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__);
    12054 /* harmony import */ var _icons_heart_outline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../icons/heart-outline */ "./src/components/icons/heart-outline.js");
    12055 /* harmony import */ var _icons_heart_filled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons/heart-filled */ "./src/components/icons/heart-filled.js");
    12056 /* harmony import */ var _canvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./canvas */ "./src/components/pattern-thumbnail/canvas.js");
    12057 
    12058 
    12059 
    12060 /**
    12061  * WordPress dependencies
    12062  */
     12035/* harmony import */ var _wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/a11y */ "@wordpress/a11y");
     12036/* harmony import */ var _wordpress_a11y__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__);
     12037/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
     12038/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__);
     12039/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
     12040/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__);
     12041/* harmony import */ var _icons_heart_outline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../icons/heart-outline */ "./src/components/icons/heart-outline.js");
     12042/* harmony import */ var _icons_heart_filled__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../icons/heart-filled */ "./src/components/icons/heart-filled.js");
     12043/* harmony import */ var _canvas__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./canvas */ "./src/components/pattern-thumbnail/canvas.js");
     12044/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils */ "./src/utils/index.js");
     12045
     12046
     12047
     12048/**
     12049 * WordPress dependencies
     12050 */
     12051
    1206312052
    1206412053
     
    1206712056 * Internal dependencies
    1206812057 */
     12058
    1206912059
    1207012060
     
    1208112071      setFavorite = _useState2[1];
    1208212072
     12073  var _useState3 = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useState"])(false),
     12074      _useState4 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_useState3, 2),
     12075      copied = _useState4[0],
     12076      setCopied = _useState4[1];
     12077
     12078  var handleCopy = function handleCopy() {
     12079    var result = Object(_utils__WEBPACK_IMPORTED_MODULE_8__["copyToClipboard"])(pattern.pattern_content);
     12080    setCopied(result);
     12081  };
     12082
     12083  Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useEffect"])(function () {
     12084    if (!copied) {
     12085      return;
     12086    }
     12087
     12088    Object(_wordpress_a11y__WEBPACK_IMPORTED_MODULE_2__["speak"])(Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["sprintf"])(
     12089    /* translators: %s: pattern title. */
     12090    Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copied %s pattern to clipboard.', 'wporg-patterns'), pattern.title.rendered));
     12091    var timer = setTimeout(function () {
     12092      return setCopied(false);
     12093    }, 20000);
     12094    return function () {
     12095      clearTimeout(timer);
     12096    };
     12097  }, [copied]);
    1208312098  return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("div", {
    1208412099    className: "pattern-grid__pattern"
     
    1208812103  }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("span", {
    1208912104    className: "screen-reader-text"
    12090   }, 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"], {
     12105  }, 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"], {
    1209112106    className: "pattern-grid__preview",
    1209212107    html: pattern.content.rendered
     
    1209512110  }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("h2", {
    1209612111    className: "pattern-grid__title"
    12097   }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Tooltip"], {
    12098     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')
     12112  }, pattern.title.rendered), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["Tooltip"], {
     12113    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')
    1209912114  }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])("button", {
    1210012115    className: 'button button-link pattern__favorite-button' + (isFavorite ? ' is-favorited' : ''),
     
    1210212117      return setFavorite(!isFavorite);
    1210312118    }
    12104   }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_filled__WEBPACK_IMPORTED_MODULE_5__["default"], {
     12119  }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_filled__WEBPACK_IMPORTED_MODULE_6__["default"], {
    1210512120    className: "pattern__favorite-filled"
    12106   }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_outline__WEBPACK_IMPORTED_MODULE_4__["default"], {
     12121  }), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_icons_heart_outline__WEBPACK_IMPORTED_MODULE_5__["default"], {
    1210712122    className: "pattern__favorite-outline"
    12108   }))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__["Button"], {
     12123  }))), Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["Button"], {
    1210912124    className: "pattern__copy-button is-small",
    12110     isPrimary: true
    12111   }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Copy', 'wporg-patterns'))));
     12125    isPrimary: true,
     12126    onClick: handleCopy
     12127  }, copied ? Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copied!', 'wporg-patterns') : Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Copy', 'wporg-patterns'))));
    1211212128}
    1211312129
     
    1311313129/***/ }),
    1311413130
     13131/***/ "./src/utils/copy-to-clipboard.js":
     13132/*!****************************************!*\
     13133  !*** ./src/utils/copy-to-clipboard.js ***!
     13134  \****************************************/
     13135/*! exports provided: copyToClipboard */
     13136/***/ (function(module, __webpack_exports__, __webpack_require__) {
     13137
     13138"use strict";
     13139__webpack_require__.r(__webpack_exports__);
     13140/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return copyToClipboard; });
     13141/**
     13142 * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
     13143 *
     13144 * @param {string} stringToCopy A string that will be copied to the clipboard
     13145 * @return {boolean} Whether the copy function succeeded
     13146 */
     13147var copyToClipboard = function copyToClipboard(stringToCopy) {
     13148  var element = document.createElement('textarea'); // We don't want the text area to be selected since it's temporary.
     13149
     13150  element.setAttribute('readonly', ''); // We don't want screen readers to read the content since it's pattern markup
     13151
     13152  element.setAttribute('aria-hidden', 'true'); // We don't want the text area to be visible since it's temporary.
     13153
     13154  element.style.position = 'absolute';
     13155  element.style.left = '-9999px';
     13156  element.value = stringToCopy;
     13157  document.body.appendChild(element);
     13158  element.select();
     13159  var success = document.execCommand('copy');
     13160  document.body.removeChild(element);
     13161  return success;
     13162};
     13163
     13164/***/ }),
     13165
    1311513166/***/ "./src/utils/index.js":
    1311613167/*!****************************!*\
    1311713168  !*** ./src/utils/index.js ***!
    1311813169  \****************************/
    13119 /*! exports provided: getCategoryFromPath, removeQueryString, removeEmptyArgs */
     13170/*! exports provided: getCategoryFromPath, removeQueryString, removeEmptyArgs, copyToClipboard */
    1312013171/***/ (function(module, __webpack_exports__, __webpack_require__) {
    1312113172
     
    1312813179
    1312913180/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeEmptyArgs", function() { return _category__WEBPACK_IMPORTED_MODULE_0__["removeEmptyArgs"]; });
     13181
     13182/* harmony import */ var _copy_to_clipboard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./copy-to-clipboard */ "./src/utils/copy-to-clipboard.js");
     13183/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "copyToClipboard", function() { return _copy_to_clipboard__WEBPACK_IMPORTED_MODULE_1__["copyToClipboard"]; });
     13184
    1313013185
    1313113186
     
    1314413199/***/ }),
    1314513200
     13201/***/ "@wordpress/a11y":
     13202/*!******************************!*\
     13203  !*** external ["wp","a11y"] ***!
     13204  \******************************/
     13205/*! no static exports found */
     13206/***/ (function(module, exports) {
     13207
     13208(function() { module.exports = window["wp"]["a11y"]; }());
     13209
     13210/***/ }),
     13211
    1314613212/***/ "@wordpress/components":
    1314713213/*!************************************!*\
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/index.php

    r10924 r10952  
    1010 * @link https://codex.wordpress.org/Template_Hierarchy
    1111 *
    12  * @package WordPressdotorg\Theme
     12 * @package WordPressdotorg\Pattern_Directory\Theme
    1313 */
    1414
    15 namespace WordPressdotorg\Theme;
     15namespace WordPressdotorg\Pattern_Directory\Theme;
    1616
    1717get_header();
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/package.json

    r10930 r10952  
    2626    ],
    2727    "devDependencies": {
     28        "@wordpress/a11y": "2.15.2",
    2829        "@wordpress/block-editor": "5.3.0",
    2930        "@wordpress/browserslist-config": "3.0.1",
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/single-wporg-pattern.php

    r10924 r10952  
    55 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
    66 *
    7  * @package WordPressdotorg\Theme
     7 * @package WordPressdotorg\Pattern_Directory\Theme
    88 */
    99
    10 namespace WordPressdotorg\Theme;
     10namespace WordPressdotorg\Pattern_Directory\Theme;
    1111
    1212get_header();
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/copy-pattern-button/index.js

    r10924 r10952  
    66
    77/**
    8  * Uses a hidden textarea that is added and removed from the DOM in order to copy to clipboard via the Browser.
    9  *
    10  * @param {string} stringToCopy A string that will be copied to the clipboard
    11  * @return {boolean} Whether the copy function succeeded
     8 * Internal dependencies
    129 */
    13 const copyToClipboard = ( stringToCopy ) => {
    14     const element = document.createElement( 'textarea' );
    15 
    16     // We don't want the text area to be selected since it's temporary.
    17     element.setAttribute( 'readonly', '' );
    18 
    19     // We don't want the text area to be visible since it's temporary.
    20     element.style.position = 'absolute';
    21     element.style.left = '-9999px';
    22 
    23     element.value = stringToCopy;
    24 
    25     document.body.appendChild( element );
    26     element.select();
    27 
    28     const success = document.execCommand( 'copy' );
    29     document.body.removeChild( element );
    30 
    31     return success;
    32 };
     10import { copyToClipboard } from '../../utils';
    3311
    3412const CopyPatternButton = ( { onSuccess } ) => {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/components/pattern-thumbnail/index.js

    r10882 r10952  
    22 * WordPress dependencies
    33 */
    4 import { __ } from '@wordpress/i18n';
     4import { speak } from '@wordpress/a11y';
     5import { __, sprintf } from '@wordpress/i18n';
    56import { Button, Disabled, Tooltip } from '@wordpress/components';
    6 import { useState } from '@wordpress/element';
     7import { useEffect, useState } from '@wordpress/element';
    78
    89/**
     
    1213import IconHeartFilled from '../icons/heart-filled';
    1314import Canvas from './canvas';
     15import { copyToClipboard } from '../../utils';
    1416
    1517function PatternThumbnail( { pattern } ) {
    1618    // @todo Implement a real favoriting process.
    1719    const [ isFavorite, setFavorite ] = useState( Math.random() < 0.3 );
     20    const [ copied, setCopied ] = useState( false );
     21
     22    const handleCopy = () => {
     23        const result = copyToClipboard( pattern.pattern_content );
     24
     25        setCopied( result );
     26    };
     27
     28    useEffect( () => {
     29        if ( ! copied ) {
     30            return;
     31        }
     32
     33        speak(
     34            sprintf(
     35                /* translators: %s: pattern title. */
     36                __( 'Copied %s pattern to clipboard.', 'wporg-patterns' ),
     37                pattern.title.rendered
     38            )
     39        );
     40
     41        const timer = setTimeout( () => setCopied( false ), 20000 );
     42        return () => {
     43            clearTimeout( timer );
     44        };
     45    }, [ copied ] );
    1846
    1947    return (
     
    4472                    </button>
    4573                </Tooltip>
    46                 <Button className="pattern__copy-button is-small" isPrimary>
    47                     { __( 'Copy', 'wporg-patterns' ) }
     74                <Button className="pattern__copy-button is-small" isPrimary onClick={ handleCopy }>
     75                    { copied ? __( 'Copied!', 'wporg-patterns' ) : __( 'Copy', 'wporg-patterns' ) }
    4876                </Button>
    4977            </div>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/src/utils/index.js

    r10924 r10952  
    11export { getCategoryFromPath, removeQueryString, removeEmptyArgs } from './category';
     2export { copyToClipboard } from './copy-to-clipboard';
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/template-parts/content-grid.php

    r10869 r10952  
    33 * The template part for displaying content
    44 *
    5  * @package WordPressdotorg\Theme;
     5 * @package WordPressdotorg\Pattern_Directory\Theme;
    66 */
    77
    8 namespace WordPressdotorg\Theme;
     8namespace WordPressdotorg\Pattern_Directory\Theme;
    99
    1010?>
Note: See TracChangeset for help on using the changeset viewer.