beyond_canvas 0.9.0.pre → 0.10.0.pre
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 +4 -4
- data/app/assets/javascripts/beyond_canvas/buttons.js +1 -1
- data/app/assets/javascripts/beyond_canvas/inputs.js +28 -0
- data/app/assets/javascripts/beyond_canvas.js +2 -1
- data/app/assets/stylesheets/beyond_canvas/components/_inputs.sass +17 -0
- data/app/assets/stylesheets/beyond_canvas/components/_notices.sass +16 -22
- data/app/assets/stylesheets/beyond_canvas/settings/_variables.sass +3 -3
- data/app/controllers/beyond_canvas/application_controller.rb +1 -51
- data/app/controllers/concerns/beyond_canvas/locale_management.rb +56 -0
- data/app/form_builders/beyond_canvas/form_builder.rb +20 -0
- data/app/helpers/beyond_canvas/application_helper.rb +38 -15
- data/app/views/beyond_canvas/shared/_head.html.slim +10 -2
- data/config/initializers/beyond_canvas/assets.rb +4 -0
- data/lib/beyond_canvas/engine.rb +4 -3
- data/lib/beyond_canvas/version.rb +1 -1
- data/lib/beyond_canvas.rb +2 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd36e8ee286be66d4bee8fcae14a2b1bbc7b1196c78ad74b422bc52bb6979ee0
|
4
|
+
data.tar.gz: 5cdf4c4ff623a1a504bc323cf5cbd603c7b5286f1cf16ac144ad26db1a3ea35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b1967bcc9c9d9e5fb907c23e24332ad8f223755a982028afa3928b90d12eb6e5685a1abdc7cee7a1e6a6f8bd90aa51bc5fc5b57f3338405e2421790f33d6f0
|
7
|
+
data.tar.gz: 9180fa6cab6bb646d4a95507906c7786edd6d5ef8eb3189cee42e7ec2d769158f43420fb6b3f5e925f836762d5bb680890f54f92a4c9163ec3d6718f77c7f792
|
@@ -0,0 +1,28 @@
|
|
1
|
+
(function($) {
|
2
|
+
$(document).on('ready page:load turbolinks:load', function() {
|
3
|
+
$('input[type="file"]').each(function() {
|
4
|
+
var $input = $(this),
|
5
|
+
$label = $(`.input__file__text.${$input.attr('id')}`),
|
6
|
+
labelVal = $label.html();
|
7
|
+
|
8
|
+
$input.on('change', function(e) {
|
9
|
+
var fileName = '';
|
10
|
+
|
11
|
+
if (this.files && this.files.length > 1)
|
12
|
+
fileName = (this.getAttribute('data-multiple-caption') || '').replace('{count}', this.files.length);
|
13
|
+
else if (e.target.value)
|
14
|
+
fileName = e.target.value.split('\\').pop();
|
15
|
+
|
16
|
+
if (fileName)
|
17
|
+
$label.html(`<i class="far fa-file input__file__icon"></i>${fileName}`);
|
18
|
+
else
|
19
|
+
$label.html(labelVal);
|
20
|
+
});
|
21
|
+
|
22
|
+
// Firefox bug fix
|
23
|
+
$input
|
24
|
+
.on('focus', function() { $input.addClass('has-focus'); })
|
25
|
+
.on('blur', function() { $input.removeClass('has-focus'); });
|
26
|
+
});
|
27
|
+
});
|
28
|
+
})(jQuery);
|
@@ -44,6 +44,23 @@ select
|
|
44
44
|
font-size: 13px
|
45
45
|
margin-top: 1px
|
46
46
|
|
47
|
+
&__file
|
48
|
+
display: flex
|
49
|
+
align-items: center
|
50
|
+
|
51
|
+
&__label
|
52
|
+
display: inline-block
|
53
|
+
|
54
|
+
&__text
|
55
|
+
margin-left: 20px
|
56
|
+
font-weight: 500
|
57
|
+
|
58
|
+
&__icon
|
59
|
+
margin-right: 5px
|
60
|
+
position: relative
|
61
|
+
top: 1px
|
62
|
+
|
63
|
+
|
47
64
|
// &__with-error
|
48
65
|
// border-left: 2px solid $input-errors-color
|
49
66
|
|
@@ -1,47 +1,41 @@
|
|
1
1
|
.notice
|
2
|
-
align-items: center
|
3
2
|
border-radius: $notice-border-radius
|
3
|
+
border: 1px solid
|
4
4
|
box-sizing: border-box
|
5
5
|
display: flex
|
6
|
-
padding: 10px 15px
|
7
6
|
|
8
7
|
&--success
|
9
|
-
|
8
|
+
border-color: $notice-success-background
|
10
9
|
|
11
10
|
.notice__icon
|
12
|
-
background-color:
|
13
|
-
color: lighten($notice-success-background, 25%)
|
11
|
+
background-color: $notice-success-background
|
14
12
|
|
15
13
|
&--info
|
16
|
-
|
14
|
+
border-color: $notice-info-background
|
17
15
|
|
18
16
|
.notice__icon
|
19
|
-
background-color:
|
20
|
-
color: lighten($notice-info-background, 25%)
|
17
|
+
background-color: $notice-info-background
|
21
18
|
|
22
19
|
&--warning
|
23
|
-
|
20
|
+
border-color: $notice-warning-background
|
24
21
|
|
25
22
|
.notice__icon
|
26
|
-
background-color:
|
27
|
-
color: lighten($notice-warning-background, 25%)
|
23
|
+
background-color: $notice-warning-background
|
28
24
|
|
29
25
|
&--error
|
30
|
-
|
26
|
+
border-color: $notice-error-background
|
31
27
|
|
32
28
|
.notice__icon
|
33
|
-
background-color:
|
34
|
-
color: lighten($notice-error-background, 25%)
|
29
|
+
background-color: $notice-error-background
|
35
30
|
|
36
31
|
&__icon
|
37
|
-
+
|
38
|
-
|
39
|
-
border-radius: 100%
|
32
|
+
+padding(10px 8px)
|
33
|
+
color: $white
|
40
34
|
display: flex
|
41
|
-
font-size:
|
42
|
-
justify-content: center
|
43
|
-
margin-right: 15px
|
44
|
-
min-width: 18px
|
35
|
+
font-size: 18px
|
45
36
|
|
46
|
-
&
|
37
|
+
&__content
|
38
|
+
+padding(8px 14px)
|
47
39
|
color: $notice-color
|
40
|
+
display: flex
|
41
|
+
align-items: center
|
@@ -128,11 +128,11 @@ $comment-color: rgb(170, 169, 156) !default
|
|
128
128
|
// ************************************************************
|
129
129
|
|
130
130
|
$notice-success-background: rgb(123, 170, 81) !default
|
131
|
-
$notice-info-background: rgb(
|
132
|
-
$notice-warning-background: rgb(
|
131
|
+
$notice-info-background: rgb(153, 153, 153) !default
|
132
|
+
$notice-warning-background: rgb(235, 183, 92) !default
|
133
133
|
$notice-error-background: rgb(162, 66, 60) !default
|
134
134
|
$notice-border-radius: 4px !default
|
135
|
-
$notice-color: rgb(
|
135
|
+
$notice-color: rgb(153, 153, 153) !default
|
136
136
|
|
137
137
|
// ************************************************************
|
138
138
|
// Markdown
|
@@ -3,57 +3,7 @@
|
|
3
3
|
module BeyondCanvas
|
4
4
|
class ApplicationController < ActionController::Base
|
5
5
|
protect_from_forgery with: :exception
|
6
|
-
before_action :set_locale, except: :update_locale
|
7
6
|
|
8
|
-
|
9
|
-
# Locale management
|
10
|
-
############################################################################
|
11
|
-
|
12
|
-
def update_locale
|
13
|
-
if I18n.available_locales.map(&:to_s).include? app_locale_params[:locale]
|
14
|
-
session[:locale] = app_locale_params[:locale]
|
15
|
-
set_locale
|
16
|
-
end
|
17
|
-
|
18
|
-
redirect_back(fallback_location: main_app.root_path)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
############################################################################
|
24
|
-
# Locale management
|
25
|
-
############################################################################
|
26
|
-
|
27
|
-
#
|
28
|
-
# Sets the I18n.locale to either +session[ :locale ]+ or the browser
|
29
|
-
# compatible locale (if +session[ :locale ]+ is not set)
|
30
|
-
#
|
31
|
-
def set_locale
|
32
|
-
I18n.locale = session[:locale] || session[:locale] = browser_compatible_locale
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Reads the +HTTP_ACCEPT_LANGUAGE+ header and searches a compatible locale
|
37
|
-
# on +I18n.available_locales+. If no compatible language is found, it
|
38
|
-
# returns +I18n.default_locale+.
|
39
|
-
#
|
40
|
-
# @return [String] a browser compatible language string or
|
41
|
-
# +I18n.default_locale+. (e.g. +'en-GB'+)
|
42
|
-
#
|
43
|
-
def browser_compatible_locale
|
44
|
-
browser_locales = HTTP::Accept::Languages.parse(request.headers['HTTP_ACCEPT_LANGUAGE'])
|
45
|
-
available_locales = HTTP::Accept::Languages::Locales.new(I18n.available_locales.map(&:to_s))
|
46
|
-
|
47
|
-
locales = available_locales & browser_locales
|
48
|
-
|
49
|
-
locales.empty? ? I18n.default_locale : locales.first
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Strong parameters for locale switch
|
54
|
-
#
|
55
|
-
def app_locale_params
|
56
|
-
params.require(:app).permit(:locale)
|
57
|
-
end
|
7
|
+
include ::BeyondCanvas::LocaleManagement
|
58
8
|
end
|
59
9
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BeyondCanvas
|
4
|
+
module LocaleManagement
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
before_action :set_locale, except: :update_locale
|
9
|
+
|
10
|
+
def update_locale
|
11
|
+
if I18n.available_locales.map(&:to_s).include? app_locale_params[:locale]
|
12
|
+
session[:locale] = app_locale_params[:locale]
|
13
|
+
set_locale
|
14
|
+
end
|
15
|
+
|
16
|
+
redirect_back(fallback_location: main_app.root_path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
#
|
23
|
+
# Sets the I18n.locale to either +session[ :locale ]+ or the browser
|
24
|
+
# compatible locale (if +session[ :locale ]+ is not set)
|
25
|
+
#
|
26
|
+
def set_locale
|
27
|
+
puts '*' * 100
|
28
|
+
puts '*' * 100
|
29
|
+
I18n.locale = session[:locale] || session[:locale] = browser_compatible_locale
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Reads the +HTTP_ACCEPT_LANGUAGE+ header and searches a compatible locale
|
34
|
+
# on +I18n.available_locales+. If no compatible language is found, it
|
35
|
+
# returns +I18n.default_locale+.
|
36
|
+
#
|
37
|
+
# @return [String] a browser compatible language string or
|
38
|
+
# +I18n.default_locale+. (e.g. +'en-GB'+)
|
39
|
+
#
|
40
|
+
def browser_compatible_locale
|
41
|
+
browser_locales = HTTP::Accept::Languages.parse(request.headers['HTTP_ACCEPT_LANGUAGE'])
|
42
|
+
available_locales = HTTP::Accept::Languages::Locales.new(I18n.available_locales.map(&:to_s))
|
43
|
+
|
44
|
+
locales = available_locales & browser_locales
|
45
|
+
|
46
|
+
locales.empty? ? I18n.default_locale : locales.first
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Strong parameters for locale switch
|
51
|
+
#
|
52
|
+
def app_locale_params
|
53
|
+
params.require(:app).permit(:locale)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -24,5 +24,25 @@ module BeyondCanvas
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
def file_field(attribute, args = {})
|
29
|
+
field_wrapper(attribute, args) do
|
30
|
+
filed_identifyer = "#{attribute}_#{(Time.now.to_f * 1000).to_i.to_s}"
|
31
|
+
|
32
|
+
args.merge!(id: filed_identifyer)
|
33
|
+
.merge!(hidden: true)
|
34
|
+
|
35
|
+
custom_attributes = { data: { multiple_selection_text: '{count} files selected' } }
|
36
|
+
args = custom_attributes.merge!(args)
|
37
|
+
|
38
|
+
@template.content_tag(:div, class: 'input__file') do
|
39
|
+
super(attribute, args) +
|
40
|
+
@template.content_tag(:label, for: filed_identifyer, class: 'input__file__label button__transparent--primary') do
|
41
|
+
args[:data][:button_text] || 'Choose file'
|
42
|
+
end +
|
43
|
+
@template.content_tag(:span, args[:data][:no_file_text] || 'No file chosen', class: "input__file__text #{filed_identifyer}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
27
47
|
end
|
28
48
|
end
|
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
module BeyondCanvas
|
4
4
|
module ApplicationHelper
|
5
|
+
def full_title(page_title = '')
|
6
|
+
if I18n.exists?('app_name')
|
7
|
+
base_title = I18n.t('app_name')
|
8
|
+
else
|
9
|
+
logger.debug "[BeyondCanvas] Missing translation: #{I18n.locale}.app_name".yellow
|
10
|
+
base_title = File.basename(Rails.root).humanize
|
11
|
+
end
|
12
|
+
|
13
|
+
page_title.empty? ? base_title : page_title + ' | ' + base_title
|
14
|
+
end
|
15
|
+
|
5
16
|
def link_to_with_icon(name = nil, options = nil, fa_class = nil, html_options = nil)
|
6
17
|
options ||= {}
|
7
18
|
|
@@ -16,14 +27,30 @@ module BeyondCanvas
|
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
30
|
+
[:success, :info, :warning, :error].each do |method|
|
31
|
+
define_method :"notice_#{method}" do |name = nil, html_options = nil, &block|
|
32
|
+
notice_render(method, name, html_options, &block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def logo_image_tag(logo_path)
|
37
|
+
if File.extname(logo_path) == '.svg'
|
38
|
+
inline_svg_tag logo_path, class: 'logo', alt: 'logo'
|
39
|
+
else
|
40
|
+
image_tag logo_path, class: 'logo', alt: 'logo'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
19
46
|
def get_flash_icon(key)
|
20
47
|
case key
|
21
48
|
when 'success'
|
22
49
|
'fas fa-check'
|
23
50
|
when 'info'
|
24
|
-
'fas fa-info'
|
51
|
+
'fas fa-info-circle'
|
25
52
|
when 'warning'
|
26
|
-
'fas fa-exclamation'
|
53
|
+
'fas fa-exclamation-circle'
|
27
54
|
when 'error'
|
28
55
|
'far fa-times-circle'
|
29
56
|
else
|
@@ -31,20 +58,16 @@ module BeyondCanvas
|
|
31
58
|
end
|
32
59
|
end
|
33
60
|
|
34
|
-
|
35
|
-
|
36
|
-
content_tag('div', class: "notice notice--#{method}") do
|
37
|
-
content_tag('i', nil, class: "notice__icon #{get_flash_icon(method.to_s)}") +
|
38
|
-
content_tag('span', message, class: 'notice__message')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
61
|
+
def notice_render(method, name = nil, html_options = nil, &block)
|
62
|
+
html_options, name = name, block if block_given?
|
42
63
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
64
|
+
html_options ||= {}
|
65
|
+
|
66
|
+
html_options.merge!(class: "notice notice--#{method}") { |key, old_val, new_val| [new_val, old_val].join(' ') }
|
67
|
+
|
68
|
+
content_tag('div', html_options) do
|
69
|
+
content_tag('i', nil, class: "notice__icon #{get_flash_icon(method.to_s)}") +
|
70
|
+
content_tag('span', block_given? ? capture(&name) : name, class: 'notice__content')
|
48
71
|
end
|
49
72
|
end
|
50
73
|
end
|
@@ -1,12 +1,20 @@
|
|
1
1
|
head
|
2
2
|
= csrf_meta_tags
|
3
3
|
meta content='width=device-width, initial-scale=1.0' name='viewport' /
|
4
|
+
|
4
5
|
link crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" rel="stylesheet" /
|
5
6
|
script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"
|
6
7
|
|
8
|
+
title = full_title(yield :title)
|
9
|
+
|
7
10
|
- stylesheet_link_tag = BeyondCanvas.configuration.stylesheet_link_tag
|
8
11
|
- javascript_include_tag = BeyondCanvas.configuration.javascript_include_tag
|
9
|
-
|
10
|
-
|
12
|
+
|
13
|
+
- if defined?(Turbolinks)
|
14
|
+
= stylesheet_link_tag stylesheet_link_tag, 'data-turbolinks-track' => true
|
15
|
+
= javascript_include_tag javascript_include_tag, 'data-turbolinks-track' => true
|
16
|
+
- else
|
17
|
+
= stylesheet_link_tag stylesheet_link_tag
|
18
|
+
= javascript_include_tag javascript_include_tag
|
11
19
|
|
12
20
|
= render 'beyond_canvas/custom/public_head'
|
data/lib/beyond_canvas/engine.rb
CHANGED
@@ -4,10 +4,11 @@ module BeyondCanvas
|
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
isolate_namespace BeyondCanvas
|
6
6
|
|
7
|
-
|
7
|
+
config.before_initialize do
|
8
8
|
ActiveSupport.on_load :action_controller do
|
9
|
-
|
10
|
-
|
9
|
+
include ::BeyondCanvas::LocaleManagement
|
10
|
+
|
11
|
+
::ActionController::Base.helper BeyondCanvas::Engine.helpers
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/beyond_canvas.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beyond_canvas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unai Abrisketa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bourbon
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- app/assets/javascripts/beyond_canvas.js
|
145
145
|
- app/assets/javascripts/beyond_canvas/buttons.js
|
146
146
|
- app/assets/javascripts/beyond_canvas/flash.js
|
147
|
+
- app/assets/javascripts/beyond_canvas/inputs.js
|
147
148
|
- app/assets/stylesheets/beyond_canvas.sass
|
148
149
|
- app/assets/stylesheets/beyond_canvas/components/_actions.sass
|
149
150
|
- app/assets/stylesheets/beyond_canvas/components/_buttons.sass
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- app/assets/stylesheets/beyond_canvas/settings/_variables.sass
|
167
168
|
- app/assets/stylesheets/beyond_canvas/utilities/_mixins.sass
|
168
169
|
- app/controllers/beyond_canvas/application_controller.rb
|
170
|
+
- app/controllers/concerns/beyond_canvas/locale_management.rb
|
169
171
|
- app/form_builders/beyond_canvas/form_builder.rb
|
170
172
|
- app/helpers/beyond_canvas/application_helper.rb
|
171
173
|
- app/helpers/beyond_canvas/locale_switch_helper.rb
|
@@ -175,6 +177,7 @@ files:
|
|
175
177
|
- app/views/beyond_canvas/shared/_locale_switch.html.slim
|
176
178
|
- app/views/beyond_canvas/shared/_logo.html.slim
|
177
179
|
- app/views/layouts/beyond_canvas/public.html.slim
|
180
|
+
- config/initializers/beyond_canvas/assets.rb
|
178
181
|
- config/initializers/beyond_canvas/form_utils.rb
|
179
182
|
- config/routes.rb
|
180
183
|
- lib/beyond_canvas.rb
|