Skip to content

Instantly share code, notes, and snippets.

Well done! You've found code #2, it is XYICD.
Were you looking for the real docs? https://www.chromatic.com/docs/visual-testing-addon
/* Reset.less
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc).
* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
html,
body {
margin: 0;
padding: 0;
}
h1,
h2,
@tmeasday
tmeasday / jest.config.js
Last active January 4, 2021 10:01
Using Jest transformer to test CSF stories
module.exports = {
// Make sure you match CSF files!
testMatch: ['**/__tests__/**/*.js', '**/?(*.)test.js', '**/?(*.)stories.js'],
// You'll probably want to add some code to mock out things for stories
setupFilesAfterEnv: ['<rootDir>/.storybook/setupFilesAfterEnv'],
transform: {
// This is the key bit!
@tmeasday
tmeasday / component.examples.md
Last active November 28, 2019 14:03
Storybook example file format

Simple API: export Component (for docs) and examples ("renderables")

import React from 'react';

import Component from 'somewhere';

export default Component;

export const variant1 = () => <Component variant="1" />;
import { configure } from '@kadira/storybook';
import '../src/index.css';
const req = require.context('../src', true, /.story.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
@tmeasday
tmeasday / index.js
Last active September 27, 2019 02:28
// This is a hard-coded value obtained via cURL, but in a real app
// you would read this from local storage (with localStorage.getItem(..))
// and set it on the `onLogin` handler.
let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiI1OGNlMThmNTAyMjZiODZlYmY4YTNjN2UifQ.94L8T58sxT4QHEduQnYVl_V3JrT0E6eGwrEJyu_0BDo";
const networkInterface = createNetworkInterface({
uri: `${REACT_APP_API_HOST}/graphql`,
});
networkInterface.use([
{
enum TaskState {
TASK_INBOX
TASK_PINNED
TASK_SNOOZED
TASK_ARCHIVED
}
type Task {
id: ID!
title: String!
const { executablePath, args } = require('chrome-aws-lambda');
const { spawnSync,execSync } = require('child_process');
const fullArgs = args.concat(['--no-sandbox', '--headless', '--disable-gpu', '--screenshot', 'https://kqdbudnrfd.tunnel.chromaticqa.com/iframe.html?selectedKind=basics%2FA&selectedStory=fonts']);
console.log('runningWithArgs: ' + fullArgs);
const screenshotResult = spawnSync(executablePath, fullArgs, { cwd: '/tmp', timeout: 25 * 1000 });
console.log('chrome command stdio: ' + screenshotResult.output.toString());
console.log('chrome command stderr: ' + screenshotResult.stderr.toString());
@tmeasday
tmeasday / Idea.md
Last active February 14, 2019 22:54
Docs mode "low profile" design
  1. Refactor each view layer to export a "story" component

(sort of like I imagined on this PR: storybookjs/storybook#3360)

So, you could this:

import React from 'react';
import { Story }  from '@storybook/react';
@tmeasday
tmeasday / api.js
Last active January 29, 2019 03:30
SB v5 API
// The idea is to maintain the `api.X` contract that allows us to change the internal store format without releasing a breaking change
import React from 'react';
import { addons, types } from '@storybook/addons';
import { ADDON_ID, PANEL_ID } from './constants';
addons.register(ADDON_ID, api => {
addons.add(PANEL_ID, {
type: types.PANEL,