-
Notifications
You must be signed in to change notification settings - Fork 120
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
Feature/days of week #72
base: master
Are you sure you want to change the base?
Changes from all commits
64777a0
f1a6850
3900c61
fa31c67
a8ca50f
fe7ac6a
284f727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ export default Component.extend({ | |
weekdayFormat: 'short', // "min" | "short" | "long" | ||
powerCalendarService: service('power-calendar'), | ||
attributeBindings: [ | ||
'data-power-calendar-id' | ||
'data-power-calendar-id', | ||
'data-start-of-week' | ||
], | ||
|
||
// CPs | ||
|
@@ -35,6 +36,10 @@ export default Component.extend({ | |
return withLocale(this.get('calendar.locale'), () => moment.weekdaysMin()); | ||
}), | ||
|
||
'data-start-of-week': computed('localeStartOfWeek', function() { | ||
return withLocale(this.get('calendar.locale'), () => moment().startOf('week').format('ddd').toLowerCase()); | ||
}), | ||
|
||
weekdaysShort: computed('calendar.locale', function() { | ||
return withLocale(this.get('calendar.locale'), () => moment.weekdaysShort()); | ||
}), | ||
|
@@ -74,14 +79,11 @@ export default Component.extend({ | |
}), | ||
|
||
weeks: computed('showDaysAround', 'days', function() { | ||
let { showDaysAround, days } = this.getProperties('showDaysAround', 'days'); | ||
let { days } = this.getProperties('days'); | ||
let weeks = []; | ||
let i = 0; | ||
while (days[i]) { | ||
let daysOfWeek = days.slice(i, i + 7); | ||
if (!showDaysAround) { | ||
daysOfWeek = daysOfWeek.filter((d) => d.isCurrentMonth); | ||
} | ||
weeks.push({ | ||
id: days[i].moment.format('YYYY-w'), | ||
days: daysOfWeek, | ||
|
@@ -160,15 +162,18 @@ export default Component.extend({ | |
buildDay(dayMoment, today, calendar) { | ||
let id = dayMoment.format('YYYY-MM-DD'); | ||
let momentDate = dayMoment.clone(); | ||
let isCurrentMonth = momentDate.month() === calendar.center.month(); | ||
|
||
return { | ||
id, | ||
number: momentDate.date(), | ||
date: momentDate._d, | ||
moment: momentDate, | ||
dayOfWeek: momentDate.format('ddd').toLowerCase(), | ||
isDisabled: this.dayIsDisabled(momentDate), | ||
isFocused: this.get('focusedId') === id, | ||
isCurrentMonth: momentDate.month() === calendar.center.month(), | ||
isCurrentMonth, | ||
isVisible: isCurrentMonth || this.get('showDaysAround'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. If tests pass then 👍 |
||
isToday: momentDate.isSame(today, 'day'), | ||
isSelected: this.dayIsSelected(momentDate, calendar) | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
<div class="ember-power-calendar-row ember-power-calendar-weekdays"> | ||
<div class="ember-power-calendar-row ember-power-calendar-weekdays ember-power-calendar--days-of-week"> | ||
{{#each weekdaysNames as |wdn|}} | ||
<div class="ember-power-calendar-weekday">{{wdn}}</div> | ||
{{/each}} | ||
</div> | ||
|
||
<div class="ember-power-calendar-day-grid" onkeydown={{action "onKeyDown" calendar}}> | ||
{{#each weeks key='id' as |week|}} | ||
<div class="ember-power-calendar-row ember-power-calendar-week" data-missing-days={{week.missingDays}}> | ||
<div class="ember-power-calendar-row ember-power-calendar-week" > | ||
{{#each week.days key='id' as |day|}} | ||
<button type="button" | ||
data-date="{{day.id}}" | ||
class="ember-power-calendar-day {{if onSelect 'ember-power-calendar-day--interactive'}} {{if day.isCurrentMonth 'ember-power-calendar-day--current-month' 'ember-power-calendar-day--other-month'}} {{if day.isSelected 'ember-power-calendar-day--selected'}} {{if day.isToday 'ember-power-calendar-day--today'}} {{if day.isFocused 'ember-power-calendar-day--focused'}} {{if day.isRangeStart 'ember-power-calendar-day--range-start'}} {{if day.isRangeEnd 'ember-power-calendar-day--range-end'}}" | ||
onclick={{action calendar.actions.select day calendar}} | ||
onfocus={{action 'onFocusDay' day}} | ||
onblur={{action 'onBlurDay'}} | ||
disabled={{day.isDisabled}}> | ||
{{#if hasBlock}} | ||
{{yield day publicAPI}} | ||
{{else}} | ||
{{day.number}} | ||
{{/if}} | ||
</button> | ||
{{#if day.isVisible}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After your changes in the component you need to do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it ensures that each day -- whether visible or not -- has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. days which are "not visible" are easily targeted via the |
||
<button type="button" | ||
data-day-of-week="{{day.dayOfWeek}}" | ||
data-date="{{day.id}}" | ||
class="ember-power-calendar-day{{if onSelect ' ember-power-calendar-day--interactive'}} {{if day.isCurrentMonth 'ember-power-calendar-day--current-month' 'ember-power-calendar-day--other-month'}}{{if day.isSelected 'ember-power-calendar-day--selected'}} {{if day.isToday 'ember-power-calendar-day--today'}} {{if day.isFocused 'ember-power-calendar-day--focused'}} {{if day.isRangeStart ' ember-power-calendar-day--range-start'}}{{if day.isRangeEnd ' ember-power-calendar-day--range-end'}}" | ||
onclick={{action calendar.actions.select day calendar}} | ||
onfocus={{action 'onFocusDay' day}} | ||
onblur={{action 'onBlurDay'}} | ||
disabled={{day.isDisabled}}> | ||
{{#if hasBlock}} | ||
{{yield day publicAPI}} | ||
{{else}} | ||
{{day.number}} | ||
{{/if}} | ||
</button> | ||
|
||
{{else}} | ||
<span class="ember-power-calendar-day ember-power-calendar-day--blank"></span> | ||
{{/if}} | ||
{{/each}} | ||
</div> | ||
{{/each}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
$cell-spacing: 2px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this CSS changes also seem unrelated to the topic of the PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true but it is fixing an existing defect that I messaged to you about ... when days are not visible you start to have layout problems with the old styling |
||
$row-spacing: 2px; | ||
|
||
.ember-power-calendar { | ||
box-sizing: border-box; | ||
position: relative; | ||
|
@@ -24,6 +27,7 @@ | |
.ember-power-calendar-row { | ||
display: flex; | ||
justify-content: space-between; | ||
margin: $row-spacing 0; | ||
} | ||
.ember-power-calendar-weekday { | ||
-webkit-appearance: none; | ||
|
@@ -96,6 +100,9 @@ | |
.ember-power-calendar-day:not([disabled]):hover { | ||
background-color: #eee; | ||
} | ||
.ember-power-calendar-day.ember-power-calendar-day--blank:hover { | ||
background-color: inherit; | ||
} | ||
.ember-power-calendar-day--other-month:not([disabled]):hover { | ||
color: #aaa; | ||
} | ||
|
@@ -123,7 +130,7 @@ | |
$cell-size: null, | ||
$cell-width: $cell-size, | ||
$cell-height: $cell-size, | ||
$cell-with-spacing-width: $cell-width + 2px, | ||
$cell-with-spacing-width: $cell-width + $cell-spacing, | ||
$row-padding-top: 0, | ||
$row-padding-bottom: 0, | ||
$row-padding-left: 0, | ||
|
@@ -132,49 +139,16 @@ | |
|
||
width: $row-width; | ||
.ember-power-calendar-week:first-child { | ||
&[data-missing-days="1"] { | ||
padding-left: $cell-with-spacing-width * 1; | ||
} | ||
&[data-missing-days="2"] { | ||
padding-left: $cell-with-spacing-width * 2; | ||
} | ||
&[data-missing-days="3"] { | ||
padding-left: $cell-with-spacing-width * 3; | ||
} | ||
&[data-missing-days="4"] { | ||
padding-left: $cell-with-spacing-width * 4; | ||
} | ||
&[data-missing-days="5"] { | ||
padding-left: $cell-with-spacing-width * 5; | ||
} | ||
&[data-missing-days="6"] { | ||
padding-left: $cell-with-spacing-width * 6; | ||
} | ||
justify-content: flex-end; | ||
} | ||
.ember-power-calendar-week:last-child { | ||
&[data-missing-days="1"] { | ||
padding-right: $cell-with-spacing-width * 1; | ||
} | ||
&[data-missing-days="2"] { | ||
padding-right: $cell-with-spacing-width * 2; | ||
} | ||
&[data-missing-days="3"] { | ||
padding-right: $cell-with-spacing-width * 3; | ||
} | ||
&[data-missing-days="4"] { | ||
padding-right: $cell-with-spacing-width * 4; | ||
} | ||
&[data-missing-days="5"] { | ||
padding-right: $cell-with-spacing-width * 5; | ||
} | ||
&[data-missing-days="6"] { | ||
padding-right: $cell-with-spacing-width * 6; | ||
} | ||
justify-content: flex-start; | ||
} | ||
.ember-power-calendar-day, .ember-power-calendar-weekday { | ||
max-width: $cell-width; | ||
max-height: $cell-height; | ||
width: $cell-width; | ||
margin: 0 $cell-spacing; | ||
height: $cell-height; | ||
} | ||
.ember-power-calendar-weekdays, .ember-power-calendar-week { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
/*jshint node:true*/ | ||
module.exports = { | ||
"framework": "qunit", | ||
"test_page": "tests/index.html?hidepassed", | ||
"disable_watching": true, | ||
"launch_in_ci": [ | ||
"PhantomJS" | ||
"Chrome" | ||
], | ||
"launch_in_dev": [ | ||
"PhantomJS", | ||
"Chrome" | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2245,11 +2245,11 @@ ember-ajax@^2.4.1: | |
dependencies: | ||
ember-cli-babel "^5.1.5" | ||
|
||
[email protected].1: | ||
version "0.1.1" | ||
resolved "https://registry.yarnpkg.com/ember-assign-helper/-/ember-assign-helper-0.1.1.tgz#217f221f37781b64657bd371d9da911768c3fbd1" | ||
ember-assign-helper@^0.1.2: | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/ember-assign-helper/-/ember-assign-helper-0.1.2.tgz#3d1d575f3d4457b3662b214d4c6e671bd462cad0" | ||
dependencies: | ||
ember-cli-babel "^5.1.7" | ||
ember-cli-babel "^6.0.0-beta.9" | ||
|
||
[email protected]: | ||
version "0.31.0" | ||
|
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.
Why are you removing this?
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.
handled in template instead; allows for better screen layout in the
false
state of this condition