diff --git a/__tests__/tests/components/StateBadge.js b/__tests__/tests/components/StateBadge.js index 7a80a92d5..ae104c3a1 100644 --- a/__tests__/tests/components/StateBadge.js +++ b/__tests__/tests/components/StateBadge.js @@ -21,7 +21,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Open'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.green); + expect(wrapper.prop('color')).toEqual(colors.green); }); it('correctly renders with closed issue', () => { @@ -33,7 +33,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Closed'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.red); + expect(wrapper.prop('color')).toEqual(colors.red); }); it('correctly renders with open pull request', () => { @@ -45,7 +45,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Open'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.green); + expect(wrapper.prop('color')).toEqual(colors.green); }); it('correctly renders with closed pull request', () => { @@ -57,7 +57,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Closed'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.red); + expect(wrapper.prop('color')).toEqual(colors.red); }); it('correctly renders with merged pull request', () => { @@ -71,7 +71,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Merged'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.purple); + expect(wrapper.prop('color')).toEqual(colors.purple); }); it('correctly renders without issue', () => { @@ -83,7 +83,7 @@ describe('', () => { .childAt(0) .text() ).toEqual('Merged'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.purple); + expect(wrapper.prop('color')).toEqual(colors.purple); }); it('correctly renders with open type', () => { @@ -95,7 +95,7 @@ describe('', () => { .childAt(0) .text() ).toEqual(''); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.green); + expect(wrapper.prop('color')).toEqual(colors.green); }); it('correctly renders with closed type', () => { @@ -107,7 +107,7 @@ describe('', () => { .childAt(0) .text() ).toEqual(''); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.red); + expect(wrapper.prop('color')).toEqual(colors.red); }); it('correctly renders with closed type', () => { @@ -119,7 +119,7 @@ describe('', () => { .childAt(0) .text() ).toEqual(''); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.purple); + expect(wrapper.prop('color')).toEqual(colors.purple); }); it('correctly renders with custom text', () => { @@ -133,6 +133,6 @@ describe('', () => { .childAt(0) .text() ).toEqual('test text'); - expect(wrapper.prop('style')[2].backgroundColor).toEqual(colors.green); + expect(wrapper.prop('color')).toEqual(colors.green); }); }); diff --git a/src/components/issue-description.component.js b/src/components/issue-description.component.js index 0e3ef608b..f39a00d35 100644 --- a/src/components/issue-description.component.js +++ b/src/components/issue-description.component.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { StyleSheet, ActivityIndicator } from 'react-native'; +import { ActivityIndicator } from 'react-native'; import { ListItem } from 'react-native-elements'; import Parse from 'parse-diff'; import styled from 'styled-components'; @@ -15,13 +15,6 @@ import { translate, relativeTimeToNow } from 'utils'; import { colors, fonts, normalize } from 'config'; import { v3 } from 'api'; -const styles = StyleSheet.create({ - badge: { - alignItems: 'flex-end', - justifyContent: 'center', - }, -}); - const HeaderContainer = styled.View` flex-direction: row; align-items: center; @@ -164,7 +157,6 @@ export class IssueDescription extends Component { (issue.pull_request && !isPendingCheckMerge && ( props.color}; +`; + +const BadgeText = styled.Text` + color: ${colors.white}; + font-size: ${normalize(12)}; + ${fonts.fontPrimarySemiBold}; +`; export const StateBadge = ({ issue, @@ -58,19 +47,18 @@ export const StateBadge = ({ issueText = translate('issue.main.states.closed', locale); } - let issueStyle = {}; - - if (issueState === 'merged') { - issueStyle = styles.mergedIssue; - } else if (issueState === 'open') { - issueStyle = styles.openIssue; - } else if (issueState === 'closed') { - issueStyle = styles.closedIssue; - } + const stateColor = { + merged: colors.purple, + open: colors.green, + closed: colors.red, + }; + const issueStateColor = stateColor[issueState] + ? stateColor[issueState] + : colors.gray; return ( - - {issueText} - + + {issueText} + ); };