Skip to content

Commit

Permalink
Adding rough dashboard for diff results
Browse files Browse the repository at this point in the history
* Adding rough dashboard for diff results

* updating location of docs-differ images

* Adding zoom and summary

* Updating layout

Making the screenshot wrapping div take what available height there is
  • Loading branch information
LFDanLu authored Dec 8, 2021
1 parent 2d276ef commit 83c73d9
Show file tree
Hide file tree
Showing 14 changed files with 13,079 additions and 948 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# docs-differ
Created with CodeSandbox

## Getting Started
Run the following to generate a set of diff versus the base RSP docs site and spin up the comparison tool.

```
yarn diff-base <NEW_DOCS_URL>
```

The docs differ can be run independently against two user specified url link via:

```
yarn run-differ -b <BASE_URL> -c <NEW_URL>
```

The dashboard can then be started via:

```
yarn start
```
27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,41 @@
"main": "src/index.js",
"scripts": {
"clean": "rm -rf node_modules",
"start": "node src/differ.js"
"run-differ": "node src/differ.js",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"diff-base": "./scripts/generateDiff.sh"
},
"dependencies": {
"@adobe/react-spectrum": "latest",
"puppeteer": "^10.4.0",
"puppeteer-cluster": "^0.22.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"screenshots-diff": "^1.2.6"
},
"devDependencies": {
"nodemon": "1.18.4"
},
"keywords": ["website visual differ"],
"keywords": [
"website visual differ"
],
"bin": {
"docs-differ": "src/differ.js"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.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 added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
4 changes: 4 additions & 0 deletions scripts/generateDiff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn run-differ -b https://react-spectrum.adobe.com/ -c $1
yarn start
63 changes: 63 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
defaultTheme,
Flex,
Provider,
Slider,
Text,
View
} from '@adobe/react-spectrum';
import diffJSON from './docs-differ/diff/diff.json';
import React, {useState} from 'react';

function importAll(r) {
return r.keys().map(r);
}

const images = importAll(require.context('./docs-differ/diff', false, /\.(png)$/));
function App() {
let [position, setPosition] = useState(0);
let [zoom, setZoom] = useState(1);
let numImages = images.length;
let imgPath = images[position].default;
let summary = diffJSON.message;
summary = summary?.replace(/Alright, there was | But are they regressions or expected changes \?/g,'')

return (
<Provider theme={defaultTheme}>
<Flex direction="column" width="80%" height="100vh" margin="auto">
<Text marginTop="size-400" UNSAFE_style={{fontWeight: 'bold'}}>Summary: {summary}</Text>
<Slider
marginTop="size-100"
minValue={1}
maxValue={numImages}
value={position + 1}
onChange={(index) => setPosition(index - 1)}
label="Nth image diff displayed"
getValueLabel={(index) => `${index} of ${numImages} changes`}
width="50%" />
<Flex direction="column" gap="size-200" marginTop="size-600" marginBottom="size-300" minHeight="0px" flex={1}>
<Text UNSAFE_style={{fontWeight: 'bold'}}>File: {imgPath}</Text>
<Slider
label="Zoom"
value={zoom}
onChange={setZoom}
minValue={1}
maxValue={4} />
<div style={{overflow: 'auto', minHeight: "0px", flex: 1}} tabIndex={0}>
<img
alt={`image diff, file name: ${imgPath}`}
src={imgPath}
style={{
display: 'block',
maxWidth: '100%',
transform: `scale(${zoom})`,
transformOrigin: '0 0'
}} />
</div>
</Flex>
</Flex>
</Provider>
);
}

export default App;
6 changes: 3 additions & 3 deletions src/differ.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const {diffSites} = require('./screenDiff');
const {setupClusterAndCrawl} = require('./crawl');

// setting up the directories
const baselineDir = 'docs-differ/baseline';
const currentDir = 'docs-differ/current';
const diffDir = 'docs-differ/diff';
const baselineDir = 'src/docs-differ/baseline';
const currentDir = 'src/docs-differ/current';
const diffDir = 'src/docs-differ/diff';

/**
* Main execution loop:
Expand Down
13 changes: 13 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));
Loading

0 comments on commit 83c73d9

Please sign in to comment.