facades 0.0.2 → 0.0.3

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.
Files changed (52) hide show
  1. data/README.md +52 -0
  2. data/app/helpers/facades_helper.rb +0 -26
  3. data/app/views/facades/_pagination.html.erb +20 -0
  4. data/facades.gemspec +2 -3
  5. data/lib/facades/builders/sprite.rb +50 -0
  6. data/lib/facades/builders/table.rb +76 -0
  7. data/lib/facades/helpers/builders.rb +24 -0
  8. data/lib/facades/helpers/elements.rb +2 -2
  9. data/lib/facades/helpers/layout.rb +25 -8
  10. data/lib/facades/helpers/mobile.rb +16 -0
  11. data/lib/facades/helpers/navigation.rb +13 -10
  12. data/lib/facades/helpers/pagination.rb +83 -0
  13. data/lib/facades/helpers/utility.rb +31 -0
  14. data/lib/facades/helpers.rb +13 -5
  15. data/lib/facades/sass_ext/color.rb +30 -0
  16. data/lib/facades/sass_ext/form_elements.rb +8 -2
  17. data/lib/facades/sass_ext.rb +3 -4
  18. data/lib/facades/stylesheets/facades/_common.scss +7 -0
  19. data/lib/facades/stylesheets/facades/_layout.scss +5 -1
  20. data/lib/facades/stylesheets/facades/_normalize.scss +5 -0
  21. data/lib/facades/stylesheets/facades/_setup.scss +67 -0
  22. data/lib/facades/stylesheets/facades/_typography.scss +2 -0
  23. data/lib/facades/stylesheets/facades/_ui.scss +3 -1
  24. data/lib/facades/stylesheets/facades/_utilities.scss +29 -15
  25. data/lib/facades/stylesheets/facades/layout/_debug.scss +18 -0
  26. data/lib/facades/stylesheets/facades/layout/_dropdown-list.scss +7 -0
  27. data/lib/facades/stylesheets/facades/layout/_forms.scss +31 -116
  28. data/lib/facades/stylesheets/facades/layout/_grid.scss +4 -20
  29. data/lib/facades/stylesheets/facades/legacy/_forms.scss +130 -0
  30. data/lib/facades/stylesheets/facades/{_reset.scss → legacy/_reset.scss} +40 -8
  31. data/lib/facades/stylesheets/facades/setup/_forms.scss +212 -0
  32. data/lib/facades/stylesheets/facades/setup/_ie.scss +12 -0
  33. data/lib/facades/stylesheets/facades/setup/_reset.scss +198 -0
  34. data/lib/facades/stylesheets/facades/typography/_baseline.scss +89 -0
  35. data/lib/facades/stylesheets/facades/typography/_lists.scss +34 -0
  36. data/lib/facades/stylesheets/facades/typography/_rhythm.scss +3 -1
  37. data/lib/facades/stylesheets/facades/typography/_shadow.scss +9 -0
  38. data/lib/facades/stylesheets/facades/ui/_buttons.scss +35 -0
  39. data/lib/facades/stylesheets/facades/ui/_flash-messages.scss +58 -0
  40. data/lib/facades/stylesheets/facades/ui/_tool-tip.scss +2 -1
  41. data/lib/facades/stylesheets/facades/utilities/_clearfix.scss +16 -0
  42. data/lib/facades/stylesheets/facades/utilities/_color.scss +7 -0
  43. data/lib/facades/stylesheets/facades/utilities/_cursors.scss +3 -0
  44. data/lib/facades/{engine.rb → support/rails.rb} +6 -0
  45. data/lib/facades/support/serve.rb +17 -0
  46. data/lib/facades/support/tipsy.rb +17 -0
  47. data/lib/facades/version.rb +1 -1
  48. data/lib/facades.rb +25 -4
  49. data/spec/facades/helpers/navigation_spec.rb +103 -0
  50. data/spec/spec_helper.rb +12 -0
  51. metadata +39 -25
  52. data/lib/facades/stylesheets/facades/utilities/_site-map.scss +0 -18
data/README.md CHANGED
@@ -35,6 +35,8 @@ Below is a list of available mixins
35
35
  Interface
36
36
  -----------------------
37
37
  tool-tip
38
+ flash-message
39
+ flash-message-colors
38
40
 
39
41
  Forms
40
42
  ----------------------
@@ -61,10 +63,14 @@ Below is a list of available mixins
61
63
  ----------------------
62
64
  leading (shortcut to Compass adjust-leading-to)
63
65
  font-size (shortcut to Compass adjust-font-size-to)
66
+ inset-text (text-shadow text insetting)
64
67
 
65
68
  Utility
66
69
  ----------------------
67
70
  position (shorthand position relative/fixed/absolute)
71
+ luminance ( return a colors lightness in terms of 'light' or 'dark' )
72
+ tint (tint a color with white)
73
+ shade (darken a color with black)
68
74
 
69
75
  ##Helpers
70
76
 
@@ -104,3 +110,49 @@ To assign variables, pass their value to the method. To display, use the method
104
110
 
105
111
  <%= button_link 'Link Text', some_path, icon: 'image.png' %> #=> <a href='#' class='button'><img src='image.png' /></a>
106
112
 
113
+ ###Pagination Helper
114
+
115
+ Any model which responds to current_page and total_pages can utilize the pagination helper.
116
+
117
+ <%= paginate(collection) %>
118
+
119
+ Will render a link based list with the current collection pagination. If `Facades.enable_html5` is set to `true` items will be wrapped in a HTMl5 `<nav>` tag, otherwise a div will be used. The class 'pagination' is added to that top level element.
120
+ By default the included partial facades/pagination is rendered. To customize output simply override this in your application. See app/views/facades/_pagination.html.erb for more info.
121
+
122
+ ###Navigation Helper
123
+
124
+ Facades provides a navigation helper for creating nested navigation lists.
125
+
126
+ <%= nav do %>
127
+ <%= nav_link 'About Me', about_path %>
128
+ <%= nav_link 'Top Level', some_path do %>
129
+ <%= nav_link 'Sub Item', some_sub_path %>
130
+ <% end %>
131
+ <% end %>
132
+
133
+ Will output
134
+
135
+ <nav>
136
+ <ol>
137
+ <li><a href='/about-path'>About Me</a></li>
138
+ <li><a href='/some-path'>Top Level</a>
139
+ <ol>
140
+ <li><a href="/some-sub-path">Sub Item</a></li>
141
+ </ol>
142
+ </li>
143
+ </ol>
144
+ </nav>
145
+
146
+ Note: The `<nav>` tag is only included if `Facades.enable_html5` is set to true.
147
+
148
+ As a convenience, the class `on` will be added to a link when the current url matches that link. This can be overridden by using the `matcher` or `proc` attributes when calling `nav_link`.
149
+ When using a proc/lambda, returning true will set the `on` class.
150
+
151
+ # Current path /home
152
+ <%= nav_link 'Path', some_path, proc: lambda{ |current_path| true } %> #=> <a href='/anything' class='on'>Path</a>
153
+
154
+ When using `:matcher`, pass a string or regular expression in which the request.path should match to be `on`.
155
+
156
+ # Current path /somewhere
157
+ <%= nav_link 'Path', '/something-else', matcher: /somewhere/ %> #=> <a href='/something-else' class='on'>Path</a>
158
+
@@ -1,29 +1,3 @@
1
1
  module FacadesHelper
2
-
3
2
  include Facades::Helpers
4
-
5
- def facade_assets
6
- content = if_ie(8) do
7
- javascript_include_tag("https://html5shim.googlecode.com/svn/trunk/html5.js")
8
- end
9
- content.to_s.html_safe
10
- end
11
-
12
- ##
13
- # Render an IE conditional statement. By default conditionals use a less-than-or-equal-to format. Use the `specific`
14
- # param to force only that version.
15
- #
16
- # @param version [Integer] The IE version to target
17
- # @param specific [Boolean] optional Target the IE version specificially.
18
- #
19
- #
20
- def if_ie(version, specific = false, &block)
21
- content = capture(&block)
22
- condition = specific ? "IE #{version}" : "lte IE #{version}"
23
- str = "<!--[if #{condition}]>"
24
- str << content.html_safe.lstrip
25
- str << "<![endif]-->"
26
- str.html_safe
27
- end
28
-
29
3
  end
@@ -0,0 +1,20 @@
1
+ <p class='pagination-detail'>Viewing Page <%= paginator.current_page %> of <%= paginator.total_pages %></p>
2
+ <ol class='pagination-links'>
3
+ <li class='first'>
4
+ <%= paginator.first? ? "&larr;".html_safe : paginator.link(1, {}, "&larr;") %>
5
+ </li>
6
+ <li class='prev'>
7
+ <%= paginator.first? ? "&laquo; Previous".html_safe : paginator.link(paginator.previous, {}, "&laquo; Previous".html_safe) %>
8
+ </li>
9
+ <% paginator.links.each do |link| %>
10
+ <li<%= link.current? ? " class='current'" : "" %>>
11
+ <%= link.current? ? link.number : paginator.link(link.number) %>
12
+ </li>
13
+ <% end %>
14
+ <li class='next'>
15
+ <%= paginator.last? ? "Next &raquo;".html_safe : paginator.link(paginator.next, {}, "Next &raquo;".html_safe) %>
16
+ </li>
17
+ <li class='last'>
18
+ <%= paginator.last? ? "&rarr;".html_safe : paginator.link(paginator.total_pages, {}, "&rarr;") %>
19
+ </li>
20
+ </ol>
data/facades.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Brent Kirby"]
9
9
  s.email = ["brent@kurbmedia.com"]
10
10
  s.homepage = "https://github.com/kurbmedia/facades"
11
- s.summary = %q{Mixins, utilities, and helpers for front-end design/development with Compass / Rails}
12
- s.description = %q{Facades includes various helpers, methods, and compass/sass mixins for simplifying frontend development.}
11
+ s.summary = %q{Front-end development awesome-ness}
12
+ s.description = %q{Facades is a front-end development framework which takes }
13
13
 
14
14
  s.rubyforge_project = "facades"
15
15
 
@@ -19,6 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency('sass', ['~> 3.1'])
22
- s.add_dependency('compass', ['>= 0.11'])
23
22
 
24
23
  end
@@ -0,0 +1,50 @@
1
+ require 'tilt'
2
+
3
+ module Facades
4
+ module Builders
5
+ class Sprite < Tilt::Template
6
+
7
+ def prepare
8
+ end
9
+
10
+ def evaluate(scope, locals, &block)
11
+ sprites = sprite_context(scope)
12
+ sprites.instance_eval data
13
+ sprites = sprites.send(:fetch!).uniq
14
+ File.open(sprites.first).read
15
+ end
16
+
17
+ def locate_sprite_folder(scope)
18
+ paths, name = scope.environment.paths, File.basename(scope.logical_path)
19
+ paths.detect{ |p| File.directory?(File.join(p, name)) }
20
+ end
21
+
22
+ def sprite_context(scope)
23
+ cxt = SpriteContext.new
24
+ cxt.root = locate_sprite_folder(scope)
25
+ cxt.base_path = File.basename(scope.logical_path)
26
+ cxt
27
+ end
28
+
29
+ class SpriteContext
30
+ attr_accessor :base_path, :sprite_images, :root
31
+ def images(*args)
32
+ @sprite_images = args
33
+ end
34
+ private
35
+ def fetch!
36
+ @sprite_images ||= Dir.glob(File.join(root, base_path, '*.png'))
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ begin
46
+ require 'sprockets'
47
+ Sprockets::Engines
48
+ Sprockets.register_engine '.sprite', Facades::Builders::Sprite
49
+ rescue LoadError
50
+ end
@@ -0,0 +1,76 @@
1
+ module Facades
2
+ module Builders
3
+ class TableBuilder
4
+ attr_reader :template, :options, :resources, :buffer
5
+
6
+ def initialize(resources, tpl, options)
7
+ @buffer = ""
8
+ @template, @options, @resources = tpl, options, resources
9
+ end
10
+
11
+ delegate :content_tag, :to => :template
12
+
13
+ ##
14
+ # Get a list of all headings for the table
15
+ # Use the resource class's table_headings method first, options hash next
16
+ #
17
+ def headings
18
+ return resource_class.table_attributes if resource_class.respond_to?(:table_headings)
19
+ [options[:headings]].flatten.compact
20
+ end
21
+
22
+ ##
23
+ # The class for this resource
24
+ def resource_class
25
+ resources.first.class
26
+ end
27
+
28
+ ##
29
+ # Renders the table content immediately using the provided options
30
+ def inline!
31
+ [head, body].map(&:to_s).join("\n")
32
+ end
33
+
34
+ def head
35
+ return content_tag(:thead, render_heading) unless block_given?
36
+ content_tag(:thead) do
37
+ yield self
38
+ end
39
+ end
40
+
41
+ def body
42
+ return content_tag(:tbody, render_body) unless block_given?
43
+ content_tag(:tbody) do
44
+ yield self
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ # Render an entire body inline
51
+ def render_body
52
+ rows = []
53
+ resources.each_with_index do |res, index|
54
+ attrs = { :class => (ind.even? ? 'even' : 'odd') }
55
+ buff = content_tag(:tr, attrs) do
56
+ headings.collect do |hd|
57
+ content_tag(:td, res.send(:"#{hd}"))
58
+ end.to_s.join("\n")
59
+ end
60
+ rows << buff
61
+ end
62
+ rows.map(&:to_s).join("\n")
63
+ end
64
+
65
+ # Render entire body inline
66
+ def render_heading
67
+ buffer << template.content_tag(:thead) do
68
+ headings.collect do |hd|
69
+ content_tag(:th, hd)
70
+ end.to_s.join("\n")
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,24 @@
1
+ require 'facades/builders/table'
2
+
3
+ module Facades
4
+ module Helpers
5
+ module Builders
6
+
7
+ def table_for(resource_or_class, *args, &block)
8
+ options = args.extract_options!
9
+ html_attrs = options.delete(:html)
10
+ builder = options.delete(:builder) || TableBuilder
11
+ builder = builder.new(resource_or_class, self, options)
12
+
13
+ unless block_given?
14
+ content_tag(:table, builder.inline!, html_attrs)
15
+ else
16
+ content_tag(:table, html_attrs) do
17
+ yield builder
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -59,11 +59,11 @@ module Facades
59
59
  closer ||= "<span>X</span>"
60
60
  end
61
61
  klasses = (attrs.delete(:class) || "").split(" ")
62
- klasses << "flash_message"
62
+ klasses << "flash-message"
63
63
  content = ""
64
64
 
65
65
  flash.each do |key, value|
66
- klasses << "flash_message_#{key.to_s.underscore}"
66
+ klasses << "flash-message-#{key.to_s.underscore}"
67
67
  msg_attrs = attrs.merge(:class => [key.to_s, klasses].flatten.join(' '))
68
68
  content.concat content_tag(wrapper, "#{value} #{closer}".html_safe, msg_attrs).html_safe
69
69
  end
@@ -20,6 +20,20 @@ module Facades
20
20
  content
21
21
  end
22
22
 
23
+ ##
24
+ # Create a script tag for activating google analytics
25
+ # @param [String] site_id The site ID provided by google analytics
26
+ # @return [String] script tag
27
+ #
28
+ def google_analytics(site_id)
29
+ content_tag(:script) do
30
+ ["var _gaq=[['_setAccount','#{site_id}'],['_trackPageview'],['_trackPageLoadTime']];",
31
+ "(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;",
32
+ "g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';",
33
+ "s.parentNode.insertBefore(g,s)}(document,'script'));"].join("")
34
+ end
35
+ end
36
+
23
37
  ##
24
38
  #
25
39
  # Creates a page id to be used for identifying a page for CSS/design purposes. If a variable
@@ -38,11 +52,16 @@ module Facades
38
52
  #
39
53
  #
40
54
  def page_id(content = nil)
41
- _create_variable(:__page_id, content, false) and return unless content.nil?
55
+ _create_variable(:__page_id, content, false) and return if content
42
56
  return _retrieve_variable(:__page_id) if content_for?(:__page_id)
43
- cname = controller.class.to_s.gsub(/controller$/i,'').underscore.split("/").join('_')
44
- aname = controller.action_name
45
- "#{cname}_#{aname}"
57
+ result = if defined?(controller)
58
+ cname = controller.class.to_s.gsub(/controller$/i,'').underscore.split("/").join('_')
59
+ aname = controller.action_name
60
+ "#{cname}_#{aname}"
61
+ elsif defined?(request) && request.respond_to?(:path_info)
62
+ ::File.basename(request.path_info).to_s
63
+ end
64
+ result
46
65
  end
47
66
 
48
67
  ##
@@ -58,7 +77,7 @@ module Facades
58
77
  # <title><%= page_title %></title> #=> <title>This is my page title</title>
59
78
  #
60
79
  def page_title(content = nil)
61
- _create_variable(:__page_title, content, false) and return unless content.nil?
80
+ _create_variable(:__page_title, content, false) and return if content
62
81
  return _retrieve_variable(:__page_title) if content_for?(:__page_title)
63
82
  return ""
64
83
  end
@@ -96,9 +115,7 @@ module Facades
96
115
  private
97
116
 
98
117
  def _create_variable(var, content, create_method = true) #:nodoc:
99
- content_for(var.to_sym) do
100
- content
101
- end
118
+ content_for(var.to_sym, content)
102
119
  return '' unless create_method
103
120
  class_eval <<-MAKE_VAR, __FILE__, __LINE__ + 1
104
121
  def #{var}
@@ -0,0 +1,16 @@
1
+ module Facades
2
+ module Helpers
3
+ ##
4
+ # Helper methods for mobile tags and attributes
5
+ module Mobile
6
+
7
+ def mobile_meta_tags
8
+ [ tag(:meta, {"http-equiv" => 'cleartype', 'content' => 'on' }), # IE Cleartype
9
+ meta_tag('HandheldFriendly', 'True'),
10
+ meta_tag('viewport', "width=device-width, minimum-scale=1.0, initial-scale=1.0")
11
+ ].join("\n")
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -33,8 +33,9 @@ module Facades
33
33
  link_attrs = update_link_attrs(path, attrs)
34
34
  wrapper_attrs = link_attrs.delete(:wrapper)
35
35
  child_link = link_to(text, path, link_attrs)
36
- wrapper === false ? child_link : content_tag(wrapper, child_link, wrapper_attrs)
37
-
36
+ built = (wrapper === false ? child_link : content_tag(wrapper, child_link, wrapper_attrs))
37
+ built = built.html_safe if built.respond_to?(:html_safe)
38
+ built
38
39
  end
39
40
  alias :nav_link_to :nav_link
40
41
 
@@ -43,9 +44,7 @@ module Facades
43
44
  link_attrs = update_link_attrs(path, attrs.merge(:wrapper => (attrs.delete(:item) || {}) ))
44
45
  parent_link = nav_link_to(text, path, attrs, false)
45
46
  child_links = content_tag(container, capture(&block), wrapper_attrs)
46
- content_tag(container) do
47
- content_tag(wrapper, (parent_link << child_links), wrapper_attrs)
48
- end
47
+ content_tag(wrapper, (parent_link << child_links), wrapper_attrs)
49
48
  end
50
49
  private :sub_nav_link
51
50
 
@@ -75,17 +74,21 @@ module Facades
75
74
  # </li>
76
75
  # </ol>
77
76
  #
78
- def nav(container = :ol, html_attrs = {}, &block)
77
+ def nav(container = :ol, html_attrs = {}, heading = nil, &block)
79
78
 
80
79
  wrapper_attrs = html_attrs.delete(:wrapper) || {}
81
80
 
82
- if Facades.enable_html5
81
+ built = if Facades.enable_html5
82
+ inner = content_tag(container, capture(&block), wrapper_attrs)
83
+ inner = (content_tag(:h3, heading) << inner) unless heading.nil?
83
84
  content_tag(:nav, html_attrs) do
84
- content_tag(container, capture(&block), wrapper_attrs)
85
+ inner
85
86
  end
86
87
  else
87
88
  content_tag(container, capture(&block), html_attrs)
88
89
  end
90
+ built = built.html_safe if built.respond_to?(:html_safe)
91
+ built
89
92
 
90
93
  end
91
94
 
@@ -110,10 +113,10 @@ module Facades
110
113
  when Proc then proc.call(path)
111
114
  when Regexp then request.path.match(regex)
112
115
  when String then (request.path == path || request.path.match(/#{path}\/\w/im))
113
- else raise Motr::Errors::InvalidOptions.new('Proc, Regexp or String required... passed #{matcher.class}.')
116
+ else raise 'Proc, Regexp or String required... passed #{matcher.class}.'
114
117
  end
115
118
 
116
- if active
119
+ if active === true
117
120
  klasses << on_class
118
121
  wklasses << on_class
119
122
  end
@@ -0,0 +1,83 @@
1
+ module Facades
2
+ module Helpers
3
+
4
+ module Pagination
5
+
6
+ class PageLink
7
+ attr_reader :number
8
+ attr_reader :current
9
+
10
+ def initialize(num, curr)
11
+ @number = num
12
+ @current = curr
13
+ end
14
+
15
+ def current?
16
+ current === true
17
+ end
18
+
19
+ end
20
+
21
+ class Paginator
22
+
23
+ attr_reader :current_page
24
+ attr_reader :total_pages
25
+ attr_reader :attributes
26
+ attr_reader :links
27
+
28
+ def initialize(collection, view, request)
29
+ @total_pages = collection.total_pages
30
+ @current_page = collection.current_page
31
+ @links = []
32
+ @template = view
33
+ @request = request
34
+ end
35
+
36
+ def paginate!(window)
37
+ window.each do |page|
38
+ @links << PageLink.new(page, (page == current_page))
39
+ end
40
+ end
41
+
42
+ def first?
43
+ current_page == 1
44
+ end
45
+
46
+ def last?
47
+ (current_page == total_pages)
48
+ end
49
+
50
+ def next
51
+ links.detect{ |l| l.number == current_page + 1 }
52
+ end
53
+
54
+ def previous
55
+ links.detect{ |l| l.number == current_page - 1 }
56
+ end
57
+
58
+ def link(page_number, attrs = {}, text = nil)
59
+ text ||= page_number
60
+ options = CGI.parse(@request.query_string).merge('page' => page_number)
61
+ @template.link_to(text.to_s.html_safe, "?#{options.to_query}", attrs)
62
+ end
63
+
64
+ end
65
+
66
+ def paginate(collection, html_attrs = {}, file = "facades/pagination")
67
+
68
+ return "" if collection.total_count <= 0
69
+ paginator = Paginator.new(collection, self, request)
70
+ window_min = [(paginator.current_page - 5), 1].max
71
+ window_max = [(paginator.current_page + 5), paginator.total_pages].min
72
+ wrapper = Facades.enable_html5 ? :nav : :div
73
+
74
+ paginator.paginate!((window_min..window_max).to_a)
75
+ contents = render(partial: file, locals: { paginator: paginator })
76
+
77
+ content_tag(wrapper, contents.html_safe, class: 'pagination')
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,31 @@
1
+ module Facades
2
+ module Helpers
3
+ module Utility
4
+
5
+ def facade_assets
6
+ content = if_ie(8) do
7
+ javascript_include_tag("https://html5shim.googlecode.com/svn/trunk/html5.js")
8
+ end
9
+ content.to_s.html_safe
10
+ end
11
+
12
+ ##
13
+ # Render an IE conditional statement. By default conditionals use a less-than-or-equal-to format. Use the `specific`
14
+ # param to force only that version.
15
+ #
16
+ # @param version [Integer] The IE version to target
17
+ # @param specific [Boolean] optional Target the IE version specificially.
18
+ #
19
+ #
20
+ def if_ie(version, specific = false, &block)
21
+ content = capture(&block)
22
+ condition = specific ? "IE #{version}" : "lte IE #{version}"
23
+ str = "<!--[if #{condition}]>"
24
+ str << content.html_safe.lstrip
25
+ str << "<![endif]-->"
26
+ str.html_safe
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -1,15 +1,23 @@
1
+ require 'facades/helpers/layout'
2
+ require 'facades/helpers/navigation'
3
+ require 'facades/helpers/elements'
4
+ require 'facades/helpers/pagination'
5
+ require 'facades/helpers/utility'
6
+ require 'facades/helpers/builders'
7
+ require 'facades/helpers/mobile'
8
+
1
9
  module Facades
2
10
  module Helpers
3
11
  extend ActiveSupport::Concern
4
12
 
5
- autoload :Layout, 'facades/helpers/layout'
6
- autoload :Navigation, 'facades/helpers/navigation'
7
- autoload :Elements, 'facades/helpers/elements'
8
-
9
13
  included do
10
14
  include Facades::Helpers::Layout
11
15
  include Facades::Helpers::Navigation
12
16
  include Facades::Helpers::Elements
13
- end
17
+ include Facades::Helpers::Utility
18
+ include Facades::Helpers::Builders
19
+ include Facades::Helpers::Mobile
20
+ end
21
+
14
22
  end
15
23
  end
@@ -0,0 +1,30 @@
1
+ module Facades
2
+ module SassExt
3
+ module Color
4
+
5
+ # Check the luminance of color. This differs from lightness as it returns the actual values as 'light' and 'dark'
6
+ def luminance(color)
7
+ assert_type color, :Color
8
+ result = ((color.red * 299) + (color.green * 587) + (color.blue * 114) / 1000)
9
+ Sass::Script::String.new( result >= 160 ? 'light' : 'dark')
10
+ end
11
+
12
+ # Tint a color by mixing it with white
13
+ def tint(color, dilution = Sass::Script::Number.new(50))
14
+ assert_type color, :Color
15
+ white = Sass::Script::Color.new([255, 255, 255, 1])
16
+ assert_type dilution, :Number
17
+ mix(color, white, Sass::Script::Number.new(100 - dilution.value))
18
+ end
19
+
20
+ # Shade a color by mixing it with black
21
+ def shade(color, dilution = Sass::Script::Number.new(50))
22
+ assert_type color, :Color
23
+ black = Sass::Script::Color.new([0, 0, 0, 1])
24
+ assert_type dilution, :Number
25
+ mix(color, black, Sass::Script::Number.new(100 - dilution.value))
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -15,6 +15,10 @@ module Facades
15
15
  [:checkbox, :password, :radio, :select, :string, :textarea].collect{ |t| send(:"#{t}_input_types") }.flatten.compact
16
16
  end
17
17
 
18
+ def button_input_types
19
+ "input[type=submit], input[type=reset], button[type=submit]"
20
+ end
21
+
18
22
  def checkbox_input_types
19
23
  "input[type=checkbox]"
20
24
  end
@@ -31,9 +35,11 @@ module Facades
31
35
  def select_input_types
32
36
  "select"
33
37
  end
34
-
38
+
35
39
  def string_input_types
36
- %w{email password text}.collect{ |t| "input[type=#{t}]" }
40
+ %w{email password text number search tel time url datetime date datetime-local week month}.collect do |type|
41
+ "input[type=#{type}]"
42
+ end
37
43
  end
38
44
 
39
45
  def textarea_input_types
@@ -1,13 +1,12 @@
1
1
  require 'sass'
2
-
3
2
  module Facades
4
3
  module SassExt
5
- autoload :FormElements, 'facades/sass_ext/form_elements'
6
4
  end
7
5
  end
8
6
 
9
- module Sass::Script::Functions
10
- include Facades::SassExt::FormElements
7
+ ['form_elements', 'color'].each do |req|
8
+ require "facades/sass_ext/#{req}"
9
+ Sass::Script::Functions.send(:include, Facades::SassExt.const_get(req.camelize))
11
10
  end
12
11
 
13
12
  class Sass::Script::Functions::EvaluationContext
@@ -0,0 +1,7 @@
1
+ // Includes modules generally used in most applications.
2
+
3
+ @import 'facades/utilities';
4
+ @import 'facades/ui';
5
+ @import 'facades/layout';
6
+ @import 'facades/typography/lists';
7
+ @import 'facades/typography/shadow';