-
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
Conversation
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
package.json
Outdated
"@date-io/date-fns": "^1.3.13", | ||
"@date-io/moment": "^1.3.13", |
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.
These are packages for Date Picker, we are building a time picker so this is not required here.
package.json
Outdated
"date-fns": "^2.16.1", | ||
"moment": "^2.29.1", |
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.
Again these packages are for date pickers, not time pickers. You'd only need KeyboardTimePicker
from @material-ui/pickers
"@material-ui/core": "^4.10.2", | ||
"@material-ui/pickers": "^3.2.10", |
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": {}
value?: Date; | ||
} | ||
|
||
const BaseTimePicker: React.FC<TimePickerProps> = ({ value }) => { |
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.
const BaseTimePicker: React.FC<TimePickerProps> = ({ value }) => { | |
const TimePicker: React.FC = () => { |
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.
@S-ayanide no need to pass this value via props?
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.
Date is not required to be passed as props
interface TimePickerProps extends BaseTimePickerProps { | ||
value?: Date; | ||
} |
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.
Time Picker will not take a Date
src/core/Timepicker/style.ts
Outdated
import { makeStyles } from '@material-ui/core'; | ||
|
||
const useStyles = makeStyles(() => ({})); | ||
|
||
export { useStyles }; |
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.
If there are no styles required we can simply not have a styles.ts
file instead!
src/core/Timepicker/index.ts
Outdated
@@ -0,0 +1 @@ | |||
export * from './BaseTimePicker'; |
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.
export * from './BaseTimePicker'; | |
export * from './TimePicker'; |
src/core/index.ts
Outdated
@@ -1 +1,2 @@ | |||
export * from './Button'; | |||
export * from './Timepicker'; |
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.
export * from './Timepicker'; | |
export * from './TimePicker'; |
Can we also camel case time file name for the same!
src/core/Timepicker/base.ts
Outdated
import { TimePickerProps } from '@material-ui/pickers'; | ||
|
||
export type BaseTimePickerProps = Omit<TimePickerProps, 'value'>; |
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 should be able to use the basic props provided by KeyboardTimePicker, there's no requirement to omit any
// Litmus Portal | ||
.add('Litmus Portal', () => ( | ||
<ThemedBackground platform="litmus-portal"> | ||
<BaseTimePicker onChange={() => console.log('timepicker')} /> |
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.
<BaseTimePicker onChange={() => console.log('timepicker')} /> | |
<BaseTimePicker onChange={() => console.log('Time Changed')} /> |
package-lock.json is not required, can you please delete that! We are using yarn.lock instead |
Signed-off-by: Hasmik8 <[email protected]>
value?: Date; | ||
} | ||
|
||
const BaseTimePicker: React.FC<TimePickerProps> = ({ value }) => { |
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.
Date is not required to be passed as props
const date = value != undefined ? value : new Date(); | ||
const [selectedDate, handleDateChange] = useState<Date | null>(date); |
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.
No, Date shouldn't be passed
Please resolve the above comments as well |
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
As discussed earlier, |
"@material-ui/core": "^4.10.2", | ||
"@material-ui/pickers": "^3.2.10", |
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": {}
@AVRahul I'm running this command |
@Hasmik8 You can also copy paste the same in peerDependecies manually. |
Signed-off-by: Hasmik8 <[email protected]>
Description
I've created Timepicker component, which has one prop parameter, which is the value and it's date. It's not a required parameter.
Here are screenshots: