Best JavaScript code snippet using playwright-internal
keyboard.js
Source:keyboard.js
1/***********************2*** Version:v1.1 ***3*** Date:20140221 ***4*** Author:XieWj ***5***********************/6var _kb = null;7function SoftKeyboard() {8 this._keys = [9 [{ "text": ",", "value": ",", "text_shift": "<", "value_shift": "<", "type": 0 },10 { "text": ".", "value": ".", "text_shift": ">", "value_shift": ">", "type": 0 },11 { "text": "/", "value": "/", "text_shift": "?", "value_shift": "?", "type": 0 },12 { "text": ";", "value": ";", "text_shift": ":", "value_shift": ":", "type": 0 },13 { "text": "'", "value": "'", "text_shift": "\"", "value_shift": "\"", "type": 0 },14 { "text": "[", "value": "[", "text_shift": "{", "value_shift": "{", "type": 0 },15 { "text": "]", "value": "]", "text_shift": "}", "value_shift": "}", "type": 0 },16 { "text": "\\", "value": "\\", "text_shift": "|", "value_shift": "|", "type": 0 },17 { "text": "-", "value": "-", "text_shift": "_", "value_shift": "_", "type": 0 },18 { "text": "=", "value": "=", "text_shift": "+", "value_shift": "+", "type": 0 },19 { "text": "æ¸
空", "value": "", "text_shift": "", "value_shift": "", "type": 1 }20 ],21 [{ "text": "1", "value": "1", "text_shift": "!", "value_shift": "!", "type": 0 },22 { "text": "2", "value": "2", "text_shift": "@", "value_shift": "@", "type": 0 },23 { "text": "3", "value": "3", "text_shift": "#", "value_shift": "#", "type": 0 },24 { "text": "4", "value": "4", "text_shift": "$", "value_shift": "$", "type": 0 },25 { "text": "5", "value": "5", "text_shift": "%", "value_shift": "%", "type": 0 },26 { "text": "6", "value": "6", "text_shift": "^", "value_shift": "^", "type": 0 },27 { "text": "7", "value": "7", "text_shift": "&", "value_shift": "&", "type": 0 },28 { "text": "8", "value": "8", "text_shift": "*", "value_shift": "*", "type": 0 },29 { "text": "9", "value": "9", "text_shift": "(", "value_shift": "(", "type": 0 },30 { "text": "0", "value": "0", "text_shift": ")", "value_shift": ")", "type": 0 },31 { "text": "é æ ¼", "value": "", "text_shift": "", "value_shift": "", "type": 2 }32 ],33 [{ "text": "q", "value": "q", "text_shift": "Q", "value_shift": "Q", "type": 0 },34 { "text": "w", "value": "w", "text_shift": "W", "value_shift": "W", "type": 0 },35 { "text": "e", "value": "e", "text_shift": "E", "value_shift": "E", "type": 0 },36 { "text": "r", "value": "r", "text_shift": "R", "value_shift": "R", "type": 0 },37 { "text": "t", "value": "t", "text_shift": "T", "value_shift": "T", "type": 0 },38 { "text": "y", "value": "y", "text_shift": "Y", "value_shift": "Y", "type": 0 },39 { "text": "u", "value": "u", "text_shift": "U", "value_shift": "U", "type": 0 },40 { "text": "i", "value": "i", "text_shift": "I", "value_shift": "I", "type": 0 },41 { "text": "o", "value": "o", "text_shift": "O", "value_shift": "O", "type": 0 },42 { "text": "p", "value": "p", "text_shift": "P", "value_shift": "P", "type": 0 },43 { "text": "ç¡® 认", "value": "", "text_shift": "", "value_shift": "", "type": 3 }44 ],45 [{ "text": "a", "value": "a", "text_shift": "A", "value_shift": "A", "type": 0 },46 { "text": "s", "value": "s", "text_shift": "S", "value_shift": "S", "type": 0 },47 { "text": "d", "value": "d", "text_shift": "D", "value_shift": "D", "type": 0 },48 { "text": "f", "value": "f", "text_shift": "F", "value_shift": "F", "type": 0 },49 { "text": "g", "value": "g", "text_shift": "G", "value_shift": "G", "type": 0 },50 { "text": "h", "value": "h", "text_shift": "H", "value_shift": "H", "type": 0 },51 { "text": "j", "value": "j", "text_shift": "J", "value_shift": "J", "type": 0 },52 { "text": "k", "value": "k", "text_shift": "K", "value_shift": "K", "type": 0 },53 { "text": "l", "value": "l", "text_shift": "L", "value_shift": "L", "type": 0 },54 { "text": "å æ¢", "value": "", "text_shift": "", "value_shift": "", "type": 4 }55 ],56 [{ "text": "z", "value": "z", "text_shift": "Z", "value_shift": "Z", "type": 0 },57 { "text": "x", "value": "x", "text_shift": "X", "value_shift": "X", "type": 0 },58 { "text": "c", "value": "c", "text_shift": "C", "value_shift": "C", "type": 0 },59 { "text": "v", "value": "v", "text_shift": "V", "value_shift": "V", "type": 0 },60 { "text": "b", "value": "b", "text_shift": "B", "value_shift": "B", "type": 0 },61 { "text": "n", "value": "n", "text_shift": "N", "value_shift": "N", "type": 0 },62 { "text": "m", "value": "m", "text_shift": "M", "value_shift": "M", "type": 0 },63 { "text": "", "value": "", "text_shift": "", "value_shift": "", "type": 5 },64 { "text": "空 æ ¼", "value": " ", "text_shift": "空 æ ¼", "value_shift": " ", "type": 0 }65 ],66 [{ "text": "", "value": "", "text_shift": "", "value_shift": "", "type": -1 }67 ]68 ];69 this._skinId = 0;70 this._skinName = ["default", "wp8", "white"];71 this._board = document.createElement("div");72 this._board.className = "bg" + "_" + this._skinName[this._skinId];73 for (i = 0; i < this._keys.length; i++) {74 for (j = 0; j < this._keys[i].length; j++) {75 var charDiv = document.createElement("div");76 charDiv.innerText = this._keys[i][j].text;77 charDiv.className = "label" + "_" + this._skinName[this._skinId] + " key" + i + "_" + j + "_" + this._skinName[this._skinId];78 this._board.appendChild(charDiv);79 }80 }81 this._focusElement = document.createElement("div");82 this._focusElement.className = "focus" + "_" + this._skinName[this._skinId];83 this._board.appendChild(this._focusElement);84 this._focus=new KeyboardFucos();85}86SoftKeyboard.prototype = {87 _screenWidth: 1280,88 _screenHeight: 720,89 _isShifted: false,90 _alignCenter: false,91 _focusElement: undefined,92 _inputElement: undefined,93 pop:94 function (inputElement) {95 //this.close();96 var boardDiv = this._board;97 this._focus = new KeyboardFucos();98 this._inputElement = inputElement;99 var input = inputElement;100 if (input.charArray == undefined)101 input.charArray = new Array();102 input.style.overflow = "hidden";103 input.parentNode.appendChild(boardDiv);104 var iTop = parseInt(getCurrentStyle(input, "top"));105 var iLeft = parseInt(getCurrentStyle(input, "left"));106 var iWidth = parseInt(getCurrentStyle(input, "width"));107 var iHeight = parseInt(getCurrentStyle(input, "height"));108 var bWidth = parseInt(getCurrentStyle(boardDiv, "width"));109 var bHeight = parseInt(getCurrentStyle(boardDiv, "height"));110 if (iTop + iHeight + bHeight <= this._screenHeight)111 boardDiv.style.top = (iTop + iHeight + 2) + "px";112 else113 boardDiv.style.top = (iTop - bHeight) + "px";114 if (!this._alignCenter) {115 if (iLeft + bWidth <= this._screenWidth)116 boardDiv.style.left = iLeft + "px";117 else118 boardDiv.style.left = (iLeft + iWidth - bWidth) + "px";119 }120 else {121 boardDiv.style.left = (this._screenWidth - bWidth) / 2 + "px";122 }123 document.onkeydown = keyDownEvent;124 document.onkeyup = keyUpEvent;125 //document.onkeypress = sytemEvent;126 document.onsystemevent = keyDownEvent;127 document.onirkeypres = keyDownEvent;128 this._changeFocus(this._focus);129 _kb = this;130 },131 close:132 function () {133 if (this._board != undefined)134 this._board.parentNode.removeChild(this._board);135 this._focus.x = 0;136 this._focus.y = 0;137 this._isShifted = false;138 if (this._inputElement.hasChildNodes()) {139 var textDiv = this._inputElement.firstChild;140 this._inputElement.text = textDiv.innerText;141 }142 this.onClose();143 },144 onClose:145 function () {146 },147 _keyUp:148 function () {149 this._focusElement.className = "focus" + "_" + this._skinName[this._skinId] + " key" + this._focus.y + "_" + this._focus.x + "_" + this._skinName[this._skinId] + " focus" + this._focus.y + "_" + this._focus.x + "_" + this._skinName[this._skinId];150 },151 _keyDown:152 function () {153 this._focusElement.className = "focus" + "_" + this._skinName[this._skinId] + " key" + this._focus.y + "_" + this._focus.x + "_" + this._skinName[this._skinId] + " focus" + this._focus.y + "_" + this._focus.x + "_d_" + this._skinName[this._skinId];154 var input = this._inputElement;155 var type = this._getFocusKey().type;156 if (type == 0) {//å符æé®157 var c = this._getFocusKey().value;158 if (this._isShifted)159 c = this._getFocusKey().value_shift;160 input.charArray.push(c);161 {162 if (input.hasChildNodes()) {163 var textDiv = input.firstChild;164 if (input.maxlength == undefined || input.maxlength < 1 || textDiv.innerText.length < input.maxlength)165 textDiv.innerHTML = HtmlEncode(textDiv.innerText + c);166 }167 else {168 var textDiv = document.createElement("div");169 textDiv.style.position = "absolute";170 //textDiv.style.border = "1px solid green";171 textDiv.style.whiteSpace = "nowrap";172 textDiv.innerHTML = HtmlEncode(c);173 textDiv.style.left = "0px";174 input.appendChild(textDiv);175 }176 setTimeout("_kb._updateInputDisplay();", 10);177 }178 }179 else if (type == 1)//æ¸
é¤é®180 {181 if (input.hasChildNodes()) {182 var textDiv = input.firstChild;183 textDiv.innerHTML = "";184 input.charArray = new Array();185 setTimeout("_kb._updateInputDisplay();", 10);186 }187 }188 else if (type == 2)//éæ ¼é®189 {190 if (input.hasChildNodes()) {191 var textDiv = input.firstChild;192 var text = (textDiv.innerText);193 if (input.charArray.length > 0) {194 var key_value = input.charArray.pop();195 textDiv.innerHTML = HtmlEncode(text.substring(0, text.length - key_value.length));196 setTimeout("_kb._updateInputDisplay();", 10);197 }198 }199 }200 else if (type == 3)//确认é®201 {202 this.close();203 this.onEnter();204 }205 else if (type == 4)//åæ¢é®206 {207 this._shift();208 }209 else if (type == 5)//æ¢è¤210 {211 this._skinId++;212 if (this._skinId >= this._skinName.length)213 this._skinId = 0;214 this._updateSkinDisplay();215 }216 else if (type == -1)//å
³éé®217 {218 this.close();219 }220 },221 onEnter:222 function () {223 },224 _changeFocus:225 function (_focus) {226 this._focusElement.className = "focus" + "_" + this._skinName[this._skinId] + " key" + _focus.y + "_" + _focus.x + "_" + this._skinName[this._skinId] + " focus" + _focus.y + "_" + _focus.x + "_" + this._skinName[this._skinId];227 },228 _getFocusKey:229 function () {230 return this._keys[this._focus.y][this._focus.x];231 },232 _setFocusKey:233 function (_focus) {234 this._focus.y = _focus.y;235 this._focus.x = _focus.x;236 this._changeFocus(_focus);237 },238 _shift:239 function () {240 if (this._board.hasChildNodes()) {241 var nodes = this._board.childNodes;242 var keys = this._keys;243 var k = 0;244 for (i = 0; i < keys.length; i++) {245 for (j = 0; j < keys[i].length; j++) {246 if (keys[i][j].type == 0) {247 if (!this._isShifted) {248 nodes[k].innerText = keys[i][j].text_shift;249 }250 else {251 nodes[k].innerText = keys[i][j].text;252 }253 }254 k++;255 }256 }257 this._isShifted = !this._isShifted258 }259 },260 _updateInputDisplay:261 function () {262 var input = this._inputElement;263 if (input.hasChildNodes()) {264 var textDiv = input.firstChild;265 var inputWidth = parseInt(getCurrentStyle(input, "width"));266 var textWidth = parseInt(textDiv.offsetWidth);267 var leftMargin = inputWidth - textWidth;268 if (leftMargin < 0)269 textDiv.style.left = leftMargin + "px";270 else271 textDiv.style.left = "0px";272 }273 },274 setAlignCenter:275 function (_bool) {276 this._alignCenter = _bool;277 },278 _updateSkinDisplay:279 function () {280 this._board.className = "bg" + "_" + this._skinName[this._skinId];281 var nodes = this._board.childNodes;282 var keys = this._keys;283 var k = 0;284 for (i = 0; i < keys.length; i++) {285 for (j = 0; j < keys[i].length; j++) {286 nodes[k].className = "label" + "_" + this._skinName[this._skinId] + " key" + i + "_" + j + "_" + this._skinName[this._skinId];287 k++;288 }289 }290 this._focusElement.className = "focus key" + this._focus.y + "_" + this._focus.x + "_" + this._skinName[this._skinId] + " focus" + this._focus.y + "_" + this._focus.x + "_d_" + this._skinName[this._skinId];291 },292 setSkin:293 function (skinId) {294 if (skinId < this._skinName.length) {295 this._skinId = skinId;296 this._updateSkinDisplay();297 }298 }299}300function getCurrentStyle(obj, prop) {301 if (obj.currentStyle) {302 return obj.currentStyle[prop];303 }304 else if (window.getComputedStyle) {305 propprop = prop.replace(/([A-Z])/g, "-$1");306 propprop = prop.toLowerCase();307 return document.defaultView.getComputedStyle(obj, null)[prop];308 }309 return null;310}311function KeyboardFucos() { }312KeyboardFucos.prototype = {313 x: 0,314 y: 0315}316function HtmlDecode(text) {317 return text.replace(/&/g, '&').replace(/"/g, '\"').replace(/</g, '<').replace(/>/g, '>').replace(/ /g, ' ');318}319function HtmlEncode(text) {320 return text.replace(/&/g, "&").replace(/"/g, """).replace(/</g, '<').replace(/>/g, '>').replace(/ /g, ' ');321}322function keyUpEvent() {323 var key_code = event.which != undefined ? event.which : event.keyCode;324 switch (key_code) {325 case 13: //enter326 case 48: //0327 case 49: 328 case 50: 329 case 51: 330 case 52: 331 case 53: 332 case 54: 333 case 55: 334 case 56:335 case 57: //9336 _kb._keyUp();337 return 0;338 break;339 }340}341function keyDownEvent() {342 var key_code = event.which != undefined ? event.which : event.keyCode;343 switch (key_code) {344 //up 345 case 1:346 case 28:347 case 269:348 case 38:349 _kb._focus.y--;350 if (_kb._focus.y < 0)351 _kb._focus.y = _kb._keys.length - 1;352 if (_kb._focus.x > _kb._keys[_kb._focus.y].length - 1)353 _kb._focus.x = _kb._keys[_kb._focus.y].length - 1;354 _kb._changeFocus(_kb._focus);355 return 0;356 break;357 //down 358 case 2:359 case 40:360 case 31:361 case 270:362 _kb._focus.y++;363 if (_kb._focus.y > _kb._keys.length - 1)364 _kb._focus.y = 0;365 if (_kb._focus.x > _kb._keys[_kb._focus.y].length - 1)366 _kb._focus.x = _kb._keys[_kb._focus.y].length - 1;367 _kb._changeFocus(_kb._focus);368 return 0;369 break;370 case 3: //left371 case 37:372 case 29:373 case 271:374 _kb._focus.x--;375 if (_kb._focus.x < 0)376 _kb._focus.x = _kb._keys[_kb._focus.y].length - 1;377 _kb._changeFocus(_kb._focus);378 return 0;379 break;380 //right 381 case 4:382 case 30:383 case 272:384 case 39:385 _kb._focus.x++;386 if (_kb._focus.x > _kb._keys[_kb._focus.y].length - 1)387 _kb._focus.x = 0;388 _kb._changeFocus(_kb._focus);389 return 0;390 break;391 case 13: //enter392 _kb._keyDown();393 return 0;394 break;395 case 340: //back396 _kb.close();397 return 0;398 break;399 case 48: //0400 case 49:401 case 50:402 case 51:403 case 52:404 case 53:405 case 54:406 case 55:407 case 56:408 case 57: //9409 var newFocus = new KeyboardFucos();410 var _x = key_code == 48 ? key_code = 9 : key_code - 48 - 1;411 newFocus.x = _x;412 newFocus.y = 1;413 _kb._setFocusKey(newFocus);414 _kb._keyDown();415 return 0;416 break;417 }...
writers.js
Source:writers.js
1import React from 'react';2import Masonry from 'react-masonry-css';3import { Helmet } from 'react-helmet';4import {5 Box,6 Heading,7 Text,8 Button,9 Flex,10 Image,11 Skeleton,12 Spinner,13 useColorMode,14} from '@chakra-ui/core';15import { Link } from 'react-router-dom';16import { connect } from 'react-redux';17import { getAuthors } from '../../redux/actions/authorActions';18function Writers({ getAuthors }) {19 const { colorMode } = useColorMode();20 const bg = { light: 'white', dark: '#151a23' };21 const [data, setData] = React.useState(null);22 const [loaded, setLoaded] = React.useState(false);23 const imageLoaded = () => {24 setLoaded(true);25 };26 React.useEffect(() => {27 async function getData() {28 const res = await getAuthors();29 setData(res.data);30 }31 getData();32 }, []);33 const getFiltredAuthors = async letter => {34 const res = await getAuthors(letter);35 setData(res.data);36 };37 const breakpointColumnsObj = {38 default: 3,39 1300: 3,40 1100: 2,41 1000: 1,42 };43 return (44 <Box className="padding" mt={{ base: '2em', md: '6em' }} mb="100px">45 <Helmet>46 <title> Ùتاب اÙÙ
تÙسط</title>47 </Helmet>48 <Heading fontFamily="diodrum-bold !important" size="xl">49 Ùتاب اÙÙ
تÙسط50 </Heading>51 <Flex52 mt="8"53 overflowX={{ base: 'auto', sm: 'auto' }}54 wrap={['nowrap', 'nowrap', 'wrap', 'wrap']}55 direction={['row', 'row', 'row', 'row']}56 >57 <Button58 _focus={{ bg: 'black', color: 'white' }}59 onClick={() => getFiltredAuthors('Ø£')}60 fontWeight="normal"61 fontSize="2xl"62 m="2"63 >64 Ø£65 </Button>66 <Button67 _focus={{ bg: 'black', color: 'white' }}68 onClick={() => getFiltredAuthors('Ø¥')}69 fontWeight="normal"70 fontSize="2xl"71 m="2"72 >73 Ø¥74 </Button>75 <Button76 _focus={{ bg: 'black', color: 'white' }}77 onClick={() => getFiltredAuthors('ب')}78 fontWeight="normal"79 fontSize="2xl"80 m="2"81 >82 ب83 </Button>84 <Button85 _focus={{ bg: 'black', color: 'white' }}86 onClick={() => getFiltredAuthors('ت')}87 fontWeight="normal"88 fontSize="2xl"89 m="2"90 >91 ت92 </Button>93 <Button94 _focus={{ bg: 'black', color: 'white' }}95 onClick={() => getFiltredAuthors('Ø«')}96 fontWeight="normal"97 fontSize="2xl"98 m="2"99 >100 Ø«101 </Button>102 <Button103 _focus={{ bg: 'black', color: 'white' }}104 onClick={() => getFiltredAuthors('ج')}105 fontWeight="normal"106 fontSize="2xl"107 m="2"108 >109 ج110 </Button>111 <Button112 _focus={{ bg: 'black', color: 'white' }}113 onClick={() => getFiltredAuthors('Ø')}114 fontWeight="normal"115 fontSize="2xl"116 m="2"117 >118 Ø119 </Button>120 <Button121 _focus={{ bg: 'black', color: 'white' }}122 onClick={() => getFiltredAuthors('Ø®')}123 fontWeight="normal"124 fontSize="2xl"125 m="2"126 >127 Ø®128 </Button>129 <Button130 _focus={{ bg: 'black', color: 'white' }}131 onClick={() => getFiltredAuthors('د')}132 fontWeight="normal"133 fontSize="2xl"134 m="2"135 >136 د137 </Button>138 <Button139 _focus={{ bg: 'black', color: 'white' }}140 onClick={() => getFiltredAuthors('Ø°')}141 fontWeight="normal"142 fontSize="2xl"143 m="2"144 >145 Ø°146 </Button>147 <Button148 _focus={{ bg: 'black', color: 'white' }}149 onClick={() => getFiltredAuthors('ر')}150 fontWeight="normal"151 fontSize="2xl"152 m="2"153 >154 ر155 </Button>156 <Button157 _focus={{ bg: 'black', color: 'white' }}158 onClick={() => getFiltredAuthors('ز')}159 fontWeight="normal"160 fontSize="2xl"161 m="2"162 >163 ز164 </Button>165 <Button166 _focus={{ bg: 'black', color: 'white' }}167 onClick={() => getFiltredAuthors('س')}168 fontWeight="normal"169 fontSize="2xl"170 m="2"171 >172 س173 </Button>174 <Button175 _focus={{ bg: 'black', color: 'white' }}176 onClick={() => getFiltredAuthors('Ø´')}177 fontWeight="normal"178 fontSize="2xl"179 m="2"180 >181 Ø´182 </Button>183 <Button184 _focus={{ bg: 'black', color: 'white' }}185 onClick={() => getFiltredAuthors('ص')}186 fontWeight="normal"187 fontSize="2xl"188 m="2"189 >190 ص191 </Button>192 <Button193 _focus={{ bg: 'black', color: 'white' }}194 onClick={() => getFiltredAuthors('ض')}195 fontWeight="normal"196 fontSize="2xl"197 m="2"198 >199 ض200 </Button>201 <Button202 _focus={{ bg: 'black', color: 'white' }}203 onClick={() => getFiltredAuthors('Ø·')}204 fontWeight="normal"205 fontSize="2xl"206 m="2"207 >208 Ø·209 </Button>210 <Button211 _focus={{ bg: 'black', color: 'white' }}212 onClick={() => getFiltredAuthors('ظ')}213 fontWeight="normal"214 fontSize="2xl"215 m="2"216 >217 ظ218 </Button>219 <Button220 _focus={{ bg: 'black', color: 'white' }}221 onClick={() => getFiltredAuthors('ع')}222 fontWeight="normal"223 fontSize="2xl"224 m="2"225 >226 ع227 </Button>228 <Button229 _focus={{ bg: 'black', color: 'white' }}230 onClick={() => getFiltredAuthors('غ')}231 fontWeight="normal"232 fontSize="2xl"233 m="2"234 >235 غ236 </Button>237 <Button238 _focus={{ bg: 'black', color: 'white' }}239 onClick={() => getFiltredAuthors('Ù')}240 fontWeight="normal"241 fontSize="2xl"242 m="2"243 >244 Ù245 </Button>246 <Button247 _focus={{ bg: 'black', color: 'white' }}248 onClick={() => getFiltredAuthors('Ù')}249 fontWeight="normal"250 fontSize="2xl"251 m="2"252 >253 Ù254 </Button>255 <Button256 _focus={{ bg: 'black', color: 'white' }}257 onClick={() => getFiltredAuthors('Ù')}258 fontWeight="normal"259 fontSize="2xl"260 m="2"261 >262 Ù263 </Button>264 <Button265 _focus={{ bg: 'black', color: 'white' }}266 onClick={() => getFiltredAuthors('Ù')}267 fontWeight="normal"268 fontSize="2xl"269 m="2"270 >271 Ù272 </Button>273 <Button274 _focus={{ bg: 'black', color: 'white' }}275 onClick={() => getFiltredAuthors('Ù
')}276 fontWeight="normal"277 fontSize="2xl"278 m="2"279 >280 Ù
281 </Button>282 <Button283 _focus={{ bg: 'black', color: 'white' }}284 onClick={() => getFiltredAuthors('Ù')}285 fontWeight="normal"286 fontSize="2xl"287 m="2"288 >289 Ù290 </Button>291 <Button292 _focus={{ bg: 'black', color: 'white' }}293 onClick={() => getFiltredAuthors('Ù')}294 fontWeight="normal"295 fontSize="2xl"296 m="2"297 >298 Ù299 </Button>300 <Button301 _focus={{ bg: 'black', color: 'white' }}302 onClick={() => getFiltredAuthors('Ù')}303 fontWeight="normal"304 fontSize="2xl"305 m="2"306 >307 Ù308 </Button>309 <Button310 _focus={{ bg: 'black', color: 'white' }}311 onClick={() => getFiltredAuthors('Ù')}312 fontWeight="normal"313 fontSize="2xl"314 m="2"315 >316 Ù317 </Button>318 </Flex>{' '}319 {!data && (320 <Box textAlign="center">321 <Spinner size="xl" />322 </Box>323 )}324 <Masonry325 breakpointCols={breakpointColumnsObj}326 className="my-masonry-grid"327 columnClassName="my-masonry-grid_column"328 >329 {data &&330 Object.values(data).map(author => (331 <Link key={author.id} to={`/author/${author.id}`}>332 <Box oveflow="hidden" pb="4" mt="4" mb="4" bg={bg[colorMode]}>333 <Skeleton w="100%" isLoaded={loaded}>334 <Image335 loading="lazy"336 onLoad={imageLoaded}337 w="100%"338 // h="150px"339 // m="2"340 src={`${process.env.REACT_APP_STORAGE}/${author.image}`}341 ></Image>342 </Skeleton>343 <Text344 _hover={{345 bg: 'black',346 color: 'white',347 textDecoration: 'underline',348 }}349 mt="4"350 mr="4"351 fontSize="xl"352 fontFamily="diodrum-med !important"353 >354 {author.name}355 </Text>356 </Box>357 </Link>358 ))}359 </Masonry>360 {/* <Flex mt="8" flexWrap="wrap"></Flex> */}361 </Box>362 );363}364const mapDispatchToProps = dispatch => {365 return { getAuthors: letter => dispatch(getAuthors(letter)) };366};...
Footer.js
Source:Footer.js
1import React from "react";2import {3 Box,4 Stack,5 Heading,6 Text,7 Link as ChakraLink,8 SimpleGrid,9 Input,10 Button,11 Flex12} from "@chakra-ui/core";13const Footer = () => {14 return (15 <Box mt="70px" borderTopColor="gray.900" borderTopWidth={2} p="5em 2em 5em">16 <SimpleGrid17 flexDirection="column-reverse"18 gridTemplateColumns={["1fr", "1fr", "repeat(4, 1fr)", "repeat(4, 1fr)"]}19 justifyItems={["left", "left", "center", "center"]}20 maxW="1300px"21 margin="0 auto"22 >23 <Box d={["block", "block", "none", "none"]} mb="30px">24 {/* <FooterSignup /> */}25 <>26 <Heading27 fontSize="24px"28 mb="15px"29 className="yellow-gradient-color"30 >31 Be the first to know32 </Heading>33 <Text color="gray.400" mb="15px">34 Get notified about the upcoming sessions, news, articles, jobs,35 and opensource projects.36 </Text>37 <form38 method="post"39 action="https://docs.google.com/forms/u/0/d/e/1FAIpQLSchU6KKhFoSWk_cAgjyRXUh4oNKQQbvO5ZjmDBqrJisA76qIg/formResponse"40 >41 <Box position="relative">42 <Input43 type="email"44 isRequired45 name="entry.1808449400"46 px="25px"47 bg="gray.900"48 height="50px"49 rounded="50px"50 _placeholder={{ color: "gray.600" }}51 placeholder="Enter your email"52 _focus={{ outline: 0 }}53 color="gray.100"54 borderWidth={0}55 />56 <Button57 type="submit"58 height="50px"59 color="gray.100"60 _hover={{ bg: "yellow.400", color: "gray.900" }}61 position="absolute"62 top="0"63 right="0"64 bg="gray.700"65 rounded="50px"66 px="25px"67 >68 Subscribe69 </Button>70 </Box>71 </form>72 </>73 </Box>74 <Stack mb={["10px", "10px", 0, 0]}>75 <Text as="span">76 <ChakraLink77 _focus={{ outline: "none", boxShadow: "none" }}78 href={""}79 // target={isExternal ? "_blank" : "_self"}80 target={"_blank"}81 fontWeight={500}82 color="gray.500"83 _hover={{ color: "gray.100", textDecoration: "none" }}84 >85 Home86 </ChakraLink>87 </Text>88 <Text as="span">89 <ChakraLink90 _focus={{ outline: "none", boxShadow: "none" }}91 href={""}92 // target={isExternal ? "_blank" : "_self"}93 target={"_blank"}94 fontWeight={500}95 color="gray.500"96 _hover={{ color: "gray.100", textDecoration: "none" }}97 >98 Write a Post99 </ChakraLink>100 </Text>101 <Text as="span">102 <ChakraLink103 _focus={{ outline: "none", boxShadow: "none" }}104 href={""}105 target={"_blank"}106 fontWeight={500}107 color="gray.500"108 _hover={{ color: "gray.100", textDecoration: "none" }}109 >110 Tags111 </ChakraLink>112 </Text>113 <Text as="span">114 <ChakraLink115 _focus={{ outline: "none", boxShadow: "none" }}116 href={""}117 // target={isExternal ? "_blank" : "_self"}118 target={"_blank"}119 fontWeight={500}120 color="gray.500"121 _hover={{ color: "gray.100", textDecoration: "none" }}122 >123 Reading List124 </ChakraLink>125 </Text>126 </Stack>127 <Stack>128 <Text as="span">129 <ChakraLink130 _focus={{ outline: "none", boxShadow: "none" }}131 href={""}132 // target={isExternal ? "_blank" : "_self"}133 target={"_blank"}134 fontWeight={500}135 color="gray.500"136 _hover={{ color: "gray.100", textDecoration: "none" }}137 >138 Code of Conduct139 </ChakraLink>140 </Text>141 <Text as="span">142 <a>143 <ChakraLink144 _focus={{ outline: "none", boxShadow: "none" }}145 as="span"146 fontWeight={500}147 color="gray.500"148 _hover={{ color: "gray.100", textDecoration: "none" }}149 >150 Join Community151 </ChakraLink>152 </a>153 </Text>154 <Text as="span">155 <ChakraLink156 _focus={{ outline: "none", boxShadow: "none" }}157 href={""}158 // target={isExternal ? "_blank" : "_self"}159 target={"_blank"}160 fontWeight={500}161 color="gray.500"162 _hover={{ color: "gray.100", textDecoration: "none" }}163 >164 Sponser us165 </ChakraLink>166 </Text>167 <Text as="span">168 <ChakraLink169 _focus={{ outline: "none", boxShadow: "none" }}170 href={""}171 // target={isExternal ? "_blank" : "_self"}172 target={"_blank"}173 fontWeight={500}174 color="gray.500"175 _hover={{ color: "gray.100", textDecoration: "none" }}176 >177 FAQs178 </ChakraLink>179 </Text>180 </Stack>181 <Stack mb={["10px", "10px", 0, 0]}>182 <Text as="span">183 <ChakraLink184 _focus={{ outline: "none", boxShadow: "none" }}185 href={""}186 // target={isExternal ? "_blank" : "_self"}187 target={"_blank"}188 fontWeight={500}189 color="gray.500"190 _hover={{ color: "gray.100", textDecoration: "none" }}191 >192 Home193 </ChakraLink>194 </Text>195 <Text as="span">196 <ChakraLink197 _focus={{ outline: "none", boxShadow: "none" }}198 href={""}199 // target={isExternal ? "_blank" : "_self"}200 target={"_blank"}201 fontWeight={500}202 color="gray.500"203 _hover={{ color: "gray.100", textDecoration: "none" }}204 >205 Write a Post206 </ChakraLink>207 </Text>208 <Text as="span">209 <ChakraLink210 _focus={{ outline: "none", boxShadow: "none" }}211 href={""}212 target={"_blank"}213 fontWeight={500}214 color="gray.500"215 _hover={{ color: "gray.100", textDecoration: "none" }}216 >217 Tags218 </ChakraLink>219 </Text>220 <Text as="span">221 <ChakraLink222 _focus={{ outline: "none", boxShadow: "none" }}223 href={""}224 // target={isExternal ? "_blank" : "_self"}225 target={"_blank"}226 fontWeight={500}227 color="gray.500"228 _hover={{ color: "gray.100", textDecoration: "none" }}229 >230 Reading List231 </ChakraLink>232 </Text>233 </Stack>234 <Stack>235 <Text as="span">236 <ChakraLink237 _focus={{ outline: "none", boxShadow: "none" }}238 href={""}239 // target={isExternal ? "_blank" : "_self"}240 target={"_blank"}241 fontWeight={500}242 color="gray.500"243 _hover={{ color: "gray.100", textDecoration: "none" }}244 >245 Code of Conduct246 </ChakraLink>247 </Text>248 <Text as="span">249 <a>250 <ChakraLink251 _focus={{ outline: "none", boxShadow: "none" }}252 as="span"253 fontWeight={500}254 color="gray.500"255 _hover={{ color: "gray.100", textDecoration: "none" }}256 >257 Join Community258 </ChakraLink>259 </a>260 </Text>261 <Text as="span">262 <ChakraLink263 _focus={{ outline: "none", boxShadow: "none" }}264 href={""}265 // target={isExternal ? "_blank" : "_self"}266 target={"_blank"}267 fontWeight={500}268 color="gray.500"269 _hover={{ color: "gray.100", textDecoration: "none" }}270 >271 Sponser us272 </ChakraLink>273 </Text>274 <Text as="span">275 <ChakraLink276 _focus={{ outline: "none", boxShadow: "none" }}277 href={""}278 // target={isExternal ? "_blank" : "_self"}279 target={"_blank"}280 fontWeight={500}281 color="gray.500"282 _hover={{ color: "gray.100", textDecoration: "none" }}283 >284 FAQs285 </ChakraLink>286 </Text>287 </Stack>288 </SimpleGrid>289 <Flex justifyContent="center">290 <Text mt="20px" color="gray.500">291 Made with 𧡠by{" "}292 <ChakraLink293 _focus={{ boxShadow: "none", outline: "none" }}294 target="_blank"295 href={""}296 fontWeight={600}297 color={"gray.400"}298 _hover={{ textDecoration: "none", color: "yellow.400" }}299 >300 Muhammad Ahmad301 </ChakraLink>{" "}302 in Lahore, Pakistan303 </Text>304 </Flex>305 </Box>306 );307};...
Rule.js
Source:Rule.js
1import Message from "./Message";2export default class Rule {3 static FocusType = {4 // For Node.StateChange or Node.PropChange Messages5 CURRENT: 1,6 PREVIOUS: 2,7 KEY: 3,8 // For other Messages9 TYPE: 4,10 PAYLOAD: 5,11 SOURCE: 6,12 // For running a rule without using a Message13 VALUE: 7,14 };15 static ScopeType = {16 OR: "or",17 AND: "and",18 NAND: "nor",19 NOR: "nand",20 };21 constructor(msgOrValue, type = Rule.ScopeType.AND) {22 if(Message.conforms(msgOrValue)) {23 this._message = msgOrValue;24 this._value = null;25 } else {26 this._message = null;27 this._value = msgOrValue;28 }29 this._scope = {30 type: type,31 parent: null,32 children: []33 };34 this._currentScope = this._scope;35 36 this._focus = Rule.FocusType.CURRENT;37 }38 _beginScope(type = Rule.ScopeType.AND) {39 let scope = {40 type: type,41 parent: this._scope,42 children: []43 };44 this._currentScope.children.push(scope);45 this._currentScope = scope;46 }47 _endScope() {48 if(this._currentScope.parent) {49 this._currentScope = this._currentScope.parent;50 }51 }52 current() {53 this._focus = Rule.FocusType.CURRENT;54 return this;55 }56 previous() {57 this._focus = Rule.FocusType.PREVIOUS;58 return this;59 }60 key() {61 this._focus = Rule.FocusType.KEY;62 return this;63 }64 type() {65 this._focus = Rule.FocusType.TYPE;66 return this;67 }68 payload() {69 this._focus = Rule.FocusType.PAYLOAD;70 return this;71 }72 source() {73 this._focus = Rule.FocusType.SOURCE;74 return this;75 }76 value(value) {77 this._value = value;78 this._focus = Rule.FocusType.VALUE;79 return this;80 }81 begin(type = Rule.ScopeType.AND) {82 this._beginScope(type);83 return this;84 }85 end() {86 this._endScope();87 return this;88 }89 90 _getFocus() {91 if(this._focus === Rule.FocusType.CURRENT) {92 return this._message.payload.current;93 } else if(this._focus === Rule.FocusType.PREVIOUS) {94 return this._message.payload.previous;95 } else if(this._focus === Rule.FocusType.KEY) {96 return this._message.payload.key;97 } else if(this._focus === Rule.FocusType.TYPE) {98 return this._message.type;99 } else if(this._focus === Rule.FocusType.PAYLOAD) {100 return this._message.payload;101 } else if(this._focus === Rule.FocusType.SOURCE) {102 return this._message.source;103 } else if(this._focus === Rule.FocusType.VALUE) {104 return this._value;105 }106 return false;107 }108 or() {109 return this.begin(Rule.ScopeType.OR);110 }111 and() {112 return this.begin(Rule.ScopeType.AND);113 }114 nor() {115 return this.begin(Rule.ScopeType.NOR);116 }117 nand() {118 return this.begin(Rule.ScopeType.NAND);119 }120 //* COMPARATORS121 equals(input) {122 this._currentScope.children.push(this._getFocus() === input);123 return this;124 }125 gt(input) {126 this._currentScope.children.push(this._getFocus() > input);127 return this;128 }129 gte(input) {130 this._currentScope.children.push(this._getFocus() >= input);131 return this;132 }133 lt(input) {134 this._currentScope.children.push(this._getFocus() < input);135 return this;136 }137 lte(input) {138 this._currentScope.children.push(this._getFocus() <= input);139 return this;140 }141 in(...input) {142 this._currentScope.children.push(input.includes(this._getFocus()));143 return this;144 }145 between(a, b) {146 let focus = this._getFocus();147 this._currentScope.children.push((focus >= a) && (focus <= b));148 return this;149 }150 regex(pattern) {151 this._currentScope.children.push(pattern instanceof RegExp ? pattern.test(this._getFocus()) : false);152 return this;153 }154 155 //* NEGATED COMPARATORS156 notEquals(input) {157 this._currentScope.children.push(this._getFocus() !== input);158 return this;159 }160 notIn(...input) {161 this._currentScope.children.push(!(input.includes(this._getFocus())));162 return this;163 }164 notBetween(a, b) {165 let focus = this._getFocus();166 this._currentScope.children.push(!((focus >= a) && (focus <= b)));167 return this;168 }169 booleanize(scope) {170 let result = null;171 for(let child of scope.children) {172 if(typeof child === "object") {173 let childResult = this.booleanize(child);174 if(result === null || result === void 0) {175 result = childResult;176 }177 if(child.type === Rule.ScopeType.AND || scope.type === Rule.ScopeType.NAND) {178 result = result && childResult;179 } else if(child.type === Rule.ScopeType.OR || scope.type === Rule.ScopeType.NOR) {180 result = result || childResult;181 }182 } else {183 if(result === null || result === void 0) {184 result = child;185 }186 if(scope.type === Rule.ScopeType.AND || scope.type === Rule.ScopeType.NAND) {187 result = result && child;188 } else if(scope.type === Rule.ScopeType.OR || scope.type === Rule.ScopeType.NOR) {189 result = result || child;190 }191 }192 }193 if(scope.type === Rule.ScopeType.NOR || scope.type === Rule.ScopeType.NAND) {194 result = !result;195 }196 return result;197 }198 //* TERMINAL FUNCTIONS199 /**200 * A default terminator function201 */202 done() {203 return this.getResult();204 }205 getResult() {206 let result = this.booleanize(this._scope);207 return result;208 }209 getMessage() {210 return this._message;211 }212 getScope() {213 return this._scope;214 }215 debug(fn = console.log) {216 if(typeof fn === "function") {217 fn(this._message);218 }219 }220 static Process(msgOrValue, type = Rule.ScopeType.AND) {221 return new Rule(msgOrValue, type);222 }...
Footer.jsx
Source:Footer.jsx
1import {2 Box,3 Button,4 Container,5 Link,6 SimpleGrid,7 Stack,8 Text,9 useColorModeValue,10} from '@chakra-ui/react';11import { NavLink } from 'react-router-dom';12import * as FaIcons from 'react-icons/fa';13const ListHeader = ({ children }) => {14 return (15 <Text fontWeight={'500'} fontSize={'lg'} mb={2}>16 {children}17 </Text>18 );19};20export default function Footer() {21 return (22 <>23 <Box24 bg={useColorModeValue('purple.50', 'gray.900')}25 color={useColorModeValue('gray.700', 'gray.200')}26 >27 <Container as={Stack} maxW={'6xl'} py={10}>28 <SimpleGrid29 templateColumns={{ sm: '1fr', md: '2fr 1fr 1fr 2fr' }}30 spacing={8}31 >32 <Stack33 spacing={2}34 align={{35 sm: 'center',36 md: 'start',37 }}38 >39 <Text fontSize={'4xl'}>Invoicetor</Text>40 <Text fontSize={'sm'}>41 Create invoices for your business in no time.42 </Text>43 </Stack>44 <Stack45 align={{46 sm: 'center',47 md: 'start',48 }}49 >50 <ListHeader align={'start'}>Product</ListHeader>51 <Link52 as={NavLink}53 to="about"54 _focus={{55 outline: 'none',56 }}57 >58 About Us59 </Link>60 <Link61 as={NavLink}62 to="features"63 _focus={{64 outline: 'none',65 }}66 >67 Features68 </Link>69 <Link70 as={NavLink}71 to={'releases'}72 _focus={{73 outline: 'none',74 }}75 >76 Releases77 </Link>78 <Link79 as={NavLink}80 to={'sponsor'}81 _focus={{82 outline: 'none',83 }}84 >85 Sponsor86 </Link>87 </Stack>88 <Stack89 align={{90 sm: 'center',91 md: 'start',92 }}93 >94 <ListHeader>Support</ListHeader>95 <Link96 as={NavLink}97 to={'help-center'}98 _focus={{99 outline: 'none',100 }}101 >102 Help Center103 </Link>104 {/* <Link105 href={'#'}106 _focus={{107 outline: 'none',108 }}109 >110 Terms of Service111 </Link>112 <Link113 href={'#'}114 _focus={{115 outline: 'none',116 }}117 >118 Legal119 </Link>120 <Link121 href={'#'}122 _focus={{123 outline: 'none',124 }}125 >126 Privacy Policy127 </Link>128 <Link129 href={'#'}130 _focus={{131 outline: 'none',132 }}133 >134 Status135 </Link> */}136 </Stack>137 <Stack138 align={{139 sm: 'center',140 md: 'start',141 }}142 >143 <ListHeader>Community</ListHeader>144 <Stack145 direction={{146 sm: 'column',147 md: 'row',148 }}149 spacing={2}150 >151 {' '}152 <Button153 borderRadius={'lg'}154 bg={'purple.400'}155 color={'white'}156 _hover={{ bg: 'purple.500' }}157 variant="solid"158 size="sm"159 as={'a'}160 target="_blank"161 href="https://github.com/dunolabs/invoicetor-landing"162 rightIcon={<FaIcons.FaGithub />}163 >164 Contribute165 </Button>{' '}166 <Button167 borderRadius={'lg'}168 colorScheme="purple"169 variant="outline"170 size="sm"171 as={'a'}172 target="_blank"173 href="https://github.com/dunolabs/invoicetor-landing"174 rightIcon={<FaIcons.FaStar />}175 >176 Star us on GitHub177 </Button>178 </Stack>179 </Stack>180 </SimpleGrid>181 </Container>182 </Box>183 </>184 );...
Navbar.js
Source:Navbar.js
1import React from 'react'2import { Image } from "@chakra-ui/image"3import { Flex, Box, Spacer, Text } from "@chakra-ui/layout"4import { IconButton } from '@chakra-ui/button'5import icon from "../assets/icon.png"6import burger from "../assets/burger.svg"7import {8 Drawer,9 DrawerBody,10 DrawerFooter,11 DrawerHeader,12 DrawerOverlay,13 DrawerContent,14 DrawerCloseButton,15 useDisclosure,16 useBreakpointValue,17 useMediaQuery,18 Link19 } from "@chakra-ui/react"2021const Navbar = (props) => {22 const { isOpen, onOpen, onClose } = useDisclosure()23 const [placement, setPlacement] = React.useState("right")24 const [isNotMobile] = useMediaQuery("(min-width: 500px)")2526 return (27 <Flex w="100%" height="20" bg={props.bg} p="10px" alignItems="center">28 <Image boxSize="65px" src={icon} alt="logo" />29 <Text color="red.600" fontSize={ isNotMobile ? { xl: "2xl", md: "xl", sm: "md" } : "1em"} fontWeight="medium" ml="1rem">Biserica Eclesia IaÈi</Text>30 <Spacer></Spacer>31 {isNotMobile && <Box display={{ xl: "flex", lg: "flex", md: "flex", sm: "none" }} >32 <Link href="/" color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 1px 3px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>ACASÄ</Link>33 <Link href="/about" ml={10} color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 1px 3px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>DESPRE NOI</Link>34 <Link href="/resources" ml={10} color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 1px 3px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>RESURSE</Link>35 <Link href="/contact" ml={10} mr={5} color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 1px 3px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>CONTACT</Link>36 </Box>}37 <IconButton display={{ xl: "none", lg: "none", md: "none", sm: "flex" }} flexDirection="column" alignItems="center" onClick={onOpen} _active={{38 transform: "scale(0.95)",39 borderColor: "red.400"40 }} _focus={{41 boxShadow:42 "0 0 2px 2px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",43 }}>44 <Image boxSize="50px" src={burger} />45 </IconButton>46 <Drawer placement={placement} onClose={onClose} isOpen={isOpen}>47 <DrawerOverlay />48 <DrawerContent>49 <DrawerCloseButton color="red.600" _active={{50 transform: "scale(0.95)",51 borderColor: "red.400"52 }} _focus={{ boxShadow: "0 0 2px 2px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} />53 <DrawerBody backgroundColor="red.100" color="red.600">54 <Flex height="30vh" flexDirection="column" justifyContent="space-around">55 <Link href="/" color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 2px 1px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>ACASÄ</Link>56 <Link href="/about" color="red.600" width="fit-content" p="1" _focus={{ boxShadow: "0 0 2px 1px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>DESPRE NOI</Link>57 <Link href="/resources" color="red.600" width="fit-content" width="fit-content" p="1" _focus={{ boxShadow: "0 0 2px 1px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>RESURSE</Link>58 <Link href="/contact" color="red.600" width="fit-content" width="fit-content" p="1" _focus={{ boxShadow: "0 0 2px 1px rgba(242, 194, 128, .75), 0 1px 1px rgba(242, 194, 128, .15)",}} _hover={ {textDecoration: "none"} }>CONTACT</Link>59 </Flex>60 </DrawerBody>61 </DrawerContent>62 </Drawer>63 </Flex>64 )65}66
...
buttonStyles.js
Source:buttonStyles.js
1// eslint-disable-next-line import/no-extraneous-dependencies2import { darken, lighten } from "@chakra-ui/theme-tools"3export const ButtonStyles = {4 // style object for base or default style5 baseStyle: {},6 // styles for different sizes ("sm", "md", "lg")7 sizes: {},8 // styles for different visual variants ("outline", "solid")9 variants: {10 primary: {11 bg: "primary",12 color: "#fff",13 _hover: {14 bg: darken("primary", 10)15 },16 _active: {17 transform: "scale(0.9)"18 },19 _focus: {20 boxShadow: "none"21 }22 },23 secondary: {24 bg:lighten("letter",50),25 color: "gray.800",26 boxShadow: "2px 2px 2px 1px rgba(0, 0, 0, 0.2)",27 _hover: {28 bg: lighten("letter",10),29 color:"whiteAlpha.800"30 },31 _active: {32 transform: "scale(0.9)"33 },34 _focus: {35 boxShadow: "none"36 }37 },38 light: {39 bg: "#FFF",40 color: "primary",41 _hover: {42 bg: darken("#FFF", 10)43 },44 _active: {45 transform: "scale(0.9)"46 },47 _focus: {48 boxShadow: "none"49 }50 },51 third: {52 bg: "secondary",53 color: "primary",54 _hover: {55 bg: "primary",56 color: "#fff"57 },58 _active: {59 transform: "scale(0.9)"60 },61 _focus: {62 boxShadow: "none"63 }64 },65 fourth: {66 bg: "#FFFF",67 color: "primary",68 border: "1px solid #304659",69 _hover: {70 bg: "primary",71 color: "#fff"72 },73 _active: {74 transform: "scale(0.9)"75 },76 _focus: {77 boxShadow: "none"78 }79 },80 google: {81 bg: "#ffff",82 color: "#304659",83 border: "1px solid",84 borderColor: "#8298AB",85 _hover: {86 bg: darken("#ffff", 20)87 },88 _active: {89 transform: "scale(0.9)"90 },91 _focus: {92 boxShadow: "none"93 }94 },95 facebook: {96 bg: "#1877F2",97 color: "#ffff",98 _hover: {99 bg: darken("#1877F2", 20)100 },101 _active: {102 transform: "scale(0.9)"103 },104 _focus: {105 boxShadow: "none"106 }107 },108 danger: {109 bg: "#EF4444",110 color: "#ffff",111 _hover: {112 bg: darken("#EF4444", 20)113 },114 _active: {115 transform: "scale(0.9)"116 },117 _focus: {118 boxShadow: "none"119 }120 },121 warning: {122 bg: "#FCD34D",123 color: "#ffff",124 _hover: {125 bg: darken("#FCD34D", 20)126 },127 _active: {128 transform: "scale(0.9)"129 },130 _focus: {131 boxShadow: "none"132 }133 },134 success: {135 bg: "#34D399",136 color: "#ffff",137 _hover: {138 bg: darken("#34D399", 20)139 },140 _active: {141 transform: "scale(0.9)"142 },143 _focus: {144 boxShadow: "none"145 }146 },147 info: {148 bg: "#3B82F6",149 color: "#ffff",150 _hover: {151 bg: darken("#3B82F6", 20)152 },153 _active: {154 transform: "scale(0.9)"155 },156 _focus: {157 boxShadow: "none"158 }159 }160 },161 // default values for `size` and `variant`162 defaultProps: {}...
zipper.js
Source:zipper.js
1export class Zipper {2 constructor(focus, root, upper) {3 this._focus = focus;4 this._root = root;5 this._upper = upper || [];6 }7 static fromTree(focus) {8 let treeCopy = JSON.parse(JSON.stringify(focus));9 return new Zipper(treeCopy, treeCopy);10 }11 toTree() {12 return this._root;13 }14 value() {15 return this._focus.value;16 }17 left() {18 if (this._focus.left === null) { return null; }19 this._upper.push(this._focus);20 this._focus = this._focus.left;21 return new Zipper(this._focus, this._root, this._upper);22 }23 right() {24 if (this._focus.right === null) { return null; }25 this._upper.push(this._focus);26 this._focus = this._focus.right;27 return new Zipper(this._focus, this._root, this._upper);28 }29 up() {30 if (this._upper.length === 0) { return null; }31 this._focus = this._upper.pop();32 return new Zipper(this._focus, this._root, this._upper);33 }34 setValue(value) {35 this._focus.value = value;36 return new Zipper(this._focus, this._root, this._upper);37 }38 setLeft(branch) {39 this._focus.left = branch;40 return new Zipper(this._focus, this._root, this._upper);41 }42 setRight(branch) {43 this._focus.right = branch;44 return new Zipper(this._focus, this._root, this._upper);45 }...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.focus('text=Get started');7 await page.screenshot({ path: 'focused.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.focus('text=Get started');16 await page.screenshot({ path: 'focused.png' });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.focus('text=Get started');25 await page.screenshot({ path: 'focused.png' });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.focus('text=Get started');34 await page.screenshot({ path: 'focused.png' });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.focus('text=Get started');43 await page.screenshot({ path: 'focused.png' });44 await browser.close();45})();46const {
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const input = await page.$('input[name="q"]');7 await input._focus();8 await page.keyboard.type('Hello World');9 await browser.close();10})();11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 const input = await page.$('input[name="q"]');17 await page.evaluate((element) => element.focus(), input);18 await page.keyboard.type('Hello World');19 await browser.close();20})();21const input = await page.$('input[name="q"]');22await input[ (input as any)._focus.name ]();23Your name to display (optional):24Your name to display (op
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.focus('#search-input');6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page.focus('#search-input');13 await browser.close();14})();15 at CDPSession.send (C:\Users\user\Documents\Playwright\playwright\lib\cdp.js:61:23)16 at DOMDispatcher._focus (C:\Users\user\Documents\Playwright\playwright\lib\dispatchers\domDispatcher.js:76:31)17 at DOMDispatcher.focus (C:\Users\user\Documents\Playwright\playwright\lib\dispatchers\domDispatcher.js:70:18)18 at Frame._focus (C:\Users\user\Documents\Playwright\playwright\lib\frames.js:245:24)19 at Frame.focus (C:\Users\user\Documents\Playwright\playwright\lib\frames.js:241:22)20 at Page.focus (C:\Users\user\Documents\Playwright\playwright\lib\page.js:1496:25)21 at processTicksAndRejections (internal/process/task_queues.js:93:5)
Using AI Code Generation
1const { _focus } = require('@playwright/test/lib/page');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text="Get started"');7 await page.click('text="Installation"');8 await page.click('text="Node.js"');9 await page.click('text="npm"');10 await page.click('text="Playwright"');11 await _focus(page, 'text="Playwright"');12})();
Using AI Code Generation
1const { _focus } = require('playwright/lib/client/elementHandle');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const input = await page.$('input[name=q]');8 await _focus(input);9 await browser.close();10})();
Using AI Code Generation
1const { _focus } = require('playwright/lib/client/keyboard.js');2await _focus(page);3const { _keydown } = require('playwright/lib/client/keyboard.js');4await _keydown(page, 'Enter');5const { _keyup } = require('playwright/lib/client/keyboard.js');6await _keyup(page, 'Enter');7const { _press } = require('playwright/lib/client/keyboard.js');8await _press(page, 'Enter');9const { _sendCharacter } = require('playwright/lib/client/keyboard.js');10await _sendCharacter(page, 'Enter');11const { _type } = require('playwright/lib/client/keyboard.js');12await _type(page, 'Enter');13const { _insertText } = require('playwright/lib/client/keyboard.js');14await _insertText(page, 'Enter');15const { _insertText } = require('playwright/lib/client/keyboard.js');16await _insertText(page, 'Enter');17const { _insertText } = require('playwright/lib/client/keyboard.js');18await _insertText(page, 'Enter');19const { _insertText } = require('playwright/lib/client/keyboard.js');20await _insertText(page, 'Enter');21const { _insertText } = require('playwright/lib/client/keyboard.js');22await _insertText(page, 'Enter');23const { _insertText } = require('playwright/lib/client/keyboard.js');24await _insertText(page, 'Enter');25const { _insertText } = require('playwright/lib/client/keyboard.js');26await _insertText(page, 'Enter');
Using AI Code Generation
1const { _focus } = require('@playwright/test/lib/page');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 await _focus(page, 'css=button:has-text("Get Started")');7 await page.screenshot({ path: 'focused.png' });8 await browser.close();9})();
Using AI Code Generation
1const { _focus } = require('playwright');2_focus('input[type="password"]'); 3const { _focus } = require('playwright');4_focus('input[type="password"]'); 5const { _focus } = require('playwright');6_focus('input[type="password"]'); 7const { _focus } = require('playwright');8_focus('input[type="password"]'); 9const { _focus } = require('playwright');10_focus('input[type="password"]'); 11const { _focus } = require('playwright');12_focus('input[type="password"]'); 13const { _focus } = require('playwright');14_focus('input[type="password"]'); 15const { _focus } = require('playwright');16_focus('input[type="password"]'); 17const { _focus } = require('playwright');18_focus('input[type="password"]'); 19const { _focus } = require('playwright');20_focus('input[type="password"]');
Using AI Code Generation
1const { _focus } = require('@playwright/test/lib/page');2await _focus('#selector');3await page.keyboard.press('Tab');4const { _focus } = require('@playwright/test/lib/page');5await _focus('#selector');6await page.keyboard.press('Tab');7const { _focus } = require('@playwright/test/lib/page');8await _focus('#selector');9await page.keyboard.press('Tab');10const { _focus } = require('@playwright/test/lib/page');11await _focus('#selector');12await page.keyboard.press('Tab');13const { _focus } = require('@playwright/test/lib/page');14await _focus('#selector');15await page.keyboard.press('Tab');16const { _focus } = require('@playwright/test/lib/page');17await _focus('#selector');18await page.keyboard.press('Tab');19const { _focus } = require('@playwright/test/lib/page');20await _focus('#selector');21await page.keyboard.press('Tab');22const { _focus } = require('@playwright/test/lib/page');23await _focus('#selector');24await page.keyboard.press('Tab');25const { _focus } = require('@playwright/test/lib/page');26await _focus('#selector');27await page.keyboard.press('Tab');28const { _focus } = require('@playwright/test/lib/page');29await _focus('#selector');30await page.keyboard.press('Tab');31const { _focus } = require('@playwright/test/lib/page');32await _focus('#selector');33await page.keyboard.press('Tab');
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!