- Must use Sprockets for requiring mustache templates.
- Mustache templates have to be compiled with can.mustache for compatibility with 2.0 and 3.0
- Must expose compiled templates under a namespace, defaults to the commonly used
JST
variable exposed in the main object (window
)
This file contains 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 {useLayoutEffect, useState} from 'react'; | |
const fontFaces = [ | |
['tangerine', new FontFace('"Tangerine", serif', 'url(https://fonts.googleapis.com/css?family=Tangerine)')] | |
] as const; | |
export function useFontsLoaded(types = ['tangerine']) { | |
const [fontsLoaded, setFontsLoaded] = useState(false); | |
const depTypes = types.join(' '); |
This file contains 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
interface PictureInPictureResizeEvent extends Event { | |
readonly target: PictureInPictureWindow; | |
} | |
interface PictureInPictureWindow { | |
readonly width: number; | |
readonly height: number; | |
onresize(this: PictureInPictureWindow, ev: PictureInPictureResizeEvent): void; | |
addEventListener( | |
type: 'resize', |
This file contains 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
checkGitFile() { | |
git ls-files --error-unmatch $1 > /dev/null 2>&1 | |
} | |
# checking for test existence of files using react hooks | |
filesUsingHooks=$(git diff --cached --name-only --diff-filter=ACR | grep -l -E '^import.+\<use(State|Effect|Context|Reducer|Callback|Memo|Ref|ImperativeHandle|LayoutEffect|DebugValue)' --include \*.js --exclude \*.\*.js) | |
if [ -n "$filesUsingHooks" ]; then | |
headline "Checking if your react hooks have tests" | |
for fileUsingHooks in "$filesUsingHooks" |
This file contains 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
// this check is borrowed from react | |
const isProxySupported = | |
typeof Proxy === 'function' && | |
// https://github.com/facebook/react/issues/12011 | |
!Object.isSealed(new Proxy({}, {})); | |
function createProxyEnvironment(shadowRoot) { | |
const doc = shadowRoot.ownerDocument; | |
const properties = { | |
document: doc, |
This file contains 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 unexpectedLifecycleMethods = ['componentDidMount', 'componentDidUpdate', 'componentWillUpdate', 'UNSAFE_componentWillUpdate', 'componentShouldReceiveProps', 'UNSAFE_componentShouldReceiveProps']; | |
class SSRComponent extends React.Component { | |
constructor(...args) { | |
super(...args); | |
unexpectedLifecycleMethods.forEach((methodName) => { | |
if (this.hasOwnProperty(methodName)) { | |
throw new Error(`Cannot declare '${methodName}' in a server-side-rendered component`); | |
} | |
}); |
This file contains 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
namespace :assets do | |
def load_apps | |
require File.expand_path('config/boot.rb', Rake.application.original_dir) | |
Padrino.mounted_apps | |
end | |
desc "Precompile all assets" | |
task :precompile => 'precompile:build' | |
namespace :precompile do |
This file contains 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
/** | |
* If the mixpanel cookie exists this user was in the site before, | |
* we have to consider him returning, only every 24 hours, just like GA. | |
*/ | |
var RETURNING_VISITOR = document.cookie.indexOf('_mixpanel') != -1; | |
// if the mixpanel cookie does not exists the user is considered new | |
if (!RETURNING_VISITOR) { | |
$.cookie('mp_visitor', true, { expires: 1, path: '/' }); | |
// else the user might not be returning. | |
} else if ($.cookie('mp_visitor') !== null) { |
This file contains 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
$.fn.times = function(callback) { | |
var i = 0; | |
do { callback(i); } while (this[0] > ++i); | |
}; |
This file contains 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
// | |
// Copyright (C) 2014 Proudsugar.com | |
// Author Luis Merino <[email protected]> | |
// | |
function Snooper() { | |
// used to keep tab on the sync (push-array) mixpanel fakes' | |
window.__mixpanel = {}; | |
// fake methods lists | |
this.stubs = 'track alias name_tag people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user'.split(' '); |
NewerOlder