Skip to content

Commit

Permalink
SVG images! Carousel working with sidebar buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmilner committed Mar 21, 2012
1 parent 60dbd51 commit b08b4d3
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 41 deletions.
11 changes: 11 additions & 0 deletions app/assets/images/upload.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions app/assets/javascripts/application.js
Expand Up @@ -12,6 +12,7 @@
// //
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require bootstrap-transition
//= require bootstrap-carousel //= require bootstrap-carousel
//= require_tree . //= require_tree .


Expand All @@ -20,12 +21,13 @@
// favorite_btn // favorite_btn
$(document).ready(function($) { $(document).ready(function($) {



$('.carousel').carousel()

$('.previous-button').click(function() {

$('.carousel').carousel('prev');

});

$('.forward-button').click(function() {

$('.carousel').carousel('next');
});


// // $("#disableBtn").click(function() { // // $("#disableBtn").click(function() {
// // $("#clearBtn").attr("disabled", "disabled"); // // $("#clearBtn").attr("disabled", "disabled");
Expand All @@ -46,5 +48,4 @@ $(document).ready(function($) {
// //
// // $('.label').vertAlign(); // // $('.label').vertAlign();


}); // ready() }); // ready()

1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Expand Up @@ -12,6 +12,7 @@
*= require global/fontface *= require global/fontface
*= require global/global *= require global/global
*= require global/header *= require global/header
*= require carousel
*= require global/section *= require global/section
*= require global/nav *= require global/nav
*= require global/footer *= require global/footer
Expand Down
96 changes: 96 additions & 0 deletions app/assets/stylesheets/carousel.css.scss
@@ -0,0 +1,96 @@
.carousel {
position: relative;
margin-bottom: 18px;
line-height: 1;
}
.carousel-inner {
overflow: hidden;
width: 100%;
position: relative;
}
.carousel .item {
display: none;
position: relative;
-webkit-transition: 0.6s ease-in-out left;
-moz-transition: 0.6s ease-in-out left;
-ms-transition: 0.6s ease-in-out left;
-o-transition: 0.6s ease-in-out left;
transition: 0.6s ease-in-out left;
}
.carousel .item > img {
display: block;
line-height: 1;
}
.carousel .active,
.carousel .next,
.carousel .prev {
display: block;
}
.carousel .active {
left: 0;
}
.carousel .next,
.carousel .prev {
position: absolute;
top: 0;
width: 100%;
}
.carousel .next {
left: 100%;
}
.carousel .prev {
left: -100%;
}
.carousel .next.left,
.carousel .prev.right {
left: 0;
}
.carousel .active.left {
left: -100%;
}
.carousel .active.right {
left: 100%;
}
.carousel-control {
position: absolute;
top: 40%;
left: 15px;
width: 40px;
height: 40px;
margin-top: -20px;
font-size: 60px;
font-weight: 100;
line-height: 30px;
color: #ffffff;
text-align: center;
background: #222222;
border: 3px solid #ffffff;
-webkit-border-radius: 23px;
-moz-border-radius: 23px;
border-radius: 23px;
opacity: 0.5;
filter: alpha(opacity=50);
}
.carousel-control.right {
left: auto;
right: 15px;
}
.carousel-control:hover {
color: #ffffff;
text-decoration: none;
opacity: 0.9;
filter: alpha(opacity=90);
}
.carousel-caption {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 10px 15px 5px;
background: #333333;
background: rgba(0, 0, 0, 0.75);
}
.carousel-caption h4,
.carousel-caption p {
color: #ffffff;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/global/footer.css.scss
Expand Up @@ -5,6 +5,9 @@




footer { footer {

display: none;

position: fixed; position: fixed;
right: 0; right: 0;
bottom: 0; bottom: 0;
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/global/header.css.scss
Expand Up @@ -21,6 +21,7 @@ header {
right: 0; right: 0;
left: 0; left: 0;
border-bottom: 2px solid $red_shade; border-bottom: 2px solid $red_shade;
z-index: 1000;


@include box_shadow_inset(0px, 0px, 0px, 0px, rgba(0, 0, 0, 0.1)); @include box_shadow_inset(0px, 0px, 0px, 0px, rgba(0, 0, 0, 0.1));
background-color: $red; background-color: $red;
Expand Down
120 changes: 102 additions & 18 deletions app/assets/stylesheets/global/section.css.scss
@@ -1,36 +1,120 @@
/* imports */
@import 'variables';
@import 'mixins';

section { section {
height: 100%; height: 100%;
.slider { #carousel-excuses {
height: 100%; height: 100%;
.prev, .next { .previous-button, .forward-button {
background-color: rgba(0, 0, 0, 0.05); background-color: rgba(0, 0, 0, 0.05);
float: left; float: left;
height: 100%; height: 100%;
width: 10%; width: 10%;
z-index: 2;

}
.previous-button {
background-image: url('/assets/upload.svg');
background-image: none, url('/assets/upload.svg'), url('/assets/upload.svg');
background-size: 60% auto;
background-repeat: no-repeat;
background-position: center center;
opacity: 0.4;
transition: opacity 200ms;
-moz-transition: opacity 200ms;
-webkit-transition: opacity 200ms;
-o-transition: opacity 200ms;
&:hover { &:hover {
background-color: rgba(0, 0, 0, 0.15); opacity: 0.6;
} transition: opacity 200ms;
.label { -moz-transition: opacity 200ms;
position: absolute; -webkit-transition: opacity 200ms;
top: 45%; -o-transition: opacity 200ms;
span {
display: block;
text-align: center;
}
} }
} }
.prev { .forward-button {
background-image: url('/assets/upload.svg');
background-image: none, url('/assets/upload.svg'), url('/assets/upload.svg');
background-size: 60% auto;
background-repeat: no-repeat;
background-position: center center;
opacity: 0.4;
transition: opacity 200ms;
-moz-transition: opacity 200ms;
-webkit-transition: opacity 200ms;
-o-transition: opacity 200ms;
&:hover {
opacity: 0.6;
transition: opacity 200ms;
-moz-transition: opacity 200ms;
-webkit-transition: opacity 200ms;
-o-transition: opacity 200ms;
}
} }
.content { .carousel-inner {
padding-top: 90px;
padding-bottom: 90px;
float: left; float: left;
margin-top: 90px;
margin-bottom: 5%;
width: 80%; width: 80%;
ul { .item {
margin: 40px; padding: 5%;
min-height: 200px;
} }
} }
.next { }
}

.details {
margin: 20px 0;
h3 {
float: left;
font-size: 12px;
letter-spacing: 2px;
line-height: 32px;
margin-right: 10px;
text-transform: uppercase;
}
ul {
float: left;
li {
background-color: $blue;
color: #fff;
float: left;
font-size: 12px;
letter-spacing: 1px;
line-height: 18px;
margin: 2px 5px;
padding: 5px 10px;
text-transform: uppercase;
a {
color: #fff;
}
}
}
}

.favorites {

}
.tags {
li.tag {
background-color: $blue;
color: #fff;
float: left;
font-size: 12px;
letter-spacing: 1px;
line-height: 18px;
margin: 2px 5px;
padding: 5px 10px;
text-transform: uppercase;
@include border_radius(25px);
@include box_shadow_inset(0, 0, 2px, 2px, rgba(0, 0, 0, 0.03));
a {
color: #fff;
}
&:hover {
background-color: $blue_shade;
} }
} }
} }
55 changes: 40 additions & 15 deletions app/views/pages/excuse.html.haml
Expand Up @@ -4,24 +4,49 @@
= render 'layouts/notice', :notice => notice, :type => "info" = render 'layouts/notice', :notice => notice, :type => "info"


%section %section
.slider #carousel-excuses.carousel.slide
.prev
.label .previous-button
%span prev .previous-icon
.content
.carousel-inner
- if @excuses.count > 0 - if @excuses.count > 0
%ul - @excuses.each_with_index do |excuse, index|
- @excuses.each do |excuse| - if index == 0
%li .item.active
= excuse.text .text
%h2
= excuse.text
- if @current_user.present?
.details.favorites
%h3 Favorites
= form_tag favorites_path do
= hidden_field_tag :excuse, excuse.id
= submit_tag "Favorite", :name => nil
.details.tags
%h3 Tags
%ul
- excuse.tags.each do |tag|
%li.tag{ :class => "tag-blue" }= link_to tag.name, "tag/#{tag.name}", :rel => "tag"

- else
.item
.text
%h2
= excuse.text
- if @current_user.present? - if @current_user.present?
%span .details.favorites
%h3 Favorites
= form_tag favorites_path do = form_tag favorites_path do
= hidden_field_tag :excuse, excuse.id = hidden_field_tag :excuse, excuse.id
= submit_tag "Favorite", :name => nil = submit_tag "Favorite", :name => nil
.details.tags
%h3 Tags
%ul
- excuse.tags.each do |tag|
%li.tag{ :class => "tag-blue" }= link_to tag.name, "tag/#{tag.name}", :rel => "tag"
- else - else
%ul .item.active There's no excuse for no excuses! There's only an excuse for Oh, Excuses... Why don't you create one?
%li There's no excuse for no excuses! There's only an excuse for Oh, Excuses... Why don't you create one?
.next .forward-button
.label .forward-icon
%span next

0 comments on commit b08b4d3

Please sign in to comment.