Skip to content

Refactor StateBadge component#715

Merged
housseindjirdeh merged 5 commits intogitpoint:masterfrom
rkpasia:refactor-state-badge
Feb 16, 2018
Merged

Refactor StateBadge component#715
housseindjirdeh merged 5 commits intogitpoint:masterfrom
rkpasia:refactor-state-badge

Conversation

@rkpasia
Copy link
Copy Markdown
Contributor

@rkpasia rkpasia commented Feb 3, 2018

Question Response
Version? v1.4.1
Devices tested iPhone 6
Related ticket? #532

Screenshots

Before After
before after
before after

Description

This PR is related with the update of the StateBadge component. Now it uses styled-components as a driver to style the user interface.

I kept the possibility to override the styles of the StateBadge through the style prop. The object that it accept it's a StyleSheet object.

Also I removed from issue-description component the object styles. It was only related to the StateBadge component but the styles declared didn't influenced the UI placement of the latter.

machour
machour previously requested changes Feb 3, 2018
Copy link
Copy Markdown
Member

@machour machour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rkpasia, thank you for tackling this.
I left you some comments, could you review them?
Also, make sure the tests passes ;)

@@ -1,5 +1,5 @@
import React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import styled from 'styled-components/native';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use '/native' anymore, just use this:

import styled from 'styled-components';

issueStateColor = colors.red;
break;
default:
issueStateColor = colors.gray;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you do something like this instead for a better readability?

const stateColor = {
  merged: colors.purple,
  open: colors.green,
  closed: colors.red,
};
const issueStateColor = stateColor[issueState] ? stateColor[issueState] : colors.gray;

import { colors, fonts, normalize } from 'config';
import { v3 } from 'api';

const styles = StyleSheet.create({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was used just for the Badge styles so I removed it. I don't think is needed here, also styled-components are already imported.
Also the styles defined for the Badge don't change the UI so they are useless for what I can saw.

<View style={[styles.badge, style, issueStyle]}>
<Text style={styles.text}>{issueText}</Text>
</View>
<Badge color={issueStateColor} style={style}>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not passing style anymore from issue-description.component.js, but you're still using the prop here .. Could you give it a second look?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought to get completely rid of the style prop but it could still be useful in case there is a need to override something from a parent component without modifying again this one instead.

But it's up for discussion, don't know if it is really needed or not so I left it there 😆

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prop style is also used in repository-section-title.component.js, which is a useless component. I remembered @housseindjirdeh confirmed that in somewhere, but I forgot the detail issue/pr number. I will collect feedbacks in #725.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was on Gitter, I added the relevant screenshot in the issue you opened.

@rkpasia
Copy link
Copy Markdown
Contributor Author

rkpasia commented Feb 3, 2018

Don't really know how the tests work yet 😆 I'll get through them tomorrow 👍

@machour
Copy link
Copy Markdown
Member

machour commented Feb 3, 2018

No worries mate! We use jest for testing, and everything is located under <root>/__tests__
You can run the full test suite in your console like this:

yarn test

or you can run a single test like this (which is waaaayyyy faster when fixing something 😄) :

yarn test __tests__/tests/components/StateBadge.js

happy debugging 🕺

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 8, 2018

Coverage Status

Coverage decreased (-0.3%) to 43.734% when pulling d339c2e on rkpasia:refactor-state-badge into 3d793a5 on gitpoint:master.

@rkpasia
Copy link
Copy Markdown
Contributor Author

rkpasia commented Feb 12, 2018

What should I do to augment the coverage?

@machour machour dismissed their stale review February 12, 2018 18:02

Don't worry about coverage for now. Dismissing the review so I remember to re-check this PR (and especially your comments)

Copy link
Copy Markdown
Member

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in iPhone 6 simulator. LGTM!

Copy link
Copy Markdown
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thank you @rkpasia 🙏

@housseindjirdeh housseindjirdeh merged commit 600f179 into gitpoint:master Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants