Skip to content

Instantly share code, notes, and snippets.

View trotzig's full-sized avatar

Henric Trotzig trotzig

View GitHub Profile
import Button from './';
export const primary = () =>
<Button primary>Submit</Button>;
export const secondary = () =>
<Button secondary>Cancel</Button>;
export const disabled = () =>
<Button disabled>Send</Button>;
@trotzig
trotzig / happo-ci.bash
Created October 6, 2017 18:59
An example script for running happo in CI
#!/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 September 28, 2017 16:03
Summary of a discussion Gabe and I've had around happo

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 September 14, 2017 08:04
Ideas for a report format for happo

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>': {
 '': 'https://url/to/screenshot',
@trotzig
trotzig / proptypes.diff
Created May 18, 2017 12:02
Attempts at fixing custom proptypes
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,
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
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
*/
const REGEX_CONST_LET_VAR = /\A(const|let|var)\s+([\s\S]+?)\s*=\s*(w+?)(('|")([^\('|")]+)('|"));?\s*\Z/
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 March 15, 2017 19:59
Example of regex used in import-js before moving to babylon
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
\);?