JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
#albums.container
.header British Bangers!
span.count
.tags
div Filter by:
.tag.filter(data-filter='1993') '93
.tag.filter(data-filter='1994') '94
.tag.filter(data-filter='1995') '95
.tag.filter(data-filter='1996') '96
.controls
div Sort by:
a.sort(href='#' data-sort='album') Album
a.sort(href='#' data-sort='artist') Artist
a.sort(href='#' data-sort='date') Date
.list
a.list__item(href='javascript:void(0)')
.album Definately Maybe
.meta
.artist Oasis
.date 2002
@import url('https://fonts.googleapis.com/css?family=Cabin:400,600');
$base_color: rgba(0,0,0,1);
$accent_color: dimgrey;
$primary_color: #E27;
$bg_color: #ede8e8;
html,
body {
min-height: 100%;
}
body {
margin: 0;
padding: 0;
min-width: 200px;
background: $bg_color;
color: $base_color;
font-family: 'Cabin';
font-family: 16px;
line-height: 1.6;
}
a {
text-decoration: none;
}
.container {
max-width: 500px;
padding: 80px 1.5rem;
margin: 0 auto;
}
// Header
.header {
display: flex;
align-items: center;
font-size: 2rem;
font-weight: 600;
border-bottom: 1px solid lighten($base_color, 84%);
margin-bottom: 2rem;
padding-bottom: 1rem;
}
.count {
padding: .3rem;
border-radius: 1rem;
font-size: 1rem;
margin-left: .5rem;
margin-top: -2rem;
min-width: 1.5rem;
line-height: 1.2;
text-align: center;
color: white;
background: $primary_color;
}
// List Item
.list__item {
display: block;
padding: 1rem;
margin: 0 0 1rem 0;
background: white;
border-radius: 1rem;
color: inherit;
transition: all .2s ease;
&:hover {
color: $primary_color !important;
box-shadow: 0 1px 10px 0 transparentize($base_color, .9);
}
}
.album {
font-size: 1.25rem;
color: inherit !important;
font-weight: 600;
margin-bottom: .25rem;
}
.meta {
display: flex;
flex-wrap: wrap;
font-size: .9rem;
color: $accent_color;
> div {
padding-right: .5rem;
}
> div:not(:last-child):after {
content: '·';
padding-left: .5rem;
display: inline-block;
}
}
// Sort
.controls {
display: flex;
align-items: center;
margin-bottom: 1rem;
color: $base_color;
> div {
font-weight: 600;
}
> * {
margin-right: 1rem;
color: inherit;
transition: all .2s ease;
}
a:hover {
color: $primary_color;
}
.sort {
display: flex;
align-items: flex-end;
&:after {
display: block;
opacity: 0;
content: '';
margin-left: .25rem;
font-family: 'Material Icons';
font-weight: 400;
font-style: normal;
font-size: 1.5rem;
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
font-feature-settings: 'liga';
}
&.asc, &.desc {
color: $primary_color;
}
&.asc:after {
opacity: 1;
content: 'arrow_drop_up';
}
&.desc:after {
opacity: 1;
content: 'arrow_drop_down';
}
}
}
// Tags
.tags {
display: flex;
align-items: baseline;
flex-wrap: wrap;
margin-bottom: .75rem;
div {
font-weight: 600;
margin-right: .5rem;
}
.tag {
display: flex;
cursor: pointer;
margin-bottom: .5rem;
margin-right: .5rem;
color: white;
background: lighten($base_color, 60%);
padding: .2rem .6rem .2rem .6rem;
font-weight: 600;
font-size: .9rem;
transition: all .2s ease;
border-radius: 1rem;
overflow: hidden;
&:after {
content: 'x';
cursor: pointer;
opacity: 0;
visibility: hidden;
max-width: 0;
transition: all .2s ease;
}
&.active:after {
opacity: 1;
visibility: visible;
max-width: 2rem;
margin-left: .4rem;
}
&:hover,
&.active {
background: $primary_color;
}
}
}
// Create the List
var options = {
valueNames: [ 'album', 'artist', 'date' ]
};
// Populate the List
var values = [
{
album: 'Sense',
artist: 'The Lightning Seeds',
date: 1992
},
{
album: "His 'N' Hers",
artist: 'Pulp',
date: 1994
},
{
album: "Heros",
artist: 'David Bowie',
date: 1977
},
{
album: "The Pleasure Principle",
artist: 'Gary Numan',
date: 1979
},
{
album: "Dare!",
artist: 'The Human League',
date: 1981
},
{
album: "Urban Hymns",
artist: 'The Verve',
date: 1997
},
{
album: "The La's",
artist: "The La's",
date: 1990
},
{
album: "More Songs ABout Buildings and Food",
artist: 'Talking Heads',
date: 1978
},
{
album: "Laid",
artist: 'James',
date: 1993
},
{
album: "Pills 'N' Thrills and Bellyaches",
artist: 'Happy Mondays',
date: 1990
},
{
album: 'Different Class',
artist: 'Pulp',
date: 1995
},
{
album: 'Be Here Now',
artist: 'Oasis',
date: 1997
},
{
album: 'Soul Mining',
artist: 'The The',
date: 1983
},
{
album: 'Parklife',
artist: 'Blur',
date: 1994
},
{
album: 'Suede',
artist: 'Suede',
date: 1993
},
{
album: 'Stone Roses',
artist: 'The Stone Roses',
date: 1989
},
{
album: 'Screamadelica',
artist: 'Primal Scream',
date: 1991
},
{
album: "It's Great When You're Straight... Yeah",
artist: 'Black Grape',
date: 1995
},
{
album: "(What's The Story) Morning Glory",
artist: 'Oasis',
date: 1995
},
{
album: 'Moseley Shoals',
artist: 'Ocean Colour Scene',
date: 1996
}
];
// Run the list with default sort
var albums = new List('albums', options, values);
albums.sort("album", {
order: "asc"
})
// Create Filters
$('.filter').on('click',function(){
var $q = $(this).attr('data-filter');
if($(this).hasClass('active')){
albums.filter();
$('.filter').removeClass('active');
} else {
albums.filter(function(item) {
return (item.values().date == $q);
});
$('.filter').removeClass('active');
$(this).addClass('active');
}
});
// Return # of items
var $count = $('.count')
$count.append(albums.size());
albums.on('filterComplete', function(){
$count.text(albums.update().matchingItems.length);
});
Also see: Tab Triggers