Permalink
Browse files

Add prop to customise to Text style of timestamps (#942)

* 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 96f8cf8a7a55a4b5f68105679351af38dd8523bc
Showing with 11 additions and 2 deletions.
  1. +10 −2 src/Time.js
  2. +1 −0 src/__tests__/__snapshots__/Time.test.js.snap
View
@@ -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)}
@@ -66,6 +69,7 @@ Time.defaultProps = {
containerStyle: {},
textStyle: {},
timeFormat: TIME_FORMAT,
timeTextStyle: {},
};
Time.propTypes = {
@@ -80,4 +84,8 @@ Time.propTypes = {
right: Text.propTypes.style,
}),
timeFormat: PropTypes.string,
timeTextStyle: PropTypes.shape({
left: Text.propTypes.style,
right: Text.propTypes.style,
}),
};
@@ -26,6 +26,7 @@ exports[`should render <Time /> and compare with snapshot 1`] = `
"textAlign": "right",
},
undefined,
undefined,
]
}
>

0 comments on commit 96f8cf8

Please sign in to comment.