Skip to content

Commit

Permalink
DateBox: make today button look the same as cancel button (#25902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedwag authored Oct 28, 2023
1 parent 82bdce6 commit 30a21fd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { splitPair } from '../../core/utils/common';
import { isFunction, isEmptyObject } from '../../core/utils/type';
import { extend } from '../../core/utils/extend';
import messageLocalization from '../../localization/message';
import { isMaterial } from '../themes';

const TODAY_BUTTON_CLASS = 'dx-button-today';

const CalendarStrategy = DateBoxStrategy.inherit({

Expand Down Expand Up @@ -116,8 +119,8 @@ const CalendarStrategy = DateBoxStrategy.inherit({
_getTodayButtonConfig() {
const buttonsLocation = this.dateBox.option('buttonsLocation');
const isButtonsLocationDefault = buttonsLocation === 'default';

const position = isButtonsLocationDefault ? ['bottom', 'center'] : splitPair(buttonsLocation);
const stylingMode = isMaterial() ? 'text' : 'outlined';

return {
widget: 'dxButton',
Expand All @@ -126,7 +129,8 @@ const CalendarStrategy = DateBoxStrategy.inherit({
options: {
onClick: (args) => { this._widget._toTodayView(args); },
text: this.dateBox.option('todayButtonText'),
type: 'today',
elementAttr: { class: TODAY_BUTTON_CLASS },
stylingMode,
}
};
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const STATE_FOCUSED_CLASS = 'dx-state-focused';
const BUTTONS_CONTAINER_CLASS = 'dx-texteditor-buttons-container';
const GESTURE_COVER_CLASS = 'dx-gesture-cover';
const DROP_DOWN_BUTTON_CLASS = 'dx-dropdowneditor-button';
const BUTTON_CLASS = 'dx-button';
const TODAY_BUTTON_CLASS = 'dx-button-today';
const DROP_DOWN_BUTTON_VISIBLE_CLASS = 'dx-dropdowneditor-button-visible';
const OVERLAY_CONTENT_CLASS = 'dx-overlay-content';
const OVERLAY_WRAPPER_CLASS = 'dx-overlay-wrapper';
Expand All @@ -74,7 +76,7 @@ const SHOW_INVALID_BADGE_CLASS = 'dx-show-invalid-badge';

const APPLY_BUTTON_SELECTOR = '.dx-popup-done.dx-button';
const CANCEL_BUTTON_SELECTOR = '.dx-popup-cancel.dx-button';
const TODAY_BUTTON_SELECTOR = '.dx-button-today.dx-button';
const TODAY_BUTTON_SELECTOR = `.${TODAY_BUTTON_CLASS}.${BUTTON_CLASS}`;
const BUTTON_SELECTOR = '.dx-button';
const TEXTBOX_SELECTOR = '.dx-textbox';

Expand Down Expand Up @@ -537,6 +539,19 @@ QUnit.module('toolbar buttons', {}, () => {
];

types.forEach(type => {
QUnit.test(`Today button should have "dx-button-today" class (type=${type})`, function(assert) {
const dateBox = $('#dateBox').dxDateBox({
type,
pickerType: 'calendar',
opened: true,
applyValueMode: 'useButtons',
}).dxDateBox('instance');
const $overlayContent = $(dateBox.content()).parent();
const $todayButton = $overlayContent.find(`.${TODAY_BUTTON_CLASS}`);

assert.strictEqual($todayButton.length, 1);
});

buttons.forEach(button => {
QUnit.test(`"${button.optionName}" should customize ${button.name} button on init when type="${type}"`, function(assert) {
const $dateBox = $('#dateBox').dxDateBox({
Expand Down

0 comments on commit 30a21fd

Please sign in to comment.