Skip to content

Commit

Permalink
Merge branch 'master' into test-display-safety-net
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypnosphi authored Feb 19, 2018
2 parents 8b8cb71 + 7844961 commit ab15acc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exemptLabels:
- 'do not merge'
- 'needs review'
- 'high priority'
- dependencies:update

# Label to use when marking an issue as stale
staleLabel: inactive
Expand Down
26 changes: 24 additions & 2 deletions addons/storysource/src/StoryPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import { EVENT_ID } from './';

registerLanguage('jsx', jsx);

const styles = {
selections: {
backgroundColor: 'rgba(255, 242, 60, 0.2)',
},
panel: {
width: '100%',
},
};

export default class StoryPanel extends Component {
constructor(props) {
super(props);
Expand All @@ -23,9 +32,20 @@ export default class StoryPanel extends Component {
});
});

this.setSelectedStoryRef = this.setSelectedStoryRef.bind(this);
this.lineRenderer = this.lineRenderer.bind(this);
}

componentDidUpdate() {
if (this.selectedStoryRef) {
this.selectedStoryRef.scrollIntoView();
}
}

setSelectedStoryRef(ref) {
this.selectedStoryRef = ref;
}

createPart(rows, stylesheet, useInlineStyles) {
return rows.map((node, i) =>
createElement({
Expand All @@ -51,7 +71,9 @@ export default class StoryPanel extends Component {
return (
<span>
{start}
<div style={{ backgroundColor: 'rgba(255, 242, 60, 0.2)' }}>{selected}</div>
<div ref={this.setSelectedStoryRef} style={styles.selections}>
{selected}
</div>
{end}
</span>
);
Expand All @@ -67,7 +89,7 @@ export default class StoryPanel extends Component {
showLineNumbers="true"
style={darcula}
renderer={this.lineRenderer}
customStyle={{ width: '100%' }}
customStyle={styles.panel}
>
{this.state.source}
</SyntaxHighlighter>
Expand Down
5 changes: 5 additions & 0 deletions docs/src/pages/configurations/default-config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ import './styles.css';

> **Note:** this is plain CSS only. If you need a preprocessor like SASS, you need to [customize the webpack config](/configurations/custom-webpack-config/).
> **Warning:** storybooks for projects that use Angular CLI cannot import CSS by default. They must either [customize the webpack config](/configurations/custom-webpack-config/), or use the inline loader syntax:
> ```js
> import '!style-loader!css-loader!./styles.css';
> ```
### Image and Static File Support
You can also import images and media files directly via JavaScript.
Expand Down
Binary file modified integration/__image_snapshots__/angular-cli-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified integration/__image_snapshots__/cra-kitchen-sink-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified integration/__image_snapshots__/vue-kitchen-sink-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion integration/examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ const examples = [
{
name: 'cra-kitchen-sink',
storybookUrl: pathToCraKitchenSink,
storySelector: '#root *',
},
{
name: 'vue-kitchen-sink',
storybookUrl: pathToVueKitchenSink,
storySelector: '#root *',
},
{
name: 'angular-cli',
storybookUrl: pathToAngularKitchenSink,
storySelector: 'storybook-dynamic-app-root *',
},
];

examples.forEach(({ name, storybookUrl }) => {
examples.forEach(({ name, storybookUrl, storySelector }) => {
let browser = puppeteer.launch();
let page;

Expand All @@ -50,6 +53,8 @@ examples.forEach(({ name, storybookUrl }) => {

it(`Take screenshots for '${name}'`, async () => {
await page.goto(`file://${storybookUrl}`);
const iframe = page.mainFrame().childFrames()[0];
await iframe.waitFor(storySelector);
const screenshot = await page.screenshot({ fullPage: true });
expect(screenshot).toMatchImageSnapshot({
failureThreshold: 0.04, // 4% threshold,
Expand Down

0 comments on commit ab15acc

Please sign in to comment.