-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[datetime2] feat: DatePicker3 using react-day-picker v8 (#5935)
- Loading branch information
Showing
38 changed files
with
2,415 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2016 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** @fileoverview test utils for react-day-picker v7 */ | ||
|
||
import { assert } from "chai"; | ||
import { ReactWrapper } from "enzyme"; | ||
|
||
import { Classes } from "../../src/common"; | ||
|
||
const isDayHidden = (day: ReactWrapper<any, any>): boolean => | ||
day.prop("empty") && !day.prop("ariaSelected") && day.prop("ariaDisabled"); | ||
|
||
export function assertDayDisabled(day: ReactWrapper<any, any>, expectDisabled: boolean = true) { | ||
assert.equal(day.hasClass(Classes.DATEPICKER_DAY_DISABLED), expectDisabled); | ||
} | ||
|
||
export function assertDayHidden(day: ReactWrapper<any, any>, expectHidden: boolean = true) { | ||
assert.equal(isDayHidden(day), expectHidden); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright 2022 Palantir Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
// This file intentionaly left blank | ||
@import "common/react-day-picker-overrides"; | ||
@import "components/date-picker3/date-picker3"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2023 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Classes as DatetimeClasses } from "@blueprintjs/datetime"; | ||
|
||
const RDP_DAY = "rdp-day"; | ||
const DATEPICKER_NAV_BUTTON = `${DatetimeClasses.DATEPICKER}-nav-button`; | ||
|
||
export const Classes = { | ||
...DatetimeClasses, | ||
// these classes need the "3" suffix because they overlap with DatePicker v1 / react-day-picker v7 classes | ||
DATEPICKER3_DAY: RDP_DAY, | ||
DATEPICKER3_DAY_DISABLED: `${RDP_DAY}_disabled`, | ||
DATEPICKER3_DAY_IS_TODAY: `${RDP_DAY}_today`, | ||
DATEPICKER3_DAY_OUTSIDE: `${RDP_DAY}_outside`, | ||
DATEPICKER3_DAY_SELECTED: `${RDP_DAY}_selected`, | ||
// these classes intentionally left without "3" suffix because they do not overlap with DatePicker v1, and this way we don't need to migrate them later, which reduces code churn | ||
DATEPICKER_HIGHLIGHT_CURRENT_DAY: `${DatetimeClasses.DATEPICKER}-highlight-current-day`, | ||
DATEPICKER_NAV_BUTTON, | ||
DATEPICKER_NAV_BUTTON_NEXT: `${DATEPICKER_NAV_BUTTON}-next`, | ||
DATEPICKER_NAV_BUTTON_PREVIOUS: `${DATEPICKER_NAV_BUTTON}-previous`, | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/datetime2/src/common/_react-day-picker-overrides.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 Palantir Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
@import "@blueprintjs/colors/lib/scss/colors"; | ||
@import "@blueprintjs/core/src/common/variables"; | ||
|
||
// omit file extension, otherwise this will emit a `@import url()` rule | ||
@import "react-day-picker/dist/style"; | ||
|
||
.#{$ns}-datepicker-content .rdp { | ||
--rdp-cell-size: #{$pt-grid-size * 3}; | ||
--rdp-accent-color: #{$blue3}; | ||
--rdp-background-color: #{$white}; | ||
|
||
/* Switch to dark colors for dark themes */ | ||
--rdp-accent-color-dark: #{$blue2}; | ||
--rdp-background-color-dark: #{$dark-gray3}; | ||
|
||
/* Outline border for focused elements */ | ||
--rdp-outline: 2px solid var(--rdp-accent-color); | ||
|
||
/* Outline border for focused and selected elements */ | ||
--rdp-outline-selected: 2px solid rgba(0, 0, 0, 75%); | ||
|
||
margin: 0; | ||
} |
Oops, something went wrong.
bdeff6e
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.
[datetime2] feat: DatePicker3 using react-day-picker v8 (#5935)
Build artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job.