Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/hng-124 #207

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07c8e2f
124-Bio
itstolexy Jul 20, 2024
2d2177d
Merge branch 'dev' of https://github.com/hngprojects/hng_boilerplate_…
itstolexy Jul 20, 2024
4895fb2
bio field 124
itstolexy Jul 20, 2024
37b2828
bio updated
itstolexy Jul 20, 2024
17c448b
Merge branch 'dev' of https://github.com/hngprojects/hng_boilerplate_…
itstolexy Jul 20, 2024
08475fe
formatted
itstolexy Jul 20, 2024
a757595
suggestionUpdate app/components/bio/index.tsx
itstolexy Jul 20, 2024
72d2b48
Update app/components/constant/index.tsx
itstolexy Jul 20, 2024
dc3146d
Update app/components/bio/index.tsx
itstolexy Jul 20, 2024
b784595
Update app/components/textarea/index.tsx
itstolexy Jul 20, 2024
62505db
Update app/components/typings/index.tsx
itstolexy Jul 20, 2024
7c7311c
Update app/routes/_index.tsx
itstolexy Jul 20, 2024
e41c945
Update app/components/textarea/index.tsx
itstolexy Jul 20, 2024
51384ee
Update app/routes/_index.tsx
itstolexy Jul 20, 2024
ff67d2e
Update app/components/textarea/index.tsx
itstolexy Jul 20, 2024
f22ebc8
Update app/components/textarea/index.tsx
itstolexy Jul 20, 2024
b71aee1
Update app/components/constant/index.tsx
itstolexy Jul 20, 2024
2bb6b10
null changed to undefined
itstolexy Jul 20, 2024
4b8688e
null
itstolexy Jul 20, 2024
667a424
home
itstolexy Jul 20, 2024
aad49a2
fixed error
itstolexy Jul 20, 2024
49ef5c7
undefined fixed
itstolexy Jul 20, 2024
8f08fdc
fixed home
itstolexy Jul 20, 2024
81d8e0f
formatted
itstolexy Jul 20, 2024
b8d9ddc
updated
itstolexy Jul 20, 2024
c5bf490
formatt
itstolexy Jul 20, 2024
2e60fe0
update
itstolexy Jul 20, 2024
66e2bb2
Merge branch 'dev' of https://github.com/hngprojects/hng_boilerplate_…
itstolexy Jul 22, 2024
4f4185f
updated
itstolexy Jul 22, 2024
432d514
lint fixed
itstolexy Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"development"
],
"hints": {
"no-inline-styles": "off"
}
}
43 changes: 43 additions & 0 deletions app/components/bio/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useState } from "react";

import { defaultFormError, defaultFormState, FormField } from "../constant";
import { TextAreaField } from "../textarea";

export default function Bio() {
const [formState, setFormState] = useState(defaultFormState);
const [formError, setFormError] = useState(defaultFormError);

const updateFormData = (key: string, value: string) => {
if (value.length > 64) {
setFormError({
...formError,
[key]: "Your bio cannot exceed 64 characters",
});
} else {
setFormError({
...formError,
[key]: undefined,
});
}

setFormState({
...formState,
[key]: value,
});
};

return (
<div className="p-6 font-sans">
<TextAreaField
label="Bio"
placeholder="A seasoned front-end developer with fulfilling duties."
name={FormField.bio}
value={formState[FormField.bio]}
error={formError[FormField.bio]}
handleChange={(event: React.ChangeEvent<HTMLTextAreaElement>) =>
updateFormData(FormField.bio, event.target.value)
}
/>
</div>
);
}
19 changes: 19 additions & 0 deletions app/components/constant/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IFormError, IFormState } from "../typings";

export enum FormField {
bio = "bio",
}

export const defaultFormState: IFormState = {
[FormField.bio]: "",
};

export const defaultFormError: IFormError = {
[FormField.bio]: undefined,
};

export const defaultAlert: { message: string | undefined; classType?: string } =
{
message: undefined,
classType: undefined,
};
45 changes: 45 additions & 0 deletions app/components/textarea/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react";

interface Properties {
label: string;
name: string;
value: string;
placeholder?: string;
disabled?: boolean;
error?: string | null;
handleChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
style?: React.CSSProperties;
}

export const TextAreaField: React.FC<Properties> = ({
label,
name,
placeholder,
disabled,
value,
error,
handleChange,
}) => {
return (
<div className="flex flex-col gap-2 text-black">
<label htmlFor={name} className="text-sm">
{label}
</label>
<div className="flex flex-col gap-1">
<div className="w-full rounded-md bg-white text-base text-black outline-0">
<textarea
id={name}
placeholder={placeholder}
disabled={disabled}
value={value}
onChange={handleChange}
className="h-[80px] w-full text-wrap rounded-md border border-[#DC2626] bg-white px-2 outline-0 placeholder:text-sm placeholder:text-[#C2C2C2]"
/>
</div>
{error && <span className="text-xs text-[#DC2626]">* {error}</span>}
</div>
</div>
);
};

export default TextAreaField;
17 changes: 17 additions & 0 deletions app/components/typings/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FormField } from "../constant";

export interface IResult {
[key: string]: number | undefined;
}

export interface IModifiedResult {
[key: string]: Array<string>;
}

export interface IFormState {
[FormField.bio]: string;
}

export interface IFormError {
[FormField.bio]: string | undefined;
}
Loading