Skip to content

Commit

Permalink
feat: style layout and listings
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasFASouza committed Feb 6, 2023
1 parent 97fa0cf commit 18812fd
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 83 deletions.
96 changes: 89 additions & 7 deletions auctions/static/auctions/styles.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,112 @@
a, a:hover {
text-decoration: none;
color: black;
}

body {
padding: 10px;
margin-top: 69px; /* Add a top margin to avoid content overlay */
}

/* Layout */
.nav-item:hover {
font-weight: 500;
}

.topbar {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 10px 20px;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%; /* Full width */
background-color: white;
}

.topbar-greeting {
font-size: 22px;
padding: 8px 16px
}

.filter-bar {
padding: 0px 60px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}

.categories {
display: flex;
flex-direction: row;
align-items: baseline;
}

.categories-title {
font-size: 18px;
font-weight: 600;
padding: 8px 0;
}

.watchlist {
font-size: 18px;
padding: 0px 26px;
}

.watchlist:hover {
font-weight: 500;
}

.content {
padding: 30px 60px;
}


/* Index */
.listing {
list-style-type: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 0;
padding: 0;
}

.listing-card {
width: 256px;
height: 384px;
padding: 30px;
margin: 25px;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}

.listing-card:hover {
box-shadow: rgba(0, 0, 0, 0.6) 0px 5px 15px;
}

.card-image {
.card-img {
width: 100%;
height: 100%;
height: 196px;
}

.card-text {
padding: 10px;
}

.card-title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1; /* number of lines to show */
line-clamp: 1;
-webkit-box-orient: vertical;
}

.description {
.card-description {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; /* number of lines to show */
line-clamp: 2;
-webkit-line-clamp: 4; /* number of lines to show */
line-clamp: 4;
-webkit-box-orient: vertical;
}
27 changes: 19 additions & 8 deletions auctions/templates/auctions/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
{% block body %}
<h2>{{ category }} Listings</h2>

<ul>
<ul class="listing">
{% for listing in listings %}
{% if listing.category == category and listing.active %}
<li>
<img src="{{ listing.photo_url }}" width="128">
<div>
<a href="{% url 'listing' listing.id %}">{{ listing.title }}:</a>
{{ listing.description }}, by {{ listing.seller }} - $ {{ listing.price }}
</div>
</li>
<a href="{% url 'listing' listing.id %}">
<li class="listing-card">
<img class="card-img" src="{{ listing.photo_url }}" width="128">
<div class="card-text">
<h5 class="card-title">
{{ listing.title }}
</h5>

<div>
<strong>$ {{ listing.price }}</strong>
</div>

<div>
<p class="card-description">{{ listing.description }}</p>
</div>
</div>
</li>
</a>
{% endif %}
{% endfor %}
</ul>
Expand Down
29 changes: 19 additions & 10 deletions auctions/templates/auctions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ <h2>Active Listings</h2>
<ul class="listing">
{% for listing in listings %}
{% if listing.active %}
<li class="listing-card">
<img class="card-img" src="{{ listing.photo_url }}">
<div>
<a href="{% url 'listing' listing.id %}">{{ listing.title }}:</a>
<strong>$ {{ listing.price }}</strong>
</div>
<div>
<p class="description">{{ listing.description }}</p>
</div>
</li>
<a href="{% url 'listing' listing.id %}">
<li class="listing-card">
<img class="card-img" src="{{ listing.photo_url }}">

<div class="card-text">
<h5 class="card-title">
{{ listing.title }}
</h5>

<div>
<strong>$ {{ listing.price }}</strong>
</div>

<div>
<p class="card-description">{{ listing.description }}</p>
</div>
</div>
</li>
</a>
{% endif %}
{% endfor %}
</ul>
Expand Down
105 changes: 56 additions & 49 deletions auctions/templates/auctions/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,65 @@
<link href="{% static 'auctions/styles.css' %}" rel="stylesheet">
</head>
<body>
<div>
{% if user.is_authenticated %}
Signed in as <strong>{{ user.username }}</strong>.
{% else %}
Not signed in.
{% endif %}
</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'index' %}">Active Listings</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Log Out</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'add' %}">Create listing</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Log In</a>
</li>
<div class="topbar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'register' %}">Register</a>
<a class="nav-link" href="{% url 'index' %}">Active Listings</a>
</li>
{% endif %}
</ul>
<h6>Categories</h6>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Fashion' %}">Fashion</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Home' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Electronics' %}">Electronics</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Toys' %}">Toys</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Other' %}">Other</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Log Out</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'add' %}">Create listing</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">Log In</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'register' %}">Register</a>
</li>
{% endif %}
</ul>
<div class="topbar-greeting">
{% if user.is_authenticated %}
Hello, <strong>{{ user.username }}</strong>!
{% endif %}
</div>
</div>


<div class="filter-bar">
<div class="categories">
<div class="categories-title">Categories:</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Fashion' %}">Fashion</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Home' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Electronics' %}">Electronics</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Toys' %}">Toys</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'categories' 'Other' %}">Other</a>
</li>
</ul>
</div>

{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'watchlist' %}">Watchlist</a>
</li>
<a class="watchlist" href="{% url 'watchlist' %}">Watchlist</a>
{% endif %}
</ul>
<hr>
{% block body %}
{% endblock %}
</div>

<div class="content">
{% block body %}
{% endblock %}
</div>
</body>
</html>
29 changes: 20 additions & 9 deletions auctions/templates/auctions/watchlist.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
{% extends "auctions/layout.html" %}

{% block body %}
<h2>Watchlist</h2>
<h2>Your Watchlist</h2>

<ul>
<ul class="listing">
{% for listing in watchlist %}
<li>
<img src="{{ listing.photo_url }}" width="128">
<div>
<a href="{% url 'listing' listing.id %}">{{ listing.title }}:</a>
{{ listing.description }}, by {{ listing.seller }} - $ {{ listing.price }}
</div>
</li>
<a href="{% url 'listing' listing.id %}">
<li class="listing-card">
<img class="card-img" src="{{ listing.photo_url }}" width="128">
<div class="card-text">
<h5 class="card-title">
{{ listing.title }}
</h5>

<div>
<strong>$ {{ listing.price }}</strong>
</div>

<div>
<p class="card-description">{{ listing.description }}</p>
</div>
</div>
</li>
</a>
{% endfor %}
</ul>
{% endblock %}

0 comments on commit 18812fd

Please sign in to comment.