rapid_ui 1.0.0
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 +7 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +30 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/install/rapid_ui.rb +5 -0
- data/lib/install/render_monkeypatch.rb +15 -0
- data/lib/install/ui.yml +16 -0
- data/lib/install/wrapper_component.html.slim +12 -0
- data/lib/install/wrapper_component.rb +50 -0
- data/lib/rapid_ui/component.rb +141 -0
- data/lib/rapid_ui/configuration.rb +31 -0
- data/lib/rapid_ui/display.rb +20 -0
- data/lib/rapid_ui/helpers.rb +14 -0
- data/lib/rapid_ui/railtie.rb +15 -0
- data/lib/rapid_ui/utilities.rb +15 -0
- data/lib/rapid_ui/version.rb +5 -0
- data/lib/rapid_ui.rb +20 -0
- data/lib/tasks/rapid_ui.rake +22 -0
- data/sig/rapid_ui.rbs +4 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e48d6ee760575bd4fb74cc1336144bda72c04ddc557addae9645aaca88435f06
|
4
|
+
data.tar.gz: 978602ad6dde4660dae5cbf0ccf1bacf8b3439a13bf7b6a1705d60483bfaa1f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 164be638222e295ec75cf1eb89b57ca017c4b5af637e1ebd2c76e138d938fd6710da4ced570807e5838ecd8127fa23a224f9a1c0754e43657ca311053d0fa87d
|
7
|
+
data.tar.gz: 92fccbd635193494acea9221fb763b122cb755e898daeb31af959626b436f466e75a136738703020e75260c717c3246469bafccac1651b0c2d04d26d98dd6937
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at leonid@storypro.io. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rapid_ui (0.1.0)
|
5
|
+
view_component
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (7.0.3)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
ast (2.4.2)
|
16
|
+
byebug (11.1.3)
|
17
|
+
concurrent-ruby (1.1.10)
|
18
|
+
i18n (1.10.0)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
method_source (1.0.0)
|
21
|
+
minitest (5.15.0)
|
22
|
+
parallel (1.22.1)
|
23
|
+
parser (3.1.2.0)
|
24
|
+
ast (~> 2.4.1)
|
25
|
+
rainbow (3.1.1)
|
26
|
+
rake (13.0.6)
|
27
|
+
regexp_parser (2.4.0)
|
28
|
+
rexml (3.2.5)
|
29
|
+
rubocop (1.29.1)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 3.1.0.0)
|
32
|
+
rainbow (>= 2.2.2, < 4.0)
|
33
|
+
regexp_parser (>= 1.8, < 3.0)
|
34
|
+
rexml (>= 3.2.5, < 4.0)
|
35
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
36
|
+
ruby-progressbar (~> 1.7)
|
37
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
38
|
+
rubocop-ast (1.17.0)
|
39
|
+
parser (>= 3.1.1.0)
|
40
|
+
ruby-progressbar (1.11.0)
|
41
|
+
tzinfo (2.0.4)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
unicode-display_width (2.1.0)
|
44
|
+
view_component (2.55.0)
|
45
|
+
activesupport (>= 5.0.0, < 8.0)
|
46
|
+
method_source (~> 1.0)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
arm64-darwin-21
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
byebug
|
53
|
+
rake (~> 13.0)
|
54
|
+
rapid_ui!
|
55
|
+
rubocop (~> 1.21)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.2.33
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Leonid Medovyy
|
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,30 @@
|
|
1
|
+
# RapidUI 🥷
|
2
|
+
RapidUI is a modern framework that addresses linguistic complexity of designing modern user interfaces.
|
3
|
+
|
4
|
+
|
5
|
+
### Features
|
6
|
+
- Clean and readable code reduces cognitive load and improves developer happiness.
|
7
|
+
- CSS Framework agnostic. It can be configured to work with your existing CSS framework.
|
8
|
+
- You can integrate it with [sass-jesus]() and forget about the CSS framework complexity all-together.
|
9
|
+
|
10
|
+
### History
|
11
|
+
- Rapid UI is a spiritual successor to [GoodUI](https://github.com/realstorypro/good-ui), a UI meta-programming framework based on [SemanticUI](https://semantic-ui.com/).
|
12
|
+
- It's battle tested and has been used in production by [StoryPRO](https://www.storypro.io) for over a year.
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
Add this line to your application Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rapid_ui'
|
19
|
+
```
|
20
|
+
|
21
|
+
run and `bundle install`.
|
22
|
+
|
23
|
+
|
24
|
+
Next copy the configuration files.
|
25
|
+
|
26
|
+
```bash
|
27
|
+
rake rapid_ui:install
|
28
|
+
```
|
29
|
+
|
30
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "rapid_ui"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# adding r as an alias to the render method
|
4
|
+
# to make rendering our ui components easier on the eyes
|
5
|
+
if defined?(ActionView::Helpers::RenderingHelper)
|
6
|
+
module ActionView
|
7
|
+
module Helpers
|
8
|
+
module RenderingHelper
|
9
|
+
alias r render
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
else
|
14
|
+
raise 'Cant monkeypatch ActionView::Helpers::RenderingHelper'
|
15
|
+
end
|
data/lib/install/ui.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class WrapperComponent < ViewComponent::Base
|
4
|
+
def initialize(name, arguments)
|
5
|
+
defaults = Ui::Utilities.instance.defaults(component: name)
|
6
|
+
settings = merge_defaults(defaults, arguments)
|
7
|
+
|
8
|
+
@component = Ui::Component.new(settings)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def merge_defaults(defaults, args)
|
14
|
+
defaults.each do |default|
|
15
|
+
name = default_name(default)
|
16
|
+
value = default_value(default)
|
17
|
+
args[name] = value unless args.key?(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
args
|
21
|
+
end
|
22
|
+
|
23
|
+
def tag_arguments
|
24
|
+
arguments = {}
|
25
|
+
arguments[:class] = @component.css_class
|
26
|
+
arguments[:id] = @component.id
|
27
|
+
arguments[:data] = @component.data
|
28
|
+
arguments[:style] = @component.style
|
29
|
+
arguments[:alt] = @component.alt
|
30
|
+
arguments[:title] = @component.title
|
31
|
+
arguments[:method] = @component.method
|
32
|
+
arguments[:action] = @component.action_attr
|
33
|
+
arguments[:name] = @component.name_attr
|
34
|
+
arguments[:value] = @component.value
|
35
|
+
arguments[:type] = @component.type
|
36
|
+
arguments[:rows] = @component.rows
|
37
|
+
arguments[:placeholder] = @component.placeholder
|
38
|
+
arguments
|
39
|
+
end
|
40
|
+
|
41
|
+
# retreives the default name from a hash
|
42
|
+
def default_name(default)
|
43
|
+
default[0].to_sym
|
44
|
+
end
|
45
|
+
|
46
|
+
# retreives the default value from a hash
|
47
|
+
def default_value(default)
|
48
|
+
default[1]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Ui
|
2
|
+
# responsible for the out building of the component
|
3
|
+
class Component
|
4
|
+
attr_accessor :action, :action_attr, :alt, :css_class, :data, :id, :img, :method, :name_attr, :placeholder, :rows, :style, :tag, :text, :title, :type, :url, :value
|
5
|
+
|
6
|
+
def initialize(settings)
|
7
|
+
@settings = settings
|
8
|
+
set_defaults
|
9
|
+
build_component
|
10
|
+
transpose_settings %w[action_attr alt data id img method name_attr placeholder rows style tag text title type url value]
|
11
|
+
end
|
12
|
+
|
13
|
+
# sets component defaults
|
14
|
+
def set_defaults
|
15
|
+
@data = nil
|
16
|
+
@css_class = ''
|
17
|
+
end
|
18
|
+
|
19
|
+
# builds out the component
|
20
|
+
def build_component
|
21
|
+
build_dynamic
|
22
|
+
build_class
|
23
|
+
build_responsiveness
|
24
|
+
build_name
|
25
|
+
build_default_class
|
26
|
+
build_stimulus_props
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# adds dynamic class to the component is the switch is set
|
31
|
+
def build_dynamic
|
32
|
+
add_class 'dynamic' if on?(:dynamic)
|
33
|
+
end
|
34
|
+
|
35
|
+
# builds out css class for the component
|
36
|
+
def build_class
|
37
|
+
add_class @settings[:class] if @settings.key?(:class)
|
38
|
+
end
|
39
|
+
|
40
|
+
# builds out the reponsive css classes
|
41
|
+
def build_responsiveness
|
42
|
+
add_class build_only if @settings.key?(:only)
|
43
|
+
add_class build_size if @settings.key?(:size)
|
44
|
+
|
45
|
+
sizes = %i[computer tablet mobile]
|
46
|
+
sizes.each do |device|
|
47
|
+
add_class build_size(device) if @settings.key?(device)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# builds out the name for the compnent
|
52
|
+
def build_name
|
53
|
+
return unless @settings.key?(:name)
|
54
|
+
|
55
|
+
add_class @settings[:name]
|
56
|
+
add_data :name, @settings[:name].parameterize.underscore
|
57
|
+
end
|
58
|
+
|
59
|
+
# builds out a default class for the component
|
60
|
+
def build_default_class
|
61
|
+
add_class @settings[:css_class] if @settings.key?(:css_class)
|
62
|
+
end
|
63
|
+
|
64
|
+
# builds out stimulus.js shortcuts
|
65
|
+
def build_stimulus_props
|
66
|
+
add_data :controller, @settings[:controller] if @settings.key?(:controller)
|
67
|
+
add_data :target, @settings[:target] if @settings.key?(:target)
|
68
|
+
add_data :action, @settings[:action] if @settings.key?(:action)
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
# Converts numbers into words
|
74
|
+
# It seems to be having issues with larger valeus such as 1001
|
75
|
+
# rubocop:disable all
|
76
|
+
def number_in_words(int)
|
77
|
+
numbers_to_name = {
|
78
|
+
1_000_000 => 'million', 1000 => 'thousand', 100 => 'hundred', 90 => 'ninety', 80 => 'eighty', 70 => 'seventy', 60 => 'sixty', 50 => 'fifty', 40 => 'forty',
|
79
|
+
30 => 'thirty', 20 => 'twenty', 19 => 'nineteen', 18 => 'eighteen', 17 => 'seventeen', 16 => 'sixteen', 15 => 'fifteen', 14 => 'fourteen', 13 => 'thirteen',
|
80
|
+
12 => 'twelve', 11 => 'eleven', 10 => 'ten', 9 => 'nine', 8 => 'eight', 7 => 'seven', 6 => 'six', 5 => 'five', 4 => 'four', 3 => 'three', 2 => 'two', 1 => 'one'
|
81
|
+
}
|
82
|
+
str = ''
|
83
|
+
numbers_to_name.each do |num, name|
|
84
|
+
if int.zero?
|
85
|
+
return str
|
86
|
+
elsif int.to_s.length == 1 && (int / num).positive?
|
87
|
+
return str + name.to_s
|
88
|
+
elsif int < 100 && (int / num).positive?
|
89
|
+
return str + name.to_s if (int % num).zero?
|
90
|
+
return str + name.to_s + ' ' + number_in_words(int % num)
|
91
|
+
elsif (int / num).positive?
|
92
|
+
return str + number_in_words(int / num) + ' ' + name.to_s + number_in_words(int % num)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def transpose_settings(items)
|
98
|
+
items.each do |item|
|
99
|
+
instance_variable_set("@#{item}", @settings[item.to_sym])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# appends class to the css_clss object
|
104
|
+
def add_class(klass)
|
105
|
+
css_class << ' ' + klass
|
106
|
+
end
|
107
|
+
|
108
|
+
# builds out the class markup for 'only' type display
|
109
|
+
def build_only
|
110
|
+
"#{@settings[:only]} only"
|
111
|
+
end
|
112
|
+
|
113
|
+
# builds out the class markup for the size
|
114
|
+
def build_size(device = nil)
|
115
|
+
return number_in_words(@settings[:size]) if device.equal? nil
|
116
|
+
"#{number_in_words(@settings[device])} wide #{device}"
|
117
|
+
end
|
118
|
+
|
119
|
+
# appds items to the data hash
|
120
|
+
def add_data(name, value)
|
121
|
+
# initialize data hash if one doesn't exist
|
122
|
+
@settings[:data] = {} if @settings[:data].nil?
|
123
|
+
|
124
|
+
@settings[:data][name] = value
|
125
|
+
end
|
126
|
+
|
127
|
+
# checks if the key is off
|
128
|
+
# - use syntax like @settings[key].on?
|
129
|
+
# - make sure the [method]? is metaprogrammed on method_missing to map to the key
|
130
|
+
def off?(key)
|
131
|
+
return true if @settings[key].equal? :off
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
# checks if the key is on
|
136
|
+
def on?(key)
|
137
|
+
return true if @settings[key].equal? :on
|
138
|
+
false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# handles loading and serving of the configuration files
|
4
|
+
module RapidUi
|
5
|
+
# contains the configuration itself
|
6
|
+
class Configuration
|
7
|
+
attr_accessor :ui_file, :ui_yml, :ui_hash
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@ui_file = nil
|
11
|
+
|
12
|
+
@ui_hash = nil
|
13
|
+
@ui_yml = nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure
|
22
|
+
yield configuration
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.boot
|
26
|
+
raise "No ui file provided!" if configuration.ui_file.nil?
|
27
|
+
|
28
|
+
configuration.ui_yml = YAML.load_file(configuration.ui_file)
|
29
|
+
configuration.ui_hash = Hashie::Mash.load(configuration.ui_file)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ui
|
4
|
+
class Display < ActionView::Base
|
5
|
+
include Singleton
|
6
|
+
include ViewComponent
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
RapidUi.configuration.ui_yml['ui'].each do |ui_element|
|
10
|
+
define_singleton_method ui_element[0].to_s do |args = {}|
|
11
|
+
# for convenience we allow people to only pass a class string
|
12
|
+
# it is the same as setting a class
|
13
|
+
args = { class: args } if args.is_a?(String)
|
14
|
+
|
15
|
+
WrapperComponent.new(ui_element[0].to_sym, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RapidUi
|
4
|
+
module ViewHelpers
|
5
|
+
# Shortcut for accessing the ui method
|
6
|
+
# We are calling it UX for a number of reasons.
|
7
|
+
# 1. To avoid name collisions during the recursion.
|
8
|
+
# 2. It looks better then 'ui' on the front end.
|
9
|
+
|
10
|
+
def ux
|
11
|
+
Ui::Display.instance
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RapidUi
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer "rapid_ui.view_helpers" do
|
6
|
+
ActiveSupport.on_load(:action_view) do
|
7
|
+
include RapidUi::ViewHelpers
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
rake_tasks do
|
12
|
+
load "tasks/rapid_ui.rake"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/rapid_ui.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'hashie'
|
4
|
+
require "view_component"
|
5
|
+
|
6
|
+
# require 'byebug'
|
7
|
+
|
8
|
+
require_relative "rapid_ui/version"
|
9
|
+
require_relative "rapid_ui/configuration"
|
10
|
+
|
11
|
+
require_relative "rapid_ui/display"
|
12
|
+
require_relative "rapid_ui/utilities"
|
13
|
+
require_relative "rapid_ui/component"
|
14
|
+
|
15
|
+
require_relative "rapid_ui/helpers"
|
16
|
+
require_relative "rapid_ui/railtie"
|
17
|
+
|
18
|
+
module RapidUi
|
19
|
+
class Error < StandardError; end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
namespace :rapid_ui do
|
2
|
+
desc "Install Rapid UI"
|
3
|
+
task :install do
|
4
|
+
def copy_files(file, destination)
|
5
|
+
puts "Copying #{file} to #{destination}..."
|
6
|
+
|
7
|
+
source = File.join File.dirname(__FILE__), "../install/#{file}"
|
8
|
+
to = Rails.root.join(destination).to_s
|
9
|
+
FileUtils.cp_r source.to_s, to
|
10
|
+
end
|
11
|
+
|
12
|
+
puts "Installing Rapid Ui..."
|
13
|
+
puts "----------------------------------------"
|
14
|
+
copy_files("ui.yml", "config/ui.yml")
|
15
|
+
copy_files("rapid_ui.rb", "config/initializers/rapid_ui.rb")
|
16
|
+
copy_files("render_monkeypatch.rb", "config/initializers/render_monkeypatch.rb")
|
17
|
+
copy_files("wrapper_component.rb", "app/components/wrapper_component.rb")
|
18
|
+
copy_files("wrapper_component.html.slim", "app/components/wrapper_component.html.slim")
|
19
|
+
puts "----------------------------------------"
|
20
|
+
puts "Rapid Ui installed."
|
21
|
+
end
|
22
|
+
end
|
data/sig/rapid_ui.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapid_ui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leonid Medovyy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: view_component
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- leonid@storypro.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- CHANGELOG.md
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/install/rapid_ui.rb
|
73
|
+
- lib/install/render_monkeypatch.rb
|
74
|
+
- lib/install/ui.yml
|
75
|
+
- lib/install/wrapper_component.html.slim
|
76
|
+
- lib/install/wrapper_component.rb
|
77
|
+
- lib/rapid_ui.rb
|
78
|
+
- lib/rapid_ui/component.rb
|
79
|
+
- lib/rapid_ui/configuration.rb
|
80
|
+
- lib/rapid_ui/display.rb
|
81
|
+
- lib/rapid_ui/helpers.rb
|
82
|
+
- lib/rapid_ui/railtie.rb
|
83
|
+
- lib/rapid_ui/utilities.rb
|
84
|
+
- lib/rapid_ui/version.rb
|
85
|
+
- lib/tasks/rapid_ui.rake
|
86
|
+
- sig/rapid_ui.rbs
|
87
|
+
homepage: https://github.com/realstorypro/rapid-ui
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata:
|
91
|
+
homepage_uri: https://github.com/realstorypro/rapid-ui
|
92
|
+
source_code_uri: https://github.com/realstorypro/rapid-ui
|
93
|
+
changelog_uri: https://github.com/realstorypro/rapid-ui/blob/main/CHANGELOG.md
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.6.0
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.2.32
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Ruby on Rails UI development framework based on ViewComponent
|
113
|
+
test_files: []
|