Skip to content

Commit

Permalink
Make CSS module .Feature for featured libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Dec 9, 2014
1 parent 02094a3 commit 9e3a293
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 218 deletions.
48 changes: 25 additions & 23 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,33 @@
@import "layout/main";
@import "layout/footer";
@import "layout/ajax";
@import "layout/feedback"; // feedback sidelabels
@import "layout/news_header"; // header for news
@import "layout/feedback"; // feedback sidelabels
@import "layout/news_header"; // header for news

// Modules
@import "modules/notice"; // Notice boxes
@import "modules/button"; // Buttons
@import "modules/tag"; // small eco/fair/s&p tags
@import "modules/tabs"; // tab navigation
@import "modules/article"; // an article tile
@import "modules/address"; // an address tile
@import "modules/accordion"; // accordions
@import "modules/search"; // search result, filters, categories
@import "modules/grid"; // anonymos grid
@import "modules/articlelistview"; // listview articles
@import "modules/user"; // user profile tile
@import "modules/content"; // helper for cms
@import "modules/js"; // javascript controlling classes with attached styles
@import "modules/hearts"; // heart button css
@import "modules/comments"; // comments css
@import "modules/gray_box"; // comments css
@import "modules/library"; // Library containers
@import "modules/payment"; // payment box
@import "modules/rating"; // rating box
@import "modules/line_item_group"; // line_item_group box
@import "modules/collect_button"; // collect button
@import "modules/address"; // an address tile
@import "modules/accordion"; // accordions
@import "modules/article"; // an article tile
@import "modules/articlelistview"; // listview articles
@import "modules/button"; // Buttons
@import "modules/collect_button"; // collect button
@import "modules/comments"; // comments css
@import "modules/content"; // helper for cms
@import "modules/feature"; // featured library for landing page
@import "modules/gray_box";
@import "modules/grid"; // anonymous grid
@import "modules/hearts"; // heart button css
@import "modules/js"; // JavaScript controlling classes with
// attached styles
@import "modules/library"; // Library containers
@import "modules/line_item_group"; // line_item_group box
@import "modules/notice"; // Notice boxes
@import "modules/payment"; // payment box
@import "modules/rating"; // rating box
@import "modules/search"; // search result, filters, categories
@import "modules/tabs"; // tab navigation
@import "modules/tag"; // small eco/fair/s&p tags
@import "modules/user"; // user profile tile


// vendor changes
Expand Down
94 changes: 0 additions & 94 deletions app/assets/stylesheets/controller/articles.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -494,97 +494,3 @@ ul.category-selected-list {
margin-top: 2em;
width:80%;
}


/* ==============================================================
*
* Article index
*
* ==============================================================
*/

/* Landing pages for fair/eco/small/used articles */
/* CSS taken form categories controller */
/* Should maybe be modularized */


.feature-inner {
@include whitebox;
@include clearfix;
}

.feature-inner > h2 {
margin: em(6) 0 em(11) 0;
}

.feature--quadruple .Grid-item {

@include till-breakpoint( $bp-tablet) {
&:nth-last-child(2), &:last-child {
display: none;
}
}
@include between-breakpoints($bp-tablet, $bp-desktop) {
&:last-child {
display: none;
}
}
}
//.feature--double .Grid-item {
// @include till-breakpoint($bp-tablet-horizontal) {
// &:last-child {
// display: none
// }
// }
//}

.feature {
margin-bottom: 1em;
}

.feature--double {
clear:both;
}

@include between-breakpoints($bp-tablet, $bp-desktop) {
.feature--double {
@include span(2 of 3 0.05);
}
.feature--collapsible {
@include span(1 of 3 0.05);
@include omega;
}
}

@include at-breakpoint($bp-desktop) {
.feature--double {
@include span(1 of 2 0.05);
}
.feature--collapsible {
@include span(1 of 2 0.05);
@include omega;
}
}


.feature--double .Grid > .Grid-item {
@include at-breakpoint($bp-mobile) {
@include grid-with-columns(2);
}
}

.feature--collapsible .Grid > .Grid-item {
@include between-breakpoints($bp-mobile,$bp-tablet) {
@include grid-with-columns(2);
}
@include between-breakpoints($bp-tablet,$bp-desktop) {
@include grid-with-columns(1);
&:last-child {
display: none
}
}
@include at-breakpoint($bp-desktop) {
@include grid-with-columns(2);
}
}

81 changes: 0 additions & 81 deletions app/assets/stylesheets/controller/categories.css.scss

This file was deleted.

77 changes: 77 additions & 0 deletions app/assets/stylesheets/modules/_feature.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Featured libraries for category and filter landing pages
* like books, fair, eco, small, used
*/


.Feature { margin-bottom: 1em; }

.Feature-inner {
@include whitebox;
@include clearfix;
}

.Feature-inner > h2 { margin: em(6) 0 em(11) 0; }

.Feature--double { clear: both; }


/* Responsive CSS */

@include at-breakpoint($bp-mobile) {
.Feature--double .Grid > .Grid-item {
@include grid-with-columns(2);
}
}

@include between-breakpoints($bp-mobile, $bp-tablet) {
.Feature--collapsible .Grid > .Grid-item {
@include grid-with-columns(2);
}
}

@include till-breakpoint($bp-tablet) {
.Feature--quadruple .Grid-item:nth-last-child(2) {
display: none;
}
}

@include between-breakpoints($bp-tablet, $bp-desktop) {
.Feature--double {
@include span(2 of 3 0.05);
}

.Feature--collapsible {
@include span(1 of 3 0.05);
@include omega;
}

.Feature--collapsible .Grid > .Grid-item {
@include grid-with-columns(1);
}

.Feature--collapsible .Grid > .Grid-item:last-child {
display: none
}
}

@include till-breakpoint($bp-desktop) {
.Feature--quadruple .Grid-item:last-child {
display: none;
}
}

@include at-breakpoint($bp-desktop) {
.Feature--double {
@include span(1 of 2 0.05);
}

.Feature--collapsible {
@include span(1 of 2 0.05);
@include omega;
}

.Feature--collapsible .Grid > .Grid-item {
@include grid-with-columns(2);
}
}
22 changes: 7 additions & 15 deletions app/objects/form/article_search_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def search page
ArticlePolicy::Scope.new(nil, Article).resolve.page(page)
end

# for the category tree to display wich categories have which counts
# For the category tree to display wich categories have which counts
def category_article_count category_id
@search.category_facets[category_id.to_s] || 0
end
Expand All @@ -44,25 +44,17 @@ def search_by_term?
self.q.present?
end

# Did this form get request parameters or is this an empty search where someone just wants to look around?
# (category doesn't count)
# Did this form get request parameters or is this an empty search where
# someone just wants to look around? (category doesn't count)
def search_request?
!filter_attributes.reject{ |k,v| k == :category_id }.empty?
end


# Function exclusive_filter?
# Purpose: Check if filter is set exclusively, i.e. no search query or any
# other search attributes are set (with the exception of the standard
# order 'newest').
# Note that condition is treated as two separate filters here.
# Example: exclusive_filter? :fair
# Arguments:
# * filter - :fair, :ecologic, :small_and_precious, :swappable, :borrowable,
# :condition_new, :condition_old
# Returns:
# * true - if passed filter is set exclusively
# * false - if filter is not set exclusively
# Check if an attribute has a specific value and if it is set exclusively,
#
# exclusive_value?(:fair, true)
# # true, if the fair filter and no other attributes are set
def exclusive_value?(key, value)
attrs = filter_attributes
attrs.length == 1 && attrs[key] == value
Expand Down
10 changes: 5 additions & 5 deletions app/views/articles/shared/_featured_library.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
/ - mode (:full_page, :half_page, :half_page_last)
/ - title (optional)
- case mode
- when :full_page then class_name = 'feature--quadruple'
- when :half_page then class_name = 'feature--double'
- when :half_page_last then class_name = 'feature--collapsible'
- when :full_page then class_name = 'Feature--quadruple'
- when :half_page then class_name = 'Feature--double'
- when :half_page_last then class_name = 'Feature--collapsible'

- lib = FeaturedLibraryQuery.new(library).find(mode == :full_page ? 4 : 2)
- if lib[:library]
div[class="feature #{class_name}"]
.feature-inner
div[class="Feature #{class_name}"]
.Feature-inner
h2
= link_to (local_assigns.has_key? :title) ? title : lib[:library].name, library_path(lib[:library])
.Grid
Expand Down

0 comments on commit 9e3a293

Please sign in to comment.