Skip to content

Instantly share code, notes, and snippets.

Avatar

Henric Trotzig trotzig

View GitHub Profile
@trotzig
trotzig / happo-ci.bash
Created Oct 6, 2017
An example script for running happo in CI
View happo-ci.bash
#!/usr/local/bin/dock bash
# Generates and uploads Happo diffs for the differences between the previous
# and current commit.
set -euo pipefail
PREVIOUS_SHA="$(git rev-parse ${1-HEAD^})"
CURRENT_SHA="$(git rev-parse ${1-HEAD})"
echo "Previous SHA: ${PREVIOUS_SHA}"
echo "Current SHA: ${CURRENT_SHA}"
@trotzig
trotzig / happo_api_endpoints.md
Last active Sep 28, 2017
Summary of a discussion Gabe and I've had around happo
View happo_api_endpoints.md

Report format:

[{
  component: 'Button', // The name of the component
  variant: 'default', // e.g. 'blue', 'with overflow', 'large', 'without user profile'
  target: 'android', // the combination of platform and viewport. For web, this will be 'firefox-mobile', 'firefox-desktop', 'chrome-desktop', etc. 
  width: 88, // the width of the image, not the viewport
  height: 30, // the height of the image, not the viewport
@trotzig
trotzig / report-format.md
Last active Sep 14, 2017
Ideas for a report format for happo
View report-format.md

Ideas for a report format for happo

After running happo, a snapshot report file is either created or updated. In it, all tests you have specified are listed, with urls to the screenshots. Here's an example format:

{
   // snapshot-report.json
   '<component-name>': {
     '<variant>': {
       '<target>': 'https://url/to/screenshot',
@trotzig
trotzig / proptypes.diff
Created May 18, 2017
Attempts at fixing custom proptypes
View proptypes.diff
diff --git a/packages/brigade-core/src/test/types/BrigadePropTypes_spec.js b/packages/brigade-core/src/test/types/BrigadePropTypes_spec.js
index 06a395a..26d3749 100644
--- a/packages/brigade-core/src/test/types/BrigadePropTypes_spec.js
+++ b/packages/brigade-core/src/test/types/BrigadePropTypes_spec.js
@@ -7,30 +7,34 @@ import BrigadePropTypes from '../../types/BrigadePropTypes';
function typeCheckFail(declaration, value, message) {
const props = { testProp: value };
- const error = declaration(
- props,
View new-mac-address.sh
if [ ! -f .ORIGINAL_MAC_ADDRESS ]; then
ifconfig en0 | grep ether | cut -d' ' -f2 > .ORIGINAL_MAC_ADDRESS
echo "Backup of original MAC address saved in .ORIGINAL_MAC_ADDRESS"
fi
if [[ -z "$1" ]]; then
echo "Usage: ./new-mac-address.sh [generate|reset]"
exit 0
fi
View withContextWidth.jsx
import { addEventListener, removeEventListener } from 'consolidated-events';
import React, { PureComponent } from 'react';
/**
* HoC that injects a `contextWidth` prop to the component, equal to the
* available width in the current context
*
* @param {Object} Component
* @return {Object} a wrapped Component
*/
View const_let_var_pattern_plain.js
const REGEX_CONST_LET_VAR = /\A(const|let|var)\s+([\s\S]+?)\s*=\s*(w+?)(('|")([^\('|")]+)('|"));?\s*\Z/
View const_let_var_pattern.js
const REGEX_CONST_LET_VAR = XRegExp(`
\A
(?<declaration_keyword>const|let|var)\s+ # <declaration_keyword>
(?<assignment>.+?) # <assignment> variable assignment
\s*=\s*
(?<import_function>\w+?)\( # <import_function> variable assignment
(?<quote>'|\") # <quote> opening quote
(?<path>[^\\2\n]+) # <path> module path
\k<quote> # closing quote
\);?
@trotzig
trotzig / const_let_var_patttern.rb
Created Mar 15, 2017
Example of regex used in import-js before moving to babylon
View const_let_var_patttern.rb
REGEX_CONST_LET_VAR = /
\A
(?<declaration_keyword>const|let|var)\s+ # <declaration_keyword>
(?<assignment>.+?) # <assignment> variable assignment
\s*=\s*
(?<import_function>\w+?)\( # <import_function> variable assignment
(?<quote>'|") # <quote> opening quote
(?<path>[^\2\n]+) # <path> module path
\k<quote> # closing quote
\);?
View waypoint-with-children.diff
diff --git a/spec/waypoint_spec.js b/spec/waypoint_spec.js
index 2f7e316..d739cef 100644
--- a/spec/waypoint_spec.js
+++ b/spec/waypoint_spec.js
@@ -329,6 +329,46 @@ describe('<Waypoint>', function() {
});
});
+ describe('with children', () => {
+ beforeEach(() => {
You can’t perform that action at this time.