update src/components/DateRangePicker/index.js, Input.js, src/components/FormInput/index.js and src/index.scss

master
mahdi 3 years ago
parent 1c0d029641
commit 664c16f074
  1. 6
      src/components/DateRangePicker/index.js
  2. 16
      src/components/FormInput/Input.js
  3. 89
      src/components/FormInput/index.js
  4. 6
      src/index.scss

@ -47,9 +47,9 @@ function CustomRangeInput({ openCalendar, value }) {
const DateRangePicker = () => { const DateRangePicker = () => {
return ( return (
<div className="w-1/2 mx-auto" style={{ direction: "rtl" }}> <div className="w-full" style={{ direction: "rtl" }}>
<Calendar calendar={persian} locale={persian_fa} /> {/* <Calendar calendar={persian} locale={persian_fa} />
<hr className="my-20" /> <hr className="my-20" /> */}
<DatePicker <DatePicker
range range
calendar={persian} calendar={persian}

@ -9,6 +9,7 @@ const FormFields = ({
set, set,
label, label,
borderClassname, borderClassname,
inputClassname,
type, type,
maxLength, maxLength,
max, max,
@ -24,9 +25,7 @@ const FormFields = ({
className={ className={
"h-full flex flex-row items-center rounded border mx-1 relative " + "h-full flex flex-row items-center rounded border mx-1 relative " +
borderClassname + borderClassname +
(value (value ? " bg-white border rounded" : " bg-transparent")
? " border-[#2483E1] bg-white border rounded"
: " bg-transparent")
} }
> >
<div <div
@ -45,11 +44,6 @@ const FormFields = ({
maxLength={maxLength} maxLength={maxLength}
value={value} value={value}
type={"text"} type={"text"}
className={`rtl w-full h-full px-4 py-2 bg-[#F9F9F9] text-[#F9F9F9] outline-0 text-xs rounded focus:border-[#2483E1 focus:ring-[#2483E1
${value === "" ? "bg-[#F9F9F9]" : "bg-red-600"}
`}
onChange={(e) => setValue(e.target.value)}
inputMode={type === "number" ? "numeric" : ""}
onInput={(e) => { onInput={(e) => {
let value = e.target.value; let value = e.target.value;
if (type === "number") if (type === "number")
@ -60,6 +54,10 @@ const FormFields = ({
if (!isNaN(min) && +e.target.value < min) value = min; if (!isNaN(min) && +e.target.value < min) value = min;
e.target.value = value; e.target.value = value;
}} }}
className={`rtl w-full h-full px-4 py-2 outline-0 text-xs rounded-md text-[#0F0543] focus:bg-white border-[#E0E0E0] focus:border-[#2483E1] focus:ring-transparent
${value === "" ? "bg-red-200 " : "bg-[#F9F9F9] "} `}
onChange={(e) => setValue(e.target.value)}
inputMode={type === "number" ? "numeric" : ""}
/> />
) : ( ) : (
<textarea <textarea
@ -77,5 +75,5 @@ const FormFields = ({
export default FormFields; export default FormFields;
FormFields.defaultProps = { FormFields.defaultProps = {
borderClassname: "border-[#2483E1] bg-indigo-600", // borderClassname: "border-[#E0E0E0]",
}; };

@ -1,5 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import DateRangePicker from "../DateRangePicker";
import Input from "./Input"; import Input from "./Input";
@ -9,30 +10,92 @@ const FormInput = () => {
return ( return (
<div className="mx-72 mt-20 flex flex-row items-center justify-between divide-x-2 divide-[#F3F3F3] divide-x-reverse bg-white p-4 py-7 border border-gray-200 rounded-sm shadow-sm"> <div className="mx-72 mt-20 flex flex-row items-center justify-between divide-x-2 divide-[#F3F3F3] divide-x-reverse bg-white p-4 py-7 border border-gray-200 rounded-sm shadow-sm">
<div className="flex-grow px-4"> <div className="flex-grow flex-1 flex flex-col gap-y-4 px-4">
<Input <Input
register={register("firstName")} register={register("firstName")}
// defaultValue={info?.firstName} // defaultValue={info?.firstName}
label="نام " label="نام "
borderClassname={` ${ type="text"
selectedInput === true ? "border-[#E0E0E0]" : "border-[#2483E1]" borderClassname={`border-transparent `}
}`} className={``}
onClick={() => setSelectedInput(true)} // borderClassname={` ${
// selectedInput === true ? "border-[#2483E1]" : "border-[#E0E0E0]"
// }`}
// onClick={() => setSelectedInput(true)}
/>
<Input
register={register("lastName")}
label="نام خانوادگی"
type="text"
borderClassname={`border-transparent `}
className={``}
/>
<Input
register={register("birthYear")}
label="تاریخ تولد"
type="number"
borderClassname={`border-transparent `}
className={``}
/>
<select className="customizeSelect rounded text-xs mx-1 py-2 bg-[#F9F9F9] focus:bg-white border-[#E0E0E0] focus:border-[#2483E1] focus:ring-transparent">
<option>میزان تحصیلات</option>
<option>کارشناسی</option>
<option>ارشد</option>
<option>دکتری</option>
</select>{" "}
<Input
register={register("birthYear")}
label="جنسیت"
type="number"
borderClassname={`border-transparent `}
className={``}
/> />
</div> </div>
<div className="flex-grow px-4"> <div className="flex-grow flex-1 flex flex-col gap-y-4 px-4">
<Input <Input
register={register("firstName")} register={register("mobileNumber")}
// defaultValue={info?.firstName} label="شماره تماس"
label="نام " type="text"
borderClassname={`border-transparent `}
className={``}
/>
<Input
register={register("job")}
label="شغل"
type="text"
borderClassname={`border-transparent `}
className={``}
/>
<select className="customizeSelect rounded text-xs mx-1 py-2 bg-[#F9F9F9] focus:bg-white border-[#E0E0E0] focus:border-[#2483E1] focus:ring-transparent">
<option>شهر مبدا</option>
<option>تهران</option>
<option>تهران</option>
<option>تهران</option>
</select>
<Input
register={register("foundus")}
label="نحوه آشنایی با موکب"
type="text"
borderClassname={`border-transparent `}
className={``}
/>
<Input
register={register("foundus")}
label="کد ملی"
type="number"
borderClassname={`border-transparent `}
className={``}
/> />
</div> </div>
<div className="flex-grow px-4"> <div className="flex-grow flex-1 flex flex-col px-4">
<Input <Input
register={register("firstName")} register={register("lastName")}
// defaultValue={info?.firstName} label="تاریخ ورود"
label="نام " type="text"
borderClassname={`border-transparent `}
className={``}
/> />
<DateRangePicker />
</div> </div>
</div> </div>
); );

@ -44,3 +44,9 @@ l.leaflet-popup-content,
.leaflet-touch .leaflet-draw-actions a { .leaflet-touch .leaflet-draw-actions a {
font-family: "iransans-medium" !important; font-family: "iransans-medium" !important;
} }
// class for selectbox
.customizeSelect {
background-position: left 0.5rem center;
padding-right: 1rem;
}

Loading…
Cancel
Save