Skip to content

Commit

Permalink
refacto(prettier): Prettier format on root project & Example (#28)
Browse files Browse the repository at this point in the history
* Prettier shot

* Remove ExampleExpo from packagejson
  • Loading branch information
Marvin Frachet authored Oct 18, 2017
1 parent 58e3cc4 commit 1207fe1
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 113 deletions.
13 changes: 13 additions & 0 deletions Example/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "airbnb",
"plugins": ["react", "jsx-a11y", "import"],
"rules": {
"react/jsx-filename-extension": "off",
"jsx-a11y/img-has-alt": "off",
"jsx-a11y/href-no-hash": "off",
"import/no-extraneous-dependencies": "off"
},
"env": {
"jest": true
}
}
40 changes: 20 additions & 20 deletions Example/components/Card.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
import React, { PropTypes } from "react";
import Placeholder from "rn-placeholder";
import { View, Text, Image, StyleSheet } from "react-native";
import React, { PropTypes } from 'react';
import Placeholder from 'rn-placeholder';
import { View, Text, Image, StyleSheet } from 'react-native';

const DEFAULT_SIZE = 12;
const IMAGE_SIZE = 40;
const styles = StyleSheet.create({
card: {
padding: 20,
backgroundColor: "#ffffff",
backgroundColor: '#ffffff',
borderRadius: 2,
shadowColor: "#000000",
shadowColor: '#000000',
shadowOpacity: 0.3,
shadowRadius: 1,
shadowOffset: {
height: 1,
width: 0.3
width: 0.3,
},
marginBottom: DEFAULT_SIZE,
marginRight: DEFAULT_SIZE,
marginLeft: DEFAULT_SIZE
marginLeft: DEFAULT_SIZE,
},
media: {
height: IMAGE_SIZE,
width: IMAGE_SIZE,
marginRight: DEFAULT_SIZE
marginRight: DEFAULT_SIZE,
},
container: {
flex: 1,
flexDirection: "row"
flexDirection: 'row',
},
username: {
flex: 1,
color: "#3F51B5",
fontSize: 16
color: '#3F51B5',
fontSize: 16,
},
date: {
color: "#aaaaaa",
fontSize: 12
color: '#aaaaaa',
fontSize: 12,
},
content: {
marginTop: DEFAULT_SIZE,
lineHeight: DEFAULT_SIZE * 2,
color: "#444444"
}
color: '#444444',
},
});

const words = [
{
width: "20%"
width: '20%',
},
{
width: "40%"
width: '40%',
},
{
width: "40%"
}
width: '40%',
},
];

export default function Card({ image, username, content, isLoaded, date }) {
Expand Down Expand Up @@ -82,5 +82,5 @@ Card.propTypes = {
username: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
date: PropTypes.string.isRequired,
isLoaded: PropTypes.bool.isRequired
isLoaded: PropTypes.bool.isRequired,
};
1 change: 0 additions & 1 deletion Example/components/CustomPlaceholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const customPlaceholder = (props) => {
return <Text style={style}>I m a custom loader with props bgColor = {props.bgColor}</Text>;
};


customPlaceholder.propTypes = {
bgColor: PropTypes.string,
};
Expand Down
115 changes: 66 additions & 49 deletions Example/components/data.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,66 @@
export default [{
id: 1,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 2,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 3,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 4,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 5,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 6,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 7,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}, {
id: 8,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
}];
export default [
{
id: 1,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 2,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 3,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 4,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 5,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 6,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 7,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
{
id: 8,
image: 'https://i.stack.imgur.com/Oe5c6.jpg?s=128&g=1',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt',
username: 'Marvin Frachet',
date: '21, June 2017',
},
];
7 changes: 7 additions & 0 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@
"react": "16.0.0-alpha.12",
"react-native": "^0.48.4",
"rn-placeholder": "file:../rn-placeholder"
},
"devDependencies": {
"eslint": "^4.1.1",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0"
}
}
22 changes: 7 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
"type": "git",
"url": "https://github.com/mfrachet/rn-placeholder"
},
"description": "Display some placeholder stuff before rendering your text or media content in React Native",
"keywords": [
"react-native",
"ios",
"android",
"expo"
],
"description":
"Display some placeholder stuff before rendering your text or media content in React Native",
"keywords": ["react-native", "ios", "android", "expo"],
"author": "Marvin FRACHET <marvin.frachet@gmail.com> (https://github.com/mfrachet)",
"scripts": {
"format": "prettier-eslint --write \"src/**/*.js\"",
"format":
"prettier-eslint --write \"src/**/*.js\" && prettier-eslint --write \"Example/components/**/*.js\"",
"lint": "eslint ./src",
"test": "./node_modules/.bin/jest --coverage --no-cache",
"test:auto": "./node_modules/.bin/jest --watch"
Expand Down Expand Up @@ -46,12 +43,7 @@
},
"jest": {
"preset": "react-native",
"setupFiles": [
"./setup/test.setup.js"
],
"modulePathIgnorePatterns": [
"<rootDir>/Example/",
"<rootDir>/ExampleExpo/"
]
"setupFiles": ["./setup/test.setup.js"],
"modulePathIgnorePatterns": ["<rootDir>/Example/"]
}
}
26 changes: 13 additions & 13 deletions src/animation/shine.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from "react";
import { Animated, View, StyleSheet } from "react-native";
import PropTypes from "prop-types";
import React from 'react';
import { Animated, View, StyleSheet } from 'react-native';
import PropTypes from 'prop-types';

const styles = StyleSheet.create({
shine: {
width: 30,
position: "absolute",
height: "100%",
backgroundColor: "#ffffff",
opacity: 0.4
}
position: 'absolute',
height: '100%',
backgroundColor: '#ffffff',
opacity: 0.4,
},
});
/**
* Create a repetitive Shine animation
Expand All @@ -22,8 +22,8 @@ const Shine = ({ children }) => {
Animated.sequence([
Animated.timing(animation, {
toValue: 100,
duration: 750
})
duration: 750,
}),
]).start(() => {
start();
});
Expand All @@ -33,7 +33,7 @@ const Shine = ({ children }) => {

const marginLeft = animation.interpolate({
inputRange: [0, 100],
outputRange: ["0%", "100%"]
outputRange: ['0%', '100%'],
});

return (
Expand All @@ -45,11 +45,11 @@ const Shine = ({ children }) => {
};

Shine.propTypes = {
children: PropTypes.shape({})
children: PropTypes.shape({}),
};

Shine.defaultProps = {
children: null
children: null,
};

export default Shine;
27 changes: 12 additions & 15 deletions src/multiWords/multiWords.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import React from "react";
import { View, StyleSheet } from "react-native";
import PropTypes from "prop-types";
import Line from "./../line/line";
import React from 'react';
import { View, StyleSheet } from 'react-native';
import PropTypes from 'prop-types';
import Line from './../line/line';

const styles = StyleSheet.create({
container: {
flexDirection: "row"
}
flexDirection: 'row',
},
});

function MultiWords({ words, textSize }) {
const borderStyle = {
borderRightWidth: textSize,
borderRightColor: "transparent"
borderRightColor: 'transparent',
};

const lastIndex = words.length - 1;

return (
<View style={styles.container}>
{words.map((word, index) => (
<View
key={index}
style={[lastIndex !== index && borderStyle, { width: word.width }]}
>
<View key={index} style={[lastIndex !== index && borderStyle, { width: word.width }]}>
<Line textSize={textSize} color={word.color} />
</View>
))}
Expand All @@ -35,15 +32,15 @@ MultiWords.propTypes = {
words: PropTypes.arrayOf(
PropTypes.shape({
color: PropTypes.string,
width: PropTypes.string.isRequired
})
width: PropTypes.string.isRequired,
}),
),
textSize: PropTypes.number
textSize: PropTypes.number,
};

MultiWords.defaultProps = {
words: [],
textSize: 12
textSize: 12,
};

export default MultiWords;

0 comments on commit 1207fe1

Please sign in to comment.