Skip to content

feat(popupcls): ✨ Added a popup classname #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/Datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Datepicker: React.FC<DatepickerType> = ({
disabled = false,
inputClassName = null,
containerClassName = null,
popupClassName = null,
toggleClassName = null,
toggleIcon = undefined,
displayFormat = DATE_FORMAT,
Expand Down Expand Up @@ -327,15 +328,22 @@ const Datepicker: React.FC<DatepickerType> = ({
: defaultContainerClassName;
}, [containerClassName]);

const popupClassNameOverload = useMemo(() => {
const defaultPopupClassName =
"transition-all ease-out duration-300 absolute z-10 mt-[1px] text-sm lg:text-xs 2xl:text-sm translate-y-4 opacity-0 hidden";
return typeof popupClassName === "function"
? popupClassName(defaultPopupClassName)
: typeof popupClassName === "string" && popupClassName !== ""
? popupClassName
: defaultPopupClassName;
}, [popupClassName]);

return (
<DatepickerContext.Provider value={contextValues}>
<div className={containerClassNameOverload} ref={containerRef}>
<Input setContextRef={setInputRef} />

<div
className="transition-all ease-out duration-300 absolute z-10 mt-[1px] text-sm lg:text-xs 2xl:text-sm translate-y-4 opacity-0 hidden"
ref={calendarContainerRef}
>
<div className={popupClassNameOverload} ref={calendarContainerRef}>
<Arrow ref={arrowRef} />

<div className="mt-2.5 shadow-sm border border-gray-300 px-1 py-0.5 bg-white dark:bg-slate-800 dark:text-white dark:border-slate-600 rounded-lg">
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface DatepickerType {
disabled?: boolean;
classNames?: ClassNamesTypeProp | undefined;
containerClassName?: ((className: string) => string) | string | null;
popupClassName?: ((className: string) => string) | string | null;
inputClassName?: ((className: string) => string) | string | null;
toggleClassName?: ((className: string) => string) | string | null;
toggleIcon?: (open: boolean) => React.ReactNode;
Expand Down