Skip to content

Commit

Permalink
Product コンポーネントの実装
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronMaywood committed Apr 7, 2022
1 parent a3d732e commit f2f9a03
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='/build/bundle.css'>
<style>
body {
font-family: system-ui;
}
</style>

<script defer src='/build/bundle.js'></script>
</head>
Expand Down
5 changes: 5 additions & 0 deletions src/Index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import Product from './Lib/Product.svelte';
</script>

<Product />
119 changes: 119 additions & 0 deletions src/Lib/Product.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<div class="product">
<div class="product-container">
<figure><img src="https://www.ikea.com/us/en/images/products/fejka-artificial-potted-plant-indoor-outdoor-cactus__0935865_PE792997_S5.JPG?f=xs" />
</figure>
<div>
<h3>Cactus</h3>
<span class="price">$16.99</span>
<p>This plant is a very good one. There is a product description that talks about plant care and other details here.</p>
<button>Add to Cart</button>
</div>
</div>
</div>

<style>
img {
width: 100%;
}
figcaption,
h3 {
font-size: 14px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.25px;
margin: 0.5rem 1rem 0;
}
.price {
display: block;
font-size: 14px;
margin: 0 1rem;
}
.product p {
margin-top: 1rem;
font-size: 13px;
color: #555;
margin: 0.5rem 1rem 0;
}
button {
border: none;
display: block;
background: white;
font-size: 14px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.25px;
padding: 0.25rem 0.5rem;
margin: 1rem auto;
cursor: pointer;
background: #c2ceb0;
}
/* これはProduct を利用する側(Sidebar)に持たせるべきCSS
.sidebar .product + .product {
margin-top: 0.5rem;
}
*/
/* CQ (=Container Query) コンテナークエリーに関連するもの */
.product {
container: inline-size;
}
.hero .product {
position: absolute;
bottom: 1rem;
right: 1rem;
/* Slot the product card into a size */
width: 350px;
background: white;
}
/* Smaller version (ie. sidebar in this demo) */
/*
@container (max-width: 200px) {
.product-container {
border: 1px solid #c2ceb0;
padding: 0.5rem;
border-radius: 10px;
display: flex;
align-items: center;
}
.product-container h3 {
letter-spacing: 0;
width: 90px;
overflow: hidden;
text-overflow: ellipsis;
white-space: pre;
margin: 0;
}
.product-container span {
margin: 0;
}
.product-container p,
.product-container button {
display: none;
}
}
*/
/* wider sizes (i.e in hero) */
/*
@container (min-width: 350px) {
.product-container {
padding: 0.5rem 0 0;
display: flex;
}
.product button {
margin-left: 1rem;
}
}
*/
</style>

0 comments on commit f2f9a03

Please sign in to comment.