mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
4c2cb2368a
* chore: store various shades of accent color * refactor: custom theme selector * refactor: custom theme selector * chore: update custom theme input labels * fix: color generator function logic * fix: accent color preloaded data * chore: new theming structure * chore: update shades calculation logic * refactor: variable names * chore: update color scheming * chore: new color scheming * refactor: themes folder structure * chore: update classnames to the new ones * chore: update static colors * chore: sidebar link colors * chore: placeholder color * chore: update border classnames
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
// react-datepicker
|
|
import DatePicker from "react-datepicker";
|
|
import "react-datepicker/dist/react-datepicker.css";
|
|
// helpers
|
|
import { renderDateFormat } from "helpers/date-time.helper";
|
|
|
|
type Props = {
|
|
renderAs?: "input" | "button";
|
|
value: Date | string | null | undefined;
|
|
onChange: (val: string | null) => void;
|
|
placeholder?: string;
|
|
displayShortForm?: boolean;
|
|
error?: boolean;
|
|
noBorder?: boolean;
|
|
className?: string;
|
|
isClearable?: boolean;
|
|
disabled?: boolean;
|
|
};
|
|
|
|
export const CustomDatePicker: React.FC<Props> = ({
|
|
renderAs = "button",
|
|
value,
|
|
onChange,
|
|
placeholder = "Select date",
|
|
displayShortForm = false,
|
|
error = false,
|
|
noBorder = false,
|
|
className = "",
|
|
isClearable = true,
|
|
disabled = false,
|
|
}) => (
|
|
<DatePicker
|
|
placeholderText={placeholder}
|
|
selected={value ? new Date(value) : null}
|
|
onChange={(val) => {
|
|
if (!val) onChange(null);
|
|
else onChange(renderDateFormat(val));
|
|
}}
|
|
className={`${
|
|
renderAs === "input"
|
|
? "block px-2 py-2 text-sm focus:outline-none"
|
|
: renderAs === "button"
|
|
? `px-2 py-1 text-xs shadow-sm ${
|
|
disabled ? "" : "hover:bg-custom-background-80"
|
|
} duration-300 focus:border-custom-primary focus:outline-none focus:ring-1 focus:ring-custom-primary`
|
|
: ""
|
|
} ${error ? "border-red-500 bg-red-100" : ""} ${
|
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
} ${
|
|
noBorder ? "" : "border border-custom-border-100"
|
|
} w-full rounded-md bg-transparent caret-transparent ${className}`}
|
|
dateFormat="MMM dd, yyyy"
|
|
isClearable={isClearable}
|
|
disabled={disabled}
|
|
/>
|
|
);
|