sudo_rails 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: 1b2a206413480a731bf2285e75f5b185930db711f140b4392330c2cf7f8c3c44
4
- data.tar.gz: 42deffb7bf182734fd0cef63faefc972ad1bb396727920342c4a09c1aa67b83d
3
+ metadata.gz: 47353a5708d7d533d73eb292b6fa27dff50c84281aadb20e828ee8d15bc53433
4
+ data.tar.gz: 87b001f0a155bde05c64708c1f6c3fcfbf62b148bbedcee32b60bf52918ebc53
5
5
  SHA512:
6
- metadata.gz: 77ac6e2b6ce5b8081b56584bd5cab20d914efed66dec81baad9e636eb645a1997daf53b132de642c8e8e562b10d8eb7cfad9d2a87901c033d17203af6b6b803b
7
- data.tar.gz: 4c614f2e0972ae6510959a01bd382b3e3581abfda87a005f1dda8092a202ff713557aa4e8d1aa9bd6ed0876dbd4e0507e2a38e3e7bfbce458373afbb60c3d12d
6
+ metadata.gz: 1aeac2e9e55e5d37eb8ca6bc9e566601b29347d03e29f4d5362d3fc621f08a04498e244c83364aabdcc4f7c6e22fbf5edf96690a3a331ba270d386251517c711
7
+ data.tar.gz: ddf32a2c32464a46257fe1d4ec19048a7dbbb1d0d79d58238e307401f92d31d7853c7f9df521f94e151885a96a68427a11ac3ce1d172f10844f777c17609afcf
data/README.md CHANGED
@@ -50,6 +50,7 @@ SudoRails.setup do |config|
50
50
  # Confirmation page styling
51
51
  config.custom_logo = 'logos/medium_dark.png'
52
52
  config.primary_color = '#1A7191'
53
+ config.background_color = '#1A7191'
53
54
  config.layout = 'admin'
54
55
 
55
56
  # Confirmation strategy
@@ -63,7 +64,7 @@ end
63
64
 
64
65
  ### Styling
65
66
 
66
- Using the `custom_logo` and `primary_color` options, you can customize the confirmation page. In case you want full control of the styles, you can use your own layout (and consequently your own styles too) using the `layout` option.
67
+ Using the `custom_logo`, `primary_color` and `background_color` options, you can customize the confirmation page. In case you want full control of the styles, you can use your own layout (and consequently your own styles too) using the `layout` option.
67
68
 
68
69
  ### Confirmation strategy
69
70
 
@@ -22,8 +22,8 @@ a {
22
22
  border-radius: 5px;
23
23
  padding: 20px;
24
24
  margin: 10px auto;
25
- width: 340px;
26
- box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.1);
25
+ max-width: 340px;
26
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2);
27
27
 
28
28
  input {
29
29
  display: block;
@@ -45,6 +45,6 @@ a {
45
45
  }
46
46
 
47
47
  .sudo-tip {
48
- margin-top: 20px;
48
+ margin-top: 30px;
49
49
  font-size: 14px;
50
50
  }
@@ -1,8 +1,19 @@
1
1
  <style type="text/css">
2
- a {
3
- color: <%= SudoRails.primary_color %>;
4
- }
5
- .sudo-form input[type="submit"] {
6
- background-color: <%= SudoRails.primary_color %>;
7
- }
2
+ <% if SudoRails.background_color.present? %>
3
+ body {
4
+ background-color: <%= SudoRails.background_color %>;
5
+ color: <%= SudoRails.color_contrast(SudoRails.background_color) %>;
6
+ }
7
+ <% end %>
8
+
9
+ <% if SudoRails.primary_color.present? %>
10
+ a {
11
+ color: <%= SudoRails.primary_color %>;
12
+ }
13
+
14
+ .sudo-form input[type="submit"] {
15
+ background-color: <%= SudoRails.primary_color %>;
16
+ color: <%= SudoRails.color_contrast(SudoRails.primary_color) %>;
17
+ }
18
+ <% end %>
8
19
  </style>
@@ -0,0 +1,18 @@
1
+ module SudoRails
2
+ module Styling
3
+ def get_layout
4
+ SudoRails.layout || 'sudo_rails/application'
5
+ end
6
+
7
+ def custom_styles?
8
+ SudoRails.primary_color.present? || SudoRails.background_color.present?
9
+ end
10
+
11
+ # Ref: https://gist.github.com/charliepark/480358
12
+ def color_contrast(hex_color)
13
+ return nil unless hex_color.include?('#')
14
+
15
+ hex_color.delete('#').scan(/../).sum { |color| color.hex } > 382.5 ? '#000' : '#FFF'
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module SudoRails
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/sudo_rails.rb CHANGED
@@ -1,29 +1,25 @@
1
1
  require "sudo_rails/version"
2
2
  require "sudo_rails/controller_ext"
3
+ require "sudo_rails/styling"
3
4
  require "sudo_rails/engine"
4
5
 
5
6
  module SudoRails
6
7
  class << self
8
+ include Styling
9
+
7
10
  attr_accessor :enabled,
11
+ :confirm_strategy,
12
+ :sudo_session_duration,
13
+ :reset_pass_link,
8
14
  :layout,
9
15
  :custom_logo,
10
16
  :primary_color,
11
- :confirm_strategy,
12
- :sudo_session_duration,
13
- :reset_pass_link
17
+ :background_color
14
18
 
15
19
  def setup
16
20
  yield(self) if block_given?
17
21
  end
18
22
 
19
- def get_layout
20
- layout || 'sudo_rails/application'
21
- end
22
-
23
- def custom_styles?
24
- primary_color.present?
25
- end
26
-
27
23
  def confirm?(context, password)
28
24
  strategy = confirm_strategy
29
25
  raise(ArgumentError, 'Please, provide an strategy via SudoRails.confirm_strategy') unless strategy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sudo_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-09 00:00:00.000000000 Z
11
+ date: 2019-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,6 +73,7 @@ files:
73
73
  - lib/sudo_rails/engine.rb
74
74
  - lib/sudo_rails/integrations/clearance.rb
75
75
  - lib/sudo_rails/integrations/devise.rb
76
+ - lib/sudo_rails/styling.rb
76
77
  - lib/sudo_rails/version.rb
77
78
  homepage: https://github.com/markets/sudo_rails
78
79
  licenses: