Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

36615 primary png gif #5

Merged
merged 5 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
[
"react-app",
{
"absoluteRuntime": false
}
]
]
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: npm run jest
- run: npm run test:ci
- run: npm run eslint
- run: npm run prettier
13,377 changes: 2,395 additions & 10,982 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "apm-mimas",
"description": "A React component that takes an image endpoint from APM's APIs and returns a proper image with srcset.",
"version": "0.1.2",
"version": "0.1.3",
"main": "dist/index.js",
"module": "dist/index.js",
"license": "MIT",
Expand All @@ -20,16 +20,14 @@
"url": "https://github.com/APMG/apm-mimas"
},
"scripts": {
"start": "react-scripts start",
"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__",
"test": "react-scripts test",
"jest": "jest",
"eject": "react-scripts eject",
"eslint": "eslint ./src/**/**.js",
"eslint:fix": "eslint ./src/**/**.js --fix",
"prettier": "prettier --check './src/**/**.js'",
"prettier:fix": "prettier --check './src/**/**.js' --write",
"hook:setup": "sh setup-hooks.sh"
"build": "webpack --mode production",
"start": "webpack --mode development",
"test": "jest --watch",
"test:ci": "jest",
"storybook": "start-storybook -p 9001 -c .storybook",
"eslint": "eslint .",
"prettier": "prettier --check '**/**.js'",
"prettier:fix": "prettier --check '**/**.js' --write"
},
"husky": {
"hooks": {
Expand All @@ -47,19 +45,25 @@
"not op_mini all"
],
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"classnames": "^2.2.6",
"eslint": "^5.13.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"jest": "^24.7.1",
"jest-prop-type-error": "^1.1.0",
"prettier": "1.16.4",
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-scripts": "2.1.5",
"react-testing-library": "^5.8.0"
"react-testing-library": "^5.8.0",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
},
"dependencies": {
"husky": "^1.3.1"
Expand Down
7 changes: 6 additions & 1 deletion src/lib/Image/Image.js → src/Image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import PropTypes from 'prop-types';
// Ideally, this component will take in an image object formatted by our images API and spit out an image with a proper srcset. However, I also thought I should provide a couple of fallback options, in case you want to use an image from somewhere else entirely: fallbackSrcSet and fallbackSrc. The last one will just create a normal img tag, so I really don't recommend it.

function generateSrcSet(imageProps, props) {
props.image.aspect_ratios[props.aspectRatio].instances.forEach(
let aspectRatio =
props.image.aspect_ratios[props.aspectRatio] !== null
? props.aspectRatio
: 'uncropped';

props.image.aspect_ratios[aspectRatio].instances.forEach(
(image, i, dataSet) => {
let set = `${image.url} ${image.width}w`;
if (i !== dataSet.length - 1) {
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions src/Image/testdata/gif.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"aspect_ratios": {
"square": null,
"uncropped": {
"instances": [
{
"url": "https://img.apmcdn.org/dev/4211eee93770e5c0d2b2dab5523f7457a34796c1/uncropped/fb16d0-2019-02-arrested-devo-pants.gif",
"width": 500,
"height": 234,
"__typename": "Instance"
}
],
"__typename": "AspectRatio"
},
"__typename": "AspectRatioList"
},
"contentArea": "TBTL",
"dateTaken": null,
"dateline": "",
"fallback": "https://img.apmcdn.org/dev/4211eee93770e5c0d2b2dab5523f7457a34796c1/uncropped/fb16d0-2019-02-arrested-devo-pants.gif",
"longCaption": "Arrested Devo Pants",
"shortCaption": "Arrested Devo Pants",
"xid": 300227,
"__typename": "Image"
}
File renamed without changes.
21 changes: 2 additions & 19 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
import React from 'react';
import { render } from 'react-dom';
import { Image } from './lib';
import { image } from './lib/Image/testdata/image';

const App = () => (
<div>
<h1>Hello React</h1>
<Image
image={image}
aspectRatio="square"
alt="this image is from our test data"
elementClass="exampleImage"
sizes="(min-width: 1000px) 1000px"
/>
</div>
);

render(<App />, document.getElementById('root'));
import Image from './Image/Image';
export { Image };
2 changes: 0 additions & 2 deletions src/lib/index.js

This file was deleted.

23 changes: 23 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require('path');

module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve('dist'),
filename: 'index.js',
libraryTarget: 'commonjs2'
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
use: 'babel-loader'
}
]
},
resolve: {
extensions: ['.js']
}
};