Skip to content

Commit

Permalink
bit more of commenting and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
teseo committed Jul 6, 2016
1 parent f9b9e0a commit 28a2e5e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
43 changes: 18 additions & 25 deletions components/Article.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/**
* Article Component
* https://github.com/facebook/react-native
* @flow
*/

//React components
import React, { Component } from 'react';
import {
View,
Expand All @@ -13,46 +12,40 @@ import {
Text,
} from 'react-native';

//utils
import colors from '../utils/colors';
import Dimensions from 'Dimensions';
const width = Dimensions.get('window').width;

const height = Dimensions.get('window').height;
const width = Dimensions.get('window').width;

const Article = ({
articleData
}) => {
/**
* Article component class
*/
export default Article = ({ articleData }) => {
return (
<ScrollView style={ styles.container }>
<Text style={ styles.section }>
{ articleData.sectionName }
</Text>
<Text style={ styles.headline }>
{ articleData.headline }
</Text>
<Text style={ styles.trailtext }>
{ articleData.trailText }
</Text>
<Text style={ styles.section }>{ articleData.sectionName }</Text>

<Text style={ styles.headline }>{ articleData.headline }</Text>

<Text style={ styles.trailtext }>{ articleData.trailText }</Text>

<View style={ styles.author }>
<Text style={ styles.bylineStyled }>
{ articleData.byline + '\n\n'}
</Text>
<Text style={ styles.date }>
{ articleData.date }
</Text>

<Text style={ styles.date }>{ articleData.date }</Text>
</View>

<View style={ styles.mediaObject }>
<Image source={ articleData.imageUrl } style={ styles.image }/>
</View>
<Text style={ styles.body }>
{ articleData.body}
</Text>

<Text style={ styles.body }>{ articleData.body }</Text>
</ScrollView>
);
};

export default Article;

const styles = StyleSheet.create({
container: {
backgroundColor: colors.white,
Expand Down
20 changes: 8 additions & 12 deletions components/ListArticle.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
* List Article Component
*/

import React, { Component } from 'react';
import {
//React components
import React, { Component } from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
Image,
View
} from 'react-native';
} from 'react-native';

//utis and assets
import colors from '../utils/colors';

const placeholder = require('../assets/default.png');

const ListArticle = ({ text, image, navState, navigator }) => {
export default ListArticle = ({ text, image, navState, navigator }) => {

return (
<TouchableOpacity
Expand All @@ -26,14 +24,12 @@ const ListArticle = ({ text, image, navState, navigator }) => {

<View style={ styles.mediaObject }>
<Image source={ image } style={ styles.image }/>
<Text style={ styles.text }> { text }</Text>
<Text style={ styles.text }>{ text }</Text>
</View>
</TouchableOpacity>
);
};

export default ListArticle;

const styles = StyleSheet.create({
mediaObject: {
flex: 1,
Expand Down
2 changes: 2 additions & 0 deletions utils/articleParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default function parseArticleHTMLText(body){
parsedBody = parsedBody.replace(/<aside (?:.)*?>(.)+<\/aside>/gm, "");
//remove rest of tags
parsedBody = parsedBody.replace(/<(?:.)*?>/gm, "");
//remove rest of tags
parsedBody = parsedBody.replace(/&nbsp;/g, " ");
//remove repeated spaces
parsedBody = parsedBody.replace(/(\ )+/g, ' ');

Expand Down

0 comments on commit 28a2e5e

Please sign in to comment.