primrose 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/primrose/components/body.rb +20 -0
- data/lib/primrose/components/button.rb +9 -10
- data/lib/primrose/components/form.rb +24 -0
- data/lib/primrose/components/grid_layout.rb +29 -0
- data/lib/primrose/components/hidden_field.rb +20 -0
- data/lib/primrose/components/list.rb +24 -0
- data/lib/primrose/components/modal.rb +39 -0
- data/lib/primrose/components/table.rb +35 -0
- data/lib/primrose/helpers.rb +32 -0
- data/lib/primrose/version.rb +1 -1
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a05873db52a828030b1bc392f0604de6da140fcf57f35eedfb64afc2aa6f2818
|
4
|
+
data.tar.gz: d2ee9d7796df7bc02dc9b7ff186d07a8f7f1db1c5abc14029469049117f4a7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c09149247fb8efe55916e56f1bb36767682af9bacbb3e008a67d59a44fbd7d6e6f37f061a4421bfe87fb95e2b4566c44384a28ac9c560ba4aa1d3e3ada4fcc
|
7
|
+
data.tar.gz: 4dc252ddb95bfe4df3087d245a33a1ba77539a6be09fd5cde3644e20483d4f2b416ad1431c76a11f75ba4f7cf083d0b4374ec212884d1bfea21115f3ed99393e
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
module Body
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<body>
|
6
|
+
<%= @content %>
|
7
|
+
</body>
|
8
|
+
ERB
|
9
|
+
|
10
|
+
def initialize(content:)
|
11
|
+
@content = content
|
12
|
+
super()
|
13
|
+
end
|
14
|
+
|
15
|
+
def render
|
16
|
+
Prim.render(TEMPLATE, self)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,16 +3,15 @@ require_relative '../prim'
|
|
3
3
|
module Primrose
|
4
4
|
module Components
|
5
5
|
class Button < Rose
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
</button>
|
6
|
+
TEMPLATE = <<~ERB
|
7
|
+
<button
|
8
|
+
onclick="<%= @action %>"
|
9
|
+
class="<%= @style %>"
|
10
|
+
<%= 'disabled' if @disabled %>
|
11
|
+
<%= 'loading' if @loading %>
|
12
|
+
>
|
13
|
+
<%= @label %>
|
14
|
+
</button>
|
16
15
|
ERB
|
17
16
|
|
18
17
|
def initialize(label:, action:, style: nil, disabled: false, loading: false)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
class Form < Rose
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<form class="<%= @style_class %>" action="<%= @action %>" method="<%= @method %>">
|
6
|
+
<%= @elements.join("\n") %>
|
7
|
+
</form>
|
8
|
+
ERB
|
9
|
+
|
10
|
+
def initialize(elements:, method:, style_class: nil, action: nil, **opts)
|
11
|
+
@elements = elements
|
12
|
+
@options = opts
|
13
|
+
@style_class = style_class
|
14
|
+
@action = action
|
15
|
+
@method = method
|
16
|
+
super()
|
17
|
+
end
|
18
|
+
|
19
|
+
def render
|
20
|
+
Prim.render(TEMPLATE, self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
class GridLayout < Rose
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<div class="grid-layout <%= @style_class %>">
|
6
|
+
<% @rows.each do |row| %>
|
7
|
+
<div class="row">
|
8
|
+
<% row.each do |column| %>
|
9
|
+
<div class="column">
|
10
|
+
<%= column.render %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
ERB
|
17
|
+
|
18
|
+
def initialize(rows, columns, style_class: nil)
|
19
|
+
@style_class = style_class
|
20
|
+
@rows = rows
|
21
|
+
@columns = columns
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
Prim.render(TEMPLATE, self)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
class HiddenField < Rose
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<input type="hidden" name="<%= @name %>" value="<%= @value %>">
|
6
|
+
ERB
|
7
|
+
|
8
|
+
attr_reader :name, :value
|
9
|
+
|
10
|
+
def initialize(name:, value:)
|
11
|
+
@name = name
|
12
|
+
@value = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def render
|
16
|
+
Prim.render(TEMPLATE, self)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
class List < Rose
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<ul class="<%= @style_class %>">
|
6
|
+
<% @items.each do |item| %>
|
7
|
+
<li><%= item %></li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
ERB
|
11
|
+
|
12
|
+
def initialize(items:, id: nil, style_class: nil)
|
13
|
+
@items = items
|
14
|
+
@id = id
|
15
|
+
@style_class = style_class
|
16
|
+
super()
|
17
|
+
end
|
18
|
+
|
19
|
+
def render
|
20
|
+
Prim.render(TEMPLATE, self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../prim'
|
2
|
+
|
3
|
+
module Primrose
|
4
|
+
module Components
|
5
|
+
class Modal < Rose
|
6
|
+
TEMPLATE = <<~ERB
|
7
|
+
<% if @is_open %>
|
8
|
+
<label for="modal-<%= @name %>"><%= @label %></label>
|
9
|
+
<div class="modal <%= @style_class %>">
|
10
|
+
<div class="modal-content">
|
11
|
+
<%= @content %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
ERB
|
16
|
+
|
17
|
+
def initialize(content:, is_open: false, name: nil, label: nil, style_class: nil)
|
18
|
+
@content = content
|
19
|
+
@is_open = is_open
|
20
|
+
@name = name
|
21
|
+
@label = label
|
22
|
+
@style_class = style_class
|
23
|
+
super()
|
24
|
+
end
|
25
|
+
|
26
|
+
def render
|
27
|
+
Prim.render(TEMPLATE, self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def open
|
31
|
+
@is_open = true
|
32
|
+
end
|
33
|
+
|
34
|
+
def close
|
35
|
+
@is_open = false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Primrose
|
2
|
+
module Components
|
3
|
+
class Table < Rose
|
4
|
+
TEMPLATE = <<~ERB
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<% @headers.each do |header| %>
|
9
|
+
<th><%= header %></th>
|
10
|
+
<% end %>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% @rows.each do |row| %>
|
15
|
+
<tr>
|
16
|
+
<% row.each do |cell| %>
|
17
|
+
<td><%= cell %></td>
|
18
|
+
<% end %>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
</tbody>
|
22
|
+
</table>
|
23
|
+
ERB
|
24
|
+
|
25
|
+
def initialize(headers, rows)
|
26
|
+
@headers = headers
|
27
|
+
@rows = rows
|
28
|
+
end
|
29
|
+
|
30
|
+
def render
|
31
|
+
Prim.render(TEMPLATE, self)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/primrose/helpers.rb
CHANGED
@@ -2,6 +2,13 @@ require_relative 'components/button'
|
|
2
2
|
require_relative 'components/navbar'
|
3
3
|
require_relative 'components/text_field'
|
4
4
|
require_relative 'components/checkbox'
|
5
|
+
require_relative 'components/modal'
|
6
|
+
require_relative 'components/table'
|
7
|
+
require_relative 'components/list'
|
8
|
+
require_relative 'components/grid_layout'
|
9
|
+
require_relative 'components/hidden_field'
|
10
|
+
require_relative 'components/form'
|
11
|
+
|
5
12
|
|
6
13
|
module Primrose
|
7
14
|
module Helpers
|
@@ -35,5 +42,30 @@ module Primrose
|
|
35
42
|
def checkbox(label:, checked: false, **opts)
|
36
43
|
component('Checkbox', label: label, checked: checked, **opts)
|
37
44
|
end
|
45
|
+
|
46
|
+
# def modal(content:, is_open: false, name: nil, label: nil, style_class: nil)
|
47
|
+
# component('Modal', content: content, is_open: is_open, name: name, label: label, style_class: style_class)
|
48
|
+
# end
|
49
|
+
|
50
|
+
# def table(headers:, rows:, **opts)
|
51
|
+
# component('Table', headers: headers, rows: rows, **opts)
|
52
|
+
# end
|
53
|
+
|
54
|
+
def list(items:, **opts)
|
55
|
+
component('List', items: items, **opts)
|
56
|
+
end
|
57
|
+
|
58
|
+
# def grid_layout(rows:, columns:, **opts)
|
59
|
+
# component('GridLayout', rows: rows, columns: columns, **opts)
|
60
|
+
# end
|
61
|
+
|
62
|
+
def hidden_field(name:, value:, **opts)
|
63
|
+
puts "Creating hidden field with name #{name} and value #{value}"
|
64
|
+
component('HiddenField', name: name, value: value)
|
65
|
+
end
|
66
|
+
|
67
|
+
def form(elements:, method:, style_class: nil, action: nil, **opts, &block)
|
68
|
+
component('Form', elements: elements, method: method, style_class: style_class, action: action, **opts, &block)
|
69
|
+
end
|
38
70
|
end
|
39
71
|
end
|
data/lib/primrose/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primrose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel M. Matongo
|
@@ -33,9 +33,16 @@ files:
|
|
33
33
|
- LICENSE
|
34
34
|
- README.md
|
35
35
|
- lib/primrose.rb
|
36
|
+
- lib/primrose/components/body.rb
|
36
37
|
- lib/primrose/components/button.rb
|
37
38
|
- lib/primrose/components/checkbox.rb
|
39
|
+
- lib/primrose/components/form.rb
|
40
|
+
- lib/primrose/components/grid_layout.rb
|
41
|
+
- lib/primrose/components/hidden_field.rb
|
42
|
+
- lib/primrose/components/list.rb
|
43
|
+
- lib/primrose/components/modal.rb
|
38
44
|
- lib/primrose/components/navbar.rb
|
45
|
+
- lib/primrose/components/table.rb
|
39
46
|
- lib/primrose/components/text_field.rb
|
40
47
|
- lib/primrose/helpers.rb
|
41
48
|
- lib/primrose/observable.rb
|