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

Users should be able to search #13

Merged
merged 11 commits into from
Jul 17, 2024
Binary file added public/assets/images/noResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
@import "./assets/styles/SingleProduct.scss";
@import "./assets/styles/ImageSlider.scss";
@import "./assets/styles/Queries.scss";
@import "./assets/styles/Notifications.scss";
@import "./assets/styles/Notifications.scss";;
@import "./assets/styles/Search.scss";
@import "./assets/styles/CustomSelect.scss";
37 changes: 37 additions & 0 deletions src/assets/styles/CustomSelect.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.custom-select-wrapper {
position: relative;
width: 20rem;
.custom-select {
cursor: pointer;
}
.select-selected {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
border: 1px solid rgba(255, 109, 24, 0.49);
background-color: #fff;
}
.dropdown-icon {
font-size: 24px;
}
.select-items {
position: absolute;
width: 100%;
max-height: 10rem;
overflow-y: auto;
border: 1px solid #ccc;
border-top: none;
background-color: #fff;
z-index: 1;
}
.select-option {
padding: 10px;
cursor: pointer;
}
.select-option:hover {
background-color: #f1f1f1;
}
}
91 changes: 91 additions & 0 deletions src/assets/styles/Search.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.wrappers {
background-color: $container-color;

.upper-side {
display: flex;
align-items: center;
font-size: 1.5rem;
padding: 2rem 5rem;
border-bottom: 2px solid rgba(119, 119, 119, 0.49);

.product-name {
font-size: 2rem;
font-weight: 700;
color: $text-color;
margin-right: 2rem;
}

.filter-option {
display: flex;
gap: 10rem;

.selection-part {
display: flex;
align-items: center;
gap: 2rem;
font-size: 2rem;
font-weight: 700;
color: $text-color;

}

.search-Span-price {
font-size: 2rem;
font-weight: 700;
color: $text-color;
margin-right: 2rem;
}

.dropdown-select {

gap: 2rem;
font-size: 2rem;
font-weight: 700;
color: $text-color;
border: 1px solid rgba(255, 109, 24, 0.49);
border-radius: 4px;
padding: 0.5rem 2rem;
font-size: 15px;
cursor: pointer;
}
}

.discount-display {
font-size: 2rem;
display: flex;
align-items: center;
}
}

.product-main {
display: flex;

.product-list {
display: flex;
flex-wrap: wrap;
margin: 3rem 3rem;
margin-left: 5rem;
gap: 3rem;
}

.loader-spinner {
display: flex;
justify-content: center;
align-items: center;
margin-left: 70rem;
margin-top: 20rem;
}

.noResult {
margin: 0 auto;
display: flex;
flex-direction: column;
margin-bottom: 1rem;

img {
width: auto;
height: 400px;
}
}
}
}
121 changes: 77 additions & 44 deletions src/assets/styles/SearchInput.scss
Original file line number Diff line number Diff line change
@@ -1,56 +1,89 @@
@import "./Colors";

.search-container {
display: flex;
align-items: center;
border: 0.1rem solid $primary-color-dark;
border-radius: 10rem;
overflow: hidden;

.main-search {
gap:2rem;
position: relative;

.search-icon {
font-size: 2.4rem;
margin-left: -2rem;
.search-container {
display: flex;
color: $primary-color;
align-items: center;
justify-content: center;
position: relative;
cursor: pointer;
z-index: 1;
}
border: 0.1rem solid $primary-color-dark;
border-radius: 10rem;
overflow: hidden;

input {
border: none;
outline: none;
font-family: inherit;
font-size: 1.6rem;
flex: 1;
background-color: transparent;

&::placeholder {
color: $secondary-color;
.search-icon {
font-size: 2.4rem;
padding-left:1rem;
display: flex;
color: $primary-color;
align-items: center;
justify-content: center;
position: relative;
cursor: pointer;
z-index: 1;
}
}

.search-button {
background-color: $primary-color;
border: none;
padding: 0.8rem 4.8rem;
color: $white;
font-size: 1.6rem;
font-weight: 600;
cursor: pointer;
position: relative;
z-index: 1;
transition: all 0.2s ease-in;

&:hover {
background-color: darken($primary-color, 10%);
input {
border: none;
outline: none;
font-family: inherit;
font-size: 1.6rem;
flex: 1;
background-color: transparent;

&::placeholder {
color: $secondary-color;
}
}

&:focus {
outline: none;
.search-button {
background-color: $primary-color;
border: none;
padding: 0.8rem 4.8rem;
color: $white;
font-size: 1.6rem;
font-weight: 600;
cursor: pointer;
position: relative;
z-index: 1;
transition: all 0.2s ease-in;

&:hover {
background-color: darken($primary-color, 10%);
}

&:focus {
outline: none;
}
}
}
.search-result {
position: absolute;
width: 36.5rem;
max-height: 28em;
left: 0.5rem;
z-index: 1000;
margin-top: 0.1rem;
padding: 1rem;
font-size: 14px;
font-weight: 500;
background-color: $white;
overflow-y: auto;
text-decoration: none;
.result {
display: flex;
flex-direction: column;
padding: 13px;
border: 1px solid none;
margin-top: 1px;
}
.result:hover {
background: rgb(242, 240, 240);
padding: 15px;
cursor: pointer;
}
}
.link{
text-decoration: none;
color: black;
}
}
71 changes: 71 additions & 0 deletions src/components/Dropdown/CustomSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-disable */
import React, { useState, useEffect, useRef } from 'react';
import { RiArrowDropDownLine } from 'react-icons/ri';

interface Option {
label: string;
value: string;
}

interface CustomSelectProps {
options: Option[];
onSelect: (selected: string) => void;
value: string;
}

const CustomSelect: React.FC<CustomSelectProps> = ({ options, onSelect, value }) => {
const [selectedLabel, setSelectedLabel] = useState('Select an option');
const [isOpen, setIsOpen] = useState(false);
const wrapperRef = useRef<HTMLDivElement>(null);

useEffect(() => {
const selectedOption = options.find(option => option.value === value);
if (selectedOption) {
setSelectedLabel(selectedOption.label);
}
}, [value, options]);

useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) {
setIsOpen(false);
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);

const handleOptionClick = (option: Option) => {
setSelectedLabel(option.label);
setIsOpen(false);
onSelect(option.value);
};

return (
<div className="custom-select-wrapper" ref={wrapperRef}>
<div className="custom-select" onClick={() => setIsOpen(!isOpen)}>
<div className="select-selected">
{selectedLabel}
<RiArrowDropDownLine className="dropdown-icon" />
</div>
{isOpen && (
<div className="select-items">
{options.map((option, index) => (
<div
key={index}
className="select-option"
onClick={() => handleOptionClick(option)}
>
{option.label}
</div>
))}
</div>
)}
</div>
</div>
);
};

export default CustomSelect;
9 changes: 9 additions & 0 deletions src/components/buttons/Button2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */

import React from "react";

const Button = ({ title }: { title: string }) => (
<button type="button">{title}</button>
);

export default Button;
1 change: 0 additions & 1 deletion src/components/inputs/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable */

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

interface InputLabelProps extends React.InputHTMLAttributes<HTMLInputElement> {
label: string;
Expand Down
Loading
Loading