Skip to content

Commit a8cd1b0

Browse files
authored
feat(calendar): added inverted variant
This PR adds full inverted support to the calendar component. It also adds new metadata support for disabled/eventDates to supply new attributes inverted and variation. This way each cell tooltip can be adjusted on its own and makes it possible to have inverted or basic cell tooltips on non inverted calendars and vice versa
1 parent 656dcfc commit a8cd1b0

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

src/definitions/modules/calendar.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $.fn.calendar = function(parameters) {
7575

7676
isTouch,
7777
isTouchDown = false,
78+
isInverted = $module.hasClass(className.inverted),
7879
focusDateUsedForRange = false,
7980
module
8081
;
@@ -141,6 +142,9 @@ $.fn.calendar = function(parameters) {
141142
$container = $('<div/>').addClass(className.popup)[domPositionFunction]($activatorParent);
142143
}
143144
$container.addClass(className.calendar);
145+
if(isInverted){
146+
$container.addClass(className.inverted);
147+
}
144148
var onVisible = function () {
145149
module.refreshTooltips();
146150
return settings.onVisible.apply($container, arguments);
@@ -286,6 +290,9 @@ $.fn.calendar = function(parameters) {
286290
tempMode += ' andweek';
287291
}
288292
var table = $('<table/>').addClass(className.table).addClass(tempMode).addClass(numberText[columns] + ' column').appendTo(container);
293+
if(isInverted){
294+
table.addClass(className.inverted);
295+
}
289296
var textColumns = columns;
290297
//no header for time-only mode
291298
if (!isTimeOnly) {
@@ -355,15 +362,27 @@ $.fn.calendar = function(parameters) {
355362
var disabledDate = module.helper.findDayAsObject(cellDate, mode, settings.disabledDates);
356363
if (disabledDate !== null && disabledDate[metadata.message]) {
357364
cell.attr("data-tooltip", disabledDate[metadata.message]);
358-
cell.attr("data-position", tooltipPosition);
365+
cell.attr("data-position", disabledDate[metadata.position] || tooltipPosition);
366+
if(disabledDate[metadata.inverted] || (isInverted && disabledDate[metadata.inverted] === undefined)) {
367+
cell.attr("data-inverted", '');
368+
}
369+
if(disabledDate[metadata.variation]) {
370+
cell.attr("data-variation", disabledDate[metadata.variation]);
371+
}
359372
}
360373
} else {
361374
var eventDate = module.helper.findDayAsObject(cellDate, mode, settings.eventDates);
362375
if (eventDate !== null) {
363376
cell.addClass(eventDate[metadata.class] || settings.eventClass);
364377
if (eventDate[metadata.message]) {
365378
cell.attr("data-tooltip", eventDate[metadata.message]);
366-
cell.attr("data-position", tooltipPosition);
379+
cell.attr("data-position", eventDate[metadata.position] || tooltipPosition);
380+
if(eventDate[metadata.inverted] || (isInverted && eventDate[metadata.inverted] === undefined)) {
381+
cell.attr("data-inverted", '');
382+
}
383+
if(eventDate[metadata.variation]) {
384+
cell.attr("data-variation", eventDate[metadata.variation]);
385+
}
367386
}
368387
}
369388
}
@@ -1639,6 +1658,7 @@ $.fn.calendar.settings = {
16391658
grid: 'ui equal width grid',
16401659
column: 'column',
16411660
table: 'ui celled center aligned unstackable table',
1661+
inverted: 'inverted',
16421662
prev: 'prev link',
16431663
next: 'next link',
16441664
prevIcon: 'chevron left icon',
@@ -1667,6 +1687,9 @@ $.fn.calendar.settings = {
16671687
monthOffset: 'monthOffset',
16681688
message: 'message',
16691689
class: 'class',
1690+
inverted: 'inverted',
1691+
variation: 'variation',
1692+
position: 'position',
16701693
month: 'month',
16711694
year: 'year'
16721695
},

src/definitions/modules/calendar.less

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
right: 0;
122122
}
123123

124-
.ui.calendar .ui.table tr .disabled {
124+
.ui.ui.calendar .ui.table tr .disabled {
125125
pointer-events: auto;
126126
cursor: default;
127127
color: @disabledTextColor;
@@ -146,22 +146,31 @@
146146
box-shadow: @rangeBoxShadow;
147147
}
148148

149-
.ui.calendar .ui.table.inverted tr td.range {
150-
background: @rangeInvertedBackground;
151-
color: @rangeInvertedTextColor;
152-
box-shadow: @rangeInvertedBoxShadow;
153-
}
154-
155149
.ui.calendar:not(.disabled) .calendar:focus .ui.table tbody tr td.focus,
156150
.ui.calendar:not(.disabled) .calendar.active .ui.table tbody tr td.focus {
157151
box-shadow: @focusBoxShadow;
158152
}
159153

160-
.ui.calendar:not(.disabled) .calendar:focus .ui.table.inverted tbody tr td.focus,
161-
.ui.calendar:not(.disabled) .calendar.active .ui.table.inverted tbody tr td.focus {
162-
box-shadow: @focusInvertedBoxShadow;
163-
}
154+
& when (@variationCalendarInverted) {
155+
.ui.inverted.calendar .ui.table.inverted tr td.range {
156+
background: @rangeInvertedBackground;
157+
color: @rangeInvertedTextColor;
158+
box-shadow: @rangeInvertedBoxShadow;
159+
}
164160

161+
.ui.inverted.calendar:not(.disabled) .calendar:focus .ui.table.inverted tbody tr td.focus,
162+
.ui.inverted.calendar:not(.disabled) .calendar.active .ui.table.inverted tbody tr td.focus {
163+
box-shadow: @focusInvertedBoxShadow;
164+
}
165+
.ui.inverted.calendar .ui.inverted.table tr .disabled {
166+
color: @invertedDisabledTextColor;
167+
}
168+
169+
.ui.inverted.calendar .ui.inverted.table tr .adjacent:not(.disabled) {
170+
color: @adjacentInvertedTextColor;
171+
background: @adjacentInvertedBackground;
172+
}
173+
}
165174

166175
/*******************************
167176
States

src/themes/default/globals/variation.variables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
@variationAccordionFluid: true;
368368

369369
/* Calendar */
370+
@variationCalendarInverted: true;
370371
@variationCalendarDisabled: true;
371372

372373
/* Checkbox */

src/themes/default/modules/calendar.variables

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616

1717
@adjacentTextColor: @mutedTextColor;
1818
@adjacentBackground: @subtleTransparentBlack;
19+
@adjacentInvertedTextColor: @invertedMutedTextColor;
20+
@adjacentInvertedBackground: @subtleTransparentWhite;

0 commit comments

Comments
 (0)