Smarter sidebar logic

This commit is contained in:
Chris Eppstein 2010-12-18 16:25:49 -08:00
parent ff6c3a078a
commit 2040be4b6c
40 changed files with 42 additions and 33 deletions

View File

@ -14,7 +14,7 @@ GIT
PATH
remote: ..
specs:
compass (0.11.alpha.4.992eb8d)
compass (0.11.alpha.4.ff6c3a0)
chunky_png (~> 0.10.3)
sass (>= 3.1.0.alpha.50)

View File

@ -3,6 +3,7 @@ title: Blueprint Reset
crumb: Reset
framework: blueprint
stylesheet: blueprint/_reset.scss
sidebar: true
layout: blueprint
classnames:
- reference

View File

@ -3,6 +3,7 @@ title: Compass CSS3
crumb: CSS3
framework: compass
stylesheet: compass/_css3.scss
sidebar: true
layout: core
classnames:
- reference

View File

@ -2,6 +2,7 @@
title: Compass Helpers
crumb: Helpers
framework: compass
sidebar: true
layout: core
classnames:
- reference

View File

@ -2,6 +2,7 @@
title: Compass Layout
crumb: Layout
framework: compass
sidebar: true
stylesheet: compass/_layout.scss
meta_description: Page layout module. So far, this is just the sticky-footer mixin.
layout: core

View File

@ -4,6 +4,7 @@ crumb: Reset
framework: compass
stylesheet: compass/_reset.scss
layout: core
sidebar: true
classnames:
- reference
- core

View File

@ -2,6 +2,7 @@
title: Compass Utilities
crumb: Utilities
framework: compass
sidebar: true
stylesheet: compass/_utilities.scss
classnames:
- reference

View File

@ -3,8 +3,8 @@ title: Compass General Utilities
crumb: General
framework: compass
stylesheet: compass/utilities/_general.scss
sidebar: true
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Generally useful utilities that don't fit elsewhere.
classnames:
- reference

View File

@ -4,7 +4,6 @@ crumb: Clearfix
framework: compass
stylesheet: compass/utilities/general/_clearfix.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Mixins for clearfixing.
classnames:
- reference

View File

@ -4,7 +4,6 @@ crumb: Float
framework: compass
stylesheet: compass/utilities/general/_float.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Mixins for cross-browser floats.
classnames:
- reference

View File

@ -4,7 +4,6 @@ crumb: Hacks
framework: compass
stylesheet: compass/utilities/general/_hacks.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Mixins for hacking specific browsers.
classnames:
- reference

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/general/_min.scss
layout: core
meta_description: Mixins for cross-browser min-height and min-width.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/general/_reset.scss
layout: core
meta_description: Mixins for resetting elements (old import).
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/general/_tag-cloud.scss
layout: core
meta_description: Mixin for styling tag clouds.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -3,8 +3,8 @@ title: Compass Links
crumb: Links
framework: compass
stylesheet: compass/utilities/_links.scss
sidebar: true
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Tools for styling anchor links.
classnames:
- reference

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/links/_hover-link.scss
layout: core
meta_description: Underline a link when you hover over it.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/links/_link-colors.scss
layout: core
meta_description: Easy assignment of colors to link states.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/links/_unstyled-link.scss
layout: core
meta_description: Make a link appear like regular text.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -3,8 +3,8 @@ title: Compass Lists
crumb: Lists
framework: compass
stylesheet: compass/utilities/_lists.scss
sidebar: true
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Tools for styling lists.
classnames:
- reference

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/lists/_bullets.scss
layout: core
meta_description: Mixins for managing list bullets.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/lists/_horizontal-list.scss
layout: core
meta_description: Float a list so it appears horizontally.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/lists/_inline-block-list.scss
layout: core
meta_description: set list-elements to inline-block so they appear horizontally while retaining their structure.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/lists/_inline-list.scss
layout: core
meta_description: Style a list as inline text.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/_print.scss
layout: core
meta_description: Control what elements gets printed.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -3,9 +3,9 @@ title: Compass Sprites
crumb: Sprites
framework: compass
stylesheet: compass/utilities/_sprites.scss
sidebar: true
layout: core
meta_description: Sprite mixins.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -4,7 +4,6 @@ crumb: Sprite Base
framework: compass
stylesheet: compass/utilities/sprites/_base.scss
layout: core
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -4,7 +4,6 @@ crumb: Sprite Image
framework: compass
stylesheet: compass/utilities/sprites/_sprite-img.scss
layout: core
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -4,8 +4,8 @@ crumb: Tables
framework: compass
stylesheet: compass/utilities/_tables.scss
layout: core
sidebar: true
meta_description: Style helpers for your tables.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -4,7 +4,6 @@ crumb: Table Striping
framework: compass
stylesheet: compass/utilities/tables/_alternating-rows-and-columns.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Add striping to a table.
classnames:
- reference

View File

@ -4,7 +4,6 @@ crumb: Table Borders
framework: compass
stylesheet: compass/utilities/tables/_borders.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Add borders to a table.
classnames:
- reference

View File

@ -4,7 +4,6 @@ crumb: Table Scaffolding
framework: compass
stylesheet: compass/utilities/tables/_scaffolding.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Basic styling of tables to get you started.
classnames:
- reference

View File

@ -4,8 +4,8 @@ crumb: Text
framework: compass
stylesheet: compass/utilities/_text.scss
layout: core
sidebar: true
meta_description: Style helpers for your text.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -4,7 +4,6 @@ crumb: Ellipsis
framework: compass
stylesheet: compass/utilities/text/_ellipsis.scss
layout: core
nav_stylesheet: compass/_utilities.scss
meta_description: Text truncation with ellipsis.
classnames:
- reference

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/text/_nowrap.scss
layout: core
meta_description: Remembering whether or not there's a hyphen in white-space is too hard.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -5,7 +5,6 @@ framework: compass
stylesheet: compass/utilities/text/_replacement.scss
layout: core
meta_description: Replace text with images.
nav_stylesheet: compass/_utilities.scss
classnames:
- reference
- core

View File

@ -16,6 +16,12 @@ aside {
a {
font-size: .85em;
}
ul ul a {
&.selected, &.selected:hover {
font-weight: bold;
text-decoration: underline;
}
}
.deprecated {
text-decoration: line-through;
}

View File

@ -1,4 +1,4 @@
- render 'main' do
%aside(role="sidebar")= render 'partials/sidebar', :default_stylesheet => "_blueprint.scss"
%aside(role="sidebar")= render 'partials/sidebar', :default_stylesheet => "_blueprint.scss", :omit_self => false, :heading_level => 2, :heading_depth => 1
%article= yield

View File

@ -1,5 +1,5 @@
- render 'main' do
- content_for :module_nav do
%ul= item_tree(reference_item(:stylesheet => "compass.scss"), :depth => 1, :omit_self => true, :headings => false)
%aside(role="sidebar")= render 'partials/sidebar', :default_stylesheet => "_compass.scss"
%aside(role="sidebar")= render 'partials/sidebar', :default_stylesheet => "_compass.scss", :omit_self => false, :heading_level => 2, :heading_depth => 1
%article= yield

View File

@ -1,2 +1,5 @@
%nav#local-nav
= item_tree(reference_item(:stylesheet => (@item[:nav_stylesheet] || @default_stylesheet)), :depth => 2, :omit_self => get_var(:omit_self){true}, :heading_level => get_var(:heading_level){1})
- sidebar_item = reference_item(:stylesheet => @item[:nav_stylesheet]) if @item[:nav_stylesheet]
- sidebar_item ||= sidebar_item(@item)
- sidebar_item ||= reference_item(:stylesheet => @default_stylesheet)
%ul= item_tree(sidebar_item, :depth => 1, :omit_self => get_var(:omit_self){true}, :heading_level => get_var(:heading_level){1}, :heading_depth => get_var(:heading_depth){10})

View File

@ -61,6 +61,21 @@ end
def get_var(instance_var)
instance_variable_defined?("@#{instance_var}") ? instance_variable_get("@#{instance_var}") : yield
end
def sidebar_item(item)
if item.nil?
nil
elsif item[:sidebar]
item
else
sidebar_item(item.parent)
end
end
def sidebar_stylesheet(item)
i = sidebar_item(item)
i[:stylesheet] if i
end
def item_tree(item, options = {})
@ -70,6 +85,7 @@ def item_tree(item, options = {})
if options.fetch(:depth,1) > 0
child_opts = options.dup
child_opts[:depth] -= 1 if child_opts.has_key?(:depth)
child_opts[:heading_depth] -= 1 if child_opts.has_key?(:heading_depth)
child_opts[:heading_level] += 1 if child_opts[:heading_level]
child_opts.delete(:omit_self)
item.children.sort_by{|c| c[:crumb] || c[:title]}.each do |child|
@ -87,7 +103,7 @@ def item_tree(item, options = {})
:selected => !!@item.identifier[item.identifier],
:crumb => item[:crumb] || item[:title]
}
if options[:heading_level]
if options[:heading_level] && (options.fetch(:heading_depth, 1) > 0)
render("partials/sidebar/heading",
item_opts.merge(:heading => "h#{options[:heading_level]}")
)