-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RangeDatePickerV2): adjusted selecting
- Loading branch information
1 parent
b8099d9
commit 91b70d3
Showing
8 changed files
with
194 additions
and
45 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
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
11 changes: 11 additions & 0 deletions
11
...src/components/DatePicker/RangeDatePickerV2/components/RangeDatePickerV2Label.module.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,11 @@ | ||
$base-class: 'range-date-picker-v2-label'; | ||
|
||
.#{$base-class} { | ||
flex: 1; | ||
margin: 0; | ||
color: var(--content-basic-secondary); | ||
|
||
&--selected { | ||
color: var(--content-basic-primary); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ponents/src/components/DatePicker/RangeDatePickerV2/components/RangeDatePickerV2Label.tsx
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,55 @@ | ||
import { FC } from 'react'; | ||
|
||
import cx from 'clsx'; | ||
import { format } from 'date-fns'; | ||
import { DateRange } from 'react-day-picker'; | ||
|
||
import { Text } from '../../../Typography'; | ||
|
||
import styles from './RangeDatePickerV2Label.module.scss'; | ||
|
||
const baseClass = 'range-date-picker-v2-label'; | ||
|
||
interface IRangeDatePickerV2LabelProps { | ||
tempDate?: DateRange; | ||
date?: DateRange; | ||
} | ||
|
||
export const RangeDatePickerV2Label: FC<IRangeDatePickerV2LabelProps> = ({ | ||
tempDate, | ||
date, | ||
}) => { | ||
const getStartDate = () => { | ||
if (tempDate?.from) { | ||
return `${format(tempDate.from, 'dd-MM-yy')}`; | ||
} | ||
|
||
if (date?.from) { | ||
return `${format(date.from, 'dd-MM-yy')}`; | ||
} | ||
|
||
return 'Start date'; | ||
}; | ||
|
||
const getEndDate = () => { | ||
if (tempDate?.to) { | ||
return `${format(tempDate.to, 'dd-MM-yy')}`; | ||
} | ||
|
||
if (date?.to) { | ||
return `${format(date.to, 'dd-MM-yy')}`; | ||
} | ||
|
||
return 'End date'; | ||
}; | ||
|
||
return ( | ||
<Text | ||
className={cx(styles[`${baseClass}`], { | ||
[styles[`${baseClass}--selected`]]: date?.from && date?.to, | ||
})} | ||
> | ||
{getStartDate()} - {getEndDate()} | ||
</Text> | ||
); | ||
}; |
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
Oops, something went wrong.