@bufferapp/components
Advanced tools
Comparing version 0.4.15-beta03 to 0.4.15-beta04
@@ -9,3 +9,30 @@ import React, { PropTypes } from 'react'; | ||
/* eslint-disable react/prop-types */ | ||
/* | ||
0: 12 midnight am | ||
1: 1 am | ||
2: 2 a | ||
3: 3 a | ||
4: 4 a | ||
5: 5 a | ||
6: 6 a | ||
7: 7 a | ||
8: 8 a | ||
9: 9 a | ||
10: 10 a | ||
11: 11 a | ||
12: 12 noon pm | ||
13: 1 p | ||
14: 2 p | ||
15: 3 p | ||
16: 4 p | ||
17: 5 p | ||
18: 6 p | ||
19: 7 p | ||
20: 8 p | ||
21: 9 p | ||
22 10 p | ||
23: 11 p | ||
*/ | ||
const renderAmPm = ({ value, onChange }) => | ||
@@ -16,3 +43,3 @@ <select | ||
...value, | ||
hours: e.target.value === 'am' && value.hours - 12 >= 0 | ||
hours: e.target.value === 'am' && value.hours < 12 | ||
? value.hours - 12 | ||
@@ -28,2 +55,11 @@ : value.hours + 12, | ||
const displayHour = (hour, select24Hours) => { | ||
if (select24Hours) { | ||
return hour; | ||
} else if (hour === 0) { | ||
return 12; | ||
} | ||
return hour % 12; | ||
}; | ||
const InputTime = ({ | ||
@@ -46,8 +82,11 @@ select24Hours, | ||
> | ||
{genArray(0, select24Hours ? 23 : 11).map(hour => | ||
{genArray( | ||
select24Hours || value.hours < 12 ? 0 : 12, | ||
select24Hours || value.hours > 11 ? 23 : 11, | ||
).map(hour => | ||
<option | ||
key={!select24Hours && value.hours > 11 ? hour + 12 : hour} | ||
value={!select24Hours && value.hours > 11 ? hour + 12 : hour} | ||
key={hour} | ||
value={hour} | ||
> | ||
{leftPadTimeUnit(select24Hours ? hour : hour + 1)} | ||
{leftPadTimeUnit(displayHour(hour, select24Hours))} | ||
</option>) | ||
@@ -54,0 +93,0 @@ } |
{ | ||
"name": "@bufferapp/components", | ||
"version": "0.4.15-beta03", | ||
"version": "0.4.15-beta04", | ||
"description": "A shared set of UI Components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1490360
5175