Best JavaScript code snippet using storybook-root
NavigationHistory.js
Source:NavigationHistory.js
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for 2 * full list of contributors). Published under the Clear BSD license. 3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the4 * full text of the license. */5/**6 * @requires OpenLayers/Control.js7 * @requires OpenLayers/Control/Button.js8 */9/**10 * Class: OpenLayers.Control.NavigationHistory11 * A navigation history control. This is a meta-control, that creates two12 * dependent controls: <previous> and <next>. Call the trigger method13 * on the <previous> and <next> controls to restore previous and next14 * history states. The previous and next controls will become active15 * when there are available states to restore and will become deactive16 * when there are no states to restore.17 *18 * Inherits from:19 * - <OpenLayers.Control>20 */21OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {22 /**23 * Property: type24 * {String} Note that this control is not intended to be added directly25 * to a control panel. Instead, add the sub-controls previous and26 * next. These sub-controls are button type controls that activate27 * and deactivate themselves. If this parent control is added to28 * a panel, it will act as a toggle.29 */30 type: OpenLayers.Control.TYPE_TOGGLE,31 /**32 * APIProperty: previous33 * {<OpenLayers.Control>} A button type control whose trigger method restores34 * the previous state managed by this control.35 */36 previous: null,37 38 /**39 * APIProperty: previousOptions40 * {Object} Set this property on the options argument of the constructor41 * to set optional properties on the <previous> control.42 */43 previousOptions: null,44 45 /**46 * APIProperty: next47 * {<OpenLayers.Control>} A button type control whose trigger method restores48 * the next state managed by this control.49 */50 next: null,51 /**52 * APIProperty: nextOptions53 * {Object} Set this property on the options argument of the constructor54 * to set optional properties on the <next> control.55 */56 nextOptions: null,57 /**58 * APIProperty: limit59 * {Integer} Optional limit on the number of history items to retain. If60 * null, there is no limit. Default is 50.61 */62 limit: 50,63 /**64 * APIProperty: autoActivate65 * {Boolean} Activate the control when it is added to a map. Default is66 * true.67 */68 autoActivate: true,69 /**70 * Property: clearOnDeactivate71 * {Boolean} Clear the history when the control is deactivated. Default72 * is false.73 */74 clearOnDeactivate: false,75 /**76 * Property: registry77 * {Object} An object with keys corresponding to event types. Values78 * are functions that return an object representing the current state.79 */80 registry: null,81 /**82 * Property: nextStack83 * {Array} Array of items in the history.84 */85 nextStack: null,86 /**87 * Property: previousStack88 * {Array} List of items in the history. First item represents the current89 * state.90 */91 previousStack: null,92 93 /**94 * Property: listeners95 * {Object} An object containing properties corresponding to event types.96 * This object is used to configure the control and is modified on97 * construction.98 */99 listeners: null,100 101 /**102 * Property: restoring103 * {Boolean} Currently restoring a history state. This is set to true104 * before calling restore and set to false after restore returns.105 */106 restoring: false,107 108 /**109 * Constructor: OpenLayers.Control.NavigationHistory 110 * 111 * Parameters:112 * options - {Object} An optional object whose properties will be used113 * to extend the control.114 */115 initialize: function(options) {116 OpenLayers.Control.prototype.initialize.apply(this, [options]);117 118 this.registry = OpenLayers.Util.extend({119 "moveend": this.getState120 }, this.registry);121 122 var previousOptions = {123 trigger: OpenLayers.Function.bind(this.previousTrigger, this),124 displayClass: this.displayClass + " " + this.displayClass + "Previous"125 };126 OpenLayers.Util.extend(previousOptions, this.previousOptions);127 this.previous = new OpenLayers.Control.Button(previousOptions);128 129 var nextOptions = {130 trigger: OpenLayers.Function.bind(this.nextTrigger, this),131 displayClass: this.displayClass + " " + this.displayClass + "Next"132 };133 OpenLayers.Util.extend(nextOptions, this.nextOptions);134 this.next = new OpenLayers.Control.Button(nextOptions);135 this.clear();136 },137 138 /**139 * Method: onPreviousChange140 * Called when the previous history stack changes.141 *142 * Parameters:143 * state - {Object} An object representing the state to be restored144 * if previous is triggered again or null if no previous states remain.145 * length - {Integer} The number of remaining previous states that can146 * be restored.147 */148 onPreviousChange: function(state, length) {149 if(state && !this.previous.active) {150 this.previous.activate();151 } else if(!state && this.previous.active) {152 this.previous.deactivate();153 }154 },155 156 /**157 * Method: onNextChange158 * Called when the next history stack changes.159 *160 * Parameters:161 * state - {Object} An object representing the state to be restored162 * if next is triggered again or null if no next states remain.163 * length - {Integer} The number of remaining next states that can164 * be restored.165 */166 onNextChange: function(state, length) {167 if(state && !this.next.active) {168 this.next.activate();169 } else if(!state && this.next.active) {170 this.next.deactivate();171 }172 },173 174 /**175 * APIMethod: destroy176 * Destroy the control.177 */178 destroy: function() {179 OpenLayers.Control.prototype.destroy.apply(this);180 this.previous.destroy();181 this.next.destroy();182 this.deactivate();183 for(var prop in this) {184 this[prop] = null;185 }186 },187 188 /** 189 * Method: setMap190 * Set the map property for the control and <previous> and <next> child191 * controls.192 *193 * Parameters:194 * map - {<OpenLayers.Map>} 195 */196 setMap: function(map) {197 this.map = map;198 this.next.setMap(map);199 this.previous.setMap(map);200 },201 /**202 * Method: draw203 * Called when the control is added to the map.204 */205 draw: function() {206 OpenLayers.Control.prototype.draw.apply(this, arguments);207 this.next.draw();208 this.previous.draw();209 },210 211 /**212 * Method: previousTrigger213 * Restore the previous state. If no items are in the previous history214 * stack, this has no effect.215 *216 * Returns:217 * {Object} Item representing state that was restored. Undefined if no218 * items are in the previous history stack.219 */220 previousTrigger: function() {221 var current = this.previousStack.shift();222 var state = this.previousStack.shift();223 if(state != undefined) {224 this.nextStack.unshift(current);225 this.previousStack.unshift(state);226 this.restoring = true;227 this.restore(state);228 this.restoring = false;229 this.onNextChange(this.nextStack[0], this.nextStack.length);230 this.onPreviousChange(231 this.previousStack[1], this.previousStack.length - 1232 );233 } else {234 this.previousStack.unshift(current);235 }236 return state;237 },238 239 /**240 * APIMethod: nextTrigger241 * Restore the next state. If no items are in the next history242 * stack, this has no effect. The next history stack is populated243 * as states are restored from the previous history stack.244 *245 * Returns:246 * {Object} Item representing state that was restored. Undefined if no247 * items are in the next history stack.248 */249 nextTrigger: function() {250 var state = this.nextStack.shift();251 if(state != undefined) {252 this.previousStack.unshift(state);253 this.restoring = true;254 this.restore(state);255 this.restoring = false;256 this.onNextChange(this.nextStack[0], this.nextStack.length);257 this.onPreviousChange(258 this.previousStack[1], this.previousStack.length - 1259 );260 }261 return state;262 },263 264 /**265 * APIMethod: clear266 * Clear history.267 */268 clear: function() {269 this.previousStack = [];270 this.previous.deactivate();271 this.nextStack = [];272 this.next.deactivate();273 },274 /**275 * Method: getState276 * Get the current state and return it.277 *278 * Returns:279 * {Object} An object representing the current state.280 */281 getState: function() {282 return {283 center: this.map.getCenter(),284 resolution: this.map.getResolution(),285 projection: this.map.getProjectionObject(),286 units: this.map.getProjectionObject().getUnits() || 287 this.map.units || this.map.baseLayer.units288 };289 },290 /**291 * Method: restore292 * Update the state with the given object.293 *294 * Parameters:295 * state - {Object} An object representing the state to restore.296 */297 restore: function(state) {298 var center, zoom;299 if (this.map.getProjectionObject() == state.projection) { 300 zoom = this.map.getZoomForResolution(state.resolution);301 center = state.center;302 } else {303 center = state.center.clone();304 center.transform(state.projection, this.map.getProjectionObject());305 var sourceUnits = state.units;306 var targetUnits = this.map.getProjectionObject().getUnits() || 307 this.map.units || this.map.baseLayer.units;308 var resolutionFactor = sourceUnits && targetUnits ? 309 OpenLayers.INCHES_PER_UNIT[sourceUnits] / OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;310 zoom = this.map.getZoomForResolution(resolutionFactor*state.resolution); 311 }312 this.map.setCenter(center, zoom);313 },314 315 /**316 * Method: setListeners317 * Sets functions to be registered in the listeners object.318 */319 setListeners: function() {320 this.listeners = {};321 for(var type in this.registry) {322 this.listeners[type] = OpenLayers.Function.bind(function() {323 if(!this.restoring) {324 var state = this.registry[type].apply(this, arguments);325 this.previousStack.unshift(state);326 if(this.previousStack.length > 1) {327 this.onPreviousChange(328 this.previousStack[1], this.previousStack.length - 1329 );330 }331 if(this.previousStack.length > (this.limit + 1)) {332 this.previousStack.pop();333 }334 if(this.nextStack.length > 0) {335 this.nextStack = [];336 this.onNextChange(null, 0);337 }338 }339 return true;340 }, this);341 }342 },343 /**344 * APIMethod: activate345 * Activate the control. This registers any listeners.346 *347 * Returns:348 * {Boolean} Control successfully activated.349 */350 activate: function() {351 var activated = false;352 if(this.map) {353 if(OpenLayers.Control.prototype.activate.apply(this)) {354 if(this.listeners == null) {355 this.setListeners();356 }357 for(var type in this.listeners) {358 this.map.events.register(type, this, this.listeners[type]);359 }360 activated = true;361 if(this.previousStack.length == 0) {362 this.initStack();363 }364 }365 }366 return activated;367 },368 369 /**370 * Method: initStack371 * Called after the control is activated if the previous history stack is372 * empty.373 */374 initStack: function() {375 if(this.map.getCenter()) {376 this.listeners.moveend();377 }378 },379 380 /**381 * APIMethod: deactivate382 * Deactivate the control. This unregisters any listeners.383 *384 * Returns:385 * {Boolean} Control successfully deactivated.386 */387 deactivate: function() {388 var deactivated = false;389 if(this.map) {390 if(OpenLayers.Control.prototype.deactivate.apply(this)) {391 for(var type in this.listeners) {392 this.map.events.unregister(393 type, this, this.listeners[type]394 );395 }396 if(this.clearOnDeactivate) {397 this.clear();398 }399 deactivated = true;400 }401 }402 return deactivated;403 },404 405 CLASS_NAME: "OpenLayers.Control.NavigationHistory"...
scriptFeat.js
Source:scriptFeat.js
1console.clear();23const { gsap, imagesLoaded } = window;45const buttons = {6 prev: document.querySelector(".btn--left"),7 next: document.querySelector(".btn--right"),8};9const cardsContainerEl = document.querySelector(".cards__wrapper");10const appBgContainerEl = document.querySelector(".app__bg");1112const cardInfosContainerEl = document.querySelector(".info__wrapper");1314buttons.next.addEventListener("click", () => swapCards("right"));1516buttons.prev.addEventListener("click", () => swapCards("left"));1718function swapCards(direction) {19 const currentCardEl = cardsContainerEl.querySelector(".current--card");20 const previousCardEl = cardsContainerEl.querySelector(".previous--card");21 const previous_previous_CardEl = cardsContainerEl.querySelector(".previous--previous--card");22 const nextCardEl = cardsContainerEl.querySelector(".next--card");23 const next_next_CardEl = cardsContainerEl.querySelector(".next--next--card");2425 const currentBgImageEl = appBgContainerEl.querySelector(".current--image");26 const previousBgImageEl = appBgContainerEl.querySelector(".previous--image");27 const previous_previousBgImageEl = appBgContainerEl.querySelector(".previous--previous--image");28 const nextBgImageEl = appBgContainerEl.querySelector(".next--image");29 const next_nextBgImageEl = appBgContainerEl.querySelector(".next--next--image");3031 changeInfo(direction);32 swapCardsClass();3334 removeCardEvents(currentCardEl);3536 function swapCardsClass() {37 currentCardEl.classList.remove("current--card");38 previousCardEl.classList.remove("previous--card");39 previous_previous_CardEl.classList.remove("previous--previous--card");40 nextCardEl.classList.remove("next--card");41 next_next_CardEl.classList.remove("next--next--card");4243 currentBgImageEl.classList.remove("current--image");44 previousBgImageEl.classList.remove("previous--image");45 previous_previousBgImageEl.classList.remove("previous--previous--image");46 nextBgImageEl.classList.remove("next--image");47 next_nextBgImageEl.classList.remove("next--next--image");4849 currentCardEl.style.zIndex = "50";50 currentBgImageEl.style.zIndex = "-2";5152 if (direction === "right") {53 previousCardEl.style.zIndex = "30";54 previous_previous_CardEl.style.zIndex = "20";55 nextCardEl.style.zIndex = "40";56 next_next_CardEl.style.zIndex = "30";5758 nextBgImageEl.style.zIndex = "-1";59 next_nextBgImageEl.style.zIndex = "0";6061 currentCardEl.classList.add("previous--card");62 previousCardEl.classList.add("previous--previous--card");63 previous_previous_CardEl.classList.add("next--next--card");64 nextCardEl.classList.add("current--card");65 next_next_CardEl.classList.add("next--card");6667 currentBgImageEl.classList.add("previous--image");68 previousBgImageEl.classList.add("previous--previous--image");69 previous_previousBgImageEl.classList.add("next--next--image");70 nextBgImageEl.classList.add("current--image");71 next_nextBgImageEl.classList.add("next--image");7273 } else if (direction === "left") {74 previousCardEl.style.zIndex = "40";75 previous_previous_CardEl.style.zIndex = "30";76 nextCardEl.style.zIndex = "30";77 next_next_CardEl.style.zIndex = "20";7879 previousBgImageEl.style.zIndex = "-1";80 previous_previousBgImageEl.style.zIndex = "-2";8182 currentCardEl.classList.add("next--card");83 previousCardEl.classList.add("current--card");84 previous_previous_CardEl.classList.add("previous--card");85 nextCardEl.classList.add("next--next--card");86 next_next_CardEl.classList.add("previous--previous--card");8788 currentBgImageEl.classList.add("next--image");89 previousBgImageEl.classList.add("current--image");90 previous_previousBgImageEl.classList.add("previous--image");91 nextBgImageEl.classList.add("next--next--image");92 next_nextBgImageEl.classList.add("previous--previous--image");93 }94 }95}9697function changeInfo(direction) {98 let currentInfoEl = cardInfosContainerEl.querySelector(".current--info");99 let previousInfoEl = cardInfosContainerEl.querySelector(".previous--info");100 let previous_previousInfoEl = cardInfosContainerEl.querySelector(".previous--previous--info");101 let nextInfoEl = cardInfosContainerEl.querySelector(".next--info");102 let next_nextInfoEl = cardInfosContainerEl.querySelector(".next--next--info");103104 gsap.timeline()105 .to([buttons.prev, buttons.next], {106 duration: 0.2,107 opacity: 0.5,108 pointerEvents: "none",109 })110 .to(111 currentInfoEl.querySelectorAll(".text"),112 {113 duration: 0.4,114 stagger: 0.1,115 translateY: "-120px",116 opacity: 0,117 },118 "-="119 )120 .call(() => {121 swapInfosClass(direction);122 })123 .call(() => initCardEvents())124 .fromTo(125 direction === "right"126 ? nextInfoEl.querySelectorAll(".text")127 : previousInfoEl.querySelectorAll(".text"),128 {129 opacity: 0,130 translateY: "40px",131 },132 {133 duration: 0.4,134 stagger: 0.1,135 translateY: "0px",136 opacity: 1,137 }138 )139 .to([buttons.prev, buttons.next], {140 duration: 0.2,141 opacity: 1,142 pointerEvents: "all",143 });144145 function swapInfosClass() {146 currentInfoEl.classList.remove("current--info");147 previousInfoEl.classList.remove("previous--info");148 previous_previousInfoEl.classList.remove("previous--previous--info");149 nextInfoEl.classList.remove("next--info");150 next_nextInfoEl.classList.remove("next--next--info");151152 if (direction === "right") {153 currentInfoEl.classList.add("previous--info");154 nextInfoEl.classList.add("current--info");155 previousInfoEl.classList.add("previous--previous--info");156 previous_previousInfoEl.classList.add("next--next--info");157 next_nextInfoEl.classList.add("next--info")158 } else if (direction === "left") { 159 currentInfoEl.classList.add("next--info");160 nextInfoEl.classList.add("next--next--info");161 next_nextInfoEl.classList.add("previous--previous--info")162 previousInfoEl.classList.add("current--info");163 previous_previousInfoEl.classList.add("previous--info");164 }165 }166}167168function updateCard(e) {169 const card = e.currentTarget;170 const box = card.getBoundingClientRect();171 const centerPosition = {172 x: box.left + box.width / 2,173 y: box.top + box.height / 2,174 };175 let angle = Math.atan2(e.pageX - centerPosition.x, 0) * (35 / Math.PI);176 gsap.set(card, {177 "--current-card-rotation-offset": `${angle}deg`,178 });179 const currentInfoEl = cardInfosContainerEl.querySelector(".current--info");180 gsap.set(currentInfoEl, {181 rotateY: `${angle}deg`,182 });183}184185function resetCardTransforms(e) {186 const card = e.currentTarget;187 const currentInfoEl = cardInfosContainerEl.querySelector(".current--info");188 gsap.set(card, {189 "--current-card-rotation-offset": 0,190 });191 gsap.set(currentInfoEl, {192 rotateY: 0,193 });194}195196function initCardEvents() {197 const currentCardEl = cardsContainerEl.querySelector(".current--card");198 currentCardEl.addEventListener("pointermove", updateCard);199 currentCardEl.addEventListener("pointerout", (e) => {200 resetCardTransforms(e);201 });202}203204initCardEvents();205206function removeCardEvents(card) {207 card.removeEventListener("pointermove", updateCard);208}209210function init() {211212 let tl = gsap.timeline();213214 tl.to(cardsContainerEl.children, {215 delay: 0.15,216 duration: 0.5,217 stagger: {218 ease: "power4.inOut",219 from: "right",220 amount: 0.1,221 },222 "--card-translateY-offset": "0%",223 })224 .to(cardInfosContainerEl.querySelector(".current--info").querySelectorAll(".text"), {225 delay: 0.5,226 duration: 0.4,227 stagger: 0.1,228 opacity: 1,229 translateY: 0,230 })231 .to(232 [buttons.prev, buttons.next],233 {234 duration: 0.4,235 opacity: 1,236 pointerEvents: "all",237 },238 "-=0.4"239 );240}241242const waitForImages = () => {243 const images = [...document.querySelectorAll(".img-feat")];244 const totalImages = images.length;245 let loadedImages = 0;246 const loaderEl = document.querySelector(".loader span");247248 gsap.set(cardsContainerEl.children, {249 "--card-translateY-offset": "100vh",250 });251 gsap.set(cardInfosContainerEl.querySelector(".current--info").querySelectorAll(".text"), {252 translateY: "40px",253 opacity: 0,254 });255 gsap.set([buttons.prev, buttons.next], {256 pointerEvents: "none",257 opacity: "0",258 });259260 images.forEach((image) => {261 imagesLoaded(image, (instance) => {262 if (instance.isComplete) {263 loadedImages++;264 let loadProgress = loadedImages / totalImages;265266 gsap.to(loaderEl, {267 duration: 1,268 scaleX: loadProgress,269 backgroundColor: `hsl(${loadProgress * 120}, 100%, 50%`,270 });271272 if (totalImages == loadedImages) {273 gsap.timeline()274 .to(".loading__wrapper", {275 duration: 0.8,276 opacity: 0,277 pointerEvents: "none",278 })279 .call(() => init());280 }281 }282 });283 });284};285
...
Using AI Code Generation
1import { getStorybookUI, configure } from '@storybook/react-native';2import { loadStories } from './storyLoader';3configure(() => {4 loadStories();5}, module);6const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });7export default StorybookUIRoot;8import { addDecorator, configure } from '@storybook/react-native';9import { withKnobs } from '@storybook/addon-knobs';10import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';11addDecorator(withKnobs);12addDecorator(withBackgrounds);13const req = require.context('../src/components', true, /\.stories\.js$/);14function loadStories() {15 req.keys().forEach(filename => req(filename));16}17configure(loadStories, module);18"scripts": {19 }20import { configure } from '@storybook/react-native';21import { loadStories } from '../storyLoader';22configure(loadStories, module);23import { addDecorator } from '@storybook/react-native';24import { withKnobs } from '@storybook/addon-knobs';25import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';26addDecorator(withKnobs);27addDecorator(withBackgrounds);28import '@storybook/addon-ondevice-knobs/register';29import '@storybook/addon-ondevice-backgrounds/register';30module.exports = ({ config }) => {31 config.module.rules.push({32 });33 config.resolve.extensions.push('.ts', '.tsx');34 return config;35};36module.exports = {37};38{39 "compilerOptions": {
Using AI Code Generation
1import { getStorybookUI, configure } from '@storybook/react-native';2import { loadStories } from './storyLoader';3configure(() => {4 loadStories();5}, module);6const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });7export default StorybookUIRoot;8In your App.js file, import the storybook root from the test.js file9import StorybookUIRoot from './test';10const App = () => {11 return <StorybookUIRoot />;12};13export default App;14import React from 'react';15import { View, Text, TouchableOpacity } from 'react-native';16export default function Button({ text, onPress }) {17 return (18 <TouchableOpacity onPress={onPress}>19 <Text>{text}</Text>20 );21}22import React from 'react';23import { storiesOf } from '@storybook/react-native';24import Button from '../components/Button/Button';25storiesOf('Button', module).add('default', () => (26 <Button text="Hello Button" onPress={() => {}} />27));
Using AI Code Generation
1import { getStorybookUI, configure } from '@storybook/react-native';2import { loadStories } from './storyLoader';3configure(loadStories, module);4const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });5export default StorybookUIRoot;6import { AppRegistry } from 'react-native';7import { getStorybookUI, configure } from '@storybook/react-native';8import { loadStories } from './storyLoader';9import './rn-addons';10import { name as appName } from './app.json';11configure(() => {12 require('./stories');13}, module);14const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });15AppRegistry.registerComponent(appName, () => StorybookUIRoot);16{17}18import { configure } from '@storybook/react';19configure(require.context('../src', true, /\.stories\.js$/), module);20import React from 'react';21import { storiesOf } from '@storybook/react-native';22import { action } from '@storybook/addon-actions';23import Button from './Button';24storiesOf('Button', module)25 .add('with text', () => (26 <Button onPress={action('clicked-text')}>27 .add('with some emoji', () => (28 <Button onPress={action('clicked-emoji')}>
Using AI Code Generation
1import { getStorybookUI, configure } from '@storybook/react-native';2import { loadStories } from './storyLoader';3import './rn-addons';4configure(() => {5 loadStories();6}, module);
Using AI Code Generation
1import { addDecorator } from '@storybook/react';2import { withA11y } from '@storybook/addon-a11y';3import { withKnobs } from '@storybook/addon-knobs';4import { withTests } from '@storybook/addon-jest';5import results from '../.jest-test-results.json';6addDecorator(withA11y);7addDecorator(withKnobs);8addDecorator(9 withTests({10 })11);12import { addons } from '@storybook/addons';13import { themes } from '@storybook/theming';14addons.setConfig({15});16import { configure } from '@storybook/react';17import results from '../.jest-test-results.json';18function loadStories() {19 require('../src/stories');20}21export const parameters = {22 actions: { argTypesRegex: '^on[A-Z].*' },23};
Using AI Code Generation
1import { getStorybookUI, configure } from '@storybook/react-native';2import { loadStories } from './storyLoader';3configure(loadStories, module);4configure(() => {5 require('./stories');6}, module);7const StorybookUIRoot = getStorybookUI({8});9export default StorybookUIRoot;10import { loadStories } from './storyLoader';11const req = require.context('../src/components', true, /\.stories\.js$/);12function loadStories() {13 req.keys().forEach(filename => req(filename));14}15export { loadStories };16import { configure } from '@storybook/react';17const req = require.context('../src/components', true, /\.stories\.js$/);18function loadStories() {19 req.keys().forEach(filename => req(filename));20}21configure(loadStories, module);22const path = require('path');23module.exports = ({ config }) => {24 config.module.rules.push({25 test: /\.(ts|tsx)$/,26 include: path.resolve(__dirname, '../'),27 {28 loader: require.resolve('awesome-typescript-loader'),29 options: {30 configFileName: path.resolve(__dirname, '../tsconfig.json'),31 },32 },33 { loader: require.resolve('react-docgen-typescript-loader') },34 });35 config.resolve.extensions.push('.ts', '.tsx');36 return config;37};38import '@storybook/addon-ondevice-actions/register';39import '@storybook/addon-ondevice-knobs/register';40import { addDecorator } from '@storybook/react-native';41import { withKnobs } from '@storybook/addon-knobs';42import { withA11y } from '@storybook/addon-a11y';43addDecorator(withKnobs);44addDecorator(withA11y);45import { loadStories } from './storyLoader';46const req = require.context('../src/components', true, /\.stories\.js$/);47function loadStories() {48 req.keys().forEach(filename => req(filename));49}50export { loadStories };51{
Using AI Code Generation
1import { addParameters, configure } from '@storybook/react';2import { create } from '@storybook/theming';3addParameters({4 options: {5 theme: create({6 }),7 },8});9configure(require.context('../src', true, /\.stories\.js$/), module);
Using AI Code Generation
1import { configure } from '@storybook/react';2import 'storybook-chromatic';3configure(require.context('../src', true, /\.stories\.js$/), module);4module.exports = {5};6import { addParameters } from '@storybook/react';7addParameters({8 chromatic: {9 },10});11import { addParameters } from '@storybook/react';12addParameters({13 chromatic: {14 },15});16import { addParameters } from '@storybook/react';17addParameters({18 chromatic: {19 },20});21import { addParameters } from '@storybook/react';22addParameters({23 chromatic: {24 },25});26import { addParameters } from '@storybook/react';27addParameters({28 chromatic: {29 },30});31import { addParameters } from '@storybook/react';32addParameters({33 chromatic: {34 },35});36import { addParameters } from '@storybook/react';37addParameters({38 chromatic: {39 },40});41import { addParameters } from '@storybook/react';42addParameters({43 chromatic: {44 },45});46import { addParameters } from '@storybook/react';
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!