generated from ReCoded-Org/capstone-react-redux-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finalized filter results component (#99)
* finalized filter results component * updated snapshot * updated snapshot Co-authored-by: Allan <[email protected]> Co-authored-by: allan <[email protected]>
- Loading branch information
1 parent
63a3583
commit 34e3341
Showing
12 changed files
with
755 additions
and
35 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,69 @@ | ||
import { Fragment } from "react"; | ||
import { Menu, Transition } from "@headlessui/react"; | ||
|
||
function FilterButton() { | ||
return ( | ||
<Menu | ||
as="div" | ||
data-testid="filter-button" | ||
className="relative inline-block text-left" | ||
> | ||
<div> | ||
<Menu.Button | ||
data-testid="filter-botton-toggle" | ||
className="rounded-full bg-gray-300 mr-5 mt-5 pl-5 pr-5 text-lg duration-500 hover:bg-accent" | ||
> | ||
{" "} | ||
Sort results by | ||
</Menu.Button> | ||
</div> | ||
|
||
<Transition | ||
as={Fragment} | ||
enter="transition ease-out duration-100" | ||
enterFrom="transform opacity-0 scale-95" | ||
enterTo="transform opacity-100 scale-100" | ||
leave="transition ease-in duration-75" | ||
leaveFrom="transform opacity-100 scale-100" | ||
leaveTo="transform opacity-0 scale-95" | ||
> | ||
<Menu.Items className="absolute left-0 md:right-0 z-10 mt-2 w-40 origin-center md:origin-top-right rounded-md bg-accent shadow-lg ring-1 ring-white ring-opacity-5 focus:outline-none"> | ||
<div> | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<div | ||
data-testid="language-button-option" | ||
aria-hidden="true" | ||
className={`${ | ||
active | ||
? "bg-white text-secondary rounded" | ||
: "text-black-500" | ||
}`} | ||
> | ||
<h3>Newest</h3> | ||
</div> | ||
)} | ||
</Menu.Item> | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<div | ||
data-testid="language-button-option" | ||
aria-hidden="true" | ||
className={`${ | ||
active | ||
? "bg-white text-secondary rounded" | ||
: "text-black-500" | ||
}`} | ||
> | ||
<h3>Oldest</h3> | ||
</div> | ||
)} | ||
</Menu.Item> | ||
</div> | ||
</Menu.Items> | ||
</Transition> | ||
</Menu> | ||
); | ||
} | ||
|
||
export default FilterButton; |
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,62 @@ | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faBookmark } from "@fortawesome/free-regular-svg-icons"; | ||
import FilterButton from "./FilterButton"; | ||
|
||
function FilterResults({ filterData }) { | ||
const jobCard = filterData.map((job) => { | ||
return ( | ||
<div | ||
key={job.id} | ||
className="rounded-md grid justify-items-center gap-3 m-5 bg-white drop-shadow-xl grid-cols-2 grid-rows-4 md:grid-cols-5 md:grid-rows-2" | ||
> | ||
<img | ||
className="order-1 col-span-2 h-20 md:row-span-2 md:col-span-1 md:scale-60 object-contain md:h-28 md:order-1" | ||
src={job.src} | ||
alt="hiring company logo" | ||
/> | ||
<h2 className="order-4 font-semibold text-center md:font-semibold md:mt-3 md:order-2"> | ||
{job.position} | ||
</h2> | ||
<h2 className="order-5 md:font-semibold md:mt-3 md:order-3"> | ||
{job.jobModel} | ||
</h2> | ||
<h2 className="order-6 font-semibold md:font-semibold md:mt-3 md:order-4 "> | ||
{job.salary} | ||
</h2> | ||
<FontAwesomeIcon | ||
className="order-3 md:mt-3 md:order-5" | ||
icon={faBookmark} | ||
/> | ||
<h2 className="order-8 font-semibold mb-5 md:font-normal md:order-6"> | ||
{" "} | ||
{job.employer} | ||
</h2> | ||
<h2 className="order-9 mb-5 md:order-7"> {job.jobType}</h2> | ||
<h2 className="order-7 md:order-8"> {job.payFreq}</h2> | ||
<h2 className="order-2 font-semibold md:font-normal md:order-9"> | ||
{" "} | ||
{job.postingDate} | ||
</h2> | ||
</div> | ||
); | ||
}); | ||
return ( | ||
<div className="bg-gray-500/5"> | ||
<div className="flex justify-between"> | ||
<h2 className="ml-5 mt-5 text-lg"> | ||
{" "} | ||
Total{" "} | ||
<span className="text-accent font-semibold"> | ||
{" "} | ||
{filterData.length}{" "} | ||
</span> | ||
Results | ||
</h2> | ||
<FilterButton /> | ||
</div> | ||
{jobCard} | ||
</div> | ||
); | ||
} | ||
|
||
export default FilterResults; |
10 changes: 10 additions & 0 deletions
10
src/components/FilterResults/__tests__/FilterResults.test.jsx
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 @@ | ||
import renderer from "react-test-renderer"; | ||
import FilterResults from "../FilterResults"; | ||
import { filterData } from "../../../data/filterData"; | ||
|
||
it("renders Company Showcase Component correctly", () => { | ||
const tree = renderer | ||
.create(<FilterResults filterData={filterData} />) | ||
.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); |
Oops, something went wrong.