From 457d9468749a5514a560b531451c8ca07ad917b8 Mon Sep 17 00:00:00 2001 From: Gerigot Date: Sun, 13 Nov 2016 00:31:02 +0100 Subject: [PATCH] [TimePicker] Port component #4796 fixed lint errores --- docs/site/src/demos/pickers/SimpleTimePicker.js | 9 +++++++-- docs/site/src/demos/tables/EnhancedTable.js | 4 ++-- src/TimePicker/Clock.js | 5 ++--- src/TimePicker/ClockHours.js | 4 ++-- src/TimePicker/ClockMinutes.js | 2 +- src/TimePicker/TimePicker.js | 12 ++++-------- src/TimePicker/TimePicker.spec.js | 7 ++++--- src/TimePicker/TimePickerDialog.js | 4 +--- src/TimePicker/TimePickerDialog.spec.js | 2 +- src/TimePicker/index.js | 2 ++ src/utils/timeUtils.js | 2 +- 11 files changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/site/src/demos/pickers/SimpleTimePicker.js b/docs/site/src/demos/pickers/SimpleTimePicker.js index aca9d02fa14945..8a2981440310b5 100644 --- a/docs/site/src/demos/pickers/SimpleTimePicker.js +++ b/docs/site/src/demos/pickers/SimpleTimePicker.js @@ -1,14 +1,19 @@ // @flow weak import React from 'react'; -import TimeDisplay from 'material-ui/TimePicker/TimeDisplay'; import TimePicker from 'material-ui/TimePicker/TimePicker'; export default function BasicTimePicker() { return (
- + +
+
+ +
+
+
); } diff --git a/docs/site/src/demos/tables/EnhancedTable.js b/docs/site/src/demos/tables/EnhancedTable.js index 4ceecb53ee3f18..3277d0d04149cd 100644 --- a/docs/site/src/demos/tables/EnhancedTable.js +++ b/docs/site/src/demos/tables/EnhancedTable.js @@ -136,7 +136,7 @@ function EnhancedTableToolbar(props, context) { {numSelected > 0 ? ( {numSelected} selected ) : ( - Nutrition + Nutrition )}
@@ -144,7 +144,7 @@ function EnhancedTableToolbar(props, context) { {numSelected > 0 ? ( delete ) : ( - filter_list + filter_list )}
diff --git a/src/TimePicker/Clock.js b/src/TimePicker/Clock.js index 3f6342bec4a60e..d4904ffb775d03 100644 --- a/src/TimePicker/Clock.js +++ b/src/TimePicker/Clock.js @@ -8,7 +8,6 @@ import ClockHours from './ClockHours'; import ClockMinutes from './ClockMinutes'; export const styleSheet = createStyleSheet('Clock', (theme) => { - console.log(theme); return { clock: { userSelect: 'none', @@ -178,8 +177,8 @@ class Clock extends Component { format={this.props.format} affix={this.getAffix()} onSelectAffix={this.handleSelectAffix} - onSelectHour={this.setMode.bind(this, 'hour')} - onSelectMin={this.setMode.bind(this, 'minute')} + onSelectHour={() => { this.setMode('hour'); }} + onSelectMin={() => { this.setMode('minute'); }} />
diff --git a/src/TimePicker/ClockHours.js b/src/TimePicker/ClockHours.js index 1b2148331ccd62..0e0cbc6aedbacd 100644 --- a/src/TimePicker/ClockHours.js +++ b/src/TimePicker/ClockHours.js @@ -8,7 +8,7 @@ import ClockPointer from './ClockPointer'; import { getTouchEventOffsetValues, rad2deg } from '../utils/timeUtils'; -export const styleSheet = createStyleSheet('ClockHours', (theme) => { +export const styleSheet = createStyleSheet('ClockHours', () => { return { root: { height: '100%', @@ -60,7 +60,7 @@ class ClockHours extends Component { }; } - isMousePressed(event) { + isMousePressed = (event) => { if (typeof event.buttons === 'undefined') { return event.nativeEvent.which; } diff --git a/src/TimePicker/ClockMinutes.js b/src/TimePicker/ClockMinutes.js index 95836d1360345b..5e3feb45c9cef0 100644 --- a/src/TimePicker/ClockMinutes.js +++ b/src/TimePicker/ClockMinutes.js @@ -7,7 +7,7 @@ import ClockNumber from './ClockNumber'; import ClockPointer from './ClockPointer'; import { getTouchEventOffsetValues, rad2deg } from '../utils/timeUtils'; -export const styleSheet = createStyleSheet('ClockMinutes', (theme) => { +export const styleSheet = createStyleSheet('ClockMinutes', () => { return { root: { height: '100%', diff --git a/src/TimePicker/TimePicker.js b/src/TimePicker/TimePicker.js index 2eb9688760a86f..814945e5fe9954 100644 --- a/src/TimePicker/TimePicker.js +++ b/src/TimePicker/TimePicker.js @@ -32,10 +32,6 @@ class TimePicker extends Component { * The initial time value of the TimePicker. */ defaultTime: PropTypes.object, - /** - * Override the inline-styles of TimePickerDialog's body element. - */ - dialogBodyStyle: PropTypes.object, /** * Override the inline-styles of TimePickerDialog's root element. */ @@ -73,8 +69,10 @@ class TimePicker extends Component { /** * If true, uses ("noon" / "midnight") instead of ("12 a.m." / "12 p.m."). * - * It's technically more correct to refer to "12 noon" and "12 midnight" rather than "12 a.m." and "12 p.m." - * and it avoids confusion between different locales. By default (for compatibility reasons) TimePicker uses + * It's technically more correct to refer to "12 noon" and "12 midnight" + * rather than "12 a.m." and "12 p.m." + * and it avoids confusion between different locales. + * By default (for compatibility reasons) TimePicker uses * ("12 a.m." / "12 p.m."). */ pedantic: PropTypes.bool, @@ -182,7 +180,6 @@ class TimePicker extends Component { autoOk, cancelLabel, defaultTime, // eslint-disable-line no-unused-vars - dialogBodyStyle, dialogStyle, format, okLabel, @@ -215,7 +212,6 @@ class TimePicker extends Component { { this.dialogWindow = dialogWindow; }} - bodyStyle={dialogBodyStyle} initialTime={this.state.dialogTime} onAccept={this.handleAcceptDialog} format={format} diff --git a/src/TimePicker/TimePicker.spec.js b/src/TimePicker/TimePicker.spec.js index 72e15623263a81..d946d2e09a1d2e 100644 --- a/src/TimePicker/TimePicker.spec.js +++ b/src/TimePicker/TimePicker.spec.js @@ -1,11 +1,12 @@ +// @flow weak /* eslint-env mocha */ + import React from 'react'; -import {shallow} from 'enzyme'; -import {assert} from 'chai'; +import { assert } from 'chai'; import { createShallowWithContext } from 'test/utils'; import TimePicker from './TimePicker'; -import {addHours, formatTime} from '../utils/timeUtils'; +import { addHours, formatTime } from '../utils/timeUtils'; import { TextFieldInput } from '../TextField'; describe('', () => { diff --git a/src/TimePicker/TimePickerDialog.js b/src/TimePicker/TimePickerDialog.js index e08f5a13c7366c..f42d752f103052 100644 --- a/src/TimePicker/TimePickerDialog.js +++ b/src/TimePicker/TimePickerDialog.js @@ -9,7 +9,7 @@ import Clock from './Clock'; import { Dialog, DialogActions } from '../Dialog'; import Button from '../Button'; -export const styleSheet = createStyleSheet('TimePickerDialog', (theme) => { +export const styleSheet = createStyleSheet('TimePickerDialog', () => { return { dialogRoot: { fontSize: 14, @@ -23,7 +23,6 @@ export const styleSheet = createStyleSheet('TimePickerDialog', (theme) => { class TimePickerDialog extends Component { static propTypes = { autoOk: PropTypes.bool, - bodyStyle: PropTypes.object, cancelLabel: PropTypes.node, format: PropTypes.oneOf(['ampm', '24hr']), initialTime: PropTypes.object, @@ -92,7 +91,6 @@ class TimePickerDialog extends Component { render() { const { - bodyStyle, initialTime, onAccept, // eslint-disable-line no-unused-vars format, diff --git a/src/TimePicker/TimePickerDialog.spec.js b/src/TimePicker/TimePickerDialog.spec.js index f64ebc24d532ab..b09343186738e8 100644 --- a/src/TimePicker/TimePickerDialog.spec.js +++ b/src/TimePicker/TimePickerDialog.spec.js @@ -1,6 +1,6 @@ +// @flow weak /* eslint-env mocha */ import React from 'react'; -import { shallow } from 'enzyme'; import { createShallowWithContext } from 'test/utils'; import { expect } from 'chai'; import { spy, stub } from 'sinon'; diff --git a/src/TimePicker/index.js b/src/TimePicker/index.js index 57f9fc91cb772e..ec76703c340774 100644 --- a/src/TimePicker/index.js +++ b/src/TimePicker/index.js @@ -1 +1,3 @@ +/* eslint-disable flowtype/require-valid-file-annotation */ + export default from './TimePicker'; diff --git a/src/utils/timeUtils.js b/src/utils/timeUtils.js index 4db4721af0d22e..1aa24373f66311 100644 --- a/src/utils/timeUtils.js +++ b/src/utils/timeUtils.js @@ -36,7 +36,7 @@ export function formatTime(date, format = 'ampm', pedantic = false) { if (format === 'ampm') { const isAM = hours < 12; - hours = hours % 12; + hours %= 12; const additional = isAM ? ' am' : ' pm'; hours = (hours || 12).toString();