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
Expand Up @@ -9,10 +9,13 @@ import moment from 'moment';
import Color from './Color'; import Color from './Color';
import { TIME_FORMAT } from './Constant'; 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 ( return (
<View style={[styles[position].container, containerStyle[position]]}> <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) {moment(currentMessage.createdAt)
.locale(context.getLocale()) .locale(context.getLocale())
.format(timeFormat)} .format(timeFormat)}
Expand Down Expand Up @@ -66,6 +69,7 @@ Time.defaultProps = {
containerStyle: {}, containerStyle: {},
textStyle: {}, textStyle: {},
timeFormat: TIME_FORMAT, timeFormat: TIME_FORMAT,
timeTextStyle: {},
}; };


Time.propTypes = { Time.propTypes = {
Expand All @@ -80,4 +84,8 @@ Time.propTypes = {
right: Text.propTypes.style, right: Text.propTypes.style,
}), }),
timeFormat: PropTypes.string, 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
Expand Up @@ -26,6 +26,7 @@ exports[`should render <Time /> and compare with snapshot 1`] = `
"textAlign": "right", "textAlign": "right",
}, },
undefined, undefined,
undefined,
] ]
} }
> >
Expand Down

0 comments on commit 96f8cf8

Please sign in to comment.