-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(datepicker): initial version of datepicker component #618
Conversation
e6d1e3e
to
9c2ef50
Compare
export interface NgbCalendar { | ||
getDaysPerWeek(): number; | ||
getWeeksPerMonth(): number; | ||
getFirstDayOfWeek(): number; |
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.
Would it make more sense to make these three functions getters?
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.
Hmm, I don't think you can have getters in interfaces in Typescript
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.
But you can have fields :-)
@pkozlowski-opensource thanks for the initial review. I know the HTML markup and CSS are a mess now - it migrated here from my proof-of-concept prototype. I'll leave only the bare minimum for the layout and use bootstrap styles wherever possible. |
9c2ef50
to
70a9eb8
Compare
|
43eb02e
to
b5b1053
Compare
@@ -0,0 +1,25 @@ | |||
export class NgbDate { | |||
static from(date: {year: number, month: number, date?: number}) { |
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.
can we make month
also optional ?
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.
Sure, but NgbDate
is not user-exposed, so it wasn't necessary for now. See the public API in the NgbDatepicker
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.
This PR should stick to minimal features as possible, that would be a feature request for the future.
b5b1053
to
c9164dd
Compare
If anybody was following current pull request / issue #20, looks like the initial version is ready. Last changes are:
So it looks like this for now (see demo for minimal API example): Reviews are welcome. It's big, but the minimal working component is kinda big. |
|
||
model; | ||
|
||
minDate = {year: 2000, month: 0, date: 7}; |
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.
Shouldn't it be day
instead of date
? For me date
indicated the whole object. Could we please rename it?
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.
Yeah, you're right, will rename, it will be better. Got confused by the standard js Date
where there is a day
field but getDate()
method that returns it and getDay()
that returns the day of the week...
} | ||
`], | ||
template: ` | ||
<tr> |
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.
This restricts this component to being inside a tbody
element - is this what we want?
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.
I know it's restrictive as of now. Not only the ngbDatepickerNavigation
, but also ngbDatepickerMonthView
as well. It's because the simplest layout for the calendar I've came up with for now is a table - so all column alignment would be synchronised easily between navigation and dates, weekdays, etc. I would probably migrate to a better one if I knew how to do it easily with purer CSS.
Having said that, the only thing that's exposed now to the user is the template inside of a <td>
element so the internals should be replaceable in the longer run. Now each section is just a table's <tbody>
I have a question about |
|
||
@Component({ | ||
selector: 'ngbd-datepicker-basic', | ||
template: require('./datepicker-basic.html') |
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.
This should just be templateUrl: './datepicker-basic.html'
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.
Oh, it's the script that generates the demo skeleton apparently. Good catch, thanks. Will update the script in a separate PR.
TBH, it's been 6 weeks since I've done ng2 development and am not familiar w/ the changes past RC3. All this looks fine to me, but that should be taken w/ a grain of salt. |
After talking with @pkozlowski-opensource, this LGTM as is minus the demo template if we want to get in. My comments were more minor/affirming the decisions being made. |
Thanks for taking a look, @wesleycho and @icfantv. About calendars: I'm no calendar expert here, but I think it would be quite challenging to support calendars without day/month/year notion as well in one component. Or it will just be a parallel implementation inside. Plus current implementation will need tuning for sure (ex. |
2dd9931
to
4d2c8f8
Compare
import {NgbDatepickerModule} from './datepicker.module'; | ||
import {NgbDatepickerDayView} from './datepicker-day-view'; | ||
|
||
function getElement(element: HTMLElement): HTMLElement { |
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.
Could you rename it to sth more descriptive? What kind of an element we are trying to get?
LGTM apart from a small nit (don't really need to be fixed) and a missing browser sniffing. Great stuff @maxokorokov - datepickers are not easy but I think that we've got really nice API and architecture in here! Let's land this baby so people can play with it. |
@maxokorokov great one really 👏 👏 👏 👍 |
That looks great. 👍 I come a bit late to the game, but after just looking at the demo and playing a little bit with it, here are a few remarks:
Again, very good job! |
Thanks for the review @jnizet
|
IMO, this is good. @maxokorokov have you made [do you want to make] any changes per @jnizet's recommendations, specifically, the last bullet above? If not, I'm inclined to merge this. We can tweak the padding after it lands. |
3997fd6
to
e3e256f
Compare
Amended ie9 cursor test ignore and |
e3e256f
to
c6fde0c
Compare
First datepicker version (WIP)
Is inline datepicker, not in a popup and only the month view (this will easily extended later)
Current checklist:
Please leave feedback.
WIP for #20