mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 13:38:51 +00:00
Merge pull request #31 from Nez27/feat/update-components-ui
Update components UI
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
import { FormEvent, ReactNode } from 'react';
|
import { FormEvent, ReactNode } from 'react';
|
||||||
|
|
||||||
// Styled
|
// Styled
|
||||||
import { StyledActionBtn, StyledForm } from './styled';
|
import {
|
||||||
|
StyledActionBtn,
|
||||||
|
StyledForm,
|
||||||
|
Error,
|
||||||
|
Label,
|
||||||
|
StyledFormRow,
|
||||||
|
} from './styled';
|
||||||
|
|
||||||
interface IFormProps {
|
interface IFormProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -9,6 +15,12 @@ interface IFormProps {
|
|||||||
id?: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IFormRow {
|
||||||
|
label: string;
|
||||||
|
error?: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
const Form = ({ children, onSubmit, id }: IFormProps) => {
|
const Form = ({ children, onSubmit, id }: IFormProps) => {
|
||||||
return (
|
return (
|
||||||
<StyledForm onSubmit={onSubmit} id={id}>
|
<StyledForm onSubmit={onSubmit} id={id}>
|
||||||
@@ -17,6 +29,20 @@ const Form = ({ children, onSubmit, id }: IFormProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const FormRow = ({ label, error, children }: IFormRow) => {
|
||||||
|
return (
|
||||||
|
<StyledFormRow>
|
||||||
|
<Label>{label}</Label>
|
||||||
|
<div>
|
||||||
|
{children}
|
||||||
|
{error && <Error>{error}</Error>}
|
||||||
|
</div>
|
||||||
|
</StyledFormRow>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Form.Row = FormRow;
|
||||||
Form.Action = StyledActionBtn;
|
Form.Action = StyledActionBtn;
|
||||||
|
|
||||||
export default Form;
|
export default Form;
|
||||||
|
|||||||
@@ -13,4 +13,26 @@ const StyledActionBtn = styled.div`
|
|||||||
gap: 100px;
|
gap: 100px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export { StyledForm, StyledActionBtn };
|
const StyledFormRow = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 100px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Label = styled.label`
|
||||||
|
font-size: var(--fs-sm);
|
||||||
|
text-transform: capitalize;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Error = styled.p`
|
||||||
|
color: var(--error-text);
|
||||||
|
font-size: var(--fs-sm-2x);
|
||||||
|
|
||||||
|
margin-top: 5px;
|
||||||
|
padding-inline: 5px;
|
||||||
|
|
||||||
|
width: 220px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export { StyledForm, StyledActionBtn, StyledFormRow, Label, Error };
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Components
|
// Components
|
||||||
import { IoPersonCircleOutline } from 'react-icons/io5';
|
import { IoPersonCircleOutline } from 'react-icons/io5';
|
||||||
import { HiOutlineLogout } from 'react-icons/hi';
|
import { HiOutlineLogout } from 'react-icons/hi';
|
||||||
import ButtonIcon from '@component/ButtonIcon/ButtonIcon';
|
import ButtonIcon from '@component/ButtonIcon';
|
||||||
|
|
||||||
// Styled
|
// Styled
|
||||||
import { StyledHeaderMenu } from './styled';
|
import { StyledHeaderMenu } from './styled';
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
|
|
||||||
// Styled
|
|
||||||
import { Error, Label, StyledFormRow } from './styled';
|
|
||||||
|
|
||||||
interface IFormRow {
|
|
||||||
label: string;
|
|
||||||
error?: string;
|
|
||||||
children: ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
const FormRow = ({ label, error, children }: IFormRow) => {
|
|
||||||
return (
|
|
||||||
<StyledFormRow>
|
|
||||||
<Label>{label}</Label>
|
|
||||||
<div>
|
|
||||||
{children}
|
|
||||||
{error && <Error>{error}</Error>}
|
|
||||||
</div>
|
|
||||||
</StyledFormRow>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FormRow;
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
const StyledFormRow = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: 100px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Label = styled.label`
|
|
||||||
font-size: var(--fs-sm);
|
|
||||||
text-transform: capitalize;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Error = styled.p`
|
|
||||||
color: var(--error-text);
|
|
||||||
font-size: var(--fs-sm-2x);
|
|
||||||
|
|
||||||
margin-top: 5px;
|
|
||||||
padding-inline: 5px;
|
|
||||||
|
|
||||||
width: 220px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export { StyledFormRow, Label, Error };
|
|
||||||
@@ -14,7 +14,7 @@ import MenusContext from '@context/MenuContext';
|
|||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { Nullable } from '@type/common';
|
import { Nullable } from '@type/common';
|
||||||
import ButtonIcon from '@component/ButtonIcon/ButtonIcon';
|
import ButtonIcon from '@component/ButtonIcon';
|
||||||
import { COLOR } from '@constant/styles';
|
import { COLOR } from '@constant/styles';
|
||||||
|
|
||||||
interface IButton {
|
interface IButton {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import { REGEX } from '../../constants/commons.ts';
|
|||||||
import { isValidRegex, isValidString } from '@helper/validators.ts';
|
import { isValidRegex, isValidString } from '@helper/validators.ts';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import FormRow from '@component/LabelControl/index.tsx';
|
|
||||||
import Form from '@component/Form/index.tsx';
|
import Form from '@component/Form/index.tsx';
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
@@ -83,7 +82,7 @@ const RoomForm = ({ onCloseModal, room }: IRoomFormProp) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={handleSubmit(onSubmit)}>
|
<Form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<FormRow label="Name" error={errors?.name?.message}>
|
<Form.Row label="Name" error={errors?.name?.message}>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="name"
|
id="name"
|
||||||
@@ -96,9 +95,9 @@ const RoomForm = ({ onCloseModal, room }: IRoomFormProp) => {
|
|||||||
onChange: () => trigger('name'),
|
onChange: () => trigger('name'),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</Form.Row>
|
||||||
|
|
||||||
<FormRow label="Price" error={errors?.price?.message}>
|
<Form.Row label="Price" error={errors?.price?.message}>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="price"
|
id="price"
|
||||||
@@ -113,7 +112,7 @@ const RoomForm = ({ onCloseModal, room }: IRoomFormProp) => {
|
|||||||
onChange: () => trigger('price'),
|
onChange: () => trigger('price'),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</Form.Row>
|
||||||
|
|
||||||
<Form.Action>
|
<Form.Action>
|
||||||
<FormBtn
|
<FormBtn
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import Input from '@commonStyle/Input.ts';
|
|||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Form from '@component/Form/index.tsx';
|
import Form from '@component/Form/index.tsx';
|
||||||
import FormRow from '@component/LabelControl/index.tsx';
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
import { isValidRegex } from '@helper/validators.ts';
|
import { isValidRegex } from '@helper/validators.ts';
|
||||||
@@ -76,7 +75,7 @@ const UserForm = ({ onCloseModal, user }: IUserFormProp) => {
|
|||||||
return (
|
return (
|
||||||
<FormProvider {...formMethods}>
|
<FormProvider {...formMethods}>
|
||||||
<Form onSubmit={handleSubmit(onSubmit)}>
|
<Form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<FormRow label="Full Name" error={errors?.name?.message}>
|
<Form.Row label="Full Name" error={errors?.name?.message}>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="name"
|
id="name"
|
||||||
@@ -89,9 +88,9 @@ const UserForm = ({ onCloseModal, user }: IUserFormProp) => {
|
|||||||
onChange: () => trigger('name'),
|
onChange: () => trigger('name'),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</Form.Row>
|
||||||
|
|
||||||
<FormRow label="Phone" error={errors?.phone?.message}>
|
<Form.Row label="Phone" error={errors?.phone?.message}>
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="phone"
|
id="phone"
|
||||||
@@ -104,7 +103,7 @@ const UserForm = ({ onCloseModal, user }: IUserFormProp) => {
|
|||||||
onChange: () => trigger('phone'),
|
onChange: () => trigger('phone'),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</Form.Row>
|
||||||
|
|
||||||
<Form.Action>
|
<Form.Action>
|
||||||
<FormBtn
|
<FormBtn
|
||||||
|
|||||||
Reference in New Issue
Block a user