This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * # Preview what would be renamed (dry run) | |
| * node rename-jsx-files.mjs packages/components --dry-run | |
| * | |
| * # Actually rename files | |
| * node rename-jsx-files.mjs packages/components | |
| * | |
| * # Verbose mode to see all files processed | |
| * node rename-jsx-files.mjs packages/components --verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function generateContrastingColors(baseColor, numberOfColors, minContrastRatio = 4.5) { | |
| const colors = []; | |
| let attempts = 0; | |
| const maxAttempts = numberOfColors * 100; | |
| while (colors.length < numberOfColors && attempts < maxAttempts) { | |
| const newColor = getRandomColor(); | |
| const contrastRatio = getContrastRatio(baseColor, newColor); | |
| if (contrastRatio >= minContrastRatio) { | |
| colors.push(newColor); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git config --global alias.lol "log --graph --pretty=format:'%s' --abbrev-commit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Run `node css.js` from this package root to compile every `*.module.scss` to a sibling `*.module.css` and rewrite imports accordingly. | |
| * | |
| * - Scans the package for `*.module.scss` files (ignoring node_modules, lib, lib-esm, .turbo, .git, dist, build, etc.). | |
| * - Compiles each of them with `sass` into a `*.module.css` that sits in the same folder. | |
| * - Updates `.js`, `.jsx`, `.ts`, and `.tsx` files so `.module.scss` imports point to the new `.module.css` files. | |
| * - Optionally deletes the original `*.module.scss` files after successful compilation (use --delete flag). | |
| * | |
| * Usage: | |
| * node css.js # Compile and update imports (keep .scss files) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ts-node | |
| import * as fs from 'fs' | |
| import * as path from 'path' | |
| import * as glob from 'glob' | |
| const CWD = process.cwd() | |
| // describe coverage-final.json file | |
| type Statement = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const CWD = process.cwd(); | |
| const EXTENSIONS = /\.(scss)$/; | |
| const SASS_DATA = "@use '~@talend/bootstrap-theme/src/theme/guidelines' as *;\n"; | |
| function transform(filename) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const program = require('commander'); | |
| const fs = require('fs'); | |
| const tmp = require('tmp-promise'); | |
| const PNG = require('pngjs').PNG; | |
| const pixelmatch = require('pixelmatch'); | |
| const puppeteer = require('puppeteer'); | |
| program | |
| .option('-p, --pullrequest [pr]', 'Pull request') | |
| .option('-c, --config [config]', 'JSON config file') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const os = require('os'); | |
| const fs = require('fs'); | |
| const versions = require('./versions.json'); | |
| function updatePart(dependencies) { | |
| Object.keys(dependencies).forEach(dep => { | |
| if (versions[dep]) { | |
| dependencies[dep] = versions[dep]; | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| export default function WebComponent({ component, ...props }) { | |
| const [myEl, setState] = React.useState(document.createElement(component)); | |
| const el = React.useRef(null); | |
| React.useEffect(() => { | |
| if (myEl.tagName.toLowerCase() !== component.toLowerCase() ) { | |
| setState(document.createElement(component)); | |
| } else { | |
| Object.keys(props).forEach(key => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * IMPORTANT NOTE. | |
| * Because react use synthetic event we have to patch the shadowDOM | |
| * The following patch has to be applied just after the attachShadow | |
| * and you must ban the use document.createElement. Use shadowRoot.createElement instead. | |
| * Source: https://github.com/facebook/react/issues/9242 | |
| */ | |
| function changeOwnerDocumentToShadowRoot(element, shadowRoot) { | |
| Object.defineProperty(element, 'ownerDocument', {value: shadowRoot}); | |
| } |
NewerOlder