Skip to content

refactor(mention-area): migrate mention-area to styled component#553

Merged
andrewda merged 6 commits intogitpoint:masterfrom
binkpitch:532-mention-area
Oct 24, 2017
Merged

refactor(mention-area): migrate mention-area to styled component#553
andrewda merged 6 commits intogitpoint:masterfrom
binkpitch:532-mention-area

Conversation

@binkpitch
Copy link
Copy Markdown
Contributor

#532
This migrate mention area component to styled component.

Note that, I am not really sure about how to refractor this part.

<Animated.View style={[{ ...this.props.style }, { height: this.state.height }]}> ... </Animated.View>

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.

I guess you can refactor as following. But not sure whether it is the best practice. (cc @alejandronanez)

const StyledAnimatedView = styled(Animated.View)`
    ${({style}) => style}
`

// in render
<StyledAnimatedView style={{...this.props.style, height: this.state.height}}></StyledAnimatedView>


const DisplayNameText = styled.Text`
fontSize: ${normalize(12)};
${{ ...fonts.fontPrimary }}'
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.

@binkpitch Can we simply write ${fonts.fontPrimary} here? Please correct me if I am wrong. 😅

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.

@chinesedfan I think ${{ ...fonts.fontPrimary }} can be change to ${fonts.fontPrimary}. I'll make a new commit to fix that.


const UserDetailsBox = styled.View`
flex: 1;
margin-left: 5;
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.

If just use margin: 5;, will it work?

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.

@lex111 When I use margin: 5;, I got the following error. Seperating margin into margin-left, margin-right, margin-top, and, margin-buttom works but I have no idea why.
screen shot 2560-10-22 at 20 35 57

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.

@lex111 It is due to styled component's shorthands properties restriction.

@alejandronanez
Copy link
Copy Markdown
Member

@binkpitch I haven't dealt with that case before, but what @chinesedfan sounds good to me.

Copy link
Copy Markdown
Member

@alejandronanez alejandronanez left a comment

Choose a reason for hiding this comment

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

Can you please try what @chinesedfan suggested related to Animated.View?
Thanks!

@binkpitch
Copy link
Copy Markdown
Contributor Author

@alejandronanez Sorry for the late reply, I just woke up. Sure, I'll make a commit of what @chinesedfan suggested.

@alejandronanez
Copy link
Copy Markdown
Member

@binkpitch no rush at all! Let us know how this goes.

@binkpitch
Copy link
Copy Markdown
Contributor Author

binkpitch commented Oct 23, 2017

@alejandronanez I have changed Animated.View to StyledAnimatedView in my last commit. Does this look good to you?

Copy link
Copy Markdown
Member

@alejandronanez alejandronanez left a comment

Choose a reason for hiding this comment

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

@binkpitch it does! thanks a lot!

Copy link
Copy Markdown
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

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

👏

@andrewda andrewda merged commit 43e629d into gitpoint:master Oct 24, 2017
@binkpitch binkpitch deleted the 532-mention-area branch October 24, 2017 02:26
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