barnardos-ruby_design_system 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +143 -0
- data/lib/barnardos/ruby_design_system.rb +18 -0
- data/lib/barnardos/ruby_design_system/component_helper.rb +38 -0
- data/lib/barnardos/ruby_design_system/generators/ds_install/templates/postcss.config.js +21 -0
- data/lib/barnardos/ruby_design_system/inputs/collection_check_boxes_input.rb +17 -0
- data/lib/barnardos/ruby_design_system/inputs/collection_select_input.rb +14 -0
- data/lib/barnardos/ruby_design_system/inputs/string_input.rb +14 -0
- data/lib/barnardos/ruby_design_system/inputs/text_input.rb +14 -0
- data/lib/barnardos/ruby_design_system/simple_form.rb +197 -0
- data/lib/barnardos/ruby_design_system/version.rb +5 -0
- data/lib/generators/barnardos/USAGE +10 -0
- data/lib/generators/barnardos/install_generator.rb +36 -0
- data/lib/generators/barnardos/templates/postcss.config.js +21 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f3547e71601e1103ceda6447e1f8eb34d5ac33d6aec20330daf23c825ea3f1f
|
4
|
+
data.tar.gz: f000043b2a23cc728f31e1de399fe2cd8d31086f1fdc2fe40732c65279eea790
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f0d56811483953ddc7933d2e699c5716ef7f674307d6a4f4c59532420282cee62a75574dab7a48d719a0ffdf10929b57270df624ab29e8cc9c3e79899c9faf5
|
7
|
+
data.tar.gz: 585df7f643bca237738da845befa08c280b8b796d826564658d407002e0208881f983acf47edf96a0cb7370269de3b6f8e6efd3db1d1a7cec259c6a75049fde9
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Rob Nichols
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# Barnardos::RubyDesignSystem
|
2
|
+
|
3
|
+
Tools for appling Barnardo's Design System to Ruby projects.
|
4
|
+
|
5
|
+
The tools include helper methods and modification to simple form to make it Design System compliant.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'barnardos-ruby_design_system'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
### Installing PostCSS
|
20
|
+
|
21
|
+
The CSS used in the Design System requires processing in JavaScript space by PostCSS.
|
22
|
+
|
23
|
+
#### `/app/views/layouts/application.html.erb`
|
24
|
+
|
25
|
+
All CSS should be defined within the folder `app/javascript` so the `stylesheet_link_tag` declaration can be removed
|
26
|
+
from the application template. Also make sure that JavaScript is loaded here with `javascript_pack_tag`. For example:
|
27
|
+
|
28
|
+
```
|
29
|
+
<%= javascript_pack_tag 'application' %>
|
30
|
+
```
|
31
|
+
|
32
|
+
#### `/package.json`
|
33
|
+
|
34
|
+
Update `package.json` to include declarations for PostCSS and related plugins.
|
35
|
+
|
36
|
+
Also while this file is being modified, add `@barnardos/components` which will make the Design System code
|
37
|
+
available.
|
38
|
+
|
39
|
+
For example:
|
40
|
+
|
41
|
+
```json
|
42
|
+
{
|
43
|
+
"name": "my_app",
|
44
|
+
"private": true,
|
45
|
+
"dependencies": {
|
46
|
+
"@barnardos/components": "^1.0.0",
|
47
|
+
"@rails/actioncable": "^6.0.0-alpha",
|
48
|
+
"@rails/activestorage": "^6.0.0-alpha",
|
49
|
+
"@rails/ujs": "^6.0.0-alpha",
|
50
|
+
"@rails/webpacker": "^4.0.7",
|
51
|
+
"polyfill-nodelist-foreach": "^1.0.1",
|
52
|
+
"postcss-browser-reporter": "^0.6.0",
|
53
|
+
"postcss-import": "^12.0.1",
|
54
|
+
"postcss-inline-svg": "^4.1.0",
|
55
|
+
"postcss-preset-env": "^6.7.0",
|
56
|
+
"postcss-reporter": "^6.0.1",
|
57
|
+
"postcss-svgo": "^4.0.2"
|
58
|
+
},
|
59
|
+
"version": "0.1.0",
|
60
|
+
"devDependencies": {
|
61
|
+
"webpack-dev-server": "^3.9.0"
|
62
|
+
}
|
63
|
+
}
|
64
|
+
```
|
65
|
+
|
66
|
+
#### `/postcss.config.js`
|
67
|
+
|
68
|
+
A PostCSS configuration file is also present. The following is an example that works with the Design System:
|
69
|
+
|
70
|
+
```javascript
|
71
|
+
module.exports = () => ({
|
72
|
+
plugins: [
|
73
|
+
require("postcss-import"),
|
74
|
+
require("postcss-preset-env")({
|
75
|
+
autoprefixer: {},
|
76
|
+
features: {
|
77
|
+
"focus-within": true,
|
78
|
+
"nesting-rules": true,
|
79
|
+
"color-mod-function": {
|
80
|
+
unresolved: "warn"
|
81
|
+
},
|
82
|
+
"custom-properties": {
|
83
|
+
preserve: false,
|
84
|
+
warnings: true
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}),
|
88
|
+
require("postcss-browser-reporter"),
|
89
|
+
require("postcss-reporter")
|
90
|
+
]
|
91
|
+
});
|
92
|
+
```
|
93
|
+
|
94
|
+
#### `/app/javascript/packs/application.js`
|
95
|
+
|
96
|
+
For each Design System component you wish to use in the app, add a line to `application.js` in the form:
|
97
|
+
|
98
|
+
```javascript
|
99
|
+
import "@barnardos/components/src/components/<component name>/index.css";
|
100
|
+
```
|
101
|
+
For example:
|
102
|
+
|
103
|
+
```javascript
|
104
|
+
import "@barnardos/components/src/components/Footer/index.css";
|
105
|
+
import "@barnardos/components/src/components/Header/index.css";
|
106
|
+
import "@barnardos/components/src/components/Layout/index.css";
|
107
|
+
import "@barnardos/components/src/components/Link/index.css";
|
108
|
+
import "@barnardos/components/src/components/Main/index.css";
|
109
|
+
import "@barnardos/components/src/components/Paragraph/index.css";
|
110
|
+
import "@barnardos/components/src/components/Title/index.css";
|
111
|
+
```
|
112
|
+
|
113
|
+
This will load the associated CSS where it can be processed by PostCSS. The list of imports can get quite long, so
|
114
|
+
placing them in alphabetical order is a good idea as it makes them a little easier to manage.
|
115
|
+
|
116
|
+
#### Complete PostCSS installation
|
117
|
+
|
118
|
+
The following two commands will clear out the current Webpacker setup and install the requires elements:
|
119
|
+
|
120
|
+
```bash
|
121
|
+
rake webpacker:clobber
|
122
|
+
yarn
|
123
|
+
```
|
124
|
+
|
125
|
+
Then restart the server and the changes should take effect.
|
126
|
+
|
127
|
+
## Usage
|
128
|
+
|
129
|
+
TODO: Write usage instructions here
|
130
|
+
|
131
|
+
## Development
|
132
|
+
|
133
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
134
|
+
|
135
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
136
|
+
|
137
|
+
## Contributing
|
138
|
+
|
139
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/barnardos-ruby_design_system.
|
140
|
+
|
141
|
+
## License
|
142
|
+
|
143
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'barnardos/ruby_design_system/version'
|
4
|
+
require 'barnardos/ruby_design_system/component_helper'
|
5
|
+
|
6
|
+
module Barnardos
|
7
|
+
# A Ruby module for easier working with Barnardos Design System
|
8
|
+
module RubyDesignSystem
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
require 'simple_form'
|
12
|
+
Dir[File.join(__dir__, 'ruby_design_system/inputs', '*.rb')].each do |file|
|
13
|
+
require file
|
14
|
+
end
|
15
|
+
|
16
|
+
require_relative 'ruby_design_system/simple_form'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Barnardos
|
2
|
+
module RubyDesignSystem
|
3
|
+
module ComponentHelper
|
4
|
+
def prominent_link(name = nil, options = nil, html_options = {}, &block)
|
5
|
+
colour = html_options.delete(:colour)
|
6
|
+
colour_class = colour && "ProminentLink--#{colour}"
|
7
|
+
html_options[:class] = [html_options[:class], 'ProminentLink', colour_class].flatten.compact
|
8
|
+
link_to(name, options, html_options, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def skip_link(text, anchor: '#main-anchor')
|
12
|
+
link_to text, anchor, class: 'SkipLink'
|
13
|
+
end
|
14
|
+
|
15
|
+
def link(name = nil, options = nil, html_options = {}, &block)
|
16
|
+
html_options[:class] = [html_options[:class], 'Link'].flatten.compact
|
17
|
+
link_to(name, options, html_options, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def link_to(name = nil, options = nil, html_options = {}, &block)
|
21
|
+
html_options[:target] = '_blank' if html_options.delete(:new_window)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def fieldset(legend: nil, hint: nil)
|
26
|
+
content_tag :fieldset, class: 'Fieldset' do
|
27
|
+
concat(content_tag(:legend, legend, class: 'Fieldset-legend')) if legend
|
28
|
+
concat(
|
29
|
+
content_tag(:div, class: 'Fieldset-children') do
|
30
|
+
concat(content_tag(:p, hint, class: 'Hint')) if hint
|
31
|
+
concat(yield)
|
32
|
+
end
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module.exports = () => ({
|
2
|
+
plugins: [
|
3
|
+
require("./node_modules/postcss-import"),
|
4
|
+
require("./node_modules/postcss-preset-env")({
|
5
|
+
autoprefixer: {},
|
6
|
+
features: {
|
7
|
+
"focus-within": true,
|
8
|
+
"nesting-rules": true,
|
9
|
+
"color-mod-function": {
|
10
|
+
unresolved: "warn"
|
11
|
+
},
|
12
|
+
"custom-properties": {
|
13
|
+
preserve: false,
|
14
|
+
warnings: true
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}),
|
18
|
+
require("./node_modules/postcss-browser-reporter"),
|
19
|
+
require("./node_modules/postcss-reporter")
|
20
|
+
]
|
21
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barnardos
|
4
|
+
module RubyDesignSystem
|
5
|
+
module Inputs
|
6
|
+
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
|
7
|
+
def input(wrapper_options = nil)
|
8
|
+
input_html_classes.unshift('Switch-input')
|
9
|
+
options[:item_label_class] = 'Switch-label'
|
10
|
+
options[:item_wrapper_tag] = :div
|
11
|
+
options[:item_wrapper_class] = 'Switches-item Switch Switch--checkbox'
|
12
|
+
template.content_tag(:div, super, class: 'Switches-items')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barnardos
|
4
|
+
module RubyDesignSystem
|
5
|
+
module Inputs
|
6
|
+
class CollectionSelectInput < SimpleForm::Inputs::CollectionSelectInput
|
7
|
+
def input(wrapper_options = nil)
|
8
|
+
input_html_classes.unshift('Select')
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barnardos
|
4
|
+
module RubyDesignSystem
|
5
|
+
module Inputs
|
6
|
+
class StringInput < SimpleForm::Inputs::StringInput
|
7
|
+
def input(wrapper_options = nil)
|
8
|
+
input_html_classes.unshift('TextInput-input')
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barnardos
|
4
|
+
module RubyDesignSystem
|
5
|
+
module Inputs
|
6
|
+
class TextInput < SimpleForm::Inputs::TextInput
|
7
|
+
def input(wrapper_options = nil)
|
8
|
+
input_html_classes.unshift('TextArea-textarea')
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Uncomment this and change the path if necessary to include your own
|
4
|
+
# components.
|
5
|
+
# See https://github.com/plataformatec/simple_form#custom-components to know
|
6
|
+
# more about custom components.
|
7
|
+
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
8
|
+
#
|
9
|
+
# Use this setup block to configure all options available in SimpleForm.
|
10
|
+
SimpleForm.setup do |config|
|
11
|
+
# Wrappers are used by the form builder to generate a
|
12
|
+
# complete input. You can remove any component from the
|
13
|
+
# wrapper, change the order or even add your own to the
|
14
|
+
# stack. The options given below are used to wrap the
|
15
|
+
# whole input.
|
16
|
+
config.wrappers(
|
17
|
+
:default,
|
18
|
+
class: :Field,
|
19
|
+
hint_class: :field_with_hint,
|
20
|
+
error_class: :field_with_errors,
|
21
|
+
valid_class: :field_without_errors
|
22
|
+
) do |b|
|
23
|
+
## Extensions enabled by default
|
24
|
+
# Any of these extensions can be disabled for a
|
25
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
26
|
+
# You can make any of these extensions optional by
|
27
|
+
# renaming `b.use` to `b.optional`.
|
28
|
+
|
29
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
30
|
+
# and required attributes
|
31
|
+
b.use :html5
|
32
|
+
|
33
|
+
# Calculates placeholders automatically from I18n
|
34
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
35
|
+
b.use :placeholder
|
36
|
+
|
37
|
+
## Optional extensions
|
38
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
39
|
+
# to the input. If so, they will retrieve the values from the model
|
40
|
+
# if any exists. If you want to enable any of those
|
41
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
42
|
+
|
43
|
+
# Calculates maxlength from length validations for string inputs
|
44
|
+
# and/or database column lengths
|
45
|
+
b.optional :maxlength
|
46
|
+
|
47
|
+
# Calculate minlength from length validations for string inputs
|
48
|
+
b.optional :minlength
|
49
|
+
|
50
|
+
# Calculates pattern from format validations for string inputs
|
51
|
+
b.optional :pattern
|
52
|
+
|
53
|
+
# Calculates min and max from length validations for numeric inputs
|
54
|
+
b.optional :min_max
|
55
|
+
|
56
|
+
# Calculates readonly automatically from readonly attributes
|
57
|
+
b.optional :readonly
|
58
|
+
|
59
|
+
## Inputs
|
60
|
+
# b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
|
61
|
+
b.use :label_input
|
62
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
63
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
64
|
+
|
65
|
+
## full_messages_for
|
66
|
+
# If you want to display the full error message for the attribute, you can
|
67
|
+
# use the component :full_error, like:
|
68
|
+
#
|
69
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
70
|
+
end
|
71
|
+
|
72
|
+
config.wrappers(
|
73
|
+
:design_system_select,
|
74
|
+
class: :Field
|
75
|
+
) do |b|
|
76
|
+
b.use :label
|
77
|
+
b.use :input, class: :Select, wrap_with: { tag: :div, class: 'Select__wrapper' }
|
78
|
+
end
|
79
|
+
|
80
|
+
config.wrappers(
|
81
|
+
:in_fieldset,
|
82
|
+
class: :Fieldset
|
83
|
+
) do |b|
|
84
|
+
b.use :label, wrap_with: { tag: :legend, class: 'Fieldset-legend' }
|
85
|
+
b.use :input, wrap_with: { tag: :div, class: 'Fieldset-children' }
|
86
|
+
end
|
87
|
+
|
88
|
+
# The default wrapper to be used by the FormBuilder.
|
89
|
+
config.default_wrapper = :default
|
90
|
+
|
91
|
+
# Define the way to render check boxes / radio buttons with labels.
|
92
|
+
# Defaults to :nested for bootstrap config.
|
93
|
+
# inline: input + label
|
94
|
+
# nested: label > input
|
95
|
+
config.boolean_style = :nested
|
96
|
+
|
97
|
+
# Default class for buttons
|
98
|
+
config.button_class = :Submit
|
99
|
+
|
100
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
101
|
+
# :first lists the first message for each field.
|
102
|
+
# Use :to_sentence to list all errors for each field.
|
103
|
+
# config.error_method = :first
|
104
|
+
|
105
|
+
# Default tag used for error notification helper.
|
106
|
+
config.error_notification_tag = :div
|
107
|
+
|
108
|
+
# CSS class to add for error notification helper.
|
109
|
+
config.error_notification_class = 'error_notification'
|
110
|
+
|
111
|
+
# Series of attempts to detect a default label method for collection.
|
112
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
113
|
+
|
114
|
+
# Series of attempts to detect a default value method for collection.
|
115
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
116
|
+
|
117
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
118
|
+
# config.collection_wrapper_tag = nil
|
119
|
+
|
120
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
121
|
+
# config.collection_wrapper_class = nil
|
122
|
+
|
123
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
124
|
+
# defaulting to :span.
|
125
|
+
# config.item_wrapper_tag = :span
|
126
|
+
|
127
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
128
|
+
# config.item_wrapper_class = nil
|
129
|
+
|
130
|
+
# How the label text should be generated altogether with the required text.
|
131
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
132
|
+
|
133
|
+
# You can define the class to use on all labels. Default is nil.
|
134
|
+
config.label_class = :Label
|
135
|
+
|
136
|
+
# You can define the default class to be used on forms. Can be overriden
|
137
|
+
# with `html: { :class }`. Defaulting to none.
|
138
|
+
# config.default_form_class = nil
|
139
|
+
|
140
|
+
# You can define which elements should obtain additional classes
|
141
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
142
|
+
|
143
|
+
# Whether attributes are required by default (or not). Default is true.
|
144
|
+
# config.required_by_default = true
|
145
|
+
|
146
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
147
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
148
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
149
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
150
|
+
# change this configuration to true.
|
151
|
+
config.browser_validations = false
|
152
|
+
|
153
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
154
|
+
# to match as key, and the input type that will be used when the field name
|
155
|
+
# matches the regexp as value.
|
156
|
+
# config.input_mappings = { /count/ => :integer }
|
157
|
+
|
158
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
159
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
160
|
+
# config.wrapper_mappings = { string: :prepend }
|
161
|
+
|
162
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
163
|
+
# override default inputs.
|
164
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
165
|
+
|
166
|
+
# Default priority for time_zone inputs.
|
167
|
+
# config.time_zone_priority = nil
|
168
|
+
|
169
|
+
# Default priority for country inputs.
|
170
|
+
# config.country_priority = nil
|
171
|
+
|
172
|
+
# When false, do not use translations for labels.
|
173
|
+
# config.translate_labels = true
|
174
|
+
|
175
|
+
# Automatically discover new inputs in Rails' autoload path.
|
176
|
+
# config.inputs_discovery = true
|
177
|
+
|
178
|
+
# Cache SimpleForm inputs discovery
|
179
|
+
# config.cache_discovery = !Rails.env.development?
|
180
|
+
|
181
|
+
# Default class for inputs
|
182
|
+
# config.input_class = nil
|
183
|
+
|
184
|
+
# Define the default class of the input wrapper of the boolean input.
|
185
|
+
config.boolean_label_class = 'checkbox'
|
186
|
+
|
187
|
+
# Defines if the default input wrapper class should be included in radio
|
188
|
+
# collection wrappers.
|
189
|
+
# config.include_default_input_wrapper_class = true
|
190
|
+
|
191
|
+
# Defines which i18n scope will be used in Simple Form.
|
192
|
+
# config.i18n_scope = 'simple_form'
|
193
|
+
|
194
|
+
# Defines validation classes to the input_field. By default it's nil.
|
195
|
+
# config.input_field_valid_class = 'is-valid'
|
196
|
+
# config.input_field_error_class = 'is-invalid'
|
197
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barnardos
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
DEV_PACKAGES = ['webpack-dev-server'].freeze
|
8
|
+
PACKAGES = [
|
9
|
+
'@barnardos/components',
|
10
|
+
'@rails/actioncable',
|
11
|
+
'@rails/activestorage',
|
12
|
+
'@rails/ujs',
|
13
|
+
'@rails/webpacker',
|
14
|
+
'polyfill-nodelist-foreach',
|
15
|
+
'postcss-browser-reporter',
|
16
|
+
'postcss-import',
|
17
|
+
'postcss-inline-svg',
|
18
|
+
'postcss-preset-env',
|
19
|
+
'postcss-reporter',
|
20
|
+
'postcss-svgo'
|
21
|
+
].freeze
|
22
|
+
|
23
|
+
def install
|
24
|
+
`yarn add #{PACKAGES.join(' ')}`
|
25
|
+
`yarn add #{DEV_PACKAGES.join(' ')} --dev`
|
26
|
+
copy_file 'postcss.config.js', 'postcss.config.js'
|
27
|
+
if File.exist?('app/views/layouts/application.html.erb')
|
28
|
+
gsub_file('app/views/layouts/application.html.erb',
|
29
|
+
/<%= stylesheet_link_tag[^%]*%>?/, '')
|
30
|
+
end
|
31
|
+
rake 'webpacker:clobber'
|
32
|
+
`yarn`
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module.exports = () => ({
|
2
|
+
plugins: [
|
3
|
+
require("postcss-import"),
|
4
|
+
require("postcss-preset-env")({
|
5
|
+
autoprefixer: {},
|
6
|
+
features: {
|
7
|
+
"focus-within": true,
|
8
|
+
"nesting-rules": true,
|
9
|
+
"color-mod-function": {
|
10
|
+
unresolved: "warn"
|
11
|
+
},
|
12
|
+
"custom-properties": {
|
13
|
+
preserve: false,
|
14
|
+
warnings: true
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}),
|
18
|
+
require("postcss-browser-reporter"),
|
19
|
+
require("postcss-reporter")
|
20
|
+
]
|
21
|
+
});
|
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barnardos-ruby_design_system
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Nichols
|
8
|
+
- Marcin Jedras
|
9
|
+
- Barnardo's
|
10
|
+
autorequire:
|
11
|
+
bindir: exe
|
12
|
+
cert_chain: []
|
13
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: simple_form
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '5.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '5.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: actionpack
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '6.0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: activemodel
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '6.0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '6.0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: bundler
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.17'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.17'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: faker
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.9'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '2.9'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: generator_spec
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: nokogiri
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.10'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '1.10'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rails
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '6.0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '6.0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: rake
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '10.0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '10.0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rspec
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '3.0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '3.0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: rspec-rails
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - "~>"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 3.0.0
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 3.0.0
|
169
|
+
description: Includes helper methods and modification to simple form.
|
170
|
+
email:
|
171
|
+
- rob.nichols@barnardos.org.uk
|
172
|
+
- marcin.jedras@barnardos.org.uk
|
173
|
+
executables: []
|
174
|
+
extensions: []
|
175
|
+
extra_rdoc_files: []
|
176
|
+
files:
|
177
|
+
- LICENSE.txt
|
178
|
+
- README.md
|
179
|
+
- lib/barnardos/ruby_design_system.rb
|
180
|
+
- lib/barnardos/ruby_design_system/component_helper.rb
|
181
|
+
- lib/barnardos/ruby_design_system/generators/ds_install/templates/postcss.config.js
|
182
|
+
- lib/barnardos/ruby_design_system/inputs/collection_check_boxes_input.rb
|
183
|
+
- lib/barnardos/ruby_design_system/inputs/collection_select_input.rb
|
184
|
+
- lib/barnardos/ruby_design_system/inputs/string_input.rb
|
185
|
+
- lib/barnardos/ruby_design_system/inputs/text_input.rb
|
186
|
+
- lib/barnardos/ruby_design_system/simple_form.rb
|
187
|
+
- lib/barnardos/ruby_design_system/version.rb
|
188
|
+
- lib/generators/barnardos/USAGE
|
189
|
+
- lib/generators/barnardos/install_generator.rb
|
190
|
+
- lib/generators/barnardos/templates/postcss.config.js
|
191
|
+
homepage: https://design-system.barnardos.org.uk
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
metadata: {}
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options: []
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
requirements: []
|
210
|
+
rubygems_version: 3.0.4
|
211
|
+
signing_key:
|
212
|
+
specification_version: 4
|
213
|
+
summary: Tools for applying Barnardo's Design System to Ruby projects.
|
214
|
+
test_files: []
|