Skip to content

Commit

Permalink
(#0) npm publish (0.0.105)
Browse files Browse the repository at this point in the history
  • Loading branch information
baegofda committed Dec 13, 2023
1 parent 2fc3c35 commit 87eac2c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbodek-ui",
"version": "0.0.104",
"version": "0.0.105",
"type": "module",
"author": "Bbodek",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const SingleDatePicker = () => {
return (
<div className = {"w-[500px] border rounded-3xl py-6"}>
<DatePickerCalendar
cutoffDate = "2023-12-08"
variants = "single"
label = {["해지 신청일"]}
periodDates = {periodDates}
Expand Down
10 changes: 9 additions & 1 deletion src/core/components/Calendar/DatePickerCalendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const DatePickerCalendar = ({
label = ["사용일"],
periodDates,
disabledDates,
cutoffDate,
afterAllDate = false,
onDateClick,
}: DatePickerCalendarProps) => {
Expand Down Expand Up @@ -116,6 +117,12 @@ const DatePickerCalendar = ({
operations.setCalendarPeriodDates(periodDates);
}, [periodDates]);

const isCutoffDateValidation = ({ cutoffDate, calendarDate }: Pick<DatePickerCalendarProps, "cutoffDate"> & { calendarDate: string }) => {
if(!cutoffDate) return false;

return dayjs(calendarDate).isBefore(cutoffDate);
};

return (
<div className = {"flex flex-col h-full w-full"}>
<CalendarHeader
Expand All @@ -133,7 +140,7 @@ const DatePickerCalendar = ({
<button
type = "button"
className = {"w-full h-full"}
disabled = {(!calendarDate.isThisMonth || disabledDates?.includes(calendarDate.dayjs.format("YYYY-MM-DD")))}
disabled = {!calendarDate.isThisMonth || disabledDates?.includes(calendarDate.dayjs.format("YYYY-MM-DD")) || isCutoffDateValidation({ cutoffDate, calendarDate: calendarDate.dayjs.format("YYYY-MM-DD") })}
onClick = {(): void => {
const currentDate = calendarDate.dayjs.format("YYYY-MM-DD");

Expand All @@ -147,6 +154,7 @@ const DatePickerCalendar = ({
>
<div className = {clsx("flex flex-col")}>
<CalendarComponentDayText
disabled = {isCutoffDateValidation({ cutoffDate, calendarDate: calendarDate.dayjs.format("YYYY-MM-DD") })}
calendarDate = {calendarDate}
periodDates = {models.periodDates}
periodDateArray = {models.periodDateArray}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ interface CalendarComponentDayTextProps {
afterAllDate: boolean;
periodDates: PeriodDates;
periodDateArray?: string[];
disabled: boolean
}

export const CalendarComponentDayText = ({
calendarDate,
afterAllDate,
periodDates,
periodDateArray,
disabled,
}: CalendarComponentDayTextProps) => {
const currentDate = calendarDate.dayjs.format("YYYY-MM-DD");
const isPeriod = periodDates.startDate && periodDates.endDate;
Expand All @@ -37,7 +39,7 @@ export const CalendarComponentDayText = ({
"rounded-full w-8 bg-primary-03 text-white": isStartDate || isEndDate || singleSelectedDate,
"bg-gray-03 text-white rounded-full w-8": calendarDate.isToday,
"w-full bg-primary-00 rounded-none !text-gray-08": (periodDateArray?.slice(1, -1).includes(currentDate)) || (afterAllDate && calendarDate.dayjs.isAfter(periodDates.startDate)),
"!text-gray-03": !calendarDate.isThisMonth && !periodDateArray?.includes(currentDate) && !calendarDate.isToday!,
"!text-gray-03": disabled || !calendarDate.isThisMonth && !periodDateArray?.includes(currentDate) && !calendarDate.isToday!,
},
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface DatePickerCalendarProps {
label?: string[];
disabledDates?: string[];
afterAllDate?: boolean;
cutoffDate?: string;
disabled?: boolean;
onDateClick: (periodDates: PeriodDates) => void;
}

0 comments on commit 87eac2c

Please sign in to comment.