forked from github/plane
3c2f5d12ed
* chore: add next theme and initial setup * chore: add dark mode colors to layouts * chore: user general setting page theming * chore: dashboard theming * chore: project page theming * chore: workspace setting page theming * chore: my issue page theming * chore: cmdk theming * chore: change hardcode bg and text color to theme * chore: change color name according to the design * style: fix card in the dashboard * style: fix merge conflict design issues * style: add light high contrast and dark high contrast * style: fix cmd k menu color and selection * feat: change theme from cmdk menu * chore: add multiple theme field to custom theme * chore: removed custom theming * fix: build error --------- Co-authored-by: Saheb Giri <iamsahebgiri@gmail.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 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;
|
|
className?: string;
|
|
isClearable?: boolean;
|
|
disabled?: boolean;
|
|
};
|
|
|
|
export const CustomDatePicker: React.FC<Props> = ({
|
|
renderAs = "button",
|
|
value,
|
|
onChange,
|
|
placeholder = "Select date",
|
|
displayShortForm = false,
|
|
error = 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 border-brand-base bg-transparent px-3 py-2 text-sm focus:outline-none"
|
|
: renderAs === "button"
|
|
? `px-3 py-1 text-xs shadow-sm ${
|
|
disabled ? "" : "hover:bg-brand-surface-1"
|
|
} duration-300 focus:border-brand-accent focus:outline-none focus:ring-1 focus:ring-brand-accent`
|
|
: ""
|
|
} ${error ? "border-red-500 bg-red-100" : ""} ${
|
|
disabled ? "cursor-not-allowed" : "cursor-pointer"
|
|
} w-full rounded-md border bg-transparent caret-transparent ${className}`}
|
|
dateFormat="dd-MM-yyyy"
|
|
isClearable={isClearable}
|
|
disabled={disabled}
|
|
/>
|
|
);
|