Mock Shop
About this app
A simple React app that displays products from Mock Shop
Mock Shop
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Mock Shop</title>
<meta name="description" content="A simple React app that displays products from Mock Shop">
<meta name="keywords" content="React, app, Mock Shop, products, Shopify Polaris, grid">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
font-family: 'Roboto', sans-serif;
}
.container {
padding-top: 40px;
}
.product-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 30px;
}
.product-card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
transition: all 0.3s ease;
cursor: pointer;
text-align: center;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.product-image {
margin-bottom: 20px;
}
.product-title {
font-size: 18px;
font-weight: 500;
margin-bottom: 10px;
}
.product-price {
font-size: 16px;
color: #666;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<div id="app"></div>
</div>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/@shopify/polaris@5.3.0/dist/index.js"></script>
<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
const { useState, useEffect } = React;
const { Button, Card, Layout, SkeletonPage, SkeletonBodyText, SkeletonDisplayText } = window.Polaris;
const App = () => {
const [products, setProducts] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
axios.get('https://mock.shop/products')
.then(response => {
setProducts(response.data);
setLoading(false);
})
.catch(error => {
console.log(error);
setLoading(false);
});
}, []);
return (
<Layout>
<Layout.Section>
{loading ? (
<SkeletonPage primaryAction secondaryActions={1}>
<Layout>
<Layout.Section>
<Card sectioned>
<SkeletonBodyText />
</Card>
<Card sectioned>
<SkeletonBodyText />
</Card>
<Card sectioned>
<SkeletonBodyText />
</Card>
</Layout.Section>
</Layout>
</SkeletonPage>
) : (
<div className="product-grid">
{products.map((product) => (
<Card key={product.id} sectioned>
<div className="product-image">
<img src={product.image} alt={product.title} />
</div>
<div className="product-title">{product.title}</div>
<div className="product-price">${product.price}</div>
<Button>Buy Now</Button>
</Card>
))}
</div>
)}
</Layout.Section>
</Layout>
);
};
ReactDOM.render(<App />, document.getElementById('app'));
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
</body>
</html>
NEW APPS
These are apps made by the community!