Skip to content

Commit e74f49a

Browse files
committed
Merge branch 'main' of github.com:devtron-labs/devtron-fe-common-lib into feat/release-track-apps
2 parents 188008c + 5268627 commit e74f49a

File tree

5 files changed

+92
-25
lines changed

5 files changed

+92
-25
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.3-beta-1",
3+
"version": "0.1.4-beta-3",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/DatePicker/DateTimePicker.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { DateTimePickerProps } from './types'
3131
import { DATE_PICKER_IDS, DATE_PICKER_PLACEHOLDER, customDayStyles } from './constants'
3232
import './datePicker.scss'
3333
import { ReactComponent as CalendarIcon } from '../../../Assets/Icon/ic-calendar.svg'
34+
import { ReactComponent as ICWarning } from '../../../Assets/Icon/ic-warning.svg'
3435
import { DATE_TIME_FORMATS } from '../../../Common'
3536
import 'react-dates/initialize'
3637
import 'react-dates/lib/css/_datepicker.css'
@@ -50,6 +51,8 @@ const DateTimePicker = ({
5051
isTodayBlocked = false,
5152
dataTestIdForTime = DATE_PICKER_IDS.TIME,
5253
dataTestidForDate = DATE_PICKER_IDS.DATE,
54+
openDirection = 'down',
55+
error = '',
5356
}: DateTimePickerProps) => {
5457
const time = getTimeValue(dateObject)
5558
const selectedTimeOption = DEFAULT_TIME_OPTIONS.find((option) => option.value === time) ?? DEFAULT_TIME_OPTIONS[0]
@@ -71,20 +74,20 @@ const DateTimePicker = ({
7174
const isDayBlocked = (day) => isTodayBlocked && !day.isAfter(today)
7275

7376
return (
74-
<div>
77+
<div className="date-time-picker">
7578
<label className={`form__label ${required ? 'dc__required-field' : ''}`} htmlFor={id}>
7679
{label}
7780
</label>
78-
<div className="dc__grid-row-one-half dc__gap-8">
81+
<div className="flex left dc__gap-8">
7982
<SingleDatePicker
80-
id="single_date_picker"
83+
id={id}
8184
placeholder="Select date"
8285
date={moment(dateObject)}
8386
onDateChange={handleDateChange}
8487
focused={isFocused}
8588
onFocusChange={handleFocusChange}
8689
numberOfMonths={1}
87-
openDirection="down"
90+
openDirection={openDirection}
8891
renderCalendarDay={(props) => <CustomizableCalendarDay {...props} {...customDayStyles} />}
8992
hideKeyboardShortcutsPanel
9093
withFullScreenPortal={false}
@@ -95,6 +98,8 @@ const DateTimePicker = ({
9598
displayFormat={DATE_TIME_FORMATS.DD_MMM_YYYY}
9699
data-testid={dataTestidForDate}
97100
isDayBlocked={isDayBlocked}
101+
disabled={disabled}
102+
appendToBody
98103
/>
99104
{!hideTimeSelect && (
100105
<div className="dc__no-shrink">
@@ -119,6 +124,12 @@ const DateTimePicker = ({
119124
</div>
120125
)}
121126
</div>
127+
{error && (
128+
<div className="form__error">
129+
<ICWarning className="form__icon form__icon--error" />
130+
{error}
131+
</div>
132+
)}
122133
</div>
123134
)
124135
}

src/Shared/Components/DatePicker/datePicker.scss

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,90 @@
1414
* limitations under the License.
1515
*/
1616

17-
.window-configuration {
18-
.DayPicker__horizontal {
19-
position: fixed !important;
17+
.SingleDatePicker_picker {
18+
z-index: calc(var(--modal-index) + 1) !important;
19+
}
20+
21+
.date-time-picker {
22+
.SingleDatePicker {
23+
width: 100%;
2024
}
21-
25+
2226
.SingleDatePickerInput {
2327
display: flex !important;
24-
width: 200px;
28+
width: 100%;
2529
background-color: var(--N50);
2630
margin-right: 0 !important;
2731
padding: 0 !important;
2832
height: 36px !important;
33+
overflow: hidden;
34+
border: 1px solid var(--N200);
35+
border-radius: 4px;
36+
37+
&:hover {
38+
border: 1px solid var(--N400);
39+
}
40+
41+
&:focus,
42+
&:focus-visible,
43+
&:focus-within {
44+
border: 1px solid var(--B500);
45+
}
46+
47+
&__disabled {
48+
background-color: var(--N100);
49+
border-color: var(--N200);
50+
}
2951
}
30-
52+
3153
.SingleDatePickerInput_calendarIcon {
3254
padding: 0 !important;
3355
margin: 0 !important;
3456
padding-right: 8px !important;
35-
background-color: var(--N50) !important;
36-
height: 36px !important;
57+
background-color: transparent !important;
58+
height: 34px !important;
59+
display: flex;
60+
align-items: center;
61+
62+
&:focus-visible {
63+
outline: none;
64+
}
3765
}
38-
39-
.SingleDatePickerInput__withBorder .DateInput {
40-
line-height: 20px !important;
66+
67+
.SingleDatePickerInput__withBorder {
68+
.DateInput {
69+
line-height: 20px !important;
70+
height: 34px;
71+
background-color: transparent;
72+
width: 100%;
73+
74+
&:focus-visible {
75+
outline: none;
76+
}
77+
}
78+
79+
.DateInput_input {
80+
font-size: 13px;
81+
border-bottom: none;
82+
cursor: pointer;
83+
background-color: transparent;
84+
color: var(--N900);
85+
86+
&__focused+.DateInput_fang {
87+
display: none;
88+
}
89+
90+
&__disabled {
91+
cursor: not-allowed;
92+
}
93+
}
4194
}
42-
95+
4396
.DateInput_input {
44-
padding: 6px 8px !important
97+
padding: 6px 8px !important;
98+
99+
&__disabled {
100+
font-style: normal;
101+
}
45102
}
46-
}
103+
}

src/Shared/Components/DatePicker/types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Moment } from 'moment'
1818
import { SelectInstance } from 'react-select'
19+
import { SingleDatePickerShape } from 'react-dates'
1920
import { OptionType } from '../../../Common'
2021

2122
export interface SingleDatePickerProps {
@@ -100,10 +101,8 @@ export interface TimeSelectProps {
100101
}
101102

102103
export interface DateTimePickerProps
103-
extends Pick<
104-
TimeSelectProps,
105-
'date' | 'onChange' | 'timePickerProps' | 'error' | 'disabled' | 'dataTestIdForTime'
106-
> {
104+
extends Pick<TimeSelectProps, 'date' | 'onChange' | 'timePickerProps' | 'error' | 'disabled' | 'dataTestIdForTime'>,
105+
Pick<SingleDatePickerShape, 'openDirection'> {
107106
/**
108107
* Props for the date picker
109108
*/

0 commit comments

Comments
 (0)