Skip to content
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): improve default look and feel #1205

Merged
merged 1 commit into from
Jan 12, 2017

Conversation

maxokorokov
Copy link
Member

Updating default datepicker look and feel as a part of #862 :

  • Moving to flex layout instead of table layout
  • More space and border around the datepicker
  • Less pronounced weekdays
  • Visual separation of the header from the body
  • Buttons same as in the timepicker
  • Prefixing css classes with ngb-dp-

Before:
screen shot 2017-01-10 at 11 38 46

After:
screen shot 2017-01-10 at 11 39 17

screen shot 2017-01-10 at 11 41 47

P.S. Will also add full month names with a separate request later

BREAKING CHANGES: switched to flex layout instead of table-based (drop IE9 support) and prefixed datepicker-related css classes with ngb-dp-

Fixes #706

`],
host: {
'[class.bg-primary]': 'selected',
'[class.text-white]': 'selected',
'[class.text-muted]': 'isMuted()',
'[class.outside]': 'isMuted()',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for the different classes if they go off the same exact check? Is it possible to have text-muted without outside, or vice versa?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text-muted is the bootstrap class. I wanted to add 50% opacity on top of it, so two options:

  • [style.opacity]="isMuted() ? 0.5 : 1"
  • add the css class

I picked the last one, not sure which one is better though

<div class="ngb-dp-navigation bg-faded">
<ngb-datepicker-navigation *ngIf="navigation !== 'none'"
[date]="months[0]?.firstDate"
[minDate]="_minDate"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should private variables be used in templates? Not sure if these should be public or not. Maybe they are, just going by the name of the var here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is not a private variable... the thing is there is an @Input() minDate: NgbDateStruct and an internal data model _minDate: NgbDate

Not sure about this whole NgbDateStruct vs NgbDate thing, but it's a whole another story :)

</div>

<div class="ngb-dp-months d-flex">
<div class="ngb-dp-month-spacer-sm bg-faded" [style.height.rem]="navigation !== 'select' || displayMonths > 1 ? 4 : 2"></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind it that much, but might it be easier to read if you move this logic to a function? Or is the standard to keep simple stuff like this int he HTML?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just simplified layout significantly and got rid of spacers altogether. Done with css now. Thanks for pointing this

Copy link
Contributor

@deeg deeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posted a few basic questions which probably don't need changes. Looks good man!

BREAKING CHANGES: switched to flex layout instead of table-based (drop IE9 support) and prefixed datepicker-related css classes with `ngb-dp-`

Fixes ng-bootstrap#706
Fixes ng-bootstrap#1061
@maxokorokov
Copy link
Member Author

Amended:

  • simplified layout even more → removed spacers and did them with css
  • fixed and added tests with various [showWeekdays], [navigation] and [displayMonths] values
  • fixed TS < 2.0 compatibility

P.S. Tested in IE 10, 11, Edge. Seems to look fine.

@maxokorokov maxokorokov merged commit d88c8b7 into ng-bootstrap:master Jan 12, 2017
@Matmo10
Copy link

Matmo10 commented Feb 8, 2017

Hi @maxokorokov, thanks for the visual refresh on this. Do you happen to know what version this will land / landed in? I just installed 1.0.0-alpha.20 but I still see the old calendar. I'm just slightly confused as the demo website already shows the new design, and says that 1.0.0-alpha.20 is the latest release - but I can't see the new calendar after installing 1.0.0-alpha.20.

I have this in my package.json: "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.20",, and I deleted my whole node_modules directory before reinstalling just to be sure.

@maxokorokov
Copy link
Member Author

@Matmo10 it landed in alpha.19.

I've just upgraded to alpha.20 on one of my projects and it worked fine.
Did the same, also deleted node_modules/@ng-bootstrap before installing just to be sure too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datepicker: visual improvements
5 participants