Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to format time as Am Pm #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/__snapshots__/input-moment.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`render 1`] = `
<div
amPmFormat={false}
className="m-input-moment"
>
<div
Expand Down
2 changes: 2 additions & 0 deletions src/input-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Time from './time';

export default class InputMoment extends Component {
static defaultProps = {
amPmFormat: false,
prevMonthIcon: 'ion-ios-arrow-left',
nextMonthIcon: 'ion-ios-arrow-right',
minStep: 1,
Expand Down Expand Up @@ -73,6 +74,7 @@ export default class InputMoment extends Component {
minStep={this.props.minStep}
hourStep={this.props.hourStep}
onChange={this.props.onChange}
amPmFormat={this.props.amPmFormat}
/>
</div>

Expand Down
9 changes: 9 additions & 0 deletions src/less/time.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
padding-top: 50px;

.showtime {
position: relative;
text-align: center;
}

Expand Down Expand Up @@ -42,4 +43,12 @@
border-radius: 3px;
text-align: center;
}

.amPmText {
color: @color-blue;
font-size: 28px;
position: absolute;
right: 10px;
top: 26px;
}
}
9 changes: 7 additions & 2 deletions src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ export default class extends Component {
return (
<div className={cx('m-time', this.props.className)}>
<div className="showtime">
<span className="time">{m.format('HH')}</span>
<span className="time">
{this.props.amPmFormat ? m.format("h") : m.format("HH")}
</span>
<span className="separater">:</span>
<span className="time">{m.format('mm')}</span>
<span className="time">{m.format("mm")}</span>
{this.props.amPmFormat && (
<span className="amPmText">{m.format("A")}</span>
)}
</div>

<div className="sliders">
Expand Down