Skip to content

Commit

Permalink
Resolve longstanding style issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddbirchard committed Dec 16, 2023
1 parent fd52118 commit f98c205
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 574 deletions.
4 changes: 2 additions & 2 deletions flask_blueprint_tutorial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def create_app():
# Import parts of our application
from .assets import compile_static_assets
from .home import home
from .products import products
from .product import product
from .profile import profile

# Register Blueprints
app.register_blueprint(profile.profile_blueprint)
app.register_blueprint(home.home_blueprint)
app.register_blueprint(products.product_bp)
app.register_blueprint(product.product_blueprint)

# Compile static assets
compile_static_assets(assets)
Expand Down
4 changes: 2 additions & 2 deletions flask_blueprint_tutorial/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def compile_static_assets(assets: Bundle) -> Bundle:
extra={"rel": "stylesheet/less"},
)
product_style_bundle = Bundle(
"products_blueprint/less/products.less",
"product_blueprint/less/product.less",
filters="less,cssmin",
output="dist/css/products.css",
output="dist/css/product.css",
extra={"rel": "stylesheet/less"},
)
assets.register("common_style_bundle", common_style_bundle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from flask_blueprint_tutorial.api import fetch_products

# Blueprint Configuration
product_bp = Blueprint("products_blueprint", __name__, template_folder="templates", static_folder="static")
product_blueprint = Blueprint("product_blueprint", __name__, template_folder="templates", static_folder="static")


@product_bp.route("/products/<int:product_id>/", methods=["GET"])
@product_blueprint.route("/products/<int:product_id>/", methods=["GET"])
def product_page(product_id: int) -> str:
"""
Product detail page for a given product ID.
Expand All @@ -20,8 +20,8 @@ def product_page(product_id: int) -> str:
"""
product = fetch_products(app)[product_id]
return render_template(
"products.jinja2",
"product.jinja2",
title=product["name"],
product=product,
template="profile-template",
template="product-template",
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import 'vars.less';

.profile-template {
.product-template {
.product-name {
font-size: 1.9em;
margin-bottom: 30px !important;
Expand All @@ -9,13 +9,20 @@

.product-image {
height: 250px;
max-width: 30vw;
margin-right: 40px;
border-radius: 3px;
}

.product-flex {
display: flex;
justify-content: space-between;
.product-details {
display: grid;
grid-template-columns: 1fr 2fr;

.product-info {
display: flex;
justify-content: space-between;
flex-direction: column;
}
}

.meta {
Expand All @@ -41,8 +48,10 @@
font-weight: 400;
border: 1px solid @theme-color;
transition: @transition;
padding: 8px 14px;
padding: 10px;
font-size: 1em;
font-weight: bold;
max-width: 283px;

&:hover {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "layout.jinja2" %}

{% block pagestyles %}
{% assets "product_less_bundle" %}
{% assets "product_style_bundle" %}
<link href="{{ ASSET_URL }}" rel="stylesheet" type="text/css">
{% endassets %}
{% endblock %}
Expand All @@ -11,9 +11,9 @@

<div class="container">
<h1 class="product-name">{{ product.name }}</h1>
<div class="product-flex">
<img class="product-image" src="{{ product.image }}" alt="profile">
<div class="product-details">
<div class="product-details">
<img class="product-image" src="{{ product.image }}" alt="{{ product.name }}">
<div class="product-info">
<div class="product-price meta"><span class="meta-name">Price:</span> <span>${{ product.salePrice }}</span></div>
<div class="product-review-average meta"><span class="meta-name">Rating:</span> <span>{{ product.customerReviewAverage }}/5</span></div>
<div class="product-review-count meta"><span class="meta-name"># Reviews:</span> <span>{{ product.customerReviewCount }}</span></div>
Expand Down
2 changes: 1 addition & 1 deletion flask_blueprint_tutorial/profile/templates/profile.jinja2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "layout.jinja2" %}

{% block pagestyles %}
{% assets "profile_less_bundle" %}
{% assets "profile_style_bundle" %}
<link href="{{ ASSET_URL }}" rel="stylesheet" type="text/css">
{% endassets %}
{% endblock %}
Expand Down
1 change: 1 addition & 0 deletions flask_blueprint_tutorial/static/dist/css/product.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion flask_blueprint_tutorial/static/dist/css/products.css

This file was deleted.

2 changes: 1 addition & 1 deletion flask_blueprint_tutorial/static/dist/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions flask_blueprint_tutorial/static/src/less/nav.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

nav {
background: #fff;
padding: 30px;
width: auto;
padding: 20px 0;
margin-bottom: 40px;
box-shadow: 0 0 5px #bec6cf;

.nav-wrapper {
max-width: 1014px !important;
width: 985px !important;
max-width: 88% !important;
display: flex;
justify-content: space-between;
align-items: center;
width: auto;
margin: 0 auto;
margin: 0 !important;

.left-nav {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion flask_blueprint_tutorial/static/src/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ html {
}

h1 {
line-height: 1;
line-height: 1.5;
margin: 0 0 5px;
}

Expand Down
Loading

0 comments on commit f98c205

Please sign in to comment.