<body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
</body>
*,
*:after,
*:before {
    margin: 0;
    padding: 0;
}
img {
    width: 100%;
}
:root {
    --bg: hsl(0, 0%, 98%);
    --bg-offset: hsl(0, 0%, 100%);
    --text: hsl(200, 15%, 8%);
    --gray: hsl(0, 0%, 52%);
    --border: rgba(0, 0, 0, 0.1);
}
ul,
ol {
    list-style: none;
}
body {
    background: var(--bg);
    font-family: sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
}
h1,
h2 {
    heigh: 18px;
}
.wrapper {
    width: 96%;
    max-width: 1140px;
    margin: 0 auto;
}
.card-grid {
    margin: 2em 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-gap: 48px;
}
.card {
    background-color: var(--bg-offset);
    padding: 0px;
    box-shadow: 0px 2px 4px var(--border);
    transition: all 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);

    &:hover {
        transform: scale(1.1);

        .card-content {
            h2 {
                display: block;
                -webkit-line-clamp: none;
                -webkit-box-orient: none;
                overflow: visible;
            }
        }
    }
}
.card-image {
    max-height: 150px;

    img {
        min-height: 100%;
        width: 100%;
        object-fit: cover;
        object-position: center;
    }
}
.card-content {
    padding: 32px 15px;

    h2 {
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
.card-list {
    margin-top: 16px;

    li {
        color: var(--text);
        margin-top: 8px;

        span {
            color: var(--gray);
        }
    }
}
View Compiled
import React from "https://cdn.skypack.dev/react@17.0.1";
import ReactDOM from "https://cdn.skypack.dev/react-dom@17.0.1";

import { useState, useEffect } from "https://cdn.skypack.dev/react";

function App() {
    const [error, setError] = useState(null);
    const [isLoaded, setIsLoaded] = useState(false);
    const [items, setItems] = useState([]);

    // Note: the empty deps array [] means
    // this useEffect will run once
    // similar to componentDidMount()

    useEffect(() => {
        fetch("https://restcountries.eu/rest/v2/all")
            .then((res) => res.json())
            .then(
                (result) => {
                    setIsLoaded(true);
                    setItems(result);
                },

                // Note: it's important to handle errors here
                // instead of a catch() block so that we don't swallow
                // exceptions from actual bugs in components.

                (error) => {
                    setIsLoaded(true);
                    setError(error);
                }
            );
    }, []);

    if (error) {
        return <>{error.message}</>;
    } else if (!isLoaded) {
        return <>loading...</>;
    } else {
        return (
            <div className="wrapper">
                <ul className="card-grid">
                    {items.map((item) => (
                        <li>
                            <article className="card" key={item.callingCodes}>
                                <div className="card-image">
                                    <img src={item.flag} alt={item.name} />
                                </div>
                                <div className="card-content">
                                    <h2 className="card-name">{item.name}</h2>
                                    <ol className="card-list">
                                        <li>
                                            population:{" "}
                                            <span>{item.population}</span>
                                        </li>
                                        <li>
                                            Region: <span>{item.region}</span>
                                        </li>
                                        <li>
                                            Capital: <span>{item.capital}</span>
                                        </li>
                                    </ol>
                                </div>
                            </article>
                        </li>
                    ))}
                </ul>
            </div>
        );
    }
}

ReactDOM.render(<App />, document.getElementById("root"));
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.