How to use sheet method in storybook-root

Best JavaScript code snippet using storybook-root

timesheet.js

Source:timesheet.js Github

copy

Full Screen

1/**2 * TimeSheet.js [v1.0]3 * Li Bin4 */5(function ($) {6 /*7 * 表格中的单元格类8 * */9 var CSheetCell = function(opt){10 /*11 * opt : {12 * state : 0 or 1,13 * toggleCallback : function(curState){...}14 * settingCallback : function(){...}15 * }16 *17 * */18 var cellPrivate = $.extend({19 state : 0,20 toggleCallback : false,21 settingCallback : false22 },opt);23 /*反向切换单元格状态*/24 this.toggle = function(){25 cellPrivate.state = cellPrivate.state>0 ? cellPrivate.state-1 : cellPrivate.state+1;26 if(cellPrivate.toggleCallback){27 cellPrivate.toggleCallback(cellPrivate.state);28 }29 }30 /*31 * 设置单元格状态32 * state : 0 or 133 * */34 this.set = function(state){35 cellPrivate.state = state==0 ? 0 : 1;36 if(cellPrivate.settingCallback){37 cellPrivate.settingCallback();38 }39 }40 /*41 * 获取单元格状态42 * */43 this.get = function(){44 return cellPrivate.state;45 }46 }47 /*48 * 表格类49 * */50 var CSheet = function(opt){51 /*52 * opt : {53 * dimensions : [8,9], [行数,列数]54 * sheetData : [[0,1,1,0,0],[...],[...],...] sheet数据,二维数组,索引(a,b),a-行下标,b-列下标,每个cell只有0,1两态,与dimensions对应55 * toggleCallback : function(){..}56 * settingCallback : function(){..}57 * }58 *59 * */60 var sheetPrivate = $.extend({61 dimensions : undefined,62 sheetData : undefined,63 toggleCallback : false,64 settingCallback : false65 },opt);66 sheetPrivate.cells = [];67 /*68 * 初始化表格中的所有单元格69 * */70 sheetPrivate.initCells = function(){71 var rowNum = sheetPrivate.dimensions[0];72 var colNum = sheetPrivate.dimensions[1];73 if(sheetPrivate.dimensions.length==2 && rowNum>0 && colNum>0){74 for(var row= 0,curRow = []; row<rowNum; ++row){75 curRow = [];76 for(var col=0; col<colNum; ++col){77 curRow.push(new CSheetCell({78 state : sheetPrivate.sheetData ? (sheetPrivate.sheetData[row]?parseInt(sheetPrivate.sheetData[row][col]):0) : 079 }));80 }81 sheetPrivate.cells.push(curRow);82 }83 }else{84 throw new Error("CSheet : wrong dimensions");85 }86 }87 /*88 * 对给定的表各区域进行 toggle 或 set操作89 * */90 sheetPrivate.areaOperate = function(area,opt){91 /*92 * area : {93 * startCell : [2,1],94 * endCell : [7,6]95 * }96 * opt : {97 * type:"set" or "toggle",98 * state : 0 or 1 if type is set99 * }100 * */101 var rowCount = sheetPrivate.cells.length;102 var colCount = sheetPrivate.cells[0] ? sheetPrivate.cells[0].length : 0;103 var operationArea = $.extend({104 startCell : [0,0],105 endCell : [rowCount-1,colCount-1]106 },area);107 var isSheetEmpty = rowCount==0 || colCount==0;108 var isAreaValid = operationArea.startCell[0]>=0 && operationArea.endCell[0]<=rowCount-1 &&109 operationArea.startCell[1]>=0 && operationArea.endCell[1]<=colCount-1 && //operationArea不能超越sheet的边界110 operationArea.startCell[0]<=operationArea.endCell[0] && operationArea.startCell[1]<=operationArea.endCell[1]; //startCell必须居于endCell的左上方,或与之重合111 if(!isAreaValid){112 throw new Error("CSheet : operation area is invalid");113 }else if(!isSheetEmpty){114 for(var row=operationArea.startCell[0]; row<=operationArea.endCell[0]; ++row){115 for(var col=operationArea.startCell[1]; col<=operationArea.endCell[1]; ++col){116 if(opt.type=="toggle"){117 sheetPrivate.cells[row][col].toggle();118 }else if(opt.type=="set"){119 sheetPrivate.cells[row][col].set(opt.state);120 }121 }122 }123 }124 }125 sheetPrivate.initCells();126 /*127 * 对表格的指定区域进行状态反向切换128 * toggleArea : {129 * startCell : [2,1],130 * endCell : [7,6]131 * }132 *133 * */134 this.toggle = function(toggleArea){135 sheetPrivate.areaOperate(toggleArea,{type:"toggle"});136 if(sheetPrivate.toggleCallback){137 sheetPrivate.toggleCallback();138 }139 }140 /*141 * 对表格的指定区域进行状态设置142 * state : 0 or 1143 * settingArea : {144 * startCell : [2,1],145 * endCell : [7,6]146 * }147 * */148 this.set = function(state,settingArea){149 sheetPrivate.areaOperate(settingArea,{type:"set",state:state});150 if(sheetPrivate.settingCallback){151 sheetPrivate.settingCallback();152 }153 }154 /*155 * 获取指定单元格的状态156 * cellIndex : [2,3]157 * @return : 0 or 1158 * */159 this.getCellState = function(cellIndex){160 return sheetPrivate.cells[cellIndex[0]][cellIndex[1]].get();161 }162 /*163 * 获取指定行所有单元格的状态164 * row : 2165 * @return : [1,0,...,1]166 * */167 this.getRowStates = function(row){168 var rowStates = [];169 for(var col=0; col<sheetPrivate.dimensions[1]; ++col){170 rowStates.push(sheetPrivate.cells[row][col].get());171 }172 return rowStates;173 }174 /*175 * 获取所有单元格的状态176 * @return : [[1,0,...,1],[1,0,...,1],...,[1,0,...,1]]177 * */178 this.getSheetStates = function(){179 var sheetStates = [];180 for(var row= 0,rowStates = []; row<sheetPrivate.dimensions[0]; ++row){181 rowStates = [];182 for(var col=0; col<sheetPrivate.dimensions[1]; ++col){183 rowStates.push(sheetPrivate.cells[row][col].get());184 }185 sheetStates.push(rowStates);186 }187 return sheetStates;188 }189 }190 191 $.fn.timeSheet = function(opt){192 /*193 * 说明 :194 *195 * TimeSheet 应该被绑定在 TBODY 元素上,其子元素有如下默认class:196 *197 * 表头 ---- class: .TimeSheet-head198 * 列表头 ---- class: .TimeSheet-colHead199 * 行表头 ---- class: .TimeSheet-rowHead200 * 单元格 ---- class: .TimeSheet-cell201 *202 * 用户可在传入的sheetClass下将元素的默认样式覆盖203 * sheetClass将被赋予 TBODY 元素204 *205 *206 * opt :207 * {208 * data : {209 * dimensions : [7,8],210 * colHead : [{name:"name1",title:"",style:"width,background,color,font"},{name:"name2",title:"",style:"width,background,color,font"},...]211 * rowHead : [{name:"name1",title:"",style:"height,background,color,font"},{name:"name2",title:"",style:"height,background,color,font"},...]212 * sheetHead : {name:"headName",style:"width,height,background,color,font"}213 * sheetData : [[0,1,1,0,0],[...],[...],...] sheet数据,二维数组,行主序,索引(a,b),a-行下标,b-列下标,每个cell只有0,1两态,与dimensions对应214 * },215 *216 * sheetClass : "",217 * start : function(ev){...}218 * end : function(ev, selectedArea){...}219 * remarks : false220 * }221 *222 */223 var thisSheet = $(this);224 if(!thisSheet.is("TBODY")){225 throw new Error("TimeSheet needs to be bound on a TBODY element");226 }227 var sheetOption = $.extend({228 data: {},229 sheetClass: "",230 start: false,231 end : false,232 remarks : null233 }, opt);234 if(!sheetOption.data.dimensions || sheetOption.data.dimensions.length!==2 || sheetOption.data.dimensions[0]<0 || sheetOption.data.dimensions[1]<0){235 throw new Error("TimeSheet : wrong dimensions");236 }237 var operationArea = {238 startCell : undefined,239 endCell : undefined240 };241 var sheetModel = new CSheet({242 dimensions : sheetOption.data.dimensions,243 sheetData : sheetOption.data.sheetData ? sheetOption.data.sheetData : undefined244 });245 /*246 * 表格初始化247 * */248 var initSheet = function(){249 thisSheet.html("");250 thisSheet.addClass("TimeSheet");251 if(sheetOption.sheetClass){252 thisSheet.addClass(sheetOption.sheetClass);253 }254 initColHeads();255 initRows();256 repaintSheet();257 };258 /*259 * 初始化每一列的顶部表头260 * */261 var initColHeads = function(){262 var colHeadHtml = '<tr>';263 for(var i=0,curColHead=''; i<=sheetOption.data.dimensions[1]; ++i){264 if(i===0){265 curColHead = '<td class="TimeSheet-head" style="'+(sheetOption.data.sheetHead.style?sheetOption.data.sheetHead.style:'')+'">'+sheetOption.data.sheetHead.name+'</td>';266 }else{267 curColHead = '<td title="'+(sheetOption.data.colHead[i-1].title ? sheetOption.data.colHead[i-1].title:"")+'" data-col="'+(i-1)+'" class="TimeSheet-colHead '+(i===sheetOption.data.dimensions[1]?'rightMost':'')+'" style="'+(sheetOption.data.colHead[i-1].style ? sheetOption.data.colHead[i-1].style : '')+'">'+sheetOption.data.colHead[i-1].name+'</td>';268 }269 colHeadHtml += curColHead;270 }271 if(sheetOption.remarks){272 colHeadHtml += '<td class="TimeSheet-remarkHead">'+sheetOption.remarks.title+'</td>';273 }274 colHeadHtml += '</tr>';275 thisSheet.append(colHeadHtml);276 };277 /*278 * 初始化每一行279 * */280 var initRows = function(){281 for(var row=0,curRowHtml=''; row<sheetOption.data.dimensions[0]; ++row){282 curRowHtml='<tr class="TimeSheet-row">'283 for(var col= 0, curCell=''; col<=sheetOption.data.dimensions[1]; ++col){284 if(col===0){285 curCell = '<td title="'+(sheetOption.data.rowHead[row].title ? sheetOption.data.rowHead[row].title:"")+'"class="TimeSheet-rowHead '+(row===sheetOption.data.dimensions[0]-1?'bottomMost ':' ')+'" style="'+(sheetOption.data.rowHead[row].style ? sheetOption.data.rowHead[row].style : '')+'">'+sheetOption.data.rowHead[row].name+'</td>';286 }else{287 curCell = '<td class="TimeSheet-cell '+(row===sheetOption.data.dimensions[0]-1?'bottomMost ':' ')+(col===sheetOption.data.dimensions[1]?'rightMost':'')+'" data-row="'+row+'" data-col="'+(col-1)+'"></td>';288 }289 curRowHtml += curCell;290 }291 if(sheetOption.remarks){292 curRowHtml += '<td class="TimeSheet-remark '+(row===sheetOption.data.dimensions[0]-1?'bottomMost ':' ')+'">'+sheetOption.remarks.default+'</td>';293 }294 curRowHtml += '</tr>';295 thisSheet.append(curRowHtml);296 }297 };298 /*299 * 比较两个单元格谁更靠近左上角300 * cell1:[2,3]301 * cell2:[4,5]302 * @return:{303 topLeft : cell1,304 bottomRight : cell2305 }306 * */307 var cellCompare = function(cell1,cell2){ //check which cell is more top-left308 var sum1 = cell1[0] + cell1[1];309 var sum2 = cell2[0] + cell2[1];310 if((cell1[0]-cell2[0])*(cell1[1]-cell2[1])<0){311 return {312 topLeft : cell1[0]<cell2[0] ? [cell1[0],cell2[1]] : [cell2[0],cell1[1]],313 bottomRight : cell1[0]<cell2[0] ? [cell2[0],cell1[1]] : [cell1[0],cell2[1]]314 };315 }316 return {317 topLeft : sum1<=sum2 ? cell1 : cell2,318 bottomRight : sum1>sum2 ? cell1 : cell2319 };320 };321 /*322 * 刷新表格323 * */324 var repaintSheet = function(){325 var sheetStates = sheetModel.getSheetStates();326 thisSheet.find(".TimeSheet-row").each(function(row,rowDom){327 var curRow = $(rowDom);328 curRow.find(".TimeSheet-cell").each(function(col,cellDom){329 var curCell = $(cellDom);330 if(sheetStates[row][col]===1){331 curCell.addClass("TimeSheet-cell-selected");332 }else if(sheetStates[row][col]===0){333 curCell.removeClass("TimeSheet-cell-selected");334 }335 });336 });337 };338 /*339 * 移除所有单元格的 TimeSheet-cell-selecting 类340 * */341 var removeSelecting = function(){342 thisSheet.find(".TimeSheet-cell-selecting").removeClass("TimeSheet-cell-selecting");343 };344 /*345 * 清空备注栏346 * */347 var cleanRemark = function(){348 thisSheet.find(".TimeSheet-remark").each(function(idx,ele){349 var curDom = $(ele);350 curDom.prop("title","");351 curDom.html(sheetOption.remarks.default);352 });353 };354 /*355 * 鼠标开始做选择操作356 * startCel : [1,4]357 * */358 var startSelecting = function(ev,startCel){359 operationArea.startCell = startCel;360 if(sheetOption.start){361 sheetOption.start(ev);362 }363 };364 /*365 * 鼠标在选择操作过程中366 * topLeftCell : [1,4], 鼠标选择区域的左上角367 * bottomRightCell : [3,9] 鼠标选择区域的右下角368 * */369 var duringSelecting = function(ev,topLeftCell,bottomRightCell){370 var curDom = $(ev.currentTarget);371 if(isSelecting && curDom.hasClass("TimeSheet-cell") || isColSelecting && curDom.hasClass("TimeSheet-colHead")){372 removeSelecting();373 for(var row=topLeftCell[0]; row<=bottomRightCell[0]; ++row){374 for(var col=topLeftCell[1]; col<=bottomRightCell[1]; ++col){375 $($(thisSheet.find(".TimeSheet-row")[row]).find(".TimeSheet-cell")[col]).addClass("TimeSheet-cell-selecting");376 }377 }378 }379 };380 /*381 * 选择操作完成后382 * targetArea : {383 * topLeft : [1,2],384 * bottomRight: [3,8]385 * }386 * */387 var afterSelecting = function(ev,targetArea){388 var curDom = $(ev.currentTarget);389 var key = $(ev.which);390 var targetState = !sheetModel.getCellState(operationArea.startCell);391 //if(key[0]===1){ targetState = 1;} //鼠标左键,将选定区域置1392 //else if(key[0]===3){ targetState = 0;} //鼠标右键,将选定区域置0393 if(isSelecting && curDom.hasClass("TimeSheet-cell") || isColSelecting && curDom.hasClass("TimeSheet-colHead")){394 sheetModel.set(targetState,{395 startCell : targetArea.topLeft,396 endCell : targetArea.bottomRight397 });398 removeSelecting();399 repaintSheet();400 if(sheetOption.end){401 sheetOption.end(ev,targetArea);402 }403 }else{404 removeSelecting();405 }406 isSelecting = false;407 isColSelecting = false;408 operationArea = {409 startCell : undefined,410 endCell : undefined411 }412 };413 var isSelecting = false; /*鼠标在表格区域做选择*/414 var isColSelecting = false; /*鼠标在列表头区域做选择*/415 var eventBinding = function(){416 /*防止重复绑定*/417 thisSheet.undelegate(".umsSheetEvent");418 /*表格开始选择*/419 thisSheet.delegate(".TimeSheet-cell","mousedown.umsSheetEvent",function(ev){420 var curCell = $(ev.currentTarget);421 var startCell = [curCell.data("row"),curCell.data("col")];422 isSelecting = true;423 startSelecting(ev,startCell);424 });425 /*表格选择完成*/426 thisSheet.delegate(".TimeSheet-cell","mouseup.umsSheetEvent",function(ev){427 if(!operationArea.startCell){428 return;429 }430 var curCell = $(ev.currentTarget);431 var endCell = [curCell.data("row"),curCell.data("col")];432 var correctedCells = cellCompare(operationArea.startCell,endCell);433 afterSelecting(ev,correctedCells);434 });435 /*表格正在选择*/436 thisSheet.delegate(".TimeSheet-cell","mouseover.umsSheetEvent",function(ev){437 if(!isSelecting){438 return;439 }440 var curCell = $(ev.currentTarget);441 var curCellIndex = [curCell.data("row"),curCell.data("col")];442 var correctedCells = cellCompare(operationArea.startCell,curCellIndex);443 var topLeftCell = correctedCells.topLeft;444 var bottomRightCell = correctedCells.bottomRight;445 duringSelecting(ev,topLeftCell,bottomRightCell);446 });447 /*列表头开始选择*/448 thisSheet.delegate(".TimeSheet-colHead","mousedown.umsSheetEvent",function(ev){449 var curColHead = $(ev.currentTarget);450 var startCell = [0,curColHead.data("col")];451 isColSelecting = true;452 startSelecting(ev,startCell);453 });454 /*列表头选择完成*/455 thisSheet.delegate(".TimeSheet-colHead","mouseup.umsSheetEvent",function(ev){456 if(!operationArea.startCell){457 return;458 }459 var curColHead = $(ev.currentTarget);460 var endCell = [sheetOption.data.dimensions[0]-1,curColHead.data("col")];461 var correctedCells = cellCompare(operationArea.startCell,endCell);462 afterSelecting(ev,correctedCells);463 });464 /*列表头正在选择*/465 thisSheet.delegate(".TimeSheet-colHead","mouseover.umsSheetEvent",function(ev){466 if(!isColSelecting){467 return;468 }469 var curColHead = $(ev.currentTarget);470 var curCellIndex = [sheetOption.data.dimensions[0]-1,curColHead.data("col")];471 var correctedCells = cellCompare(operationArea.startCell,curCellIndex);472 var topLeftCell = correctedCells.topLeft;473 var bottomRightCell = correctedCells.bottomRight;474 duringSelecting(ev,topLeftCell,bottomRightCell);475 });476 /*表格禁止鼠标右键菜单*/477 thisSheet.delegate("td","contextmenu.umsSheetEvent",function(ev){478 return false;479 });480 };481 initSheet();482 eventBinding();483 var publicAPI = {484 /*485 * 获取单元格状态486 * cellIndex :[1,2]487 * @return : 0 or 1488 * */489 getCellState : function(cellIndex){490 return sheetModel.getCellState(cellIndex);491 },492 /*493 * 获取某行所有单元格状态494 * row :2495 * @return : [1,0,0,...,0,1]496 * */497 getRowStates : function(row){498 return sheetModel.getRowStates(row);499 },500 /*501 * 获取表格所有单元格状态502 * @return : [[1,0,0,...,0,1],[1,0,0,...,0,1],...,[1,0,0,...,0,1]]503 * */504 getSheetStates : function(){505 return sheetModel.getSheetStates();506 },507 /*508 * 设置某行的说明文字509 * row : 2,510 * html : 说明511 * */512 setRemark : function(row,html){513 if($.trim(html)!==''){514 $(thisSheet.find(".TimeSheet-row")[row]).find(".TimeSheet-remark").prop("title",html).html(html);515 }516 },517 /*518 * 重置表格519 * */520 clean : function(){521 sheetModel.set(0,{});522 repaintSheet();523 cleanRemark();524 },525 /*526 * 获取 default remark527 * */528 getDefaultRemark : function(){529 return sheetOption.remarks.default;530 },531 /*532 * 使表格不可操作533 * */534 disable : function(){535 thisSheet.undelegate(".umsSheetEvent");536 },537 /*538 * 使表格可操作539 * */540 enable : function(){541 eventBinding();542 },543 /*544 * 判断表格是否所有单元格状态都是1545 * @return : true or false546 * */547 isFull : function(){548 for(var row=0; row<sheetOption.data.dimensions[0]; ++row){549 for(var col=0; col<sheetOption.data.dimensions[1]; ++col){550 if(sheetModel.getCellState([row,col])===0){551 return false;552 }553 }554 }555 return true;556 }557 };558 return publicAPI;559 }...

Full Screen

Full Screen

ExcelReport.js

Source:ExcelReport.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3const Plan_1 = require("../Model/Plan");4const Common_1 = require("../Model/Common");5const Resource_1 = require("../Resource");6const XLSX = require("xlsx");7function WorkBook() {8 let k = XLSX.utils.book_new();9 k.Props = {};10 k.Props.Author = "kin lei";11 k.Props.Title = "travel report";12 return k;13}14exports.WorkBook = WorkBook;15function attractionSheet(list) {16 let sheet = {};17 let c = 0;18 let r = 0;19 let ratio = 5;20 let lastCountry = "";21 let lastCity = "";22 let lastArea = "";23 sheet['!cols'] = [];24 //-------------------------------------------------------------------------------sheet header25 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.country, t: 's' };26 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.city, t: 's' };27 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.area, t: 's' };28 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.name, t: 's' };29 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.attraction + Resource_1.default.detail, t: 's' };30 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.openTime, t: 's' };31 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.bestTime, t: 's' };32 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.avoidTime, t: 's' };33 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { v: Resource_1.default.remark, t: 's' };34 sheet['!cols'].push({ width: Resource_1.default.country.length + ratio });35 sheet['!cols'].push({ width: Resource_1.default.city.length + ratio });36 sheet['!cols'].push({ width: Resource_1.default.area.length + ratio });37 sheet['!cols'].push({ width: Resource_1.default.name.length + ratio });38 sheet['!cols'].push({ width: Resource_1.default.attraction.length + ratio });39 sheet['!cols'].push({ width: Resource_1.default.openTime.length + ratio });40 sheet['!cols'].push({ width: Resource_1.default.bestTime.length + ratio });41 sheet['!cols'].push({ width: Resource_1.default.avoidTime.length + ratio });42 sheet['!cols'].push({ width: Resource_1.default.remark.length + ratio });43 //------------------------------------------------------------------------------ sheet body44 for (var i of list) {45 c = 0;46 let area = i.area.join(" ");47 let ot = i.openTime.map(r => r[0] + "-" + r[1]).join("\n");48 let bt = i.bestTime.map(r => r[0] + "-" + r[1]).join("\n");49 let at = i.avoidTime.map(r => r[0] + "-" + r[1]).join("\n");50 i.country == lastCountry ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.country };51 i.city == lastCity ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.city };52 area == lastArea ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: area };53 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.name };54 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.attractionDetail };55 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: ot };56 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: bt };57 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: at };58 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { t: 's', v: i.remark };59 lastCity = i.city;60 lastArea = area;61 lastCountry = i.country;62 //--------------------------- update col width63 sheet['!cols'][0].width = sheet['!cols'][0].width < i.country.length + ratio ? i.country.length + ratio : sheet['!cols'][0].width;64 sheet['!cols'][1].width = sheet['!cols'][1].width < i.city.length + ratio ? i.city.length + ratio : sheet['!cols'][1].width;65 sheet['!cols'][2].width = sheet['!cols'][2].width < area.length + ratio ? area.length + ratio : sheet['!cols'][2].width;66 sheet['!cols'][3].width = sheet['!cols'][3].width < i.name.length + ratio ? i.name.length + ratio : sheet['!cols'][3].width;67 sheet['!cols'][4].width = sheet['!cols'][4].width < i.attractionDetail.length + ratio ? i.attractionDetail.length + ratio : sheet['!cols'][4].width;68 sheet['!cols'][5].width = sheet['!cols'][5].width < ot.length + ratio ? ot.length + ratio : sheet['!cols'][5].width;69 sheet['!cols'][6].width = sheet['!cols'][6].width < bt.length + ratio ? bt.length + ratio : sheet['!cols'][6].width;70 sheet['!cols'][7].width = sheet['!cols'][7].width < at.length + ratio ? at.length + ratio : sheet['!cols'][7].width;71 sheet['!cols'][8].width = sheet['!cols'][8].width < i.remark.length + ratio ? i.remark.length + ratio : sheet['!cols'][8].width;72 }73 //------------------------------------------------------------------------------------74 sheet['!ref'] = "A1:" + XLSX.utils.encode_cell({ c: c, r: r });75 return sheet;76}77exports.attractionSheet = attractionSheet;78function restaurantSheet(list) {79 let sheet = {};80 let c = 0;81 let r = 0;82 let lastCountry = "";83 let lastCity = "";84 let lastArea = "";85 let lastBrand = "";86 let ratio = 5;87 sheet['!cols'] = [];88 //-------------------------------------------------------------------------------sheet header89 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.country, t: 's' };90 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.city, t: 's' };91 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.area, t: 's' };92 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.brand, t: 's' };93 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.name, t: 's' };94 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.priceRange, t: 's' };95 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.restaurant + Resource_1.default.detail, t: 's' };96 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.openTime, t: 's' };97 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.bestTime, t: 's' };98 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.avoidTime, t: 's' };99 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { v: Resource_1.default.remark, t: 's' };100 sheet['!cols'].push({ width: Resource_1.default.country.length + ratio });101 sheet['!cols'].push({ width: Resource_1.default.city.length + ratio });102 sheet['!cols'].push({ width: Resource_1.default.area.length + ratio });103 sheet['!cols'].push({ width: Resource_1.default.brand.length + ratio });104 sheet['!cols'].push({ width: Resource_1.default.name.length + ratio });105 sheet['!cols'].push({ width: Resource_1.default.priceRange.length + ratio });106 sheet['!cols'].push({ width: Resource_1.default.restaurant.length + ratio });107 sheet['!cols'].push({ width: Resource_1.default.openTime.length + ratio });108 sheet['!cols'].push({ width: Resource_1.default.bestTime.length + ratio });109 sheet['!cols'].push({ width: Resource_1.default.avoidTime.length + ratio });110 sheet['!cols'].push({ width: Resource_1.default.remark.length + ratio });111 //------------------------------------------------------------------------------ sheet body112 for (var i of list) {113 c = 0;114 let area = i.area.join(" ");115 let ot = i.openTime.map(r => r[0] + "-" + r[1]).join("\n");116 let bt = i.bestTime.map(r => r[0] + "-" + r[1]).join("\n");117 let at = i.avoidTime.map(r => r[0] + "-" + r[1]).join("\n");118 i.country == lastCountry ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.country };119 i.city == lastCity ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.city };120 area == lastArea ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: area };121 i.brand == lastBrand ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.brand };122 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.name };123 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.priceRange.join("~") };124 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.restaurantDetail };125 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: ot };126 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: bt };127 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: at };128 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { t: 's', v: i.remark };129 lastCity = i.city;130 lastArea = area;131 lastCountry = i.country;132 lastBrand = i.brand;133 //--------------------------- update col width134 sheet['!cols'][0].width = sheet['!cols'][0].width < i.country.length + ratio ? i.country.length + ratio : sheet['!cols'][0].width;135 sheet['!cols'][1].width = sheet['!cols'][1].width < i.city.length + ratio ? i.city.length + ratio : sheet['!cols'][1].width;136 sheet['!cols'][2].width = sheet['!cols'][2].width < area.length + ratio ? area.length + ratio : sheet['!cols'][2].width;137 sheet['!cols'][3].width = sheet['!cols'][3].width < i.brand.length + ratio ? i.brand.length + ratio : sheet['!cols'][3].width;138 sheet['!cols'][4].width = sheet['!cols'][4].width < i.name.length + ratio ? i.name.length + ratio : sheet['!cols'][4].width;139 sheet['!cols'][5].width = sheet['!cols'][5].width < i.priceRange.join("~").length + ratio ? i.priceRange.join("~").length + ratio : sheet['!cols'][5].width;140 sheet['!cols'][6].width = sheet['!cols'][6].width < i.restaurantDetail.length + ratio ? i.restaurantDetail.length + ratio : sheet['!cols'][6].width;141 sheet['!cols'][7].width = sheet['!cols'][7].width < ot.length + ratio ? ot.length + ratio : sheet['!cols'][7].width;142 sheet['!cols'][8].width = sheet['!cols'][8].width < bt.length + ratio ? bt.length + ratio : sheet['!cols'][8].width;143 sheet['!cols'][9].width = sheet['!cols'][9].width < at.length + ratio ? at.length + ratio : sheet['!cols'][9].width;144 sheet['!cols'][10].width = sheet['!cols'][10].width < i.remark.length + ratio ? i.remark.length + ratio : sheet['!cols'][10].width;145 }146 sheet['!ref'] = "A1:" + XLSX.utils.encode_cell({ c: c, r: r });147 return sheet;148}149exports.restaurantSheet = restaurantSheet;150function souvenirSheet(list) {151 let sheet = {};152 let c = 0;153 let r = 0;154 let lastCountry = "";155 let lastCity = "";156 let lastArea = "";157 let lastBrand = "";158 let ratio = 5;159 sheet['!cols'] = [];160 //-------------------------------------------------------------------------------sheet header161 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.country, t: 's' };162 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.city, t: 's' };163 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.area, t: 's' };164 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.brand, t: 's' };165 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.name, t: 's' };166 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.recommendFood, t: 's' };167 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.price, t: 's' };168 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.dateCanBeStored, t: 's' };169 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.souvenir + Resource_1.default.detail, t: 's' };170 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.openTime, t: 's' };171 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { v: Resource_1.default.remark, t: 's' };172 sheet['!cols'].push({ width: Resource_1.default.country.length + ratio });173 sheet['!cols'].push({ width: Resource_1.default.city.length + ratio });174 sheet['!cols'].push({ width: Resource_1.default.area.length + ratio });175 sheet['!cols'].push({ width: Resource_1.default.brand.length + ratio });176 sheet['!cols'].push({ width: Resource_1.default.name.length + ratio });177 sheet['!cols'].push({ width: Resource_1.default.recommendFood.length + ratio });178 sheet['!cols'].push({ width: Resource_1.default.price.length + ratio });179 sheet['!cols'].push({ width: Resource_1.default.dateCanBeStored.length + ratio });180 sheet['!cols'].push({ width: Resource_1.default.souvenir.length + ratio });181 sheet['!cols'].push({ width: Resource_1.default.openTime.length + ratio });182 sheet['!cols'].push({ width: Resource_1.default.remark.length + ratio });183 //------------------------------------------------------------------------------ sheet body184 for (var i of list) {185 c = 0;186 let area = i.area.join(" ");187 let ot = i.openTime.map(r => r[0] + "-" + r[1]).join("\n");188 i.country == lastCountry ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.country };189 i.city == lastCity ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.city };190 area == lastArea ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: area };191 i.brand == lastBrand ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.brand };192 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.name };193 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.recommendFood };194 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 'n', v: i.price };195 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 'n', v: i.dateCanBeStored };196 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.souvenirDetail };197 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: ot };198 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { t: 's', v: i.remark };199 lastCity = i.city;200 lastArea = area;201 lastCountry = i.country;202 lastBrand = i.brand;203 //--------------------------- update col width204 sheet['!cols'][0].width = sheet['!cols'][0].width < i.country.length + ratio ? i.country.length + ratio : sheet['!cols'][0].width;205 sheet['!cols'][1].width = sheet['!cols'][1].width < i.city.length + ratio ? i.city.length + ratio : sheet['!cols'][1].width;206 sheet['!cols'][2].width = sheet['!cols'][2].width < area.length + ratio ? area.length + ratio : sheet['!cols'][2].width;207 sheet['!cols'][3].width = sheet['!cols'][3].width < i.brand.length + ratio ? i.brand.length + ratio : sheet['!cols'][3].width;208 sheet['!cols'][4].width = sheet['!cols'][4].width < i.name.length + ratio ? i.name.length + ratio : sheet['!cols'][4].width;209 sheet['!cols'][5].width = sheet['!cols'][5].width < i.recommendFood.length + ratio ? i.recommendFood.length + ratio : sheet['!cols'][5].width;210 sheet['!cols'][6].width = sheet['!cols'][6].width < i.price.toString().length + ratio ? i.price.toString().length + ratio : sheet['!cols'][6].width;211 sheet['!cols'][7].width = sheet['!cols'][7].width < i.dateCanBeStored.toString().length + ratio ? i.dateCanBeStored.toString().length + ratio : sheet['!cols'][7].width;212 sheet['!cols'][8].width = sheet['!cols'][8].width < i.souvenirDetail.length + ratio ? i.souvenirDetail.length + ratio : sheet['!cols'][8].width;213 sheet['!cols'][9].width = sheet['!cols'][9].width < ot.length + ratio ? ot.length + ratio : sheet['!cols'][9].width;214 sheet['!cols'][10].width = sheet['!cols'][10].width < i.remark.length + ratio ? i.remark.length + ratio : sheet['!cols'][10].width;215 }216 sheet['!ref'] = "A1:" + XLSX.utils.encode_cell({ c: c, r: r });217 return sheet;218}219exports.souvenirSheet = souvenirSheet;220function trafficSheet(list) {221 let sheet = {};222 let c = 0;223 let r = 0;224 let lastCountry = "";225 let lastCity = "";226 let lastArea = "";227 let lastBrand = "";228 let ratio = 5;229 sheet['!cols'] = [];230 //-------------------------------------------------------------------------------sheet header231 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.country, t: 's' };232 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.city, t: 's' };233 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.area, t: 's' };234 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.traffic + Resource_1.default.name, t: 's' };235 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.price, t: 's' };236 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.totalTime, t: 's' };237 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { v: Resource_1.default.step, t: 's' };238 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { v: Resource_1.default.traffic + Resource_1.default.detail, t: 's' };239 sheet['!cols'].push({ width: Resource_1.default.country.length + ratio });240 sheet['!cols'].push({ width: Resource_1.default.city.length + ratio });241 sheet['!cols'].push({ width: Resource_1.default.area.length + ratio });242 sheet['!cols'].push({ width: Resource_1.default.traffic.length + Resource_1.default.name.length + ratio });243 sheet['!cols'].push({ width: Resource_1.default.price.length + ratio });244 sheet['!cols'].push({ width: Resource_1.default.totalTime.length + ratio });245 sheet['!cols'].push({ width: Resource_1.default.step.length + ratio });246 sheet['!cols'].push({ width: Resource_1.default.traffic.length + Resource_1.default.detail.length + ratio });247 //------------------------------------------------------------------------------ sheet body248 for (var i of list) {249 c = 0;250 let area = i.area.join(" ");251 i.country == lastCountry ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.country };252 i.city == lastCity ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.city };253 area == lastArea ? c++ : sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: area };254 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.name };255 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 'n', v: i.price };256 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 'n', v: i.totalTime };257 sheet[XLSX.utils.encode_cell({ c: c++, r: r })] = { t: 's', v: i.step };258 sheet[XLSX.utils.encode_cell({ c: c++, r: r++ })] = { t: 's', v: i.trafficDetail };259 lastCity = i.city;260 lastArea = area;261 lastCountry = i.country;262 //--------------------------- update col width263 sheet['!cols'][0].width = sheet['!cols'][0].width < i.country.length + ratio ? i.country.length + ratio : sheet['!cols'][0].width;264 sheet['!cols'][1].width = sheet['!cols'][1].width < i.city.length + ratio ? i.city.length + ratio : sheet['!cols'][1].width;265 sheet['!cols'][2].width = sheet['!cols'][2].width < area.length + ratio ? area.length + ratio : sheet['!cols'][2].width;266 sheet['!cols'][3].width = sheet['!cols'][3].width < i.name.length + ratio ? i.name.length + ratio : sheet['!cols'][3].width;267 sheet['!cols'][4].width = sheet['!cols'][4].width < i.price.toString().length + ratio ? i.price.toString().length + ratio : sheet['!cols'][4].width;268 sheet['!cols'][5].width = sheet['!cols'][5].width < i.totalTime.toString().length + ratio ? i.totalTime.toString().length + ratio : sheet['!cols'][5].width;269 sheet['!cols'][6].width = sheet['!cols'][6].width < i.step.length + ratio ? i.step.length + ratio : sheet['!cols'][6].width;270 sheet['!cols'][7].width = sheet['!cols'][7].width < i.trafficDetail.length + ratio ? i.trafficDetail.length + ratio : sheet['!cols'][7].width;271 }272 sheet['!ref'] = "A1:" + XLSX.utils.encode_cell({ c: c, r: r });273 return sheet;274}275exports.trafficSheet = trafficSheet;276function attractionListSort(arr, setting) {277 return arr.sort(function (a, b) {278 if (a.country > b.country)279 return 1;280 else if (a.country < b.country)281 return -1;282 else if (a.city > b.city)283 return 1;284 else if (a.city < b.city)285 return -1;286 else {287 let r = setting.attractionSetting.order ? -1 : 1;288 switch (setting.attractionSetting.priority) {289 case Plan_1.PlanReportSetting.openTime:290 return (Common_1.TimeCheck.hhmmStringToValue(a.openTime[0][0]) - Common_1.TimeCheck.hhmmStringToValue(b.openTime[0][0])) * r;291 }292 }293 });294}295exports.attractionListSort = attractionListSort;296function restaurantListSort(arr, setting) {297 return arr.sort(function (a, b) {298 if (a.country > b.country)299 return 1;300 else if (a.country < b.country)301 return -1;302 else if (a.city > b.city)303 return 1;304 else if (a.city < b.city)305 return -1;306 else {307 let r = setting.restaurantSetting.order ? -1 : 1;308 switch (setting.attractionSetting.priority) {309 case Plan_1.PlanReportSetting.openTime:310 return (Common_1.TimeCheck.hhmmStringToValue(a.openTime[0][0]) - Common_1.TimeCheck.hhmmStringToValue(b.openTime[0][0])) * r;311 case Plan_1.PlanReportSetting.price:312 return (a.priceRange[0] - b.priceRange[0]) * r;313 }314 }315 });316}317exports.restaurantListSort = restaurantListSort;318function souvenirListSort(arr, setting) {319 return arr.sort(function (a, b) {320 if (a.country > b.country)321 return 1;322 else if (a.country < b.country)323 return -1;324 else if (a.city > b.city)325 return 1;326 else if (a.city < b.city)327 return -1;328 else {329 let r = setting.restaurantSetting.order ? -1 : 1;330 switch (setting.attractionSetting.priority) {331 case Plan_1.PlanReportSetting.openTime:332 return (Common_1.TimeCheck.hhmmStringToValue(a.openTime[0][0]) - Common_1.TimeCheck.hhmmStringToValue(b.openTime[0][0])) * r;333 case Plan_1.PlanReportSetting.price:334 return (a.price - b.price) * r;335 case Plan_1.PlanReportSetting.day:336 return (a.dateCanBeStored - b.dateCanBeStored) * r;337 }338 }339 });340}341exports.souvenirListSort = souvenirListSort;342function trafficListSort(arr, setting) {343 return arr.sort(function (a, b) {344 if (a.country > b.country)345 return 1;346 else if (a.country < b.country)347 return -1;348 else if (a.city > b.city)349 return 1;350 else if (a.city < b.city)351 return -1;352 else {353 let r = setting.restaurantSetting.order ? -1 : 1;354 switch (setting.attractionSetting.priority) {355 case Plan_1.PlanReportSetting.total:356 return (a.totalTime - b.totalTime) * r;357 }358 }359 });360}...

Full Screen

Full Screen

portfolio.ts

Source:portfolio.ts Github

copy

Full Screen

1/// <reference path ="./gNamespaces.ts" />2type SheetMap = {[type: string]: GSheets.Sheet;};3type SheetNameMap = {[type: string]: string;};4enum SheetType {5 Main = "Main", 6 History = "History", 7 Utility = "Utility", 8 Sector = "Sector", 9 Stock = "Stock", 10 SP500 = "SP500"11}12const sheetExtensionMap: SheetNameMap = { };13sheetExtensionMap[SheetType.Main] = "";14sheetExtensionMap[SheetType.History] = " History";15sheetExtensionMap[SheetType.Utility] = " Utility";16sheetExtensionMap[SheetType.Sector] = " Sector Breakdown";17sheetExtensionMap[SheetType.Stock] = " Stock Breakdown";18sheetExtensionMap[SheetType.SP500] = " vs. S&P 500";19class Portfolio {20 public readonly name: string;21 public readonly sheetNameMap: SheetNameMap;22 public readonly sheetNames: string[];23 public constructor(name: string) {24 this.name = name;25 this.sheetNameMap = { };26 this.sheetNames = [ ];27 for (let type in sheetExtensionMap) {28 const sheetExtension: string = sheetExtensionMap[type];29 const sheetName: string = name + sheetExtension;30 this.sheetNameMap[type] = sheetName;31 this.sheetNames.push(sheetName);32 }33 }34 public getSheetMap(): SheetMap {35 let sheets: SheetMap = { };36 for (let type in sheetExtensionMap) {37 sheets[type] = ss.getSheetByName(this.sheetNameMap[type]);38 }39 return sheets;40 }41 public getSheetArray(): GSheets.Sheet[] {42 let sheetArr: GSheets.Sheet[] = [ ];43 for (let sheetName of this.sheetNames) {44 const sheet: GSheets.Sheet = ss.getSheetByName(sheetName);45 if (sheet) sheetArr.push(sheet);46 }47 return sheetArr;48 }49 50 public allExist(): boolean {51 const sheets: SheetMap = this.getSheetMap();52 for (let type in sheetExtensionMap) {53 if (!sheets[type]) return false;54 }55 return true;56 }57 public importantExist(): boolean {58 const sheets: SheetMap = this.getSheetMap();59 if (sheets[SheetType.Main] && sheets[SheetType.History] && sheets[SheetType.Utility]) return true;60 return false;61 }62 public anyExist(): boolean {63 const sheets: SheetMap = this.getSheetMap();64 for (let type in sheetExtensionMap) {65 if (sheets[type]) return true;66 }67 return false;68 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storiesOf } from 'storybook-root';2storiesOf('Button', module)3 .add('with text', () => (4 .add('with some emoji', () => (5 ));6import { storiesOf } from 'storybook-root';7storiesOf('Button', module)8 .add('with text', () => (9 .add('with some emoji', () => (10 ));11import { storiesOf } from 'storybook-root';12storiesOf('Button', module)13 .add('with text', () => (14 .add('with some emoji', () => (15 ));16import { storiesOf } from 'storybook-root';17storiesOf('Button', module)18 .add('with text', () => (19 .add('with some emoji', () => (20 ));21import { storiesOf } from 'storybook-root';22storiesOf('Button', module)23 .add('with text', () => (24 .add('with some emoji', () => (25 ));26import { storiesOf } from 'storybook-root';27storiesOf('Button', module)28 .add('with text', () => (29 .add('with

Full Screen

Using AI Code Generation

copy

Full Screen

1import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';2import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';3import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';4import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';5import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';6import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';7import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';8import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';9import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';10import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';11import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';12import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';13import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';14import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';15import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';16import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';17import {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { action } from '@storybook/addon-actions'2import { withA11y } from '@storybook/addon-a11y'3import { withTests } from '@storybook/addon-jest'4import results from '../.jest-test-results.json'5import { storiesOf } from '@storybook/react'6import { withInfo } from '@storybook/addon-info'7import { withReadme } from 'storybook-readme'8import { withOptions } from '@storybook/addon-options'9import { configure } from '@storybook/react'10import { setOptions } from '@storybook/addon-options'11setOptions({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { sheet } from 'storybook-root';2const styles = sheet({3 container: {4 },5});6export default function Test() {7 return <View style={styles.container} />;8}9import { StyleSheet } from 'react-native';10export const sheet = (styles) => StyleSheet.create(styles);11import { StyleSheet } from 'react-native';12export const sheet = (styles) => StyleSheet.create(styles);13import { StyleSheet } from 'react-native';14export const sheet = (styles) => styles;15import { StyleSheet } from 'react-native';16export const sheet = (styles) => styles;17import { StyleSheet } from 'react-native';18export const sheet = (styles) => StyleSheet.create(styles);19import { StyleSheet } from 'react-native';20export const sheet = (styles) => StyleSheet.create(styles);21import { StyleSheet } from 'react-native';22export const sheet = (styles) => styles;23import { StyleSheet } from 'react-native';24export const sheet = (styles) => styles;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { sheet } from 'storybook-addon-styled-component-theme/dist/sheet';2export const theme = {3 colors: {4 },5};6export default sheet(theme);7import { createGlobalStyle } from 'styled-components';8export const sheet = (theme) => createGlobalStyle`9 body {10 background-color: ${theme.colors.primary};11 }12`;13import React from 'react';14import { storiesOf } from '@storybook/react';15import { withThemesProvider } from 'storybook-addon-styled-component-theme';16import Test from './test';17storiesOf('Test', module)18 .addDecorator(withThemesProvider([Test.theme]))19 .add('Test', () => <Test />);20import React from 'react';21import { ThemeProvider } from 'styled-components';22import Test from './test';23export default class Test extends React.Component {24 render() {25 return (26 <ThemeProvider theme={Test.theme}>27 );28 }29}30import React from 'react';31import { ThemeProvider } from 'styled-components';32import Test from './test';33export default class Test extends React.Component {34 render() {35 return (36 <ThemeProvider theme={Test.theme}>37 );38 }39}40import React from 'react';41import { ThemeProvider } from 'styled-components';42import Test from './test';43export default class Test extends React.Component {44 render() {45 return (46 <ThemeProvider theme={Test.theme}>47 );48 }49}50import React from 'react';51import { ThemeProvider } from 'styled-components';52import Test from './test';53export default class Test extends React.Component {54 render() {55 return (56 <ThemeProvider theme={Test.theme}>57 );58 }59}60import React from 'react';61import { ThemeProvider } from 'styled-components';62import Test from './test';63export default class Test extends React.Component {64 render() {65 return (66 <ThemeProvider theme={Test.theme}>67 );68 }69}70import React from '

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful