fatcow 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3836c6f46580aeea988f12f4d740c8c7f858d4cf2880a22dfb678d6a2bc048d5
4
- data.tar.gz: 1a7b8e7fa73594c4c6c7555ab010decf184247f5656f07945630d1229e997e6e
3
+ metadata.gz: 16d86a78b8a3cd4859836c03556ed78d98957bdba6e320402768a5c68c2856da
4
+ data.tar.gz: b325524f806120e6ab5aa682dd7f8d537c4421f36a4b1b48bd33e52f2621a909
5
5
  SHA512:
6
- metadata.gz: 74887478182b9b2271c11a7229d0f396a0a1be306be1c24c02046c0a6a46f87bd8ed080f94f9dc0a267f53dccd0df18f00e2539cb86f50b4d136b142f2f75747
7
- data.tar.gz: 79cfea80f477618ae2752cd2eecb4941c8667bdd5a36c5437aedd9ba4ab11b88e8a9a1f1828e20fa2a705b6b7c87784eb33f4fbbbd6ab0eb4b2021b7781cd4eb
6
+ metadata.gz: d06145423f6eed536b7ac02ad7f4790c01f1220d2245ccb94f2c626b0dcc72409e1a2e965fd3673ecce7e37fda9050e5e400735c6c95dc1e21a1d6e6d9b2b24e
7
+ data.tar.gz: 55aa307a620b36d3c1ec8bd0dd1f7b780ecfb976f28addcd3dfd6a43c5cb6449b08df766a1e7b3bb3c187e18be03952fb1249098263842bba96c3a22b87311f2
data/README.md CHANGED
@@ -70,6 +70,9 @@ You cannot do this on collections, though that may be coming later.
70
70
  <%= @alert.show_icon %>
71
71
  ```
72
72
 
73
+ ## All Icons
74
+ ![a big list of icons](https://web.archive.org/web/20160324052646if_/http://www.fatcow.com/images/fatcow-icons/fatcow-3926.png)
75
+
73
76
  ## Licensing
74
77
 
75
78
  FatCow web icons are licensed under
@@ -11,8 +11,10 @@ module Fatcow
11
11
  def fatcow_style_tag
12
12
  content_tag :style do <<~CSS
13
13
  .fatcow-icon {
14
- display: inline-block;
15
- position: relative;
14
+ display: inline-block;
15
+ position: relative;
16
+ image-rendering: crisp-edges;
17
+ user-select: none;
16
18
  }
17
19
 
18
20
  .fatcow-icon__bullet {
@@ -21,10 +23,29 @@ module Fatcow
21
23
  left: 0;
22
24
  transform: translate(25%, 25%);
23
25
  }
26
+
27
+ .fatcow-icon > img:not(.fatcow-icon__bullet--hack) {
28
+ width: 100%;
29
+ }
24
30
 
25
31
  .fatcow-icon__bullet--pre-aligned {
26
32
  transform: none;
27
33
  }
34
+
35
+ .fatcow-icon--small .fatcow-icon__bullet--hack {
36
+ display: inline-block;
37
+ position: static;
38
+ transform: none;
39
+ margin-left: 4px;
40
+ }
41
+
42
+ .fatcow-icon:not(.fatcow-icon--small) .fatcow-icon__bullet--hack {
43
+ transform: none;
44
+ bottom: 0;
45
+ right: 0;
46
+ top: initial;
47
+ left: initial;
48
+ }
28
49
  CSS
29
50
  end
30
51
  end
data/lib/fatcow/icon.rb CHANGED
@@ -4,12 +4,14 @@ require 'nokogiri'
4
4
 
5
5
  module Fatcow
6
6
  class Icon
7
- attr_reader :name, :status, :app
7
+ attr_reader :name, :status, :app, :size
8
8
 
9
- def initialize(app, name, status = nil)
9
+ def initialize(app, name, status = nil, **options)
10
10
  @app = app
11
11
  @name = name
12
12
  @status = status
13
+
14
+ @size = options[:size] || :regular
13
15
  end
14
16
 
15
17
  def status=(new_status)
@@ -27,6 +29,11 @@ module Fatcow
27
29
  clear_document
28
30
  end
29
31
 
32
+ def size=(new_size)
33
+ @size = new_size
34
+ clear_document
35
+ end
36
+
30
37
  def to_html
31
38
  document.to_html.html_safe
32
39
  end
@@ -45,22 +52,28 @@ module Fatcow
45
52
 
46
53
  def asset_path
47
54
  return base_icon_path unless status
48
- "/assets/normal/FatCow_Icons32x32/#{name}_#{status}.png" if status
55
+ "/assets/normal/#{subdirectory}/#{name}_#{status}.png" if status
49
56
  end
50
57
 
51
58
  def base_icon_path
52
- "/assets/normal/FatCow_Icons32x32/#{name}.png"
59
+ "/assets/normal/#{subdirectory}/#{name}.png"
53
60
  end
54
61
 
55
62
  def bullet_icon_path
56
- "/assets/normal/FatCow_Icons32x32/bullet_#{status}.png"
63
+ return "/assets/normal/#{subdirectory}/bullet_#{status}.png" if bullet_exists?
64
+ "/assets/normal/FatCow_Icons16x16/#{status}.png"
65
+ end
66
+
67
+ def bullet_exists?
68
+ bullets = %i[archive attach back bell brush bug bulb_off bulb_on burn camera cd chart code_red code connect database document down dvd edit excel find flash gear lightning link magnify medal office palette php powerpoint table textfield up valid vector word world user blue purple pink red orange yellow green white black add delete go error key wrench toggle_minus toggle_plus feed picture disk star arrow_bottom arrow_down arrow_left_2 arrow_left arrow_right_2 arrow_right arrow_top arrow_up]
69
+ bullets.include? status
57
70
  end
58
71
 
59
72
  def document
60
73
  return @document if @document
61
74
 
62
75
  @document ||= Nokogiri::HTML::Builder.new do |doc|
63
- doc.div(class: "fatcow-icon fatcow-icon--#{name}") {
76
+ doc.div(class: container_class) {
64
77
  if status && composite?
65
78
  doc.parent << Nokogiri::HTML.fragment(@app.image_tag(base_icon_path))
66
79
  doc.parent << Nokogiri::HTML.fragment(@app.image_tag(bullet_icon_path, class: bullet_class))
@@ -77,10 +90,21 @@ module Fatcow
77
90
  @document = nil
78
91
  end
79
92
 
93
+ def container_class
94
+ return "fatcow-icon fatcow-icon--#{name}" if size == :regular
95
+ "fatcow-icon fatcow-icon--small fatcow-icon--#{name}"
96
+ end
97
+
80
98
  def bullet_class
81
99
  prealigned_bullets = %i[archive attach back bell brush bug bulb_off bulb_on burn camera cd chart code_red code connect database document down dvd edit excel find flash gear lightning link magnify medal office palette php powerpoint table textfield up valid vector word world user]
82
100
  return 'fatcow-icon__bullet fatcow-icon__bullet--pre-aligned' if prealigned_bullets.include? status
83
- return 'fatcow-icon__bullet'
101
+ return 'fatcow-icon__bullet' if bullet_exists?
102
+ 'fatcow-icon__bullet fatcow-icon__bullet--hack'
103
+ end
104
+
105
+ def subdirectory
106
+ return 'FatCow_Icons32x32' if size == :regular
107
+ 'FatCow_Icons16x16'
84
108
  end
85
109
  end
86
110
  end
data/lib/fatcow/model.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Fatcow
4
4
  module Model
5
5
  extend ActiveSupport::Concern
6
- include ActionView::Helpers
6
+ include ActionView::Helpers::AssetTagHelper
7
7
 
8
8
  DEFAULT_SHOW_STATUSES = {
9
9
  add: -> { new_record? },
@@ -16,18 +16,18 @@ module Fatcow
16
16
  }
17
17
 
18
18
  included do
19
- def show_icon
19
+ def show_icon(**options)
20
20
  current_state = find_icon_status(:FATCOW_ICON_SHOW_STATUSES)
21
21
 
22
- return custom_icon(current_state) if current_state
23
- custom_icon(nil) if current_state.nil?
22
+ return custom_icon(current_state, **options) if current_state
23
+ custom_icon(nil, **options) if current_state.nil?
24
24
  end
25
25
 
26
- def form_icon
26
+ def form_icon(**options)
27
27
  current_state = find_icon_status(:FATCOW_ICON_FORM_STATUSES)
28
28
 
29
- return custom_icon(current_state) if current_state
30
- custom_icon(nil) if current_state.nil?
29
+ return custom_icon(current_state, **options) if current_state
30
+ custom_icon(nil, **options) if current_state.nil?
31
31
  end
32
32
 
33
33
  def find_icon_status(statuses_const_key)
@@ -38,11 +38,12 @@ module Fatcow
38
38
  current_status[0]
39
39
  end
40
40
 
41
- def custom_icon(status)
41
+ def custom_icon(status, **options)
42
42
  icon = self.class.const_get :FATCOW_ICON
43
43
 
44
44
  icon.app = self if icon.app.nil?
45
45
  icon.status = status if icon.status != status
46
+ icon.size = options[:size] if options[:size]
46
47
 
47
48
  icon
48
49
  end
@@ -1,5 +1,5 @@
1
1
  module Fatcow
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
 
4
4
  ASSET_ROOT = File.expand_path("assets", __dir__)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fatcow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gray