front_man 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9768629ff7e4c4e6de7c5f396a584b3f4233e95d
4
- data.tar.gz: 3f4431ab526b6f67108323aece0e855d2c7593e0
3
+ metadata.gz: a10787fabe7a96368a32944056daadb118c1b33f
4
+ data.tar.gz: 0ed139a951bb8a553b2400cf9b0cdfc84180bab9
5
5
  SHA512:
6
- metadata.gz: 050d99748bb14ceea7d41e625102fe15671900c5a58491caad8910c4c79beee3b3d531c576eda78307efc66a80613c373361e7539be8117711d63b09877d8248
7
- data.tar.gz: c90e2087264591af64dcb77e11c4fb73ebc86cc16bcbbb7e38dea3bcee0da244b1269f9781becfa6e43b8556ad7ad6c62c4359ed002c64652e58aae695303691
6
+ metadata.gz: f6c95800f8a0cb67927e54d1bead625ecf2e404b57b4b5b6135de775f1f8a3a3fcbcbdb0f88ac33af38f55cbbe0c9004b88188a9430c512e96a17afef3f323d7
7
+ data.tar.gz: 2d211696e64cfe6077b3f66d77de38a8a75d5207336498853735e1e7a61617e22922b19d04456200264f22d83b9d52db78a86545d7936854cbe2ef278327b94c
data/README.md CHANGED
@@ -16,6 +16,14 @@ And then execute:
16
16
  $ bundle
17
17
  ```
18
18
 
19
+ ### Middleman
20
+
21
+ If you're using middleman, add this line to `config.rb`:
22
+
23
+ ```ruby
24
+ activate :front_man
25
+ ```
26
+
19
27
  ## Usage
20
28
 
21
29
  Import front_man in your `application.scss`:
@@ -30,15 +38,68 @@ Or if you want to import components manually:
30
38
  @import 'front_man/z-index';
31
39
  ```
32
40
 
33
- Make sure the file has .scss extension (or .sass for Sass syntax). If you have just generated a new Rails app, it may come with a .css file instead. If this file exists, it will be served instead of Sass, so rename it:
41
+ Make sure the `application.scss` file has .scss extension (or .sass for Sass syntax). If you
42
+ have just generated a new Rails app, it may come with a .css file instead. If this file
43
+ exists, it will be served instead of Sass, so rename it:
34
44
 
35
45
  ```bash
36
46
  $ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
37
47
  ```
38
48
 
49
+ ### Helper methods
50
+
51
+ The front_man gem includes several helper methods.
52
+
53
+ #### inline_svg(filename)
54
+
55
+ Renders svg file in a hidden div for later referencing of it's elements; usually used to load
56
+ a single svg file that consists of all svg files concatenated together.
57
+
58
+ Example (you can put this at the bottom of your layout (`application.html.erb`) file:
59
+
60
+ ```ruby
61
+ <%= inline_svg('icons.svg') %>
62
+ ```
63
+
64
+ #### sprite_tag(filename, options = {})
65
+
66
+ Works together with `inline_svg` to serve specific svg file from concatenated file.
67
+
68
+ Example:
69
+
70
+ ```ruby
71
+ <%= sprite_tag('icon-home', class: 'svgIcon svgIcon-40') %>
72
+ ```
73
+
74
+ You can use css classes to style the icon:
75
+
76
+ ```scss
77
+ .svgIcon-40 {
78
+ width: 40px;
79
+ height: 40px;
80
+ fill: $base-color; // use fill instead of color
81
+ }
82
+ ```
83
+
84
+ All the options passed to sprite_tag are passed on to svg content_tag.
85
+
86
+ #### image_set\_tag(filename, options = {})
87
+
88
+ Used to set `srcset` attribute on `img` tag.
89
+
90
+ Example:
91
+
92
+ ```ruby
93
+ image_set_tag(item.image.medium, srcset: {
94
+ item.image.thumb => '200w',
95
+ item.image.medium => '600w',
96
+ item.image.large => '800w'
97
+ })
98
+ ```
99
+
39
100
  ## Kudos
40
101
 
41
- The conventions laid out here were based upon those discussed in the article below. Kudos to [@fat](https://github.com/fat).
102
+ The conventions laid out in the asset files here were based upon those discussed in the article below. Kudos to [@fat](https://github.com/fat).
42
103
 
43
104
  https://medium.com/@fat/mediums-css-is-actually-pretty-fucking-good-b8e2a6c78b06
44
105
 
@@ -7,8 +7,16 @@ module FrontMan
7
7
  end
8
8
 
9
9
  def inline_svg(filename)
10
- file = File.read("app/assets/images/#{filename}")
11
- content_tag :div, file.html_safe, class: 'u-is-hidden'
10
+ case FrontMan.framework
11
+ when :rails
12
+ file_path = "app/assets/images/#{filename}"
13
+ when :middleman
14
+ file_path = sitemap.find_resource_by_path(image_path('icons.svg'))
15
+ .source_file
16
+ end
17
+
18
+ file_contents = File.read(file_path)
19
+ content_tag :div, file_contents.html_safe, class: 'u-is-hidden'
12
20
  end
13
21
 
14
22
  def image_set_tag(filename, options = {})
data/front_man.gemspec CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.add_dependency 'activesupport'
25
+
24
26
  spec.add_development_dependency 'bundler', '~> 1.10'
25
27
  spec.add_development_dependency 'guard'
26
28
  spec.add_development_dependency 'guard-rspec'
@@ -0,0 +1,13 @@
1
+ require_relative '../../../app/helpers/front_man/images_helper'
2
+
3
+ module FrontMan
4
+ class MiddlemanExtension < Middleman::Extension
5
+ helpers do
6
+ include FrontMan::ImagesHelper
7
+ end
8
+ end
9
+
10
+ FrontMan.framework = :middleman
11
+ end
12
+
13
+ ::Middleman::Extensions.register(:front_man, FrontMan::MiddlemanExtension)
@@ -0,0 +1,8 @@
1
+ require 'rails/engine'
2
+
3
+ module FrontMan
4
+ class Engine < ::Rails::Engine
5
+ end
6
+
7
+ FrontMan.framework = :rails
8
+ end
@@ -1,3 +1,3 @@
1
1
  module FrontMan
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/front_man.rb CHANGED
@@ -1,7 +1,13 @@
1
- require 'front_man/engine'
1
+ require 'active_support'
2
2
 
3
3
  module FrontMan
4
+ mattr_accessor :framework
5
+
4
6
  def self.root
5
7
  Pathname.new(File.dirname(__dir__))
6
8
  end
7
9
  end
10
+
11
+ extension = :railtie if defined?(Rails)
12
+ extension ||= :middleman if defined?(Middleman)
13
+ require "front_man/core_ext/#{extension}" if extension
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: front_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Fonic
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-11-23 00:00:00.000000000 Z
12
+ date: 2016-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +165,8 @@ files:
151
165
  - bin/setup
152
166
  - front_man.gemspec
153
167
  - lib/front_man.rb
154
- - lib/front_man/engine.rb
168
+ - lib/front_man/core_ext/middleman.rb
169
+ - lib/front_man/core_ext/railtie.rb
155
170
  - lib/front_man/version.rb
156
171
  homepage: http://dvelp.co.uk/
157
172
  licenses:
@@ -178,4 +193,3 @@ signing_key:
178
193
  specification_version: 4
179
194
  summary: The DVELP frontend framework.
180
195
  test_files: []
181
- has_rdoc:
@@ -1,11 +0,0 @@
1
- require 'rails/engine'
2
-
3
- module FrontMan
4
- class Engine < ::Rails::Engine
5
- initializer 'front_man.images_helper' do
6
- ActiveSupport.on_load(:action_view) do
7
- include FrontMan::ImagesHelper
8
- end
9
- end
10
- end
11
- end