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
| // Require and use modules via data attributes | |
| // your modules need to take an element as a param | |
| // the modules live in this same folder to work | |
| const moduleElements = document.querySelectorAll('[data-module]') | |
| Array.prototype.forEach.call(moduleElements, el => { | |
| const name = el.getAttribute('data-module') | |
| const Module = require(`./${name}`) | |
| Module(el) | |
| }) |
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
| /** | |
| * Make a document.querySelectorAll loopable | |
| * @author Todd Motto | |
| * @tutorial https://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack | |
| * @param {NodeList} elements | |
| * @param {Function} callback function that takes element and index | |
| * @param {this} scope what this refers to | |
| */ | |
| const loopQuery = (elements, callback, scope) => { | |
| for (let i = 0; i < elements.length; i++) { |
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
| { | |
| ... | |
| "standard": { | |
| "globals": [ | |
| "afterAll", | |
| "afterEach", | |
| "beforeAll", | |
| "beforeEach", | |
| "describe", | |
| "test", |
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 webpack = require('webpack') | |
| const UglifyJSPlugin = require('uglifyjs-webpack-plugin') | |
| const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | |
| const {cwd} = require('process') | |
| const production = process.env.NODE_ENV === 'production' | |
| const debug = process.env.NODE_ENV === 'debug' | |
| // When you really want to make the relationship work... | |
| const ENTRY_PATH = cwd() + '/src/index.js' |
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' | |
| import { BrowserRouter as Router, Switch } from 'react-router-dom' | |
| import routes from './routes' | |
| import FancyRoute from './components/tools/FancyRoute' | |
| const App = props => | |
| <Router> | |
| <Switch> | |
| {routes.map((route, i) => | |
| <FancyRoute key={i} {...route} /> |
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
| // Paste in console on the product list in the admin | |
| // EXAMPLE | |
| // https://************.myshopify.com/admin/products | |
| // Select all the links to product pages | |
| function downloadSP (name) { | |
| $(`tbody td a[href^="/admin/${name}"]`).each(function (index) { | |
| const me = $(this) | |
| // Grab the original href |
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
| /** | |
| * Make a document.querySelectorAll loopable | |
| * @author Todd Motto | |
| * @tutorial https://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack | |
| * @param {NodeList} elements | |
| * @param {Function} callback function that takes element and index | |
| * @param {this} scope what this refers to | |
| */ | |
| const loopQuery = (elements, callback, scope) => { | |
| for (let i = 0; i < elements.length; i++) { |
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
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| mQENBFnQbV8BCACyN7kRYtOgi9vY6cCp1BZcVKRBcJd6JZTieABLw6+Rgr2xozyl | |
| e3npvPBtg2ccPQqlG0CgpJkxQfNpo7MhMp3svVcgebwnYzCrJmM95NU9IDYcAI9N | |
| HR+HOAOIiXJTPX7nujoBshxZ2bl8GuJYggVLIyOEX5qtS49TdZ8jvRWkC9bxR3Jh | |
| 7O5PADlKe74Tce/k1nwQdlpIRJ+0zu/yDdjOuBtCxCrEX2h0GDHZD3xa8oYE2ed2 | |
| DBQO3bAB9x0MTcrwzatvtr163JTxGBKPc2GpC5mEaZCaLd1QhmfqtvlyLjeXHa2Z | |
| TzDdimbDgSyY/HP67Hc0RMuCC8ovxGHIgxcnABEBAAG0Kk1pZ3VlbCBQYWxhdSBa | |
| YXJ6YSA8bXBhbGF1emFyemFAZ21haWwuY29tPokBVAQTAQgAPhYhBIBn5gFjR1dK | |
| CHpqfomJAF5ePzhuBQJZ0G1fAhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMBAh4B |
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
| { | |
| // ... | |
| optimization: { | |
| splitChunks: { | |
| cacheGroups: { | |
| commons: { | |
| test: /[\\/]node_modules[\\/]/, | |
| name: 'vendor', | |
| chunks: 'initial', | |
| }, |
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 { Component, createRef } from 'react'; | |
| import PropTypes from 'prop-types'; | |
| class Toggle extends Component { | |
| state = { | |
| on: false, | |
| } | |
| wrapper = createRef() |