foundation-navigation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d2a35b69cf278dece4d6297425827fdb86b37bf3
4
+ data.tar.gz: bd0c50cf7338dbc6f47a13298356c53e98600cca
5
+ SHA512:
6
+ metadata.gz: 41e2bdf473a2c2d7fe4f282cde2ca87d6ccdaf4c3399bd8baaf7d35a8fae6e84bc0e1dd535574f1bbe55eecc90f6e4c9a100d32e544ca9f5e13c009ff2538f3e
7
+ data.tar.gz: 5f1d984067389d40f2023c18e9a3324c93f537c504a9487f2bdc23c5f03a9b350b9248cbbddfd15462ed6e09b2b3c8509381ba03f1390a52111be3ffeea7f39a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (2013-09-02)
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in foundation-navigation.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sebastian de Castelberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Foundation Navigation
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/foundation-navigation.png)](http://badge.fury.io/rb/foundation-navigation)
4
+ [![Build Status](https://secure.travis-ci.org/kpricorn/foundation-navigation.png)](http://travis-ci.org/kpricorn/foundation-navigation)
5
+ [![Dependency Status](https://gemnasium.com/kpricorn/foundation-navigation.png)](https://gemnasium.com/kpricorn/foundation-navigation)
6
+ [![Code Climate](https://codeclimate.com/github/kpricorn/foundation-navigation.png)](https://codeclimate.com/github/kpricorn/foundation-navigation)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'foundation-navigation'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install foundation-navigation
21
+
22
+ ## Usage
23
+
24
+ ### Topbar
25
+
26
+ See <http://foundation.zurb.com/docs/components/top-bar.html>
27
+
28
+ #### Example
29
+
30
+ This Haml snippet
31
+
32
+ = topbar(title: 'Expo') do
33
+ - left do
34
+ - dropdown 'Community', 'http://www.zurb.com/expo/community' do
35
+ - menu_item 'Forrst', 'http://www.forrst.com'
36
+ - menu_item 'Soapbox', 'http://www.zurb.com/soapbox'
37
+ - right do
38
+ - menu_item 'Courses', '#'
39
+ - dropdown 'Library' do
40
+ - menu_item 'Pattern Tap', 'http://patterntap.com'
41
+ - menu_item 'Word', 'http://www.zurb.com/word'
42
+ - menu_item 'Responsive', 'http://www.zurb.com/responsive'
43
+
44
+ generates the following top-bar
45
+
46
+ ![Sample Top Bar](images/menu_sample.png "Sample top-bar with expanded dropdown")
47
+
48
+ ### Methods
49
+
50
+ #### topbar ####
51
+
52
+ = topbar
53
+
54
+ or with specific options
55
+
56
+ = topbar title: 'Example', title_link: 'http://www.example.com', sticky: true
57
+
58
+ Options:
59
+
60
+ * __title__: Page Title (Default: empty)
61
+ * __title_link__: Link on Title (Default: #)
62
+ * __contain_to_grid__: Wraps top-bar in contain-to-grid div (Default: false)
63
+ * __fixed__: Wraps top-bar in fixed div (Default: false)
64
+ * __sticky__: Wraps top-bar in sticky div (Default: false)
65
+
66
+ #### menu_group/left/right ####
67
+
68
+ Helpers to nest menu-item groups and arrange them within the topbar.
69
+
70
+ = topbar do
71
+ - menu_group do # <ul>...</ul>
72
+ # or
73
+ - left do # <ul class='left'>...</ul>
74
+ ...
75
+ - right do # <ul class='right'>...</ul>
76
+ ...
77
+
78
+ #### divider ####
79
+
80
+ Adds a divider element
81
+
82
+ = topbar do
83
+ - menu_group do # <ul>...</ul>
84
+ - divider # <li class="divider"></li>
85
+ ...
86
+ - divider # <li class="divider"></li>
87
+
88
+ #### dropdown ####
89
+
90
+ Groups nested elements and renders them as dropdown box
91
+
92
+ = topbar do
93
+ - left do
94
+ - dropdown 'caption' do
95
+ ...
96
+
97
+ generates the following markup
98
+
99
+ ...
100
+ <ul>
101
+ <li class="has-dropdown not-click">
102
+ <a href="#">caption</a>
103
+ </li>
104
+ </ul>
105
+ <ul class="dropdown">
106
+ ...
107
+ </ul>
108
+
109
+ Options:
110
+
111
+ * Dropdown caption
112
+ * Dropdown link (on the caption, default: '#')
113
+
114
+ #### menu_item ####
115
+
116
+ Renders a single link and can be nested in a menu_group or a dropdown.
117
+
118
+ = topbar do
119
+ ...
120
+ - menu_item 'Title', '/link' # <a href='/link'>Title</a>
121
+
122
+ ## Contributing
123
+
124
+ 1. Fork it
125
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
126
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
127
+ 4. Push to the branch (`git push origin my-new-feature`)
128
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'foundation-navigation/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "foundation-navigation"
8
+ spec.version = FoundationNavigation::VERSION
9
+ spec.authors = ["Sebastian de Castelberg"]
10
+ spec.email = ["sebu@kpricorn.org"]
11
+ spec.description = %q{Helpers to generate a Zurb Foundation style navigation}
12
+ spec.summary = %q{Helpers to generate a Zurb Foundation style navigation}
13
+ spec.homepage = 'https://github.com/kpricorn/foundation-navigation'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 2.0.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency 'rspec', '~> 2.14.1'
24
+ spec.add_development_dependency 'rspec-html-matchers', '~> 0.4.3'
25
+ spec.add_development_dependency 'padrino-helpers', '~> 0.11.2'
26
+ spec.add_development_dependency 'guard-rspec', '~> 3.0.2'
27
+ spec.add_development_dependency 'pry'
28
+ spec.add_development_dependency 'pry-debugger'
29
+ spec.add_development_dependency "rake"
30
+ end
Binary file
@@ -0,0 +1,59 @@
1
+ require_relative './node'
2
+
3
+ module FoundationNavigation
4
+ module Builder
5
+ attr_accessor :node
6
+
7
+ def left(&block)
8
+ @node.children << FoundationNavigation::MenuGroup.new(
9
+ orientation: 'left', &block
10
+ ).node
11
+ end
12
+
13
+ def right(&block)
14
+ @node.children << FoundationNavigation::MenuGroup.new(
15
+ orientation: 'right', &block
16
+ ).node
17
+ end
18
+
19
+ def menu_group(*args, &block)
20
+ @node.children << FoundationNavigation::MenuGroup.new(*args, &block).node
21
+ end
22
+
23
+ def title_area(*args, &block)
24
+ build_subtree(FoundationNavigation::TitleArea, *args, &block)
25
+ end
26
+
27
+ def dropdown(*args, &block)
28
+ build_subtree(FoundationNavigation::Dropdown, *args, &block)
29
+ end
30
+
31
+ def divider
32
+ build_subtree(FoundationNavigation::Divider)
33
+ end
34
+
35
+ def menu_item(*args, &block)
36
+ build_subtree(FoundationNavigation::MenuItem, *args, &block)
37
+ end
38
+
39
+ def build_subtree(klass, *args, &block)
40
+ @node.children << klass.new(*args, &block).node
41
+ end
42
+
43
+ def to_s
44
+ @node.to_s
45
+ end
46
+
47
+ def method_missing(name, opts = {}, &block)
48
+ parent = @node
49
+ @node = Node.new(parent, name, opts)
50
+ parent.children << @node if parent
51
+ if block_given?
52
+ val = instance_eval(&block)
53
+ @node.children << val if val.is_a?(String)
54
+ end
55
+ parent ? @node = parent : @node
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,14 @@
1
+ require_relative './builder'
2
+
3
+ module FoundationNavigation
4
+
5
+ class Divider
6
+
7
+ include Builder
8
+
9
+ def initialize
10
+ li(class: 'divider')
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ require_relative './builder'
2
+ require_relative './menu_item'
3
+ require_relative './divider'
4
+
5
+ module FoundationNavigation
6
+
7
+ class Dropdown
8
+
9
+ include Builder
10
+
11
+ def initialize(title, link = '#', &block)
12
+ li(class: 'has-dropdown not-click') do
13
+ a(href: link) { title }
14
+ ul(class: 'dropdown') do
15
+ if block_given?
16
+ instance_eval(&block)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,12 @@
1
+ require 'foundation-navigation/divider'
2
+ require 'foundation-navigation/menu_item'
3
+ require 'foundation-navigation/dropdown'
4
+ require 'foundation-navigation/topbar'
5
+
6
+ module FoundationNavigation::Helpers
7
+
8
+ def topbar(*args, &block)
9
+ FoundationNavigation::Topbar.new(*args, &block)
10
+ end
11
+
12
+ end
@@ -0,0 +1,20 @@
1
+ require_relative './builder'
2
+
3
+ module FoundationNavigation
4
+
5
+ class MenuGroup
6
+
7
+ include Builder
8
+
9
+ def initialize(orientation: nil, &block)
10
+ params = {}
11
+ params[:class] = orientation if orientation.present?
12
+ ul(params) do
13
+ if block_given?
14
+ self.instance_eval(&block)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,14 @@
1
+ require_relative './builder'
2
+
3
+ module FoundationNavigation
4
+
5
+ class MenuItem
6
+
7
+ include Builder
8
+
9
+ def initialize(title, link, orientation: nil, &block)
10
+ li { a(href: link) { title } }
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,31 @@
1
+ # http://gnuu.org/2009/07/18/metaprogramming-ruby-pt-1-markaby/
2
+ module FoundationNavigation
3
+ class Node
4
+ attr_accessor :name, :options, :children, :parent
5
+
6
+ def initialize(parent, name, options = {})
7
+ @options = options
8
+ @name = name
9
+ @parent = parent
10
+ @children = []
11
+
12
+ if options.is_a?(String)
13
+ @options = nil
14
+ @children = [options]
15
+ end
16
+ end
17
+
18
+ def to_s
19
+ if children.size > 0
20
+ "<#{name}#{' ' + attrs unless attrs.empty?}>#{children.join}</#{name}>"
21
+ else
22
+ "<#{name}#{' ' + attrs unless attrs.empty?} />"
23
+ end
24
+ end
25
+
26
+ def attrs
27
+ return "" if options.nil?
28
+ options.map {|k, v| "#{k}=#{v.inspect}" }.join(" ")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ require_relative './builder'
2
+
3
+ module FoundationNavigation
4
+
5
+ class TitleArea
6
+
7
+ include Builder
8
+
9
+ def initialize(title: nil, title_link: nil, menu_text: 'Menu', menu_icon:
10
+ true)
11
+ ul(class: 'title-area') do
12
+ if title.present?
13
+ li(class: 'name') { h1 { a(href: title_link || '#') { title } } }
14
+ else
15
+ li(class: 'name')
16
+ end
17
+
18
+ toggle_opts = { class: 'toggle-topbar' }
19
+ toggle_opts[:class] << ' menu-icon' if menu_icon
20
+ li(toggle_opts) { a(href: '#') { span { menu_text } } }
21
+ end
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,34 @@
1
+ require_relative './builder'
2
+ require_relative './title_area'
3
+ require_relative './menu_group'
4
+
5
+ module FoundationNavigation
6
+ class Topbar
7
+
8
+ include Builder
9
+
10
+ def navigation(**args, &block)
11
+ nav(class: 'top-bar') do
12
+ build_subtree(FoundationNavigation::TitleArea, **args)
13
+ section(class: 'top-bar-section') do
14
+ if block_given?
15
+ self.instance_eval(&block)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ def initialize(contain_to_grid: false, fixed: false, sticky: true, **args, &block)
22
+ if contain_to_grid || fixed || sticky
23
+ classes = []
24
+ classes << 'contain-to-grid' if contain_to_grid
25
+ classes << 'fixed' if fixed
26
+ classes << 'sticky' if sticky
27
+ div(class: classes.join(' ')) { navigation(**args, &block) }
28
+ else
29
+ navigation(**args, &block)
30
+ end
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,3 @@
1
+ module FoundationNavigation
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/divider'
4
+
5
+ # <li class="divider">
6
+
7
+ module FoundationNavigation
8
+
9
+ describe Divider do
10
+ describe '#new' do
11
+ it 'renders a li.divider tag' do
12
+ expect(subject.to_s).to have_tag('li.divider')
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/dropdown'
4
+
5
+ # <li class="has-dropdown not-click">
6
+ # <a href="#">Library</a>
7
+ # <ul class="dropdown">
8
+ # <li><a href="http://www.forrst.com">Forrst</a></li>
9
+ # ...
10
+ # </ul>
11
+ # </li>
12
+
13
+ module FoundationNavigation
14
+
15
+ describe Dropdown do
16
+ describe '#new' do
17
+ it 'renders li.has-dropdown > a' do
18
+ expect(
19
+ Dropdown.new('Library').to_s
20
+ ).to have_tag('li.has-dropdown > a', text: 'Library')
21
+ end
22
+
23
+ it 'renders li.has-dropdown > ul.dropdown' do
24
+ expect(
25
+ Dropdown.new('Library').to_s
26
+ ).to have_tag('li.has-dropdown > ul.dropdown')
27
+ end
28
+
29
+ context 'with link' do
30
+ it 'renders the href attribute' do
31
+ expect(
32
+ Dropdown.new('Library', '/library').to_s
33
+ ).to have_tag('li.has-dropdown > a', with: {href: '/library'})
34
+ end
35
+ end
36
+
37
+ context 'with menu_item block' do
38
+ let :dropdown do
39
+ Dropdown.new('Library') do
40
+ menu_item('Link 1', '/link1')
41
+ divider
42
+ menu_item('Link 2', '/link2')
43
+ end.to_s
44
+ end
45
+
46
+ it 'renders the nested menu element' do
47
+ expect(dropdown).to have_tag(
48
+ 'li.has-dropdown > ul.dropdown > li > a',
49
+ text: 'Link 1',
50
+ with: { href: '/link1' }
51
+ )
52
+ end
53
+
54
+ it 'renders the nested divider' do
55
+ expect(dropdown).to have_tag(
56
+ 'li.has-dropdown > ul.dropdown > li',
57
+ with: { class: 'divider' }
58
+ )
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/menu_group'
4
+
5
+ # <ul class="left">
6
+ # ...
7
+ # </ul>
8
+
9
+ module FoundationNavigation
10
+
11
+ describe MenuGroup do
12
+
13
+ describe '#new' do
14
+ context 'without parameters' do
15
+ it 'renders an empty ul' do
16
+ expect(subject.to_s).to have_tag('ul')
17
+ end
18
+ end
19
+
20
+ context 'with orientation' do
21
+ it 'adds the orientation class' do
22
+ expect(MenuGroup.new(orientation: 'left').to_s).to have_tag('ul.left')
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/menu_item'
4
+
5
+ # <li class="">
6
+ # <a href="http://www.zurb.com/jobs">Job Board</a>
7
+ # </li>
8
+
9
+ module FoundationNavigation
10
+
11
+ describe MenuItem do
12
+ describe '#new' do
13
+ it 'renders the a tag' do
14
+ expect(MenuItem.new('Foo', '/foo').to_s).to have_tag(
15
+ 'li a',
16
+ text: 'Foo',
17
+ with: {href: '/foo'}
18
+ )
19
+ end
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/title_area'
4
+
5
+ module FoundationNavigation
6
+
7
+ describe TitleArea do
8
+ context 'without parameters' do
9
+ it 'renders .title-area > li.name' do
10
+ expect(subject.to_s).to have_tag('ul.title-area > li.name')
11
+ end
12
+
13
+ it 'leaves the title empty' do
14
+ expect(subject.to_s).to_not have_tag('ul.title-area > li.name > h1')
15
+ end
16
+
17
+ it 'renders .toggle-topbar.menu-icon' do
18
+ expect(subject.to_s).to have_tag('ul.title-area > li.toggle-topbar.menu-icon')
19
+ end
20
+
21
+ it 'renders the default Menu text' do
22
+ expect(subject.to_s).to have_tag('ul.title-area > li.toggle-topbar.menu-icon > a') do
23
+ with_tag('span', text: 'Menu')
24
+ end
25
+ end
26
+ end
27
+
28
+ context 'with custom menu_text' do
29
+ it 'renders that text' do
30
+ expect(TitleArea.new(menu_text: 'My Menu').to_s).to have_tag('ul.title-area > li.toggle-topbar.menu-icon > a') do
31
+ with_tag('span', text: 'My Menu')
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'with menu_icon false' do
37
+ it 'renders .toggle-topbar.menu-icon' do
38
+ expect(TitleArea.new(menu_icon: false).to_s).to_not have_tag('ul.title-area > li.menu-icon')
39
+ end
40
+ end
41
+
42
+ context 'with only title' do
43
+ it 'renders a h1 with the content of title' do
44
+ expect(TitleArea.new(title: 'title').to_s).to have_tag(
45
+ 'ul.title-area > li.name > h1'
46
+ ) do
47
+ with_tag('a', :text => 'title')
48
+ end
49
+ end
50
+
51
+ it 'renders # href' do
52
+ expect(TitleArea.new(title: 'title').to_s).to have_tag(
53
+ 'ul.title-area > li.name > h1'
54
+ ) do
55
+ with_tag('a', :href => '#')
56
+ end
57
+ end
58
+ end
59
+
60
+ context 'with title_link' do
61
+ it 'renders the corresponding link' do
62
+ expect(TitleArea.new(title: 'title', title_link: '/foo').to_s).to have_tag(
63
+ 'ul.title-area > li.name > h1'
64
+ ) do
65
+ with_tag('a', :href => '/foo')
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'padrino-helpers'
3
+ require 'foundation-navigation/topbar'
4
+
5
+ module FoundationNavigation
6
+
7
+ describe Topbar do
8
+ describe '#new' do
9
+ context 'without parameters' do
10
+ it 'renders the top-bar nav' do
11
+ expect(subject.to_s).to have_tag('nav.top-bar')
12
+ end
13
+
14
+ it 'renders top-bar-section' do
15
+ expect(subject.to_s).to have_tag('nav.top-bar > section.top-bar-section')
16
+ end
17
+ end
18
+
19
+ context 'with contain-to-grid true' do
20
+ it 'wraps the top-bar into .contain-to-grid' do
21
+ expect(Topbar.new(contain_to_grid: true).to_s).to have_tag('.contain-to-grid > nav.top-bar')
22
+ end
23
+ end
24
+
25
+ context 'with sticky true' do
26
+ it 'wraps the top-bar into .sticky' do
27
+ expect(Topbar.new(sticky: true).to_s).to have_tag('.sticky > nav.top-bar')
28
+ end
29
+ end
30
+
31
+ context 'with fixed true' do
32
+ it 'wraps the top-bar into .fixed' do
33
+ expect(Topbar.new(fixed: true).to_s).to have_tag('.fixed > nav.top-bar')
34
+ end
35
+ end
36
+
37
+ context 'with combined attributes' do
38
+ it 'combines the passed attributes' do
39
+ expect(Topbar.new(fixed: true, contain_to_grid: true).to_s
40
+ ).to have_tag('.contain-to-grid.fixed > nav.top-bar')
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec-html-matchers'
2
+ require 'pry'
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+ config.order = 'random'
9
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foundation-navigation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian de Castelberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.14.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.14.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-html-matchers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: padrino-helpers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.11.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.11.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-debugger
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Helpers to generate a Zurb Foundation style navigation
126
+ email:
127
+ - sebu@kpricorn.org
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .rspec
134
+ - .travis.yml
135
+ - CHANGELOG.md
136
+ - Gemfile
137
+ - Guardfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - foundation-navigation.gemspec
142
+ - images/menu_sample.png
143
+ - lib/foundation-navigation/builder.rb
144
+ - lib/foundation-navigation/divider.rb
145
+ - lib/foundation-navigation/dropdown.rb
146
+ - lib/foundation-navigation/helpers.rb
147
+ - lib/foundation-navigation/menu_group.rb
148
+ - lib/foundation-navigation/menu_item.rb
149
+ - lib/foundation-navigation/node.rb
150
+ - lib/foundation-navigation/title_area.rb
151
+ - lib/foundation-navigation/topbar.rb
152
+ - lib/foundation-navigation/version.rb
153
+ - spec/lib/foundation-navigation/divider_spec.rb
154
+ - spec/lib/foundation-navigation/dropdown_spec.rb
155
+ - spec/lib/foundation-navigation/menu_group_spec.rb
156
+ - spec/lib/foundation-navigation/menu_item_spec.rb
157
+ - spec/lib/foundation-navigation/title_area_spec.rb
158
+ - spec/lib/foundation-navigation/topbar_spec.rb
159
+ - spec/spec_helper.rb
160
+ homepage: https://github.com/kpricorn/foundation-navigation
161
+ licenses:
162
+ - MIT
163
+ metadata: {}
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ required_ruby_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - '>='
171
+ - !ruby/object:Gem::Version
172
+ version: 2.0.0
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 2.0.5
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Helpers to generate a Zurb Foundation style navigation
184
+ test_files:
185
+ - spec/lib/foundation-navigation/divider_spec.rb
186
+ - spec/lib/foundation-navigation/dropdown_spec.rb
187
+ - spec/lib/foundation-navigation/menu_group_spec.rb
188
+ - spec/lib/foundation-navigation/menu_item_spec.rb
189
+ - spec/lib/foundation-navigation/title_area_spec.rb
190
+ - spec/lib/foundation-navigation/topbar_spec.rb
191
+ - spec/spec_helper.rb