reativo 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -0
  3. data/app/controllers/reativo/crud_controller.rb +17 -2
  4. data/lib/generators/reativo/install_generator.rb +55 -0
  5. data/lib/generators/reativo/js_generator.rb +78 -0
  6. data/lib/generators/reativo/op_generator.rb +96 -0
  7. data/lib/generators/reativo/templates/component/Edit.js +43 -0
  8. data/lib/generators/reativo/templates/component/Form.js +52 -0
  9. data/lib/generators/reativo/templates/component/Index.js +51 -0
  10. data/lib/generators/reativo/templates/component/New.js +37 -0
  11. data/lib/generators/reativo/templates/component/Show.js +32 -0
  12. data/lib/generators/reativo/templates/operation/create.erb +3 -4
  13. data/lib/generators/reativo/templates/operation/destroy.erb +2 -2
  14. data/lib/generators/reativo/templates/operation/index.erb +2 -1
  15. data/lib/generators/reativo/templates/operation/update.erb +3 -4
  16. data/lib/generators/reativo/templates/representer/create.erb +1 -1
  17. data/lib/generators/reativo/templates/representer/index.erb +1 -1
  18. data/lib/generators/reativo/templates/representer/module.erb +1 -1
  19. data/lib/generators/reativo/templates/representer/update.erb +1 -1
  20. data/lib/generators/reativo/templates/support/store.js +24 -0
  21. data/lib/generators/reativo/templates/support/theme.js +25 -0
  22. data/lib/generators/reativo/templates/theme/Baseline.js +10 -0
  23. data/lib/generators/reativo/templates/theme/Drawer.js +50 -0
  24. data/lib/generators/reativo/templates/theme/MainBar.js +223 -0
  25. data/lib/generators/reativo/templates/theme/Menu.js +79 -0
  26. data/lib/generators/reativo/templates/theme/Snackbar.js +9 -0
  27. data/lib/generators/reativo/templates/theme/layout.erb +59 -0
  28. data/lib/generators/reativo/templates/theme/layout.rb +6 -0
  29. data/lib/reativo/version.rb +1 -1
  30. metadata +33 -4
  31. data/lib/generators/reativo/USAGE +0 -23
  32. data/lib/generators/reativo/reativo_generator.rb +0 -63
@@ -0,0 +1,79 @@
1
+ // React Imports
2
+ import React from 'react'
3
+ import PropTypes from 'prop-types'
4
+
5
+ import { withStyles } from '@material-ui/core/styles'
6
+ import classNames from 'classnames'
7
+ import ListItem from '@material-ui/core/ListItem'
8
+ import BookmarkIcon from '@material-ui/icons/Bookmark'
9
+
10
+ import { hot } from 'react-hot-loader/root'
11
+ import { wrapper } from "reativo"
12
+
13
+ const styles = theme => ({
14
+ //css buttons
15
+ button: {
16
+ width: '100%',
17
+ maxWidth: 360,
18
+ backgroundColor: theme.palette.background.paper,
19
+ borderRadius: '0 12px 12px 0',
20
+ transition: 'margin .15s cubic-bezier(0.4,0.0,0.2,1),padding .15s cubic-bezier(0.4,0.0,0.2,1)',
21
+ padding: '0 10px 0 26px',
22
+
23
+ '&:hover': {
24
+ cursor: 'pointer',
25
+ },
26
+ //css on specifc divs
27
+ },
28
+ divRoot: {
29
+ padding: '0 8px 0 26px',
30
+ alignItems: 'center',
31
+ display: 'flex',
32
+ height: '24px',
33
+ position: 'relative'
34
+ },
35
+ divIcon: {
36
+ borderColor: '#000',
37
+ alignItems: 'center',
38
+ display: 'flex',
39
+ flexShrink: '0',
40
+ height: '20px',
41
+ justifyContent: 'flex-start',
42
+ marginRight: '18px',
43
+ width: '20px',
44
+ color: '#767676',
45
+ },
46
+ });
47
+
48
+
49
+ const menuItems = [
50
+ {icon: BookmarkIcon, text: "Tasks", url: "/tasks"},
51
+ ]
52
+
53
+ function SimpleList({classes, drawer}) {
54
+ return (
55
+ <div id="menu-list" data-turbolinks-permanent>
56
+ {menuItems.map((item, index) => (
57
+ <ListItem key={index} button className={classNames(classes.button,classes.divRoot)} onClick={() => Turbolinks.visit(item.url)}>
58
+ <item.icon className={classes.divIcon}/>
59
+ {drawer.open ? item.text : ''}
60
+ </ListItem>
61
+ ))}
62
+ </div>
63
+ );
64
+ }
65
+
66
+ SimpleList.propTypes = {
67
+ classes: PropTypes.object.isRequired,
68
+ };
69
+
70
+ const mapStateToProps = state => {
71
+ const { drawer } = state
72
+ return ({
73
+ drawer
74
+ })
75
+ }
76
+
77
+ export default hot(withStyles(styles)(
78
+ wrapper(SimpleList, mapStateToProps)
79
+ ))
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Snackbar as SnackbarOriginal } from "reativo"
3
+ import { wrapper } from "reativo"
4
+
5
+ function Snackbar({messages}) {
6
+ return <SnackbarOriginal messages={messages} />
7
+ }
8
+
9
+ export default wrapper(Snackbar)
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <!-- jss-insertion-point -->
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no">
7
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
8
+ <title>Reativo</title>
9
+ <%= csrf_meta_tags %>
10
+ <%= csp_meta_tag %>
11
+
12
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
13
+ <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
14
+ <meta name="turbolinks-cache-control" content="no-cache">
15
+ <%= stylesheet_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload', media: 'all' %>
16
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
17
+ <%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %>
18
+ </head>
19
+
20
+ <body>
21
+ <style>
22
+ body {
23
+ background-color: white;
24
+ }
25
+ #side-nav {
26
+ position: fixed;
27
+ width: 256px;
28
+ height: calc(100vh - 64px);
29
+ left: 0;
30
+ right: 0;
31
+ overflow-y: auto;
32
+ top: 64px;
33
+ }
34
+
35
+ #content-wrapper {
36
+ margin: 70px 0 0 256px;
37
+ padding: 0 30px;
38
+ overflow-y: auto;
39
+ position: fixed;
40
+ left: 0;
41
+ top: 0;
42
+ height: calc(100vh - 64px);
43
+ width: calc(100% - 256px);
44
+ }
45
+ </style>
46
+
47
+ <%= react_component("theme/Snackbar", messages: flash_messages) %>
48
+ <%= react_component("theme/Baseline") %>
49
+ <%= react_component("theme/MainBar") %>
50
+ <div id="container" style="width: 100%;">
51
+ <div id="side-nav">
52
+ <%= react_component("theme/Drawer") %>
53
+ </div>
54
+ <div id="content-wrapper">
55
+ <%= yield %>
56
+ </div>
57
+ </div>
58
+ </body>
59
+ </html>
@@ -0,0 +1,6 @@
1
+ module Theme
2
+ module Cell
3
+ class Layout < Reativo::Cell::Theme
4
+ end
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Reativo
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reativo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Celso Fernandes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: pry
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  description: Make Rails more reactive
196
210
  email:
197
211
  - celso.fernandes@gmail.com
@@ -218,8 +232,14 @@ files:
218
232
  - app/models/reativo/view/component.erb
219
233
  - app/views/layouts/reativo/application.html.erb
220
234
  - config/routes.rb
221
- - lib/generators/reativo/USAGE
222
- - lib/generators/reativo/reativo_generator.rb
235
+ - lib/generators/reativo/install_generator.rb
236
+ - lib/generators/reativo/js_generator.rb
237
+ - lib/generators/reativo/op_generator.rb
238
+ - lib/generators/reativo/templates/component/Edit.js
239
+ - lib/generators/reativo/templates/component/Form.js
240
+ - lib/generators/reativo/templates/component/Index.js
241
+ - lib/generators/reativo/templates/component/New.js
242
+ - lib/generators/reativo/templates/component/Show.js
223
243
  - lib/generators/reativo/templates/contract/create.erb
224
244
  - lib/generators/reativo/templates/contract/update.erb
225
245
  - lib/generators/reativo/templates/operation/create.erb
@@ -231,6 +251,15 @@ files:
231
251
  - lib/generators/reativo/templates/representer/index.erb
232
252
  - lib/generators/reativo/templates/representer/module.erb
233
253
  - lib/generators/reativo/templates/representer/update.erb
254
+ - lib/generators/reativo/templates/support/store.js
255
+ - lib/generators/reativo/templates/support/theme.js
256
+ - lib/generators/reativo/templates/theme/Baseline.js
257
+ - lib/generators/reativo/templates/theme/Drawer.js
258
+ - lib/generators/reativo/templates/theme/MainBar.js
259
+ - lib/generators/reativo/templates/theme/Menu.js
260
+ - lib/generators/reativo/templates/theme/Snackbar.js
261
+ - lib/generators/reativo/templates/theme/layout.erb
262
+ - lib/generators/reativo/templates/theme/layout.rb
234
263
  - lib/reativo.rb
235
264
  - lib/reativo/engine.rb
236
265
  - lib/reativo/migrations/general.rb
@@ -1,23 +0,0 @@
1
- Description:
2
- Trailblazer generator for my trailblazer workflow
3
-
4
- Example:
5
- rails g reativo Admin::Todos Todo --properties title completed --crud --view_model
6
-
7
- This will create:
8
- app/concepts/admin/todos/{operation, representer}/index.rb
9
- app/concepts/admin/todos/{contract, operation, representer}/create.rb
10
- app/concepts/admin/todos/{operation}/show.rb
11
- app/concepts/admin/todos/{contract, operation, representer}/update.rb
12
- app/concepts/admin/todos/{operation}/destroy.rb
13
- app/concepts/admin/todos/representer/todo_module.rb # the model representation
14
-
15
- Example 2:
16
- If you don't wanna create for all actions, you can specify
17
-
18
- rails g reativo Admin::Todos Todo --properties title completed --actions index create --view_model
19
-
20
- This will create:
21
- app/concepts/admin/todos/{operation, representer}/index.rb
22
- app/concepts/admin/todos/{contract, operation, representer}/create.rb
23
- app/concepts/admin/todos/representer/todo_module.rb
@@ -1,63 +0,0 @@
1
- class ReativoGenerator < Rails::Generators::NamedBase
2
- MAP = {
3
- index: { operation: true, contract: false, representer: true},
4
- create: { operation: true, contract: true, representer: true},
5
- show: { operation: true, contract: false, representer: false},
6
- update: { operation: true, contract: true, representer: true},
7
- destroy: { operation: true, contract: false, representer: false},
8
- }
9
-
10
- source_root File.expand_path('templates', __dir__)
11
- argument :model_name, required: true
12
- class_option :view_model, type: :boolean, default: false, aliases: ['-v']
13
- class_option :crud, type: :boolean, default: false, aliases: ['-c']
14
- class_option :actions, type: :array, default: []
15
- class_option :properties, type: :array, default: [], aliases: ['--props']
16
-
17
- def generate_operations
18
- representer_module = false
19
- actions = options['actions'] || []
20
-
21
- actions = ['index', 'create', 'show', 'update', 'destroy'] if options[:crud]
22
-
23
- actions.each do |action|
24
- template "operation/#{action}.erb", concept_path("operation", action) if has_operation?(action)
25
- template "contract/#{action}.erb", concept_path("contract", action) if has_contract?(action)
26
- if has_representer?(action)
27
- template "representer/#{action}.erb", concept_path("representer", action)
28
- representer_module = true
29
- end
30
- end
31
-
32
- if representer_module
33
- template "representer/module.erb", concept_path("representer", "#{model_name.underscore}_module")
34
- end
35
- end
36
-
37
- private
38
- def property_attribute(property)
39
- return "property :#{property}"
40
- end
41
-
42
- def properties_symbols(include_id:)
43
- args = options[:properties].dup
44
- args.prepend(:id) if include_id
45
- args.map { |x| ":#{x}" }.join(", ")
46
- end
47
-
48
- def concept_path(operation, action)
49
- "app/concepts/#{class_name.underscore}/#{operation}/#{action}.rb"
50
- end
51
-
52
- def has_operation?(action)
53
- MAP.dig(action.to_sym, :operation) || false
54
- end
55
-
56
- def has_contract?(action)
57
- MAP.dig(action.to_sym, :contract) || false
58
- end
59
-
60
- def has_representer?(action)
61
- MAP.dig(action.to_sym, :representer) || false
62
- end
63
- end