Skip to content

Commit

Permalink
Add prop to customise to Text style of timestamps (#942)
Browse files Browse the repository at this point in the history
* Add prop to customise to Text style of rendering times

* fix(Time) linting and test snapshot issues
  • Loading branch information
gianpaj authored and xcarpentier committed Sep 6, 2018
1 parent a44cd24 commit 96f8cf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import moment from 'moment';
import Color from './Color';
import { TIME_FORMAT } from './Constant';

export default function Time({ position, containerStyle, currentMessage, timeFormat, textStyle }, context) {
export default function Time(
{ position, containerStyle, currentMessage, timeFormat, textStyle, timeTextStyle },
context,
) {
return (
<View style={[styles[position].container, containerStyle[position]]}>
<Text style={[styles[position].text, textStyle[position]]}>
<Text style={[styles[position].text, textStyle[position], timeTextStyle[position]]}>
{moment(currentMessage.createdAt)
.locale(context.getLocale())
.format(timeFormat)}
Expand Down Expand Up @@ -66,6 +69,7 @@ Time.defaultProps = {
containerStyle: {},
textStyle: {},
timeFormat: TIME_FORMAT,
timeTextStyle: {},
};

Time.propTypes = {
Expand All @@ -80,4 +84,8 @@ Time.propTypes = {
right: Text.propTypes.style,
}),
timeFormat: PropTypes.string,
timeTextStyle: PropTypes.shape({
left: Text.propTypes.style,
right: Text.propTypes.style,
}),
};
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/Time.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports[`should render <Time /> and compare with snapshot 1`] = `
"textAlign": "right",
},
undefined,
undefined,
]
}
>
Expand Down

0 comments on commit 96f8cf8

Please sign in to comment.