-
Notifications
You must be signed in to change notification settings - Fork 11
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
Timepicker component #31
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5bda6bb
create new timepicker component
Hasmik8 335ec65
fix timepicker base.ts
Hasmik8 3c9bb71
fix timepicker issues
Hasmik8 61e0b51
fix timepicker issues
Hasmik8 9d09b5e
fix issues
Hasmik8 560a44f
update branch
Hasmik8 4647d15
test error fix
Hasmik8 47d4062
update branch && fix package.json
Hasmik8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { storiesOf } from '@storybook/react'; | ||
import React from 'react'; | ||
import { ThemedBackground } from '../../utils/storybook'; | ||
import { TimePicker } from './TimePicker'; | ||
|
||
storiesOf('TimePicker', module) | ||
// Litmus Portal | ||
.add('Litmus Portal', () => ( | ||
<ThemedBackground platform="litmus-portal"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</ThemedBackground> | ||
)) | ||
|
||
// Kubera Chaos | ||
.add('Kubera Chaos', () => ( | ||
<ThemedBackground platform="kubera-chaos"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</ThemedBackground> | ||
)) | ||
|
||
// Kubera Propel | ||
.add('Kubera Propel', () => ( | ||
<ThemedBackground platform="kubera-propel"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</ThemedBackground> | ||
)) | ||
|
||
// Kubera Portal | ||
.add('Kubera Portal', () => ( | ||
<ThemedBackground platform="kubera-portal"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</ThemedBackground> | ||
)) | ||
|
||
// Kubera Core | ||
.add('Kubera Core', () => ( | ||
<ThemedBackground platform="kubera-core"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</ThemedBackground> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'date-fns'; | ||
import React, { useState } from 'react'; | ||
import MomentUtils from '@date-io/moment'; | ||
import { | ||
MuiPickersUtilsProvider, | ||
KeyboardTimePicker, | ||
} from '@material-ui/pickers'; | ||
import { BaseTimePickerProps } from './base'; | ||
|
||
interface TimePickerProps extends BaseTimePickerProps { | ||
value?: string; | ||
} | ||
|
||
const TimePicker: React.FC<TimePickerProps> = ({ value }) => { | ||
const date = value ? value : '2020 12:30 PM'; | ||
const [selectedDate, handleDateChange] = useState<number>(Date.parse(date)); | ||
return ( | ||
<MuiPickersUtilsProvider utils={MomentUtils}> | ||
<KeyboardTimePicker | ||
margin="normal" | ||
id="time-picker" | ||
autoOk | ||
okLabel="Save" | ||
label="Time picker" | ||
value={selectedDate} | ||
data-testid="timepicker" | ||
onChange={(newDate: any) => handleDateChange(newDate)} | ||
KeyboardButtonProps={{ | ||
'aria-label': 'change time', | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
); | ||
}; | ||
export { TimePicker }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { KuberaThemeProvider } from '../../../theme'; | ||
import { TimePicker } from '../TimePicker'; | ||
|
||
describe('Timepicker component', () => { | ||
it('Renders', () => { | ||
const { getByTestId } = render( | ||
<KuberaThemeProvider platform="kubera-chaos"> | ||
<TimePicker onChange={() => console.log('Time Changed')} /> | ||
</KuberaThemeProvider> | ||
); | ||
|
||
expect(getByTestId('timepicker')).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { KeyboardTimePickerProps } from '@material-ui/pickers'; | ||
|
||
export type BaseTimePickerProps = Omit<KeyboardTimePickerProps, 'value'>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './TimePicker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would also need this as a peer dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hasmik8 we can add the same in
"peerDependencies": {}