diff --git a/.all-contributorsrc b/.all-contributorsrc index bd08220c3..811fc1dc8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -554,6 +554,13 @@ "contributions": [ "code" ] + }, + { + "login": "josenaranjo", + "name": "Jose Luis Naranjo", + "avatar_url": "https://avatars2.githubusercontent.com/u/3025600?v=4", + "profile": "https://co.linkedin.com/in/josenaranjo/en", + "contributions": [] } ] } diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7c37ca584..8ae06d21d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,5 +13,5 @@ Thank you to all the people who have already contributed to GitPoint! | [
Vitaliy Kanev](https://github.com/vitalkanev)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=vitalkanev "Documentation") | [
Peter Dave Hello](https://www.peterdavehello.org/)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=PeterDaveHello "Documentation") [πŸ”§](#tool-PeterDaveHello "Tools") | [
Ernoff](https://github.com/Ernoff)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=Ernoff "Code") [πŸ›](https://github.com/gitpoint/git-point/issues?q=author%3AErnoff "Bug reports") | [
Matthew Brandly](http://words.brandly.me/about/)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=brandly "Code") | [
JoΓ£o Fonseca](https://github.com/Jpfonseca)
[🌍](#translation-Jpfonseca "Translation") | [
Arjun Curat](https://github.com/acurat)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=acurat "Documentation") | | [
siderio2](https://github.com/siderio2)
[🌍](#translation-siderio2 "Translation") | [
Kodo Verkisto](https://github.com/kodisto)
[🌍](#translation-kodisto "Translation") | [
Sarah Vessels](http://sarahvessels.com/)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=cheshire137 "Documentation") | [
Thales Sousa](https://github.com/tminussi)
[🌍](#translation-tminussi "Translation") | [
Aseem Sood](https://github.com/asood123)
[πŸ“–](https://github.com/gitpoint/git-point/commits?author=asood123 "Documentation") | [
Eliott hauteclair](https://eliott.be)
[🌍](#translation-Eliottiosdevs "Translation") | | [
Peter Blazejewicz](http://www.linkedin.com/in/peterblazejewicz)
[🌍](#translation-peterblazejewicz "Translation") | [
Eric Adamski](https://github.com/ericadamski)
[πŸ›](https://github.com/gitpoint/git-point/issues?q=author%3Aericadamski "Bug reports") | [
Jouderian Nobre Junior](https://github.com/jouderianjr)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=jouderianjr "Code") | [
Phi Dong](http://www.phidong.com)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=pdong "Code") | [
John Patrick Salcedo](https://github.com/jpls93)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=jpls93 "Code") | [
Γ“scar Carretero](https://github.com/ocarreterom)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=ocarreterom "Code") | -| [
Dyesse YUMBA](https://github.com/dyesseyumba)
[πŸ”§](#tool-dyesseyumba "Tools") | [
Bink](https://binkpitch.me/)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=binkpitch "Code") | [
khvilaboa](https://github.com/khvilaboa)
[🌍](#translation-khvilaboa "Translation") | [
James Glover](http://jamesmglover.com)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=jglover "Code") | +| [
Dyesse YUMBA](https://github.com/dyesseyumba)
[πŸ”§](#tool-dyesseyumba "Tools") | [
Bink](https://binkpitch.me/)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=binkpitch "Code") | [
khvilaboa](https://github.com/khvilaboa)
[🌍](#translation-khvilaboa "Translation") | [
James Glover](http://jamesmglover.com)
[πŸ’»](https://github.com/gitpoint/git-point/commits?author=jglover "Code") | [
Jose Luis Naranjo](https://co.linkedin.com/in/josenaranjo/en)
| diff --git a/README.md b/README.md index e33cd78e3..f8b2bdc2f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ ## Introduction [![Build Status](https://img.shields.io/travis/gitpoint/git-point.svg?style=flat-square)](https://travis-ci.org/gitpoint/git-point) -[![All Contributors](https://img.shields.io/badge/all_contributors-58-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-59-orange.svg?style=flat-square)](#contributors) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/) [![Gitter chat](https://img.shields.io/badge/chat-on_gitter-008080.svg?style=flat-square)](https://gitter.im/git-point) diff --git a/src/components/code-line.component.js b/src/components/code-line.component.js index 3e22413cd..0a051b68d 100644 --- a/src/components/code-line.component.js +++ b/src/components/code-line.component.js @@ -2,66 +2,81 @@ /* eslint-disable no-nested-ternary */ import React, { Component } from 'react'; -import { View, Text, StyleSheet, Dimensions } from 'react-native'; +import { Text, Dimensions } from 'react-native'; import SyntaxHighlighter from 'react-native-syntax-highlighter'; import { getLanguage } from 'lowlight'; import { github as GithubStyle } from 'react-syntax-highlighter/dist/styles'; -import { colors, fonts, normalize } from 'config'; - -const styles = StyleSheet.create({ - container: { - flexDirection: 'row', - }, - wrapper: { - flexDirection: 'row', - flex: 1, - }, - codeLineContainer: { - minWidth: Dimensions.get('window').width - 80, - flex: 0.85, - }, - codeLine: { - ...fonts.fontCode, - fontSize: normalize(11), - paddingHorizontal: 10, - paddingVertical: 3, - }, - newChunkLineNumbers: { - backgroundColor: colors.codeChunkLineNumberBlue, - }, - newChunkLineContainer: { - backgroundColor: colors.codeChunkBlue, - }, - newChunkLine: { - color: colors.grey, - }, - addLine: { - backgroundColor: colors.addCodeGreen, - }, - addLineNumbers: { - backgroundColor: colors.addCodeLineNumberGreen, - }, - delLine: { - backgroundColor: colors.delCodeRed, - }, - delLineNumbers: { - backgroundColor: colors.delCodeLineNumberRed, - }, - lineNumbers: { - width: 80, - paddingLeft: 10, - paddingVertical: 3, - flexDirection: 'row', - justifyContent: 'space-between', - }, - codeLineNumber: { - ...fonts.fontCode, - fontSize: normalize(11), - flex: 1, - alignItems: 'center', - color: colors.grey, - }, -}); +import { colors, normalize, styledFonts } from 'config'; +import styled, { css } from 'styled-components/native'; + +function addOrDelLineColors(change) { + const lineColors = { + lineNumbers: '', + line: '', + }; + + if (change.type === 'add') { + lineColors.lineNumbers = colors.addCodeLineNumberGreen; + lineColors.line = colors.addCodeGreen; + } else if (change.type === 'del') { + lineColors.lineNumbers = colors.delCodeLineNumberRed; + lineColors.line = colors.delCodeRed; + } + + return lineColors; +} + +const Container = styled.View` + flex-direction: row; +`; + +const Wrapper = styled.View` + flex-direction: row; + flex: 1; +`; + +const CodeLineContainer = styled.View` + min-width: ${Dimensions.get('window').width - 80} + flex: 0.85; + background-color: ${props => + props.newChunk + ? colors.codeChunkBlue + : addOrDelLineColors(props.change).line} + } +`; + +const CodeLineStyled = styled.Text` + font-family: ${styledFonts.fontCode} + font-size: ${normalize(11)} + padding: 3 10; + ${props => + props.newChunk && + css` + color: ${colors.grey}; + `} +`; + +const LineNumbers = styled.View` + width: 80; + padding-left: 10; + padding: 3; + flex-direction: row; + justify-content: space-between; + background-color: ${props => + props.newChunk + ? colors.codeChunkLineNumberBlue + : addOrDelLineColors(props.change).lineNumbers}; +`; + +const CodeLineNumber = styled.Text` + font-family: ${styledFonts.fontCode} + font-size: ${normalize(11)} + flex: 1; + align-items: center; + color: ${colors.grey} +`; + +const SyntaxHighlighterStyled = CodeLineStyled.withComponent(SyntaxHighlighter); export class CodeLine extends Component { props: { @@ -84,62 +99,45 @@ export class CodeLine extends Component { }; return ( - - - - + + + + {change.type === 'del' ? change.ln : change.type === 'normal' ? change.ln1 : change.type === 'add' ? '' : '...'} - - + + {change.type === 'add' ? change.ln : change.type === 'normal' ? change.ln2 : change.type === 'del' ? '' : '...'} - - - - + + + + {(newChunk || !this.isKnownType(language)) && ( - - {change.content} - + {change.content} )} {this.isKnownType(language) && ( - {change.content} - + )} - - - + + + ); } } diff --git a/src/config/index.js b/src/config/index.js index 1b895838e..446fb03b9 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -3,3 +3,4 @@ export * from './colors'; export * from './fonts'; export * from './normalize-text'; export * from './common'; +export * from './styled-fonts'; diff --git a/src/config/styled-fonts.js b/src/config/styled-fonts.js new file mode 100644 index 000000000..9191134ea --- /dev/null +++ b/src/config/styled-fonts.js @@ -0,0 +1,8 @@ +export const styledFonts = { + fontPrimaryLight: 'Nunito-Light', + fontPrimary: 'Nunito-Regular', + fontPrimaryItalic: 'Nunito-Italic', + fontPrimarySemiBold: 'Nunito-SemiBold', + fontPrimaryBold: 'Nunito-Bold', + fontCode: 'Menlo', +};