diff --git a/src/App.jsx b/src/App.jsx index 84162ae..907e52e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,49 +1,52 @@ import "./App.css"; +import { useState, useEffect } from "react"; +import Header from "./components/header"; +import SearchBar from "./components/searchBar"; +import Card from "./components/card"; function App() { + const [filterCards, setFilterCards] = useState([]); + + const cardsJSX = filterCards.map((card) => ( + + )); + + useEffect(() => { + fetch("https://api.github.com/search/repositories?q=stars:>10000", { + headers: { + Authorization: "Bearer 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", + }, + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + setFilterCards(data.items); + }); + }, []); return ( <> -
-
-

Welcome to the JSHeroes Bootcamp!

-
- -
- +
-
- - -
- -
    -
  • - facebook/react - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • - -
  • - vuejs/vue - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • - -
  • - sveltejs/svelte - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • -
+ { + console.log(value); + const items = []; + fetch(`https://api.github.com/search/repositories?q=${value}`) + .then((response) => response.json()) + .then((data) => { + console.log(data); + setFilterCards(data.items); + }); + console.log(items); + setFilterCards(items); + }} + /> +
    {cardsJSX}
); diff --git a/src/components/card.jsx b/src/components/card.jsx new file mode 100644 index 0000000..45b6280 --- /dev/null +++ b/src/components/card.jsx @@ -0,0 +1,12 @@ +const Card = (props) => ( +
  • + {props.title} + {props.description} +
    +
    Stars: {props.stars}
    +
    Forks: {props.forks}
    +
    +
  • +); + +export default Card; diff --git a/src/components/header.jsx b/src/components/header.jsx new file mode 100644 index 0000000..6fe9a84 --- /dev/null +++ b/src/components/header.jsx @@ -0,0 +1,10 @@ +const Header = () => ( +
    +
    +

    Welcome to the JSHeroes Bootcamp!

    +
    + +
    +); + +export default Header; \ No newline at end of file diff --git a/src/components/searchBar.jsx b/src/components/searchBar.jsx new file mode 100644 index 0000000..2315233 --- /dev/null +++ b/src/components/searchBar.jsx @@ -0,0 +1,20 @@ +import { useRef } from "react"; + +const SearchBar = (props) => { + let inputRef = useRef(null); + const handleSearch = (event) => { + event.preventDefault(); + props.onSearch(inputRef.current.value); + }; + + return ( +
    + + +
    + ); +}; + +export default SearchBar;