+
diff --git a/main/.editorconfig b/main/.editorconfig new file mode 100644 index 0000000..7cae5d5 --- /dev/null +++ b/main/.editorconfig @@ -0,0 +1,14 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab diff --git a/main/.gitignore b/main/.gitignore new file mode 100644 index 0000000..02e3282 --- /dev/null +++ b/main/.gitignore @@ -0,0 +1,36 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Coverage directory used by tools like istanbul +coverage + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Output of `npm pack` +*.tgz + +# Output of `wp-scripts plugin-zip` +*.zip + +# dotenv environment variables file +.env + +#IDE folders +.idea +.vscode + +artifacts diff --git a/main/assets/humidity.png b/main/assets/humidity.png new file mode 100644 index 0000000..b975e15 Binary files /dev/null and b/main/assets/humidity.png differ diff --git a/main/assets/wind.png b/main/assets/wind.png new file mode 100644 index 0000000..1028d57 Binary files /dev/null and b/main/assets/wind.png differ diff --git a/main/build/block.json b/main/build/block.json new file mode 100644 index 0000000..e124967 --- /dev/null +++ b/main/build/block.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "create-block/weatherblock", + "version": "0.1.0", + "title": "Weather Block", + "category": "widgets", + "icon": "smiley", + "description": "Example static block scaffolded with Create Block tool.", + "attributes": { + "cityName": { + "type": "string" + }, + "measure": { + "type": "string" + } + }, + "supports": { + "html": false + }, + "textdomain": "weatherblock", + "editorScript": "file:./index.js", + "editorStyle": "file:./index.css", + "style": "file:./style-index.css" +} \ No newline at end of file diff --git a/main/build/index.asset.php b/main/build/index.asset.php new file mode 100644 index 0000000..8ce2308 --- /dev/null +++ b/main/build/index.asset.php @@ -0,0 +1 @@ + array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '8ac6586d8ee73f12621c'); diff --git a/main/build/index.css b/main/build/index.css new file mode 100644 index 0000000..9e33d9b --- /dev/null +++ b/main/build/index.css @@ -0,0 +1,14 @@ +/*!****************************************************************************************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[3].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[3].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[3].use[3]!./src/editor.scss ***! + \****************************************************************************************************************************************************************************************************************************************/ +/** + * The following styles get applied inside the editor only. + * + * Replace them with your own styles or remove the file completely. + */ +.wp-block-create-block-weatherblock { + border-radius: 2rem; + box-shadow: 5px 10px 8px #888888; +} + +/*# sourceMappingURL=index.css.map*/ \ No newline at end of file diff --git a/main/build/index.css.map b/main/build/index.css.map new file mode 100644 index 0000000..4f3db00 --- /dev/null +++ b/main/build/index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"index.css","mappings":";;;AAAA;;;;EAAA;AAMA;EACC;EACA;AAAD,C","sources":["webpack://weatherblock/./src/editor.scss"],"sourcesContent":["/**\n * The following styles get applied inside the editor only.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.wp-block-create-block-weatherblock {\n\tborder-radius: 2rem;\n\tbox-shadow: 5px 10px 8px #888888;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/main/build/index.js b/main/build/index.js new file mode 100644 index 0000000..7bbf07f --- /dev/null +++ b/main/build/index.js @@ -0,0 +1,353 @@ +/******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "./src/edit.js": +/*!*********************!*\ + !*** ./src/edit.js ***! + \*********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Edit) +/* harmony export */ }); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); +/* 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__); + + +/** + * Retrieves the translation of text. + * + * @see https://developer.wordpress.org/block-editor/packages/packages-i18n/ + */ + + + + +/** + * The edit function describes the structure of your block in the context of the + * editor. This represents what the editor will render when the block is used. + * + * @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit + * + * @return {WPElement} Element to render. + */ + +function Edit(props) { + const { + attributes, + setAttributes + } = props; + const { + cityName, + measure + } = attributes; + const blockProps = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps)(); + return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", blockProps, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, "Type the city\u2019s name below, and get the wheather information."), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.TextControl, { + label: "City name", + value: cityName, + onChange: newCityName => setAttributes({ + cityName: newCityName + }) + })); +} + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); +/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); +/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./edit */ "./src/edit.js"); +/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./block.json */ "./src/block.json"); + + +/** + * Internal dependencies + */ + + + +(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_3__, { + /** + * @see ./edit.js + */ + edit: _edit__WEBPACK_IMPORTED_MODULE_2__["default"], + + /** + * @see ./save.js + */ + save: () => null +}); + +/***/ }), + +/***/ "./src/editor.scss": +/*!*************************!*\ + !*** ./src/editor.scss ***! + \*************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/style.scss": +/*!************************!*\ + !*** ./src/style.scss ***! + \************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "@wordpress/block-editor": +/*!*************************************!*\ + !*** external ["wp","blockEditor"] ***! + \*************************************/ +/***/ ((module) => { + +module.exports = window["wp"]["blockEditor"]; + +/***/ }), + +/***/ "@wordpress/blocks": +/*!********************************!*\ + !*** external ["wp","blocks"] ***! + \********************************/ +/***/ ((module) => { + +module.exports = window["wp"]["blocks"]; + +/***/ }), + +/***/ "@wordpress/components": +/*!************************************!*\ + !*** external ["wp","components"] ***! + \************************************/ +/***/ ((module) => { + +module.exports = window["wp"]["components"]; + +/***/ }), + +/***/ "@wordpress/element": +/*!*********************************!*\ + !*** external ["wp","element"] ***! + \*********************************/ +/***/ ((module) => { + +module.exports = window["wp"]["element"]; + +/***/ }), + +/***/ "@wordpress/i18n": +/*!******************************!*\ + !*** external ["wp","i18n"] ***! + \******************************/ +/***/ ((module) => { + +module.exports = window["wp"]["i18n"]; + +/***/ }), + +/***/ "./src/block.json": +/*!************************!*\ + !*** ./src/block.json ***! + \************************/ +/***/ ((module) => { + +module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"create-block/weatherblock","version":"0.1.0","title":"Weather Block","category":"widgets","icon":"smiley","description":"Example static block scaffolded with Create Block tool.","attributes":{"cityName":{"type":"string"},"measure":{"type":"string"}},"supports":{"html":false},"textdomain":"weatherblock","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css"}'); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/chunk loaded */ +/******/ (() => { +/******/ var deferred = []; +/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { +/******/ if(chunkIds) { +/******/ priority = priority || 0; +/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; +/******/ deferred[i] = [chunkIds, fn, priority]; +/******/ return; +/******/ } +/******/ var notFulfilled = Infinity; +/******/ for (var i = 0; i < deferred.length; i++) { +/******/ var chunkIds = deferred[i][0]; +/******/ var fn = deferred[i][1]; +/******/ var priority = deferred[i][2]; +/******/ var fulfilled = true; +/******/ for (var j = 0; j < chunkIds.length; j++) { +/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { +/******/ chunkIds.splice(j--, 1); +/******/ } else { +/******/ fulfilled = false; +/******/ if(priority < notFulfilled) notFulfilled = priority; +/******/ } +/******/ } +/******/ if(fulfilled) { +/******/ deferred.splice(i--, 1) +/******/ var r = fn(); +/******/ if (r !== undefined) result = r; +/******/ } +/******/ } +/******/ return result; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/jsonp chunk loading */ +/******/ (() => { +/******/ // no baseURI +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ "index": 0, +/******/ "./style-index": 0 +/******/ }; +/******/ +/******/ // no chunk on demand loading +/******/ +/******/ // no prefetching +/******/ +/******/ // no preloaded +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ +/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ var runtime = data[2]; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ return __webpack_require__.O(result); +/******/ } +/******/ +/******/ var chunkLoadingGlobal = self["webpackChunkweatherblock"] = self["webpackChunkweatherblock"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ })(); +/******/ +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module depends on other loaded chunks and execution need to be delayed +/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["./style-index"], () => (__webpack_require__("./src/index.js"))) +/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); +/******/ +/******/ })() +; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/main/build/index.js.map b/main/build/index.js.map new file mode 100644 index 0000000..24d868d --- /dev/null +++ b/main/build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGe,SAASG,IAAT,CAAcC,KAAd,EAAqB;EAEnC,MAAM;IAAEC,UAAF;IAAcC;EAAd,IAAgCF,KAAtC;EAEA,MAAM;IAAEG,QAAF;IAAYC;EAAZ,IAAwBH,UAA9B;EAEA,MAAMI,UAAU,GAAGR,sEAAa,EAAhC;EAEA,OACC,yEAASQ,UAAT,EACC,kJADD,EAEC,kEAAC,8DAAD;IACC,KAAK,EAAC,WADP;IAEC,KAAK,EAAEF,QAFR;IAGC,QAAQ,EAAGG,WAAD,IAAiBJ,aAAa,CAAC;MAAEC,QAAQ,EAAEG;IAAZ,CAAD;EAHzC,EAFD,CADD;AAWA;;;;;;;;;;;;;;;;ACvCD;AACA;AAEA;AACA;AACA;;AAEA;AACA;AAGAC,oEAAiB,CAAEC,wCAAF,EAAQ;EACxB;AACD;AACA;EACCC,IAAI,EAAEV,6CAJkB;;EAKxB;AACD;AACA;EACCW,IAAI,EAAE,MAAM;AARY,CAAR,CAAjB;;;;;;;;;;;ACXA;;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC7BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEnDA;UACA;UACA;UACA;UACA","sources":["webpack://weatherblock/./src/edit.js","webpack://weatherblock/./src/index.js","webpack://weatherblock/./src/editor.scss?d4ae","webpack://weatherblock/./src/style.scss?5612","webpack://weatherblock/external window [\"wp\",\"blockEditor\"]","webpack://weatherblock/external window [\"wp\",\"blocks\"]","webpack://weatherblock/external window [\"wp\",\"components\"]","webpack://weatherblock/external window [\"wp\",\"element\"]","webpack://weatherblock/external window [\"wp\",\"i18n\"]","webpack://weatherblock/webpack/bootstrap","webpack://weatherblock/webpack/runtime/chunk loaded","webpack://weatherblock/webpack/runtime/compat get default export","webpack://weatherblock/webpack/runtime/define property getters","webpack://weatherblock/webpack/runtime/hasOwnProperty shorthand","webpack://weatherblock/webpack/runtime/make namespace object","webpack://weatherblock/webpack/runtime/jsonp chunk loading","webpack://weatherblock/webpack/before-startup","webpack://weatherblock/webpack/startup","webpack://weatherblock/webpack/after-startup"],"sourcesContent":["/**\n * Retrieves the translation of text.\n *\n * @see https://developer.wordpress.org/block-editor/packages/packages-i18n/\n */\nimport { __ } from '@wordpress/i18n';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport './editor.scss';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * The edit function describes the structure of your block in the context of the\n * editor. This represents what the editor will render when the block is used.\n *\n * @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit\n *\n * @return {WPElement} Element to render.\n */\n\n\nexport default function Edit(props) {\n\n\tconst { attributes, setAttributes } = props\n\n\tconst { cityName, measure } = attributes\n\n\tconst blockProps = useBlockProps()\n\n\treturn (\n\t\t
Type the city’s name below, and get the wheather information.
\n\t\t\tType the city’s name below, and get the wheather information.
++ {__( + 'Weather Block – hello from the saved content!', + 'weatherblock' + )} +
+ ); +} diff --git a/main/src/style.scss b/main/src/style.scss new file mode 100644 index 0000000..685589a --- /dev/null +++ b/main/src/style.scss @@ -0,0 +1,42 @@ +/** + * The following styles get applied both on the front of your site + * and in the editor. + * + * Replace them with your own styles or remove the file completely. + */ + +.wp-block-create-block-weatherblock, .weather-card { + border-radius: 2rem; + box-shadow: 5px 10px 8px #888888; + background-color: #dedbd9; + color: #000000; + padding: 2rem; + .main-weather{ + display: flex; + justify-content: space-evenly; + h3{ + font-size: 3.5rem; + font-weight: 900; + margin-bottom: 0; + } + .weather-icon{ + display: flex; + align-items: center; + } + } + .temp-info{ + display: grid; + grid-template-columns: repeat(3, 1fr); + justify-items: center; + img{width: 20%;} + span{ + font-size: 3rem; + } + .humidity, .wind{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } + } +} diff --git a/main/test/weatherblock.spec.js b/main/test/weatherblock.spec.js new file mode 100644 index 0000000..5d11479 --- /dev/null +++ b/main/test/weatherblock.spec.js @@ -0,0 +1,31 @@ + + +import { createNewPost, insertBlock, wpDataSelect, enablePageDialogAccept, getEditedPostContent, getCurrentPostContent } from '@wordpress/e2e-test-utils' + +jest.setTimeout(30000) + +describe('Pruebas en bloqueclima', () => { + beforeAll( async () => { + await enablePageDialogAccept(); + }) + + beforeEach( async () => { + await createNewPost() + }) + + it('deberia insertar el bloque en el editor', async () => { + + + await insertBlock( 'Bloqueclima' ); + + expect(await page.$( '[data-type="create-block/bloqueclima"]' ) ).not.toBeNull(); + + console.log(await wpDataSelect()) + + expect ( await getEditedPostContent() ).toEqual('') + + }) + + + +}) \ No newline at end of file diff --git a/main/weatherblock.php b/main/weatherblock.php new file mode 100644 index 0000000..6b9f8a0 --- /dev/null +++ b/main/weatherblock.php @@ -0,0 +1,96 @@ + 'render_weather_widget' + ) ); +} +add_action( 'init', 'create_block_weatherblock_block_init' ); + +function render_weather_widget($attributes, $content, $block){ + + $cityname = $attributes['cityName'] ? $attributes['cityName'] : 'managua'; + + + //API variables + $url = 'https://api.openweathermap.org/data/2.5/weather'; + $apiKey = '6b1cd5a24a18ee83c55372465790bed5'; + + $fullUrl = $url . '?q=' . $cityname . '&appid=' . $apiKey; + $response = wp_remote_get($fullUrl); + + + if (is_wp_error($response)) { + error_log("Error: ". $response->get_error_message()); + return false; + } + + if ($cityname !== ''){ + + $body = wp_remote_retrieve_body($response); + + $data = json_decode($body); + + + $city = $data->name; + $temp = $data->main->temp; + $cityweather = $data->weather[0]->description; + $hummidity = $data->main->humidity; + $speed = $data->wind->speed; + $weatherIcon = $data->weather[0]->icon; + + + ob_start(); + ?> ++
F
+
+
+
+
+