center_image_tag 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDAxYjU0NGI2ZjBlMDBjOWIxYmQwZjFmMzgzODZjYzc1ODRiNjllOA==
4
+ Nzc0YjI2Y2JiMjU5MzY4NjllNGU0N2MxYmQxZTE5MjE2ZDhlMTdhZg==
5
5
  data.tar.gz: !binary |-
6
- MTJiNDljOWIyZDA0ZTUwYzIwYzQwY2FhZDg2NDNlNTQ1ODQxNGUzZQ==
6
+ ZmUzYzQwYzUyZGZhOGU1MjI0NWYyNGJmZDFmOGRhMmZkY2QzZDMxNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjI0NzQ3MTM0NTI0NzdjNjdhOTYwMzY1MjcyNDg0N2Y1YzVjZDRkZjY4N2Qw
10
- ZDI1OGJjNGNjN2Y5Y2Y4ZTdlY2I2YzkzMjVjMmQzMmM2MDI2MWRjMzE0ZDhj
11
- NjRhM2Q2YjY4NWUzOWRiZjU3NThkMmUwNWIwNWYxOWU5M2ZlMzE=
9
+ ZWY5N2Q4MDRkN2RlNDY3ZTYwZjk4Njk0YjA1Yzg5MjUzNzI1NTJiZTNhNGY1
10
+ OGM3NzE4OWYxNjJlYjk1ZjM3MWI5ODg1NWY2NGZkMDg1ZTYzMjgzYTViYWQ3
11
+ MzI0NWJhMWMxOWRjMGQ1MzMzMDJlZjY2MGFhZmVlMDUwZmE5ZmE=
12
12
  data.tar.gz: !binary |-
13
- NTk5YTkxMmY0MmU2ZmM2MTJkNWM4Y2E2Y2Y2OWIwZjNkNzUxOTg4ZGVlMTcz
14
- OTJmNTZjZmYzOGZmMWQ0ZjY1YzhlYzk2NDI1NjQzZjU1ODFiM2EyNjBiODNi
15
- MTc2NWNjMTczOTk2OTYzZTA1YTU4MWEyMTNjNzRmMzc1MzRkMmY=
13
+ NTU1ZWU0Y2U5ZDNmNTI5YWEzNmNhYmI1MGRlMjU2NTgzNDdhNmI5OTg4ZDcy
14
+ NzgyOWUxN2FiZmUzOTcwZDU4NmFkMWE5MDI4MDA4ZjU1YWJhMmFhMDk5ZTIz
15
+ ZTg3NzQ2ZjI5ZjFmNGFkYjkyZjJiMTA2NTVmYTk5MWE3Mjc4MWI=
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
+ [![Gem Version](https://badge.fury.io/rb/center_image_tag.png)](http://badge.fury.io/rb/center_image_tag)
1
2
  [![Build Status](https://travis-ci.org/anhkind/center_image_tag.png)](https://travis-ci.org/anhkind/center_image_tag)
2
3
 
3
- # CenterImageTag
4
+ # center_image_tag: Center your images with pure css
4
5
 
5
- TODO: Write a gem description
6
+ `center_image_tag` is another tag helper for Rails app which helps to center your image in its parent element view. It has the same arguments as `image_tag`, so you can easily integrate this into your current Rails app.
7
+
8
+ `center_image_tag` has a built-in fluid mode which would buy you some time to center the images in your responsive design. Otherwise, just set fixed width and height as in `image_tag`, you can also have images auto-centered with the set dimension.
6
9
 
7
10
  ## Installation
8
11
 
@@ -10,17 +13,69 @@ Add this line to your application's Gemfile:
10
13
 
11
14
  gem 'center_image_tag'
12
15
 
13
- And then execute:
14
16
 
15
- $ bundle
17
+ Then import `center_image_tag` in an SCSS file (for example, application.css.scss):
18
+
19
+ @import 'center_image_tag';
20
+
21
+ ## Options
22
+
23
+ `center_image_tag` has the same options as `image_tag` helper and adds 2 more options to the option hash:
24
+
25
+ - `fluid`: set the image to be autoscaled with its parent. See 'Fluid mode' section below for details.
26
+ - `container_class`: css classes to the outer container of center_image_tag. See 'Container class' section below for details.
27
+
28
+ ## Modes of operation
29
+
30
+ `center_image_tag` has 2 modes of operation which are mutually exclusive, i.e. can't use at the same time, so try to pick up the best mode that fits your need.
31
+
32
+ ### Fluid mode
33
+
34
+ `center_image_tag` can display the image which will auto scale with its parent element. The percentage between height and width of the image needs to be set:
35
+
36
+ ```ruby
37
+ center_image_tag 'http://yoursite/image.png', fluid: '56.25%'
38
+ ```
39
+
40
+ ### Fixed width and height mode
41
+ `center_image_tag` can display the image whose width and height are fixed:
42
+
43
+ ```ruby
44
+ center_image_tag 'http://yoursite/image.png', size: '200x100'
45
+ ```
46
+
47
+ ```ruby
48
+ center_image_tag 'http://yoursite/image.png', size: '100'
49
+ ```
50
+
51
+ ```ruby
52
+ center_image_tag 'http://yoursite/image.png', width: 200, height: 100
53
+ ```
54
+
55
+ You can notice that these options are exactly the same as the `image_tag` helper.
56
+
57
+ ## Container class
58
+ `center_image_tag` uses a nested `div` tags to make your image center. `container_class` option will help to add css classes to the outer container generated by `center_image_tag`, for example:
16
59
 
17
- Or install it yourself as:
60
+ ```ruby
61
+ center_image_tag 'http://yoursite/image.png', fluid: '56.25%', container_class: 'my-custom-class'
62
+ # =>
63
+ # <div class="... my-custom-class">
64
+ # ...
65
+ # <img src="http://yoursite/image.png" />
66
+ # ...
67
+ # </div>
68
+ ```
18
69
 
19
- $ gem install center_image_tag
70
+ With this option, it can help in the case you need to add more styles or override the current styles of the generated container, e.g. make the image inline.
20
71
 
21
- ## Usage
72
+ ## Fallback
73
+ In the case that
22
74
 
23
- TODO: Write usage instructions here
75
+ - `fluid' option is NOT set, AND
76
+ - both width and height are NOT set (throught `size` option or `width`/`height` options)
77
+
78
+ `center_image_tag` will fall back to normal `image_tag`
24
79
 
25
80
  ## Contributing
26
81
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = CenterImageTag::VERSION
9
9
  spec.authors = ["Anh Nguyen"]
10
10
  spec.email = ["anhkind@gmail.com"]
11
- spec.description = "center_image_tag helps your Rails app to center your images easily."
12
- spec.summary = "Center your images without js."
11
+ spec.description = "center_image_tag helps your Rails app to center your images easily with pure css."
12
+ spec.summary = "Center your images with pure css."
13
13
  spec.homepage = "https://github.com/anhkind/center_image_tag"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module CenterImageTag
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: center_image_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anh Nguyen
@@ -80,7 +80,8 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.12'
83
- description: center_image_tag helps your Rails app to center your images easily.
83
+ description: center_image_tag helps your Rails app to center your images easily with
84
+ pure css.
84
85
  email:
85
86
  - anhkind@gmail.com
86
87
  executables: []
@@ -125,7 +126,7 @@ rubyforge_project:
125
126
  rubygems_version: 2.1.10
126
127
  signing_key:
127
128
  specification_version: 4
128
- summary: Center your images without js.
129
+ summary: Center your images with pure css.
129
130
  test_files:
130
131
  - spec/spec_helper.rb
131
132
  - spec/view_helper_spec.rb