-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add styles for and example of breadcrumbs component to pattern library * Have changes to the _includes/examples files trigger a rebuild+browserSync * Updare UITK dependency to 1.4.0 * Fix spacing on either side of carets (after new fontawesome icons landed) * Example of pre-rendered breadcrumbs * Code review fixes * Upgrade to UITK 1.4.1 to fix small issue with focus management
- Loading branch information
Showing
7 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.breadcrumbs { | ||
font-family: $font-family-sans-serif; | ||
font-size: font-size(small); | ||
line-height: line-height(small); | ||
|
||
.nav-item { | ||
@include margin-left($baseline/4); | ||
display: inline-block; | ||
} | ||
|
||
.fa-angle-right { | ||
@include margin-left($baseline/4); | ||
display: inline-block; | ||
color: palette(grayscale, light); | ||
|
||
@include rtl { | ||
@include transform(rotateY(180deg)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
layout: pattern | ||
title: Breadcrumbs | ||
date: 2016-02-29 00:00:00 | ||
|
||
categories: component | ||
tags: | ||
- atomic | ||
- pattern | ||
- js | ||
- breadcrumbs | ||
- nav | ||
|
||
slug: breadcrumbs | ||
|
||
url_styles: "patterns/_breadcrumbs.scss" | ||
|
||
description: Breadcrumb navigation. | ||
|
||
info: Accessible tiered navigation using breadcrumbs. | ||
ui-toolkit-component: breadcrumbs | ||
js: "/examples/breadcrumbs-js.html" | ||
--- | ||
<div class="breadcrumbs-basic example-set"> | ||
<h2>Basic breadcrumbs</h2> | ||
<div class="has-breadcrumbs hd-3"></div> | ||
<a class="add-breadcrumb" href="">Add breadcrumb</a> | ||
</div> | ||
|
||
<div class="breadcrumbs-prerendered example-set"> | ||
<h2>Pre-rendered breadcrumbs</h2> | ||
<div class="has-breadcrumbs hd-3"> | ||
<nav class="breadcrumbs list-inline" aria-label="Example of pre-rendered breadcrumbs navigation"> | ||
<span class="nav-item"> | ||
<a href="/components/breadcrumbs/">Initial page</a> | ||
<span class="fa fa-angle-right" aria-hidden="true"></span> | ||
</span> | ||
<span class="nav-item"> | ||
<a href="/components/breadcrumbs/foo">foo</a> | ||
<span class="fa fa-angle-right" aria-hidden="true"></span> | ||
</span> | ||
<span class="nav-item"> | ||
<a href="/components/breadcrumbs/foo/buzz">buzz</a> | ||
<span class="fa fa-angle-right" aria-hidden="true"></span> | ||
</span> | ||
<span class="nav-item"> | ||
<a href="/components/breadcrumbs/foo/buzz/bar">bar</a> | ||
<span class="fa fa-angle-right" aria-hidden="true"></span> | ||
</span> | ||
<span class="nav-item">buzz</span> | ||
</nav> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Starts the breadcrumbs example component. | ||
*/ | ||
define([ | ||
'backbone', | ||
'jquery', | ||
'edx-ui-toolkit/js/breadcrumbs/breadcrumbs-view.js', | ||
'edx-ui-toolkit/js/breadcrumbs/breadcrumbs-model.js' | ||
], | ||
function(Backbone, $, BreadcrumbsView, BreadcrumbsModel) { | ||
'use strict'; | ||
|
||
var router = new Backbone.Router(); | ||
var $wrapper = $('.breadcrumbs-basic'); | ||
|
||
var breadcrumbsView = new BreadcrumbsView({ | ||
el: $('.has-breadcrumbs', $wrapper), | ||
model: new BreadcrumbsModel({ | ||
breadcrumbs: [{url: '/components/breadcrumbs/', title: 'Initial page'}], | ||
label: 'Example of breadcrumbs navigation' | ||
}), | ||
events: { | ||
'click nav.breadcrumbs a.nav-item': function (event) { | ||
event.preventDefault(); | ||
|
||
var url = $(event.currentTarget).attr('href'), | ||
currentCrumbs = breadcrumbsView.model.get('breadcrumbs'), | ||
indexOfCrumbClick = currentCrumbs.findIndex(function(crumb){ | ||
return crumb.url === url; | ||
}); | ||
|
||
// Remove crumbs after the one that's been clicked from the stack | ||
breadcrumbsView.model.set('breadcrumbs', currentCrumbs.slice(0, indexOfCrumbClick + 1)); | ||
|
||
router.navigate(url, {trigger: true}); | ||
} | ||
} | ||
}).render(); | ||
|
||
// This view wraps the component you will be navigating with breadcrumbs | ||
new Backbone.View({ | ||
el: $wrapper, | ||
events: { | ||
'click .add-breadcrumb': function(event) { | ||
// You may choose to direct to the href of a link here, e.g.: | ||
// var url = $(event.currentTarget).attr('href'); | ||
|
||
// This example instead generates a new random breadcrumb | ||
var path = window.location.pathname, | ||
crumbs = ['foo', 'bar', 'fizz', 'buzz'], | ||
randString = crumbs[Math.floor(Math.random() * crumbs.length)], | ||
url = path + (path.slice(-1) === '/' ? '' : '/') + randString; | ||
|
||
breadcrumbsView.model.set( | ||
'breadcrumbs', | ||
breadcrumbsView.model.get('breadcrumbs').concat([{ | ||
url: url, | ||
title: randString | ||
}]) | ||
); | ||
|
||
event.preventDefault(); | ||
router.navigate(url, {trigger: true}); | ||
} | ||
} | ||
}).render(); | ||
|
||
Backbone.history.start({pushState: true}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters