css-snippets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ require 'active_support/dependencies/autoload'
2
+
3
+ module CssSnippets
4
+
5
+ autoload :Renderer, 'css-snippets/renderer'
6
+ autoload :Version, 'css-snippets/version'
7
+
8
+ def self.register_framework!
9
+ require 'compass'
10
+ Compass::Frameworks.register "css-snippets", :path => File.expand_path("#{File.dirname(__FILE__)}/../.")
11
+ end
12
+
13
+ def self.enable_rails_engine!
14
+ require 'css-snippets/engine'
15
+ end
16
+ end
17
+
18
+ CssSnippets.register_framework!
19
+ CssSnippets.enable_rails_engine! if defined?(::Rails)
@@ -0,0 +1 @@
1
+ class CssSnippets::Engine < ::Rails::Engine; end
@@ -0,0 +1,32 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+
3
+ module CssSnippets::Renderer
4
+
5
+ SNIPPETS = %w(
6
+ justified_items
7
+ right_menu_liquid_layout
8
+ ).freeze
9
+
10
+ autoload :Base, "css-snippets/renderer/base"
11
+
12
+ SNIPPETS.each do |snippet_name|
13
+ autoload :"#{snippet_name.camelize}", "css-snippets/renderer/#{snippet_name}"
14
+ end
15
+
16
+ def self.render_html helper, snippet_name, options, &block
17
+ snippet_instance(snippet_name, helper).to_html options, &block
18
+ end
19
+
20
+ private
21
+
22
+ def self.snippet_instance name, helper
23
+ snippet_klass(name).new(helper)
24
+ end
25
+
26
+ def self.snippet_klass name
27
+ stringified_name = name.to_s
28
+ raise "Unknown snippet #{stringified_name}" if not SNIPPETS.include?(stringified_name)
29
+ "CssSnippets::Renderer::#{stringified_name.camelize}".constantize
30
+ end
31
+
32
+ end
@@ -0,0 +1,30 @@
1
+ class CssSnippets::Renderer::Base < Struct.new(:helper)
2
+
3
+ attr_accessor :options
4
+
5
+ def to_html options = {}, &block
6
+ helper.capture { instance_exec(self, &block) }
7
+ render.html_safe
8
+ end
9
+
10
+ private
11
+
12
+ def render; end
13
+
14
+ def method_missing method, *args, &block
15
+ helper.send method, *args, &block
16
+ end
17
+
18
+ def element content_or_element_options = nil, element_options = {}, &block
19
+ if block_given?
20
+ [ helper.capture(&block), ensure_options(content_or_element_options) ]
21
+ else
22
+ [ content_or_element_options, ensure_options(element_options) ]
23
+ end
24
+ end
25
+
26
+ def ensure_options value
27
+ value.is_a?(Hash) ? value : {}
28
+ end
29
+
30
+ end
@@ -0,0 +1,34 @@
1
+ module CssSnippets::Renderer
2
+
3
+ class JustifiedItems < Base
4
+
5
+ ITEM_DOM_CLASS = 'b-justified-item'
6
+ CONTAINER_DOM_CLASS = 'b-justified-container'
7
+ WRAPPER_DOM_CLASS = 'l-default-justified-items'
8
+
9
+ def item content_or_options = nil, options = {}, &block
10
+ @items ||= []
11
+ @items << render_item(*element(content_or_options, options, &block))
12
+ return_nothing
13
+ end
14
+
15
+ private
16
+
17
+ def render_item content, dirty_options
18
+ helper.content_tag :li, content, dirty_options.merge(:class => ITEM_DOM_CLASS)
19
+ end
20
+
21
+ def render
22
+ helper.content_tag :div, render_list, :class => WRAPPER_DOM_CLASS
23
+ end
24
+
25
+ def render_list
26
+ helper.content_tag :ul, @items.join("\n").html_safe, :class => CONTAINER_DOM_CLASS
27
+ end
28
+
29
+ def return_nothing
30
+ ''
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ module CssSnippets::Renderer
2
+
3
+ class RightMenuLiquidLayout < Base
4
+
5
+ WRAPPER_DOM_CLASS = 'l-default-right-menu-liquid-layout'
6
+
7
+ def left_column content_or_options = nil, options = {}, &block
8
+ @left_column_content, _ = element(content_or_options, options, &block)
9
+ end
10
+
11
+ def right_column content_or_options = nil, options = {}, &block
12
+ @right_column_content, _ = element(content_or_options, options, &block)
13
+ end
14
+
15
+ private
16
+
17
+ def render
18
+ <<-HTML
19
+ <div class="#{WRAPPER_DOM_CLASS}">
20
+ <div class="l-right-column">
21
+ <div class="l-left-column-wrap">
22
+ <div class="l-left-column">
23
+ <div class="b-left-column">#{@left_column_content}</div>
24
+ </div>
25
+ <div class="b-right-column">#{@right_column_content}</div>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ HTML
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module CssSnippets
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ @import 'compass';
2
+ @import 'css-snippets/variables';
3
+ @import 'css-snippets/mixins';
4
+ @import 'css-snippets/justified_items';
5
+ @import 'css-snippets/right_menu_liquid_layout';
@@ -0,0 +1,45 @@
1
+ @mixin justify-items($font-size: $justified-container-item-font-size) {
2
+ .b-justified-container {
3
+ @include justify-items-container;
4
+
5
+ .b-justified-item {
6
+ @include justify-container-item($font-size);
7
+ }
8
+ }
9
+ }
10
+
11
+ @mixin justify-items-container {
12
+ line-height: 0;
13
+ font-size: 1px; // for Opera
14
+
15
+ text-align: justify;
16
+
17
+ // IE6-7
18
+ text-justify: newspaper;
19
+ zoom: 1;
20
+ text-align-last: justify;
21
+
22
+ &:after {
23
+ width: 100%;
24
+ height: 0px;
25
+ visibility: hidden;
26
+ overflow: hidden;
27
+ content: '';
28
+ @include inline-block;
29
+ }
30
+ }
31
+
32
+ @mixin justify-container-item($font-size: $justified-container-item-font-size) {
33
+ text-align: left;
34
+
35
+ line-height: normal;
36
+ font-size: $font-size;
37
+
38
+ // Opera
39
+ vertical-align: top;
40
+ @include inline-block;
41
+ }
42
+
43
+ .l-default-justified-items {
44
+ @include justify-items;
45
+ }
File without changes
@@ -0,0 +1,42 @@
1
+ @mixin right-menu-liquid-layout {
2
+ .l-right-column {
3
+ clear: both;
4
+ float: left;
5
+ overflow: hidden;
6
+ position: relative;
7
+ width: 100%;
8
+
9
+ .l-left-column-wrap {
10
+ float: left;
11
+ margin-left: -$right-menu-liquid-layout-right-column-width;
12
+ position: relative;
13
+ right: 100%;
14
+ width: 200%;
15
+ background: $right-menu-liquid-layout-left-column-background;
16
+
17
+ .l-left-column {
18
+ float: left;
19
+ left: 50%;
20
+ position: relative;
21
+ width: 50%;
22
+
23
+ .b-left-column {
24
+ margin: 0 0 0 $right-menu-liquid-layout-right-column-width;
25
+ overflow: hidden;
26
+ }
27
+ }
28
+
29
+ .b-right-column {
30
+ float: right;
31
+ left: $right-menu-liquid-layout-right-column-width;
32
+ position: relative;
33
+ width: $right-menu-liquid-layout-right-column-width - $right-menu-liquid-layout-space-between-columns;
34
+ background: $right-menu-liquid-layout-right-column-background;
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ .l-default-right-menu-liquid-layout {
41
+ @include right-menu-liquid-layout;
42
+ }
@@ -0,0 +1,6 @@
1
+ $justified-container-item-font-size: 12px !default;
2
+
3
+ $right-menu-liquid-layout-right-column-width: 200px !default;
4
+ $right-menu-liquid-layout-right-column-background: none !default;
5
+ $right-menu-liquid-layout-left-column-background: none !default;
6
+ $right-menu-liquid-layout-space-between-columns: 50px !default;
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: css-snippets
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Ivan Garmatenko
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-02-24 00:00:00 +04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: compass
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 3
43
+ - 1
44
+ version: "3.1"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ description: Gem contains stylesheets and rails helpers which provides simple way to add useful css snippets to your site
48
+ email:
49
+ - cheef.che@gmail.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - lib/css-snippets.rb
58
+ - lib/css-snippets/version.rb
59
+ - lib/css-snippets/renderer.rb
60
+ - lib/css-snippets/renderer/justified_items.rb
61
+ - lib/css-snippets/renderer/base.rb
62
+ - lib/css-snippets/renderer/right_menu_liquid_layout.rb
63
+ - lib/css-snippets/engine.rb
64
+ - stylesheets/css-snippets/_justified_items.scss
65
+ - stylesheets/css-snippets/_mixins.scss
66
+ - stylesheets/css-snippets/_variables.scss
67
+ - stylesheets/css-snippets/_right_menu_liquid_layout.scss
68
+ - stylesheets/_css-snippets.scss
69
+ has_rdoc: true
70
+ homepage: http://css-snippets.heroku.com
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project: css-snippets
97
+ rubygems_version: 1.3.7
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Provides a useful css snippets and layouts
101
+ test_files: []
102
+