Skip to content

Commit

Permalink
sold out badge
Browse files Browse the repository at this point in the history
  • Loading branch information
guub committed Nov 10, 2016
1 parent 785e264 commit 6f6d9b9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,8 @@ DEPENDENCIES
uglifier (>= 1.3.0)
web-console (~> 2.0)

RUBY VERSION
ruby 2.3.0p0

BUNDLED WITH
1.11.2
1.13.2
15 changes: 13 additions & 2 deletions app/assets/stylesheets/products.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ main section.categories-show {
transition: all 0.3s;
}

aside.soldout {
font-weight: bold;
color: white;
position: absolute;
top: 0;
left: 0;
padding: 10px;
background-color: red;
border-top-left-radius: 4px;
border-bottom-right-radius: 20px;
font-size: 1em;
}

aside.price {
position: absolute;
top: 0;
Expand Down Expand Up @@ -72,5 +85,3 @@ main section.products-show {
}
}
}


6 changes: 6 additions & 0 deletions app/views/products/_product.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<% end %>
</footer>

<% if product.quantity <= 0%>
<aside class="soldout">
SOLD OUT!
</aside>
<% end %>

<aside class="price">
<%= humanized_money_with_symbol product.price %>
</aside>
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def open_asset(file_name)
name: 'World\'s Largest Smartwatch',
description: Faker::Hipster.paragraph(4),
image: open_asset('electronics3.jpg'),
quantity: 32,
quantity: 0,
price: 2_026.29
})

Expand Down

0 comments on commit 6f6d9b9

Please sign in to comment.