-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
225 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function BasicList({ items }: { items: string[] }) { | ||
if (items.length === 0) return <p>No items provided.</p>; | ||
return ( | ||
<ul> | ||
{items.map((item, index) => ( | ||
<li key={index}>{item}</li> | ||
))} | ||
</ul> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ChangeEvent, useState } from "react"; | ||
import CustomInput from "./ui/Input"; | ||
import Button from "./ui/Button"; | ||
|
||
export default function Form() { | ||
const [firstName, setFirstName] = useState(""); | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
const { value } = e.target; | ||
setFirstName(value); | ||
}; | ||
|
||
return ( | ||
<form action="" className="flex flex-col space-y-5"> | ||
<div className="self-center flex flex-col space-y-5"> | ||
<CustomInput | ||
input={{ | ||
type: "text", | ||
name: "firstName", | ||
label: "First Name", | ||
inputId: "first-name", | ||
value: firstName, | ||
onChange: handleChange, | ||
placeholder: "Enter First Name", | ||
}} | ||
/> | ||
<Button button={{ text: "Submit", type: "submit" }} /> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function ImagesList({ imageUrls }: { imageUrls: string[] }) { | ||
if (imageUrls.length === 0) return null; | ||
|
||
return ( | ||
<ul> | ||
{imageUrls.map((url) => ( | ||
<li key={url}> | ||
<img src={url} alt="" /> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useState } from "react"; | ||
import Button from "./ui/Button"; | ||
|
||
export default function ProductDescriptionToggle({ | ||
description, | ||
}: { | ||
description: string; | ||
}) { | ||
const [isFullDescriptionVisible, setIsFullDescriptionVisible] = | ||
useState(true); | ||
|
||
const toggleDescription = () => { | ||
setIsFullDescriptionVisible(!isFullDescriptionVisible); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col space-y-4"> | ||
<h4 className="text-3xl font-medium self-center">Product Description</h4> | ||
<div className="text-base flex flex-col space-y-5 text-center"> | ||
{description.length < 150 ? ( | ||
<p>{description}</p> | ||
) : isFullDescriptionVisible ? ( | ||
<p>{description}</p> | ||
) : ( | ||
<div> | ||
<p>{description.substring(0, 150)}... </p> | ||
</div> | ||
)} | ||
<Button | ||
button={{ | ||
text: isFullDescriptionVisible ? "Read Less" : "Read More", | ||
onClick: toggleDescription, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useState } from "react"; | ||
import Button from "./ui/Button"; | ||
|
||
export default function UserAgreement() { | ||
const [hasAgreed, setHasAgreed] = useState(false); | ||
|
||
const handleAgreementChange = () => { | ||
setHasAgreed(!hasAgreed); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col space-y-5"> | ||
<h1 className="self-center text-3xl font-medium text-black"> | ||
User Agreement | ||
</h1> | ||
<p className="text-base text-blue-700 self-center"> | ||
Please review the following agreement before proceeding. This agreement | ||
outlines the terms and conditions for using our service. | ||
</p> | ||
<div className="pb-3 self-center"> | ||
<label htmlFor="agree"> | ||
<input | ||
type="checkbox" | ||
id="agree" | ||
checked={hasAgreed} | ||
onChange={handleAgreementChange} | ||
className="mr-1" | ||
/> | ||
I agree to the terms and conditions. | ||
</label> | ||
</div> | ||
<Button button={{ text: "Continue", disabled: !hasAgreed }} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
export default function Button() { | ||
return <button className="">Button</button>; | ||
import { ButtonProps } from "../../types/components"; | ||
|
||
export default function Button({ button }: { button: ButtonProps }) { | ||
const { onClick, text, type, disabled } = button; | ||
return ( | ||
<button | ||
disabled={disabled ?? false} | ||
type={type} | ||
onClick={onClick} | ||
className="bg-purple-600 disabled:bg-gray-400 px-36 py-2 text-sm lg:text-lg font-medium text-white rounded-xl w-fit self-center" | ||
> | ||
{text} | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
export default function Input() { | ||
return <input className="" type="" />; | ||
import { InputProps } from "../../types/components"; | ||
|
||
export default function CustomInput({ input }: { input: InputProps }) { | ||
const { | ||
inputId, | ||
type, | ||
name, | ||
placeholder, | ||
value, | ||
label, | ||
onChange, | ||
disabled, | ||
} = input; | ||
return ( | ||
<div className={`${label ? "flex flex-col space-y-3" : ""}`}> | ||
{label && ( | ||
<label | ||
htmlFor={inputId} | ||
className="text-onSurface text-base font-medium" | ||
> | ||
{label} | ||
</label> | ||
)} | ||
<input | ||
disabled={disabled ?? false} | ||
type={type} | ||
name={name} | ||
id={inputId} | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={onChange} | ||
className="w-full border border-surface py-3 px-4 xl:py-5 text-onSurface text-sm rounded-lg placeholder:text-onSurface-light placeholder:text-sm" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
type InputType = | ||
| "button" | ||
| "checkbox" | ||
| "color" | ||
| "date" | ||
| "datetime-local" | ||
| "email" | ||
| "hidden" | ||
| "image" | ||
| "month" | ||
| "number" | ||
| "password" | ||
| "radio" | ||
| "range" | ||
| "reset" | ||
| "search" | ||
| "submit" | ||
| "tel" | ||
| "text" | ||
| "time" | ||
| "url" | ||
| "week"; | ||
|
||
export interface InputProps { | ||
inputId: string; | ||
type: InputType; | ||
placeholder: string; | ||
value: string | number | undefined; | ||
label?: string; | ||
name: string; | ||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export interface ButtonProps { | ||
onClick?: () => void; | ||
text: string; | ||
type?: "submit" | "button" | "reset"; | ||
disabled?: boolean; | ||
} |