plane/apps/app/components/modules/select/status.tsx
Aaryan Khandelwal 4c2cb2368a
chore: update classnames according to the new theming structure (#1494)
* 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
2023-07-10 12:47:00 +05:30

70 lines
2.0 KiB
TypeScript

import React from "react";
// react hook form
import { Controller, FieldError, Control } from "react-hook-form";
// ui
import { CustomSelect } from "components/ui";
// icons
import { Squares2X2Icon } from "@heroicons/react/24/outline";
// types
import type { IModule } from "types";
// constants
import { MODULE_STATUS } from "constants/module";
type Props = {
control: Control<IModule, any>;
error?: FieldError;
};
export const ModuleStatusSelect: React.FC<Props> = ({ control, error }) => (
<Controller
control={control}
rules={{ required: true }}
name="status"
render={({ field: { value, onChange } }) => (
<CustomSelect
value={value}
label={
<div
className={`flex items-center justify-center gap-2 text-xs ${
error ? "text-red-500" : ""
}`}
>
{value ? (
<span
className="h-1.5 w-1.5 flex-shrink-0 rounded-full"
style={{
backgroundColor: MODULE_STATUS.find((s) => s.value === value)?.color,
}}
/>
) : (
<Squares2X2Icon
className={`h-3 w-3 ${error ? "text-red-500" : "text-custom-text-200"}`}
/>
)}
{MODULE_STATUS.find((s) => s.value === value)?.label ?? (
<span className={`${error ? "text-red-500" : "text-custom-text-200"}`}>Status</span>
)}
</div>
}
onChange={onChange}
noChevron
>
{MODULE_STATUS.map((status) => (
<CustomSelect.Option key={status.value} value={status.value}>
<div className="flex items-center gap-2">
<span
className="h-1.5 w-1.5 flex-shrink-0 rounded-full"
style={{
backgroundColor: status.color,
}}
/>
{status.label}
</div>
</CustomSelect.Option>
))}
</CustomSelect>
)}
/>
);