Best JavaScript code snippet using storybook-root
custom.js
Source:custom.js
1function clickMiniature(imgMin){2 //recuperer les tags img3 var imgs = document.getElementsByTagName('img');4 //iterer sur ces tag 5 for ( var i = 0; i < imgs.length; i++) {6 //pour voir ceux qui ont dans un id comme imageMiniature7 if(imgs[i].id.indexOf("imageMiniature")){8 //enlever le border a ceux qui ont l'id comme imageMiniature9 imgs[i].style.borderWidth="0px";10 }11 }12 //mettre le border pour l'image cliquee13 imgMin.style.borderColor="rgb(150, 150, 150)";14 imgMin.style.borderWidth="9px";15 imgMin.style.borderStyle="double";16}1718//Change stylesheets files19function changeCSS(cssFileColor, cssFileStyle, cssFileAdmin, cssFileLayout) {20 // var ref = document.getElementById('reset');2122 // modifier le fichier color.css du thème Developr23 var sheetToBeRemoved = document.getElementById('color');24 if (sheetToBeRemoved != null) {25 var newlink = document.createElement("link");26 newlink.setAttribute("rel", "stylesheet");27 newlink.setAttribute("type", "text/css");28 newlink.setAttribute("href", cssFileColor);29 newlink.setAttribute("id", 'color');30 document.getElementsByTagName('head')[0].replaceChild(newlink,31 sheetToBeRemoved);32 }3334 // modifier le fichier style.css du thème Developr35 sheetToBeRemoved = document.getElementById('style');36 if (sheetToBeRemoved != null) {37 newlink = document.createElement("link");38 newlink.setAttribute("rel", "stylesheet");39 newlink.setAttribute("type", "text/css");40 newlink.setAttribute("href", cssFileStyle);41 newlink.setAttribute("id", 'style');42 document.getElementsByTagName('head')[0].replaceChild(newlink,43 sheetToBeRemoved);44 }45 // modifier le fichier style.css du thème bleu de Jakjoud4647 sheetToBeRemoved = document.getElementById('admin');48 if (sheetToBeRemoved != null) {49 newlink = document.createElement("link");50 newlink.setAttribute("rel", "stylesheet");51 newlink.setAttribute("type", "text/css");52 newlink.setAttribute("href", cssFileAdmin);53 newlink.setAttribute("id", 'admin');54 document.getElementsByTagName('head')[0].replaceChild(newlink,55 sheetToBeRemoved);56 }57 58 // modifier le fichier layout.css du thème rouge5960 sheetToBeRemoved = document.getElementById('layout');61 if (sheetToBeRemoved != null) {62 newlink = document.createElement("link");63 newlink.setAttribute("rel", "stylesheet");64 newlink.setAttribute("type", "text/css");65 newlink.setAttribute("href", cssFileLayout);66 newlink.setAttribute("id", 'layout');67 document.getElementsByTagName('head')[0].replaceChild(newlink,68 sheetToBeRemoved);69 }
...
a11yHighlight.ts
Source:a11yHighlight.ts
1import global from 'global';2import { addons } from '@storybook/addons';3import { STORY_CHANGED } from '@storybook/core-events';4import { EVENTS, HIGHLIGHT_STYLE_ID } from './constants';5import { highlightStyle } from './highlight';6const { document } = global;7if (module && module.hot && module.hot.decline) {8 module.hot.decline();9}10interface HighlightInfo {11 /** html selector of the element */12 elements: string[];13 color: string;14}15const channel = addons.getChannel();16const highlight = (infos: HighlightInfo) => {17 const id = HIGHLIGHT_STYLE_ID;18 resetHighlight();19 // Make sure there are no duplicated selectors20 const elements = Array.from(new Set(infos.elements));21 const sheet = document.createElement('style');22 sheet.setAttribute('id', id);23 sheet.innerHTML = elements24 .map(25 (target) =>26 `${target}{27 ${highlightStyle(infos.color)}28 }`29 )30 .join(' ');31 document.head.appendChild(sheet);32};33const resetHighlight = () => {34 const id = HIGHLIGHT_STYLE_ID;35 const sheetToBeRemoved = document.getElementById(id);36 if (sheetToBeRemoved) {37 sheetToBeRemoved.parentNode.removeChild(sheetToBeRemoved);38 }39};40channel.on(STORY_CHANGED, resetHighlight);...
InlineCSS.js
Source:InlineCSS.js
1/* globals document */2import React from 'react';3var InlineCSS = React.createClass({4 componentDidMount() {5 if( global.IS_SERVER_REQUEST ) {6 return;7 }8 var alreadyHaveIt = document.getElementById(this.props.id);9 if( alreadyHaveIt ) {10 return;11 }12 var css = this.props.css;13 var sheet = document.createElement('style');14 sheet.id = this.props.id;15 sheet.setAttribute('type', 'text/css');16 var target = document.body;17 // var taget = document.getElementsByTagName('head')[0];18 target.appendChild(sheet);19 /*20 if (ss1.styleSheet) { // IE21 ss1.styleSheet.cssText = css;22 } else { // the world23 var tt1 = document.createTextNode(css);24 ss1.appendChild(tt1);25 }26 */27 sheet.innerHTML = css;28 },29 shouldComponentUpdate() {30 return false;31 },32 componentWillUnmount() {33 var sheetToBeRemoved = document.getElementById(this.props.id);34 if( sheetToBeRemoved ) {35 var sheetParent = sheetToBeRemoved.parentNode;36 sheetParent.removeChild(sheetToBeRemoved); 37 }38 },39 render() {40 return null;41 }42});43module.exports = InlineCSS;...
Using AI Code Generation
1import { sheetToBeRemoved } from 'storybook-root';2import { sheetToBeRemoved } from 'storybook-root';3import { sheetToBeRemoved } from 'storybook-root';4import { sheetToBeRemoved } from 'storybook-root';5import { sheetToBeRemoved } from 'storybook-root';6import { sheetToBeRemoved } from 'storybook-root';7import { sheetToBeRemoved } from 'storybook-root';8import { sheetToBeRemoved } from 'storybook-root';9import { sheetToBeRemoved } from 'storybook-root';10import { sheetToBeRemoved } from 'storybook-root';11import { sheetToBeRemoved } from 'storybook-root';
Using AI Code Generation
1import { sheetToBeRemoved } from 'storybook-root';2export { sheetToBeRemoved } from './test';3@import '~storybook-root/test';4 Invalid CSS after "...ort '~storybook": expected 1 selector or at-rule, was "-root/test';"5 in /Users/username/Projects/ProjectName/node_modules/storybook-root/test.js (line 1, column 1)6import7import8import9import10import11import12import13import14import15import16import17import18import19import20import21import22import23import24import25import26import27import28import29import30import31import32import33import34import35import36import37import38import39import40import
Using AI Code Generation
1import { sheetToBeRemoved } from 'storybook-root';2sheetToBeRemoved();3import { sheetToBeRemoved } from 'storybook-root';4sheetToBeRemoved();5import { sheetToBeRemoved } from 'storybook-root';6sheetToBeRemoved();7import { sheetToBeRemoved } from 'storybook-root';8sheetToBeRemoved();9import { sheetToBeRemoved } from 'storybook-root';10sheetToBeRemoved();11import { sheetToBeRemoved } from 'storybook-root';12sheetToBeRemoved();13import { sheetToBeRemoved } from 'storybook-root';14sheetToBeRemoved();15import { sheetToBeRemoved } from 'storybook-root';16sheetToBeRemoved();17import { sheetToBeRemoved } from 'storybook-root';18sheetToBeRemoved();19import { sheetToBeRemoved } from 'storybook-root';20sheetToBeRemoved();21import { sheetToBeRemoved } from 'storybook-root';22sheetToBeRemoved();23import { sheetTo
Using AI Code Generation
1import { sheetToBeRemoved } from 'storybook-root';2sheetToBeRemoved('sheetName');3import { sheetToBeRemoved } from './src/sheetToBeRemoved';4export { sheetToBeRemoved };5import { SheetsRegistry } from 'jss';6import { createMuiTheme, createGenerateClassName } from '@material-ui/core/styles';7import { purple } from '@material-ui/core/colors';8const theme = createMuiTheme({9 palette: {10 },11});12const sheetsManager = new Map();13const generateClassName = createGenerateClassName();14export const sheetToBeRemoved = (sheetName) => {15 const sheetsRegistry = new SheetsRegistry();16 const sheet = sheetsRegistry.get(sheetName);17 sheetsManager.delete(sheet);18 sheetsRegistry.remove(sheet);19 sheetsRegistry.reset();20 sheetsRegistry.registry = [];21 sheetsRegistry.registry = {};22};23const path = require('path');24module.exports = async ({ config }) => {25 config.module.rules.push({26 test: /\.(js|jsx)$/,27 path.resolve(__dirname, '../src'),28 path.resolve(__dirname, '../node_modules/storybook-root'),29 {30 loader: require.resolve('babel-loader'),31 options: {32 presets: [['react-app', { flow: false, typescript: true }]],33 },34 },35 });36 return config;37};38import { configure, addDecorator } from '@storybook/react';39import { withInfo } from '@storybook/addon-info';40import { withKnobs } from '@storybook/addon-knobs';41import { withA11y } from '@storybook/addon-a11y';42import { withThemesProvider } from 'storybook-addon-styled-component-theme';43import { addReadme } from 'storybook-readme';44import { withTests } from '@storybook/addon-jest';45import { withContexts } from '@storybook/addon-contexts/react';46import { contexts } from './contexts';47import { theme } from './theme';48import { with
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!!