Added compass, finished shapes filter demo

pull/56/head
Glen Cheney 11 years ago
parent c1da3b374d
commit d2a08407ee

4
.gitignore vendored

@ -1,3 +1,5 @@
.DS_Store
_site
_site
.sass_cache/*
*.scssc

@ -42,6 +42,14 @@ shapes:
color: red
- shape: square
color: green
- shape: circle
color: orange
- shape: diamond
color: blue
- shape: square
color: orange
- shape: square
color: blue
items:
- groups: [ photography ]

@ -6,8 +6,7 @@ extraJS: [ "homepage.js" ]
---
<div class="container-fluid">
<div class="row-fluid">
<h1>Masonry with a sizer</h1>
<hr>
<h2>Masonry with a sizer</h2>
</div>
</div>

@ -18,28 +18,30 @@ extraCSS: [ "/css/gallery.css" ]
<div class="span6">
<div class="filter-group filter--colors js-colors">
<button data-filter-value="green"><span class="visuallyhidden">Green</span></button>
<button data-filter-value="blue"><span class="visuallyhidden">Blue</span></button>
<button data-filter-value="red"><span class="visuallyhidden">Red</span></button>
<button data-filter-value="orange"><span class="visuallyhidden">Orange</span></button>
<h5 class="filter__label">Colors</h5>
<button class="green" data-filter-value="green"><span class="visuallyhidden">Green</span></button>
<button class="blue" data-filter-value="blue"><span class="visuallyhidden">Blue</span></button>
<button class="red" data-filter-value="red"><span class="visuallyhidden">Red</span></button>
<button class="orange" data-filter-value="orange"><span class="visuallyhidden">Orange</span></button>
</div>
</div>
<div class="span6">
<ul class="filter-group unstyled filter--shapes js-shapes">
<li>
<div class="filter-group filter--shapes js-shapes">
<h5 class="filter-group__label">Shapes</h5>
<span class="ib">
<input type="checkbox" value="circle" id="cb-circle"> <label for="cb-circle">Circle</label>
</li>
<li>
</span>
<span class="ib">
<input type="checkbox" value="diamond" id="cb-diamond"> <label for="cb-diamond">Diamond</label>
</li>
<li>
</span>
<span class="ib">
<input type="checkbox" value="square" id="cb-square"> <label for="cb-square">Square</label>
</li>
<li>
</span>
<span class="ib">
<input type="checkbox" value="triangle" id="cb-triangle"> <label for="cb-triangle">Triangle</label>
</li>
</ul>
</span>
</div>
</div>
</div>

@ -1,3 +1,40 @@
.ib {
display: inline-block;
}
.keep-ratio {
position: relative;
width: 100%;
height: 0;
overflow: hidden;
padding-bottom: 100%;
&.four-three {
padding-bottom: 75%;
}
}
// Hide from both screenreaders and browsers: h5bp.com/u
.hidden {
display: none !important;
visibility: hidden;
}
// Hide only visually, but have it available for screenreaders: h5bp.com/v
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/*
* Clearfix: contain floats
*

@ -68,40 +68,6 @@ nav > a {
}
.keep-ratio {
position: relative;
width: 100%;
height: 0;
overflow: hidden;
padding-bottom: 100%;
&.four-three {
padding-bottom: 75%;
}
}
// Hide from both screenreaders and browsers: h5bp.com/u
.hidden {
display: none !important;
visibility: hidden;
}
// Hide only visually, but have it available for screenreaders: h5bp.com/v
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

@ -1,7 +1,39 @@
@import "variables";
@import "compass";
.filter-options {
margin-top: 20px;
margin-bottom: 40px;
}
.filter-group {
.filter-group__label {
margin: 0 0 5px;
}
button {
width: 40px;
height: 40px;
}
.blue {
background-color: $river;
}
.red {
background-color: $alizarin;
}
.orange {
background-color: $orange;
}
.green {
background-color: $emerald;
}
}
.shape {
margin-left: 0;
margin-top: 10px;
.shape__inner {
position: absolute;
@ -56,16 +88,71 @@
}
$triangleSize: 166px;
$triangleSize: 220px;
$halfSize: $triangleSize / 2;
$fullSideWidth: round(sqrt(3) * $halfSize);
$leftOver: $triangleSize - $fullSideWidth;
.shape--triangle .shape__space {
padding-top: $leftOver / 2;
height: 0;
width: 0;
border-width: 0 ($triangleSize / 2) $triangleSize ($triangleSize / 2);
border-width: 0 $halfSize $fullSideWidth $halfSize;
background-color: transparent;
}
@media (min-width: 1200px) {
$triangleSize: 270px;
$halfSize: $triangleSize / 2;
$fullSideWidth: round(sqrt(3) * $halfSize);
$leftOver: $triangleSize - $fullSideWidth;
.shape--triangle .shape__space {
padding-top: $leftOver / 2;
border-width: 0 $halfSize $fullSideWidth $halfSize;
}
}
@media (min-width: 768px) and (max-width: 979px) {
$triangleSize: 166px;
$halfSize: $triangleSize / 2;
$fullSideWidth: round(sqrt(3) * $halfSize);
$leftOver: $triangleSize - $fullSideWidth;
.shape--triangle .shape__space {
padding-top: $leftOver / 2;
border-width: 0 $halfSize $fullSideWidth $halfSize;
}
}
@media (max-width: 767px) {
$triangleSize: 200px;
$halfSize: $triangleSize / 2;
$fullSideWidth: round(sqrt(3) * $halfSize);
$leftOver: $triangleSize - $fullSideWidth;
.shape--triangle .shape__space {
padding-top: $leftOver / 2;
border-width: 0 $halfSize $fullSideWidth $halfSize;
}
}
@media (max-width: 480px) {
$triangleSize: 100px;
$halfSize: $triangleSize / 2;
$fullSideWidth: round(sqrt(3) * $halfSize);
$leftOver: $triangleSize - $fullSideWidth;
.shape--triangle .shape__space {
padding-top: $leftOver / 2;
border-width: 0 $halfSize $fullSideWidth $halfSize;
}
}
@ -84,7 +171,7 @@ body::before {
content: 'Default - 940px';
position: fixed;
z-index: 5;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 25px;

@ -0,0 +1,25 @@
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "_scss"
images_dir = "img"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :expanded
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

@ -1,72 +1,144 @@
.filter-options {
margin-top: 20px;
margin-bottom: 40px;
}
.filter-group .filter-group__label {
margin: 0 0 5px;
}
.filter-group button {
width: 40px;
height: 40px;
}
.filter-group .blue {
background-color: #3498db;
}
.filter-group .red {
background-color: #e74c3c;
}
.filter-group .orange {
background-color: #f39c12;
}
.filter-group .green {
background-color: #2ecc71;
}
.shape {
margin-left: 0;
margin-top: 10px;
}
.shape .shape__inner {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0; }
left: 0;
}
.shape .shape__space {
width: 100%;
height: 100%;
background-color: black;
border-style: solid;
border-width: 0;
border-color: transparent; }
border-color: transparent;
}
.shape--blue .shape__space {
background-color: #3498db;
border-bottom-color: #3498db; }
border-bottom-color: #3498db;
}
.shape--red .shape__space {
background-color: #e74c3c;
border-bottom-color: #e74c3c; }
border-bottom-color: #e74c3c;
}
.shape--orange .shape__space {
background-color: #f39c12;
border-bottom-color: #f39c12; }
border-bottom-color: #f39c12;
}
.shape--green .shape__space {
background-color: #2ecc71;
border-bottom-color: #2ecc71; }
border-bottom-color: #2ecc71;
}
.shape--circle .shape__space {
border-radius: 50%; }
border-radius: 50%;
}
.shape--diamond .shape__space {
-webkit-transform: rotate(45deg) scale(0.70711);
transform: rotate(45deg) scale(0.70711); }
transform: rotate(45deg) scale(0.70711);
}
.shape--triangle .shape__space {
padding-top: 14.5px;
height: 0;
width: 0;
border-width: 0 83px 166px 83px;
background-color: transparent; }
border-width: 0 110px 191px 110px;
background-color: transparent;
}
@media (min-width: 1200px) {
.shape--triangle .shape__space {
padding-top: 18px;
border-width: 0 135px 234px 135px;
}
}
@media (min-width: 768px) and (max-width: 979px) {
.shape--triangle .shape__space {
padding-top: 11px;
border-width: 0 83px 144px 83px;
}
}
@media (max-width: 767px) {
.shape--triangle .shape__space {
padding-top: 13.5px;
border-width: 0 100px 173px 100px;
}
}
@media (max-width: 480px) {
.shape--triangle .shape__space {
padding-top: 6.5px;
border-width: 0 50px 87px 50px;
}
}
body::before {
content: 'Default - 940px';
position: fixed;
z-index: 5;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 25px;
background-color: rgba(119, 204, 102, 0.6);
-webkit-transition: background .2s ease;
-o-transition: background .2s ease;
transition: background .2s ease; }
transition: background .2s ease;
}
@media (min-width: 1200px) {
body::before {
content: 'Large Desktop - 1200px+';
background-color: rgba(204, 119, 102, 0.6); } }
background-color: rgba(204, 119, 102, 0.6);
}
}
@media (min-width: 768px) and (max-width: 979px) {
body::before {
content: 'Portrait tablet to landscape and desktop - > 768px && < 979px';
background-color: rgba(204, 187, 102, 0.6); } }
background-color: rgba(204, 187, 102, 0.6);
}
}
@media (max-width: 767px) {
body::before {
content: 'Phones to Tablets - < 767px';
background-color: rgba(102, 153, 204, 0.6); } }
background-color: rgba(102, 153, 204, 0.6);
}
}
@media (max-width: 480px) {
body::before {
content: 'Phones - < 480px';
background-color: rgba(204, 102, 204, 0.6); } }
background-color: rgba(204, 102, 204, 0.6);
}
}

@ -5,26 +5,33 @@
height: 220px;
margin-top: 24px;
overflow: hidden;
background: #ecf0f1; }
.picture-item.shuffle-item {
margin-left: 0;
/* shuffle items shouldn't have a left margin*/ }
.picture-item.picture-item--h2 {
height: 464px;
/* 2x the height + 1 gutter */ }
.picture-item img {
display: block;
width: 100%;
height: auto; }
.picture-item .picture-item__details,
.picture-item .picture-item__description {
padding: 1em; }
.picture-item .picture-item__description {
margin: 0;
padding-top: 0;
padding-right: 2em; }
.picture-item .picture-item__tags {
margin: 0; }
background: #ecf0f1;
}
.picture-item.shuffle-item {
margin-left: 0;
/* shuffle items shouldn't have a left margin*/
}
.picture-item.picture-item--h2 {
height: 464px;
/* 2x the height + 1 gutter */
}
.picture-item img {
display: block;
width: 100%;
height: auto;
}
.picture-item .picture-item__details,
.picture-item .picture-item__description {
padding: 1em;
}
.picture-item .picture-item__description {
margin: 0;
padding-top: 0;
padding-right: 2em;
}
.picture-item .picture-item__tags {
margin: 0;
}
/*
Shuffle needs either relative or absolute positioning on the container
@ -32,9 +39,11 @@
AKA worse performance - so just set it here
*/
.shuffle--container {
position: relative; }
position: relative;
}
.shuffle--fluid .shuffle__sizer {
position: absolute;
opacity: 0;
visibility: hidden; }
visibility: hidden;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

@ -5,10 +5,12 @@ var Exports = {
Exports.Modules.Gallery = (function($, undefined) {
var $grid,
$features,
$megapixels,
features = [],
megapixels = [],
$shapes,
$colors,
shapes = [],
colors = [],
// Using shuffle with specific column widths
columnWidths = {
1170: 70,
940: 60,
@ -27,9 +29,9 @@ Exports.Modules.Gallery = (function($, undefined) {
},
setVars = function() {
$grid = $('.products');
$features = $('.filter-options .features');
$megapixels = $('.filter-options .megapixels');
$grid = $('.js-shuffle');
$shapes = $('.js-shapes');
$colors = $('.js-colors');
},
initShuffle = function() {
@ -59,9 +61,9 @@ Exports.Modules.Gallery = (function($, undefined) {
},
initFilters = function() {
// Features
$features.find('input').on('change', function() {
var $checked = $features.find('input:checked'),
// shapes
$shapes.find('input').on('change', function() {
var $checked = $shapes.find('input:checked'),
groups = [];
// At least one checkbox is checked, clear the array and loop through the checked checkboxes
@ -71,25 +73,36 @@ Exports.Modules.Gallery = (function($, undefined) {
groups.push(this.value);
});
}
features = groups;
shapes = groups;
filter();
});
// Megapixels
$megapixels.children().on('click', function() {
$(this).button('toggle');
// colors
$colors.find('button').on('click', function() {
var $this = $(this),
$alreadyChecked,
checked = [],
active = 'active',
isActive;
var $checked = $megapixels.find('.active'),
groups = [];
// Already checked buttons which are not this one
$alreadyChecked = $this.siblings('.' + active);
// Get all megapixel filters
if ( $checked.length !== 0 ) {
$checked.each(function() {
groups.push(this.getAttribute('data-megapixels'));
});
$this.toggleClass( active );
// Remove active on already checked buttons to act like radio buttons
if ( $alreadyChecked.length ) {
$alreadyChecked.removeClass( active );
}
megapixels = groups;
isActive = $this.hasClass( active );
if ( isActive ) {
checked.push( $this.data( 'filterValue' ) );
}
colors = checked;
filter();
});
@ -107,13 +120,13 @@ Exports.Modules.Gallery = (function($, undefined) {
itemPassesFilters = function(data) {
// If a features filter is active
if ( features.length > 0 && !arrayContainsArray(data.groups, features) ) {
// If a shapes filter is active
if ( shapes.length > 0 && !valueInArray(data.shape, shapes) ) {
return false;
}
// If a megapixels filter is active
if ( megapixels.length > 0 && !valueInArray(data.megapixels, megapixels) ) {
// If a colors filter is active
if ( colors.length > 0 && !valueInArray(data.color, colors) ) {
return false;
}
@ -121,32 +134,32 @@ Exports.Modules.Gallery = (function($, undefined) {
},
hasActiveFilters = function() {
return megapixels.length > 0 || features.length > 0;
return colors.length > 0 || shapes.length > 0;
},
valueInArray = function(value, arr) {
return $.inArray(value, arr) !== -1;
},
arrayContainsArray = function(arrToTest, requiredArr) {
var i = 0,
dictionary = {},
j;
// Convert groups into object which we can test the keys
for (j = 0; j < arrToTest.length; j++) {
dictionary[ arrToTest[j] ] = true;
}
// Loop through selected features, if that feature is not in this elements groups, return false
for (; i < requiredArr.length; i++) {
if ( dictionary[ requiredArr[i] ] === undefined ) {
return false;
}
}
return true;
};
// arrayContainsArray = function(arrToTest, requiredArr) {
// var i = 0,
// dictionary = {},
// j;
// // Convert groups into object which we can test the keys
// for (j = 0; j < arrToTest.length; j++) {
// dictionary[ arrToTest[j] ] = true;
// }
// // Loop through selected shapes, if that feature is not in this elements groups, return false
// for (; i < requiredArr.length; i++) {
// if ( dictionary[ requiredArr[i] ] === undefined ) {
// return false;
// }
// }
// return true;
// };
return {
init: init
};

@ -113,7 +113,12 @@ var NAV = (function( $ ) {
NavTray.prototype.onResize = function() {
var self = this;
self.$tray.css( 'height', '' );
self.saveHeight();
if ( self.isOpen ) {
self.$tray.css( 'height', self.collapseHeight );
}
};
NavTray.prototype.toggle = function() {

Loading…
Cancel
Save