Skip to content

Commit

Permalink
Reusable Components
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice-Dush committed Jul 2, 2024
1 parent ff1539f commit 25c1fb4
Show file tree
Hide file tree
Showing 20 changed files with 1,542 additions and 46 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"mini-css-extract-plugin": "^2.9.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.24.0",
"sass": "^1.77.6",
Expand Down
41 changes: 37 additions & 4 deletions src/components/buttons/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
import React from 'react';
/* eslint-disable */

const Button = ({ title }: { title: string }) => (
<button type="button">{title}</button>
);
import React from "react";
import "../../styles/_button.scss";

interface ButtonProps {
children: React.ReactNode;
variant?: "primary" | "secondary" | "outline";
disabled?: boolean;
onClick?: () => void;
icon?: React.ReactNode;
iconPosition?: "start" | "end";
}

function Button({
children,
variant = "outline",
disabled = false,
onClick,
icon,
iconPosition = "start",
}: ButtonProps) {
return (
<button
className={`button button--${variant} ${disabled ? "button--disabled" : ""}`}
onClick={onClick}
disabled={disabled}
>
{icon && iconPosition === "start" && (
<span className="button-icon">{icon}</span>
)}
<span className="button-text">{children}</span>
{icon && iconPosition === "end" && (
<span className="button-icon">{icon}</span>
)}
</button>
);
}

export default Button;
83 changes: 83 additions & 0 deletions src/components/categories/Categories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* eslint-disable */

import React from "react";
import "../../styles/_categories.scss";

function Categories() {
return (
<div className="categories__container">
<div className="categories">
<div className="categories__box categories__box__1">
<img
src="left-top.png"
alt="Product image"
className="categories__img"
/>
<div className="categories__content">
<p className="categories__text">Men's shoes</p>
<button className="categories__btn">View &gt;</button>
</div>
</div>
<div className="categories__box categories__box__2">
<img
src="left-bottom.png"
alt="Product image"
className="categories__img"
/>
<div className="categories__content">
<p className="categories__text">Phones</p>
<button className="categories__btn">View &gt;</button>
</div>
</div>
<div className="categories__box categories__box__3">
<img
src="middle.png"
alt="Product image"
className="categories__img"
/>
<div className="categories__controlls">
<button className="categories__controll categories__controll__left">
&lt;
</button>
<button className="categories__controll categories__controll__right">
&gt;
</button>
</div>
<div className="dots">
<div className="dot dot__active"></div>
<div className="dot"></div>
<div className="dot"></div>
</div>
</div>
<div className="categories__box categories__box__4">
<img
src="right-top.png"
alt="Product image"
className="categories__img"
/>
<div className="categories__content categories__content__right">
<p className="categories__text">Women's shoes</p>
<button className="categories__btn categories__btn__orange">
View &gt;
</button>
</div>
</div>
<div className="categories__box categories__box__5">
<img
src="right-bottom.png"
alt="Product image"
className="categories__img"
/>
<div className="categories__content categories__content__right">
<p className="categories__text ">Accessories</p>
<button className="categories__btn categories__btn__gray">
View &gt;
</button>
</div>
</div>
</div>
</div>
);
}

export default Categories;
58 changes: 58 additions & 0 deletions src/components/inputs/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-disable */

import React, { ReactNode } from "react";
import "../../styles/_input.scss";

interface InputLabelProps extends React.InputHTMLAttributes<HTMLInputElement> {
label: string;
type?: "text" | "date" | "password" | "select" | "textarea" | "search";
children?: ReactNode;
}

function InputLabel({
label,
type = "text",
children,
...props
}: InputLabelProps) {
return (
<div className="floating-label">
{type === "select" ? (
<select
className="floating-select"
{...(props as React.SelectHTMLAttributes<HTMLSelectElement>)}
>
<option value=""></option>
{children}
</select>
) : type === "textarea" ? (
<textarea
className="floating-input floating-textarea"
{...(props as React.TextareaHTMLAttributes<HTMLTextAreaElement>)}
></textarea>
) : (
<input className="floating-input" type={type} {...props} />
)}
<span className="input-highlight"></span>
<label>{label}</label>
</div>
);
}

function InputDefault(
props: React.JSX.IntrinsicAttributes &
React.ClassAttributes<HTMLInputElement> &
React.InputHTMLAttributes<HTMLInputElement>
) {
return <input className="input-default" {...props} />;
}

function InputRounded(
props: React.JSX.IntrinsicAttributes &
React.ClassAttributes<HTMLInputElement> &
React.InputHTMLAttributes<HTMLInputElement>
) {
return <input className="input-rounded" {...props} />;
}

export { InputLabel, InputDefault, InputRounded };
19 changes: 19 additions & 0 deletions src/components/inputs/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable */

import React from "react";
import "../../styles/_searchbox.scss";
import { FiSearch } from "react-icons/fi";

function SearchInput() {
return (
<form className="search-container">
<div className="search-icon">
<FiSearch />
</div>
<input type="text" />
<button className="search-button">Search</button>
</form>
);
}

export default SearchInput;
Loading

0 comments on commit 25c1fb4

Please sign in to comment.