diff --git a/src/components/commons/Card/Card.jsx b/src/components/commons/Card/Card.jsx index c19ca8e..740a17c 100644 --- a/src/components/commons/Card/Card.jsx +++ b/src/components/commons/Card/Card.jsx @@ -1,3 +1,69 @@ -export const Card = () => { - return
TODO
; +import { LinkButton } from "../LinkButton/LinkButton"; +import { Description } from "../Description/Description"; +import { SubTitle } from "../SubTitle/SubTitle"; +import { Title } from "../Title/Title"; + +// import data from "../../../assets/data/data.json"; + +// 1 - build the caomponent base + +// export const Card = () => { +// return ( +//
+// +// Im a title +// best location +// +// Github +// Twitter +//
+// ); +// }; + +// 2 - handle one item + +// export const Card = () => { +// const [first, ...rest] = data; +// return ( +//
+// +// {first.title} +// {first.location} +// +// {first.links[0].name} +// {first.links[1].name} +//
+// ); +// }; + +// 3 - Handle multiple buttons +// export const Card = () => { +// const [first, ..._] = data; +// return ( +//
+// place +// {first.title} +// {first.location} +// +// {first.links.map(({ url, name }) => ( +// {name} +// ))} +//
+// ); +// }; + +// 4 - add props to Card to handle multiple Cards (from Home.jsx) + +export const Card = ({ image, title, location, description, links, id }) => { + return ( +
+ place + {title} + {location} + + {links.map(({ url, name }) => ( + {name} + ))} +
+ ); }; diff --git a/src/components/commons/Description/Description.jsx b/src/components/commons/Description/Description.jsx new file mode 100644 index 0000000..8d3ed2d --- /dev/null +++ b/src/components/commons/Description/Description.jsx @@ -0,0 +1,3 @@ +export const Description = ({ text }) => { + return

{text}

; +}; diff --git a/src/components/commons/LinkButton/LinkButton.jsx b/src/components/commons/LinkButton/LinkButton.jsx new file mode 100644 index 0000000..1a962c4 --- /dev/null +++ b/src/components/commons/LinkButton/LinkButton.jsx @@ -0,0 +1,3 @@ +export const LinkButton = ({ link, children }) => { + return {children} ; +}; diff --git a/src/components/commons/SubTitle/SubTitle.jsx b/src/components/commons/SubTitle/SubTitle.jsx new file mode 100644 index 0000000..cada92e --- /dev/null +++ b/src/components/commons/SubTitle/SubTitle.jsx @@ -0,0 +1,3 @@ +export const SubTitle = ({ children }) => { + return

{children}

; +}; diff --git a/src/components/commons/Title/Title.jsx b/src/components/commons/Title/Title.jsx new file mode 100644 index 0000000..cbf03ee --- /dev/null +++ b/src/components/commons/Title/Title.jsx @@ -0,0 +1,3 @@ +export const Title = ({ children }) => { + return

{children}

; +}; diff --git a/src/index.css b/src/index.css index 8ec1960..f94540f 100644 --- a/src/index.css +++ b/src/index.css @@ -111,3 +111,4 @@ a:hover { background-color: var(--green); color: var(--grey-700); } + diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 38ad338..0ae5923 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -1,12 +1,37 @@ import { Card } from "../components"; +import data from "../assets/data/data.json"; +import { useState } from "react"; export const Home = () => { + const [filteredData, setFilteredData] = useState(data); + + const handleChange = (e) => { + const text = e.target.value; + setFilteredData( + data.filter((cardData) => + cardData.title + .toLocaleLowerCase() + .includes(text.toLocaleLowerCase()) + ) + ); + }; + return (
- {/* TODO: Implement filter by category when the user enters letters */} - {/* */} +
- + {filteredData.map((place) => ( + + ))}
);