add product page

This commit is contained in:
Amro Alfien 2024-11-17 16:59:10 +07:00
parent b7e4216705
commit 27e0d9d293
10 changed files with 112 additions and 1 deletions

View File

@ -10,6 +10,7 @@ from config import directory
import templates.plain.main as template_public import templates.plain.main as template_public
import modules.public.home as public_home import modules.public.home as public_home
import modules.public.product as public_product
app = Bottle() app = Bottle()
@ -21,3 +22,12 @@ def index():
} }
} }
return public_home.main().html(params) return public_home.main().html(params)
@app.route('/product')
def product():
params = {
"mako":{
"website" : template_public.main(directory.page["public"], "product")
}
}
return public_product.main().html(params)

View File

@ -21,6 +21,6 @@ class main:
container = Template(params["mako"]["website"]['container']).render( container = Template(params["mako"]["website"]['container']).render(
header = "Welcome to CostaCoffe", header = "Welcome to CostaCoffe",
sub_header = "Best Place To Buy Coffe", sub_header = "Best Place To Buy Coffe",
header_desc = f"Experience the rich flavors and aromas of our premium coffee" header_desc = "Experience the rich flavors and aromas of our premium coffee"
) )
) )

36
modules/public/product.py Normal file
View File

@ -0,0 +1,36 @@
from mako.template import Template
from config import globalvar
class Coffe:
def __init__(self, image, name, price) -> None:
self.image = image
self.name = name
self.price = price
class main:
def __init__(self):
pass
def html(self, params):
return Template(params["mako"]["website"]['index']).render(
title = globalvar.title,
navbar = Template(params["mako"]["website"]['navbar']).render(
title = globalvar.title,
menu = globalvar.menu['public']['navbar'],
user_roles = ["guest"],
active_page = "Our Product"
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render(
products = [
Coffe("coffe1.png", "Classic Coffe", "8.000"),
Coffe("coffe2.png", "Cappucino", "12.000"),
Coffe("coffe3.png", "Mochaccino", "15.000"),
Coffe("coffe4.png", "Latte Machiato", "16.000"),
Coffe("coffe5.png", "Ice Coffe Latte", "14.000"),
Coffe("coffe6.png", "Glass Cafe", "18.000"),
]
)
)

65
pages/public/product.html Normal file
View File

@ -0,0 +1,65 @@
<div class="container">
<h2>Our Coffe</h2>
<div class="coffe-grid">
% for coffe in products:
<div class="item">
<div class="card-img">
<img src="/img/products/${coffe.image}" alt="${coffe.name}">
</div>
<div class="card-body">
<h3>${coffe.name}</h3>
<h4>Rp. ${coffe.price}</h4>
</div>
</div>
% endfor
</div>
</div>
<style>
.container {
max-width: 860px;
margin: 0 auto;
text-align: center;
}
.container h2 {
font-size: 2.4rem;
font-weight: 600;
}
.coffe-grid {
display: grid;
grid-template-columns: repeat(3, auto);
gap: 4.2rem;
}
.coffe-grid .card-img {
width: 200px;
height: 200px;
margin: 0 auto;
}
.coffe-grid .item {
border-radius: 1.2rem;
background-color: #fdfdfd;
}
.card-img img {
width: 100%;
height: 100%;
object-fit: contain;
}
.card-body h3 {
font-size: 2rem;
font-weight: 500;
margin: 0.6rem 0;
}
.card-body h4 {
font-size: 1.2rem;
font-weight: 400;
margin-top: 0.6rem;
color: #727272;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB