beyond_canvas 0.11.2.pre → 0.15.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -20
- data/app/assets/images/icons/checkbox_checked.svg +1 -0
- data/app/assets/images/icons/checkbox_unchecked.svg +1 -0
- data/app/assets/images/icons/file.svg +1 -0
- data/app/assets/images/icons/flash_checkbox.svg +1 -0
- data/app/assets/images/icons/flash_close.svg +1 -0
- data/app/assets/images/icons/flash_error.svg +1 -0
- data/app/assets/images/icons/flash_info.svg +1 -0
- data/app/assets/images/icons/flash_warning.svg +1 -0
- data/app/assets/images/icons/radiobutton_checked.svg +1 -0
- data/app/assets/images/icons/radiobutton_unchecked.svg +1 -0
- data/app/assets/javascripts/beyond_canvas/base.js +94 -0
- data/app/assets/stylesheets/beyond_canvas/base.scss +28 -0
- data/app/assets/stylesheets/beyond_canvas/components/_actions.scss +6 -0
- data/app/assets/stylesheets/beyond_canvas/components/_buttons.scss +112 -0
- data/app/assets/stylesheets/beyond_canvas/components/_cards.scss +34 -0
- data/app/assets/stylesheets/beyond_canvas/components/_comments.scss +6 -0
- data/app/assets/stylesheets/beyond_canvas/components/_containers.scss +37 -0
- data/app/assets/stylesheets/beyond_canvas/components/_flash.scss +66 -0
- data/app/assets/stylesheets/beyond_canvas/components/_forms.scss +43 -0
- data/app/assets/stylesheets/beyond_canvas/components/_inputs.scss +143 -0
- data/app/assets/stylesheets/beyond_canvas/components/_layouts.scss +7 -0
- data/app/assets/stylesheets/beyond_canvas/components/_links.scss +17 -0
- data/app/assets/stylesheets/beyond_canvas/components/_main.scss +39 -0
- data/app/assets/stylesheets/beyond_canvas/components/_margins.scss +9 -0
- data/app/assets/stylesheets/beyond_canvas/components/_markdown.scss +74 -0
- data/app/assets/stylesheets/beyond_canvas/components/_notices.scss +58 -0
- data/app/assets/stylesheets/beyond_canvas/components/_relative.scss +3 -0
- data/app/assets/stylesheets/beyond_canvas/components/_spinner.scss +48 -0
- data/app/assets/stylesheets/beyond_canvas/components/_tables.scss +31 -0
- data/app/assets/stylesheets/beyond_canvas/components/_texts.scss +7 -0
- data/app/assets/stylesheets/beyond_canvas/mailer.scss +5 -0
- data/app/assets/stylesheets/beyond_canvas/settings/_breakpoints.scss +6 -0
- data/app/assets/stylesheets/beyond_canvas/settings/{_reset_css.sass → _reset_css.scss} +29 -21
- data/app/assets/stylesheets/beyond_canvas/settings/_typography.scss +67 -0
- data/app/assets/stylesheets/beyond_canvas/settings/_variables.scss +171 -0
- data/app/assets/stylesheets/beyond_canvas/utilities/_functions.scss +15 -0
- data/app/assets/stylesheets/beyond_canvas/utilities/_mixins.scss +24 -0
- data/app/controllers/beyond_canvas/application_controller.rb +2 -2
- data/app/controllers/beyond_canvas/system_controller.rb +24 -0
- data/app/controllers/concerns/beyond_canvas/locale_management.rb +18 -20
- data/app/controllers/concerns/beyond_canvas/request_validation.rb +37 -0
- data/app/controllers/concerns/beyond_canvas/status_codes.rb +17 -0
- data/app/form_builders/beyond_canvas/form_builder.rb +74 -13
- data/app/helpers/beyond_canvas/application_helper.rb +17 -18
- data/app/helpers/beyond_canvas/locale_switch_helper.rb +1 -1
- data/app/javascript/beyond_canvas/base.js +6 -0
- data/app/{assets/javascripts/beyond_canvas → javascript/beyond_canvas/initializers}/buttons.js +19 -14
- data/app/{assets/javascripts/beyond_canvas → javascript/beyond_canvas/initializers}/flash.js +11 -7
- data/app/javascript/beyond_canvas/initializers/inputs.js +39 -0
- data/app/views/beyond_canvas/custom/_public_head.html.erb +1 -0
- data/app/views/beyond_canvas/locales/_edit.html.erb +8 -0
- data/app/views/beyond_canvas/mailer/_header.html.erb +2 -2
- data/app/views/beyond_canvas/shared/_flash.html.erb +13 -0
- data/app/views/beyond_canvas/shared/_head.html.erb +29 -0
- data/app/views/beyond_canvas/shared/_logo.html.erb +2 -0
- data/app/views/layouts/beyond_canvas/public.html.erb +16 -0
- data/config/initializers/beyond_canvas/filter_parameter_logging.rb +9 -0
- data/config/routes.rb +1 -1
- data/lib/beyond_canvas.rb +13 -16
- data/lib/beyond_canvas/asset_registration.rb +29 -0
- data/lib/beyond_canvas/configuration.rb +27 -0
- data/lib/beyond_canvas/engine.rb +12 -1
- data/lib/beyond_canvas/version.rb +1 -1
- data/lib/generators/beyond_canvas/assets/assets_generator.rb +14 -0
- data/lib/generators/beyond_canvas/assets/templates/beyond_canvas.js +1 -0
- data/lib/generators/beyond_canvas/assets/templates/beyond_canvas.scss +1 -0
- data/lib/generators/beyond_canvas/beyond_api/beyond_api_generator.rb +19 -0
- data/lib/generators/beyond_canvas/{custom_styles_generator.rb → custom_styles/custom_styles_generator.rb} +2 -2
- data/lib/generators/{templates → beyond_canvas/custom_styles/templates}/beyond_canvas_custom_styles.sass +0 -0
- data/lib/generators/beyond_canvas/install/install_generator.rb +35 -0
- data/lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb +40 -0
- data/lib/generators/beyond_canvas/webpacker/plugins/jquery.js +7 -0
- data/lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.js +3 -0
- data/lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.scss +1 -0
- data/lib/generators/beyond_canvas/webpacker/webpacker_generator.rb +26 -0
- metadata +107 -66
- data/app/assets/javascripts/beyond_canvas.js +0 -3
- data/app/assets/javascripts/beyond_canvas/inputs.js +0 -28
- data/app/assets/stylesheets/beyond_canvas.sass +0 -24
- data/app/assets/stylesheets/beyond_canvas/components/_actions.sass +0 -5
- data/app/assets/stylesheets/beyond_canvas/components/_buttons.sass +0 -86
- data/app/assets/stylesheets/beyond_canvas/components/_cards.sass +0 -26
- data/app/assets/stylesheets/beyond_canvas/components/_comments.sass +0 -5
- data/app/assets/stylesheets/beyond_canvas/components/_flash.sass +0 -51
- data/app/assets/stylesheets/beyond_canvas/components/_forms.sass +0 -32
- data/app/assets/stylesheets/beyond_canvas/components/_inputs.sass +0 -79
- data/app/assets/stylesheets/beyond_canvas/components/_links.sass +0 -13
- data/app/assets/stylesheets/beyond_canvas/components/_main.sass +0 -28
- data/app/assets/stylesheets/beyond_canvas/components/_margins.sass +0 -7
- data/app/assets/stylesheets/beyond_canvas/components/_markdown.sass +0 -60
- data/app/assets/stylesheets/beyond_canvas/components/_notices.sass +0 -41
- data/app/assets/stylesheets/beyond_canvas/components/_relative.sass +0 -2
- data/app/assets/stylesheets/beyond_canvas/components/_spinner.sass +0 -38
- data/app/assets/stylesheets/beyond_canvas/components/_tables.sass +0 -25
- data/app/assets/stylesheets/beyond_canvas/components/_texts.sass +0 -6
- data/app/assets/stylesheets/beyond_canvas/mailer.sass +0 -5
- data/app/assets/stylesheets/beyond_canvas/settings/_typography.sass +0 -53
- data/app/assets/stylesheets/beyond_canvas/settings/_variables.sass +0 -145
- data/app/assets/stylesheets/beyond_canvas/utilities/_mixins.sass +0 -19
- data/app/views/beyond_canvas/custom/_public_head.html.slim +0 -0
- data/app/views/beyond_canvas/shared/_flash.html.slim +0 -6
- data/app/views/beyond_canvas/shared/_head.html.slim +0 -20
- data/app/views/beyond_canvas/shared/_locale_switch.html.slim +0 -6
- data/app/views/beyond_canvas/shared/_logo.html.slim +0 -2
- data/app/views/layouts/beyond_canvas/public.html.slim +0 -12
- data/config/initializers/beyond_canvas/assets.rb +0 -5
- data/lib/generators/beyond_canvas/install_generator.rb +0 -13
- data/lib/generators/templates/beyond_canvas.rb +0 -8
- data/lib/generators/templates/beyond_canvas_form_utils.rb +0 -23
@@ -0,0 +1,31 @@
|
|
1
|
+
.table {
|
2
|
+
width: 100%;
|
3
|
+
border-collapse: collapse;
|
4
|
+
|
5
|
+
th, td {
|
6
|
+
padding: 15px;
|
7
|
+
text-align: left;
|
8
|
+
}
|
9
|
+
|
10
|
+
thead {
|
11
|
+
tr {
|
12
|
+
font-weight: 700;
|
13
|
+
|
14
|
+
&:first-child {
|
15
|
+
background-color: $table-header-background;
|
16
|
+
}
|
17
|
+
|
18
|
+
&:nth-child(2) {
|
19
|
+
border-bottom: 2px solid $table-border-color;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
tbody {
|
25
|
+
tr {
|
26
|
+
&:not(:last-child) {
|
27
|
+
border-bottom: 1px solid $table-border-color;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
@@ -6,39 +6,47 @@ a, abbr, acronym, address, big, cite, code,
|
|
6
6
|
del, dfn, em, img, ins, kbd, q, s, samp,
|
7
7
|
small, strike, strong, sub, sup, tt, var,
|
8
8
|
b, u, i, center,
|
9
|
-
dl, dt, dd,
|
9
|
+
dl, dt, dd,
|
10
10
|
fieldset, form, label, legend,
|
11
11
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
12
12
|
article, aside, canvas, details, embed,
|
13
13
|
figure, figcaption, footer, header, hgroup,
|
14
14
|
menu, nav, output, ruby, section, summary,
|
15
|
-
time, mark, audio, video
|
16
|
-
border: 0
|
17
|
-
font: inherit
|
18
|
-
margin: 0
|
19
|
-
padding: 0
|
20
|
-
vertical-align: baseline
|
15
|
+
time, mark, audio, video {
|
16
|
+
border: 0;
|
17
|
+
font: inherit;
|
18
|
+
margin: 0;
|
19
|
+
padding: 0;
|
20
|
+
vertical-align: baseline;
|
21
|
+
}
|
21
22
|
|
22
23
|
article, aside, details, figcaption, figure,
|
23
|
-
footer, header, hgroup, menu, nav, section
|
24
|
-
display: block
|
24
|
+
footer, header, hgroup, menu, nav, section {
|
25
|
+
display: block;
|
26
|
+
}
|
25
27
|
|
26
|
-
body
|
27
|
-
line-height: 1
|
28
|
+
body {
|
29
|
+
line-height: 1;
|
30
|
+
}
|
31
|
+
|
32
|
+
ol, ul {
|
33
|
+
margin: 0;
|
28
34
|
|
29
|
-
ol, ul
|
30
|
-
margin: 0
|
31
35
|
// list-style: none
|
36
|
+
}
|
32
37
|
|
33
|
-
blockquote, q
|
34
|
-
quotes: none
|
38
|
+
blockquote, q {
|
39
|
+
quotes: none;
|
40
|
+
}
|
35
41
|
|
36
42
|
blockquote::before, blockquote::after,
|
37
|
-
q::before, q::after
|
38
|
-
content: none
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
border-
|
43
|
+
q::before, q::after {
|
44
|
+
content: none;
|
45
|
+
}
|
46
|
+
|
47
|
+
table {
|
48
|
+
border-collapse: collapse;
|
49
|
+
border-spacing: 0;
|
50
|
+
}
|
43
51
|
|
44
52
|
// sass-lint:enable single-line-per-selector, force-pseudo-nesting
|
@@ -0,0 +1,67 @@
|
|
1
|
+
// sass-lint:disable single-line-per-selector, no-vendor-prefixes
|
2
|
+
|
3
|
+
html {
|
4
|
+
font-size: 62.5%;
|
5
|
+
}
|
6
|
+
|
7
|
+
body, #{$all-text-inputs}, #{$all-buttons}, select {
|
8
|
+
-moz-osx-font-smoothing: grayscale;
|
9
|
+
-webkit-font-smoothing: antialiased;
|
10
|
+
font-family: unquote($main-font-family);
|
11
|
+
font-size: $main-font-size;
|
12
|
+
font-weight: normal;
|
13
|
+
}
|
14
|
+
|
15
|
+
body, #{$all-text-inputs}, select {
|
16
|
+
color: $main-color;
|
17
|
+
}
|
18
|
+
|
19
|
+
body, #{$all-text-inputs} {
|
20
|
+
line-height: $main-line-height;
|
21
|
+
}
|
22
|
+
|
23
|
+
select {
|
24
|
+
line-height: initial;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1, h2, h3, h4, h5, h6 {
|
28
|
+
color: $headline-color;
|
29
|
+
font-weight: bold;
|
30
|
+
line-height: $headline-line-height;
|
31
|
+
}
|
32
|
+
|
33
|
+
h1 {
|
34
|
+
font-size: 56px;
|
35
|
+
}
|
36
|
+
|
37
|
+
h2 {
|
38
|
+
font-size: 40px;
|
39
|
+
}
|
40
|
+
|
41
|
+
h3 {
|
42
|
+
font-size: 32px;
|
43
|
+
}
|
44
|
+
|
45
|
+
h4 {
|
46
|
+
font-size: 24px;
|
47
|
+
}
|
48
|
+
|
49
|
+
h5 {
|
50
|
+
font-size: 16px;
|
51
|
+
}
|
52
|
+
|
53
|
+
p {
|
54
|
+
font-size: $main-font-size;
|
55
|
+
}
|
56
|
+
|
57
|
+
a {
|
58
|
+
color: $main-color;
|
59
|
+
outline: none;
|
60
|
+
text-decoration: none;
|
61
|
+
}
|
62
|
+
|
63
|
+
strong {
|
64
|
+
font-weight: bold;
|
65
|
+
}
|
66
|
+
|
67
|
+
// sass-lint:enable single-line-per-selector, no-vendor-prefixes
|
@@ -0,0 +1,171 @@
|
|
1
|
+
// ************************************************************
|
2
|
+
// Colors
|
3
|
+
// ************************************************************
|
4
|
+
|
5
|
+
$white: rgb(255, 255, 255) !global;
|
6
|
+
$black: rgb(0, 0, 0) !global;
|
7
|
+
$palette-primary: rgb(78, 183, 168) !default;
|
8
|
+
$palette-secondary: rgb(28, 53, 69) !default;
|
9
|
+
$palette-cancel: rgb(153, 153, 153) !default;
|
10
|
+
$palette-danger: rgb(218, 60, 60) !default;
|
11
|
+
|
12
|
+
// ************************************************************
|
13
|
+
// General styles
|
14
|
+
// ************************************************************
|
15
|
+
|
16
|
+
$main-background: rgb(233, 232, 220) !default;
|
17
|
+
$main-transition: 0.125s ease-in !global;
|
18
|
+
|
19
|
+
// ************************************************************
|
20
|
+
// Typography
|
21
|
+
// ************************************************************
|
22
|
+
|
23
|
+
$main-font-family: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif' !global;
|
24
|
+
$main-color: rgb(62, 62, 62) !default;
|
25
|
+
$main-line-height: 1.5 !global;
|
26
|
+
$main-font-size: 14px !global;
|
27
|
+
|
28
|
+
// ************************************************************
|
29
|
+
// Headlines
|
30
|
+
// ************************************************************
|
31
|
+
|
32
|
+
$headline-color: rgb(122, 118, 76) !default;
|
33
|
+
$headline-line-height: 1 !global;
|
34
|
+
|
35
|
+
// ************************************************************
|
36
|
+
// Links
|
37
|
+
// ************************************************************
|
38
|
+
|
39
|
+
$link-primary-color: darken($palette-primary, 10%) !default;
|
40
|
+
$link-secondary-color: darken($palette-cancel, 10%) !default;
|
41
|
+
$link-danger-color: darken($palette-danger, 10%) !default;
|
42
|
+
|
43
|
+
// ************************************************************
|
44
|
+
// Buttons
|
45
|
+
// ************************************************************
|
46
|
+
|
47
|
+
$button-primary-background: $palette-primary !default;
|
48
|
+
$button-primary-color: $white !default;
|
49
|
+
|
50
|
+
$button-secondary-background: $palette-cancel !default;
|
51
|
+
$button-secondary-color: $white !default;
|
52
|
+
|
53
|
+
$button-danger-background: $palette-danger !default;
|
54
|
+
$button-danger-color: $white !default;
|
55
|
+
|
56
|
+
$button-border-radius: 3px !default;
|
57
|
+
$button-box-shadow: true !default;
|
58
|
+
$button-font-weight: 700 !global;
|
59
|
+
$button-padding: 6px 12px 7px !global;
|
60
|
+
|
61
|
+
// ************************************************************
|
62
|
+
// Cards
|
63
|
+
// ************************************************************
|
64
|
+
|
65
|
+
$card-border-radius: 3px !default;
|
66
|
+
$card-box-shadow: 0 2px 7px rgba($black, 0.2) !default;
|
67
|
+
$card-padding: 40px !global;
|
68
|
+
$card-margin: 30px !global;
|
69
|
+
$card-separator-color: rgb(222, 222, 222) !default;
|
70
|
+
$card-separator-spacing: 50px !global;
|
71
|
+
$card-title-color: rgb(247, 133, 96) !default;
|
72
|
+
|
73
|
+
// ************************************************************
|
74
|
+
// Containers
|
75
|
+
// ************************************************************
|
76
|
+
|
77
|
+
$container-spacing: 30px !global;
|
78
|
+
|
79
|
+
// ************************************************************
|
80
|
+
// Labels
|
81
|
+
// ************************************************************
|
82
|
+
|
83
|
+
$label-color: rgb(128, 128, 128) !default;
|
84
|
+
|
85
|
+
// ************************************************************
|
86
|
+
// Inputs
|
87
|
+
// ************************************************************
|
88
|
+
|
89
|
+
$input-border-color: rgb(217, 216, 195) !default;
|
90
|
+
$input-border-color-focus: $palette-primary !default;
|
91
|
+
$input-errors-color: $palette-danger !default;
|
92
|
+
|
93
|
+
// ************************************************************
|
94
|
+
// Checkboxes
|
95
|
+
// ************************************************************
|
96
|
+
|
97
|
+
$checkbox-checked-color: #97C344 !default;
|
98
|
+
$checkbox-checked-background: #ffffff !default;
|
99
|
+
$checkbox-unchecked-color: #C2BF9D !default;
|
100
|
+
$checkbox-unchecked-background: #ffffff !default;
|
101
|
+
|
102
|
+
// ************************************************************
|
103
|
+
// Radiobuttons
|
104
|
+
// ************************************************************
|
105
|
+
|
106
|
+
$radio-checked-color: #97C344 !default;
|
107
|
+
$radio-checked-background: #ffffff !default;
|
108
|
+
$radio-unchecked-color: #C2BF9D !default;
|
109
|
+
$radio-unchecked-background: #ffffff !default;
|
110
|
+
|
111
|
+
// ************************************************************
|
112
|
+
// Hints
|
113
|
+
// ************************************************************
|
114
|
+
|
115
|
+
$hint-color: rgb(158, 158, 158) !default;
|
116
|
+
|
117
|
+
// ************************************************************
|
118
|
+
// Logo
|
119
|
+
// ************************************************************
|
120
|
+
|
121
|
+
$logo-margin-top-public: 0 !default;
|
122
|
+
$logo-margin-bottom-public: 34px !default;
|
123
|
+
|
124
|
+
// ************************************************************
|
125
|
+
// Flash
|
126
|
+
// ************************************************************
|
127
|
+
|
128
|
+
$flash-success: rgb(123, 170, 81) !default;
|
129
|
+
$flash-notice: rgb(123, 170, 81) !default;
|
130
|
+
$flash-info: rgb(153, 153, 153) !default;
|
131
|
+
$flash-warning: rgb(243, 181, 71) !default;
|
132
|
+
$flash-error: rgb(218, 60, 60) !default;
|
133
|
+
$flash-border-radius: 4px !default;
|
134
|
+
$flash-box-shadow: 0 1px 2px 0 rgba($black, 0.2) !default;
|
135
|
+
$flash-color: rgb(128, 128, 128) !default;
|
136
|
+
|
137
|
+
// ************************************************************
|
138
|
+
// Tables
|
139
|
+
// ************************************************************
|
140
|
+
|
141
|
+
$table-header-background: rgb(243, 242, 236) !default;
|
142
|
+
$table-border-color: rgb(233, 232, 220) !default;
|
143
|
+
|
144
|
+
// ************************************************************
|
145
|
+
// Comments
|
146
|
+
// ************************************************************
|
147
|
+
|
148
|
+
$comment-background: rgb(246, 246, 243) !default;
|
149
|
+
$comment-color: rgb(170, 169, 156) !default;
|
150
|
+
|
151
|
+
// ************************************************************
|
152
|
+
// Notices
|
153
|
+
// ************************************************************
|
154
|
+
|
155
|
+
$notice-success-background: rgb(123, 170, 81) !default;
|
156
|
+
$notice-notice-background: rgb(123, 170, 81) !default;
|
157
|
+
$notice-info-background: rgb(153, 153, 153) !default;
|
158
|
+
$notice-warning-background: rgb(243, 181, 71) !default;
|
159
|
+
$notice-error-background: rgb(218, 60, 60) !default;
|
160
|
+
$notice-border-radius: 4px !default;
|
161
|
+
$notice-color: rgb(153, 153, 153) !default;
|
162
|
+
|
163
|
+
// ************************************************************
|
164
|
+
// Markdown
|
165
|
+
// ************************************************************
|
166
|
+
|
167
|
+
$markdown-table-head-background: #f6f8fa;
|
168
|
+
$markdown-table-border-color: #dfe2e5;
|
169
|
+
$markdown-blockquote-font-color: #6a737d;
|
170
|
+
$markdown-blockquote-border-color: #dfe2e5;
|
171
|
+
$markdown-hr-background: #e1e4e8;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/// Replace `$search` with `$replace` in `$string`
|
2
|
+
/// @author Hugo Giraudel
|
3
|
+
/// @param {String} $string - Initial string
|
4
|
+
/// @param {String} $search - Substring to replace
|
5
|
+
/// @param {String} $replace ('') - New value
|
6
|
+
/// @return {String} - Updated string
|
7
|
+
@function str-replace($string, $search, $replace: '') {
|
8
|
+
$index: str-index($string, $search);
|
9
|
+
|
10
|
+
@if $index {
|
11
|
+
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
|
12
|
+
}
|
13
|
+
|
14
|
+
@return $string;
|
15
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
@mixin background-color-darken($color, $percent) {
|
2
|
+
background-color: $color;
|
3
|
+
transition: $main-transition;
|
4
|
+
|
5
|
+
&:hover {
|
6
|
+
background-color: darken($color, $percent);
|
7
|
+
transition: $main-transition;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
@mixin color-darken($color, $percent) {
|
12
|
+
color: $color;
|
13
|
+
transition: $main-transition;
|
14
|
+
|
15
|
+
&:hover {
|
16
|
+
color: darken($color, $percent);
|
17
|
+
transition: $main-transition;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
@mixin background-color-lighten($color, $percent) {
|
22
|
+
background-color: lighten($color, $percent);
|
23
|
+
transition: $main-transition;
|
24
|
+
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BeyondCanvas
|
4
|
-
class ApplicationController < ActionController::Base
|
4
|
+
class ApplicationController < ActionController::Base # :nodoc:
|
5
5
|
protect_from_forgery with: :exception
|
6
6
|
|
7
|
-
include ::BeyondCanvas::
|
7
|
+
include ::BeyondCanvas::StatusCodes
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency 'beyond_canvas/application_controller'
|
4
|
+
|
5
|
+
module BeyondCanvas
|
6
|
+
class SystemController < ApplicationController # :nodoc:
|
7
|
+
include ::BeyondCanvas::LocaleManagement
|
8
|
+
|
9
|
+
def update_locale
|
10
|
+
cookies[:locale] = { value: system_locale_params[:locale], expires: 1.day.from_now }
|
11
|
+
|
12
|
+
redirect_back(fallback_location: main_app.root_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
#
|
18
|
+
# Strong parameters for locale switch
|
19
|
+
#
|
20
|
+
def system_locale_params
|
21
|
+
params.require(:system).permit(:locale)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,32 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BeyondCanvas
|
4
|
-
module LocaleManagement
|
4
|
+
module LocaleManagement # :nodoc:
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
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
|
8
|
+
around_action :switch_locale, except: :update_locale # rubocop:disable Rails/LexicallyScopedActionFilter
|
18
9
|
end
|
19
10
|
|
20
11
|
private
|
21
12
|
|
22
13
|
#
|
23
|
-
# Sets the
|
24
|
-
# compatible locale
|
14
|
+
# Sets the cookie locale as default locale if it is a valid locale. If it is not a valid locale, searches for a
|
15
|
+
# browser compatible locale, sets the value to the cookie and set that locale as default locale.
|
25
16
|
#
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
17
|
+
def switch_locale(&action)
|
18
|
+
# NOTE: Check the HTTP_ACCEPT_LANGUAGE header to identify if the request comes from a browser or a server
|
19
|
+
return I18n.with_locale(I18n.default_locale, &action) if request.headers['HTTP_ACCEPT_LANGUAGE'].blank?
|
20
|
+
|
21
|
+
unless valid_locale?(cookies[:locale])
|
22
|
+
cookies[:locale] = { value: browser_compatible_locale, expires: 1.day.from_now }
|
23
|
+
end
|
24
|
+
|
25
|
+
I18n.with_locale(cookies[:locale], &action)
|
26
|
+
|
27
|
+
logger.debug "[BeyondCanvas] Locale set to: #{cookies[:locale]}".yellow
|
30
28
|
end
|
31
29
|
|
32
30
|
#
|
@@ -47,10 +45,10 @@ module BeyondCanvas
|
|
47
45
|
end
|
48
46
|
|
49
47
|
#
|
50
|
-
#
|
48
|
+
# Checks if the given locale parameter is included on +I18n.available_locales+
|
51
49
|
#
|
52
|
-
def
|
53
|
-
|
50
|
+
def valid_locale?(locale)
|
51
|
+
I18n.available_locales.map(&:to_s).include? locale
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|