primrose 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bb209d0d9da846bc7696fa3e0ee9b5aaac7ae0e9ea17d1347d521a8c262c9be
4
- data.tar.gz: 6451b8fa8a5d3747c1e39279021958069eaaf2acc783aea9d760a0fce19fcef5
3
+ metadata.gz: a05873db52a828030b1bc392f0604de6da140fcf57f35eedfb64afc2aa6f2818
4
+ data.tar.gz: d2ee9d7796df7bc02dc9b7ff186d07a8f7f1db1c5abc14029469049117f4a7cc
5
5
  SHA512:
6
- metadata.gz: 6f801a9e52a670739c10aefce57b9b8566fca1c91b8ae038b1b3f5707948da270d37e95fbfaecdbb19409aa1e9801bff62142d779e3782ba9a841fcc60dacb2f
7
- data.tar.gz: 6741bf29d095cef43d8610c3c6b2e9a607171d1ed6b324b7606c4a48e43ba7b62bc8e39f73564e33d73e76632f094179e914f1cecd57fae1b9cbb3cf6a2873e4
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
- TEMPLATE = <<~ERB
8
- <button
9
- onclick="<%= @action %>"
10
- class="<%= @style %>"
11
- <%= 'disabled' if @disabled %>
12
- <%= 'loading' if @loading %>
13
- >
14
- <%= @label %>
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Primrose
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
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