relay_ui 0.2.3 → 0.3.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/relay_ui/engine.rb +9 -11
  3. data/lib/relay_ui/version.rb +1 -1
  4. data/lib/rui/badges/base.rb +5 -1
  5. data/lib/rui/badges/blue.rb +3 -1
  6. data/lib/rui/badges/gray.rb +3 -1
  7. data/lib/rui/badges/green.rb +3 -1
  8. data/lib/rui/badges/purple.rb +3 -1
  9. data/lib/rui/badges/red.rb +3 -1
  10. data/lib/rui/badges/yellow.rb +3 -1
  11. data/lib/rui/badges.rb +3 -0
  12. data/lib/rui/base.rb +3 -8
  13. data/lib/rui/buttons/base.rb +9 -7
  14. data/lib/rui/buttons/destructive.rb +3 -1
  15. data/lib/rui/buttons/ghost.rb +3 -1
  16. data/lib/rui/buttons/outline.rb +3 -1
  17. data/lib/rui/buttons/primary.rb +3 -1
  18. data/lib/rui/buttons/secondary.rb +3 -1
  19. data/lib/rui/buttons.rb +3 -0
  20. data/lib/rui/card.rb +92 -0
  21. data/lib/rui/flash.rb +51 -0
  22. data/lib/rui/forms/checkbox.rb +25 -0
  23. data/lib/rui/forms/email.rb +19 -0
  24. data/lib/rui/forms/field_group.rb +5 -0
  25. data/lib/rui/forms/label.rb +7 -0
  26. data/lib/rui/forms/password.rb +18 -0
  27. data/lib/rui/forms/phone.rb +18 -0
  28. data/lib/rui/forms/radio.rb +22 -0
  29. data/lib/rui/forms/select.rb +24 -0
  30. data/lib/rui/forms/text.rb +17 -0
  31. data/lib/rui/forms/textarea.rb +18 -0
  32. data/lib/rui/forms.rb +3 -0
  33. data/lib/rui/helpers.rb +3 -0
  34. data/lib/rui/icon.rb +3 -1
  35. data/lib/rui/layout/body.rb +7 -0
  36. data/lib/rui/layout/main.rb +5 -0
  37. data/lib/rui/layout/page.rb +5 -0
  38. data/lib/rui/layout.rb +3 -0
  39. data/lib/rui/links/base.rb +5 -3
  40. data/lib/rui/links/destructive.rb +3 -1
  41. data/lib/rui/links/ghost.rb +3 -1
  42. data/lib/rui/links/outline.rb +3 -1
  43. data/lib/rui/links/primary.rb +3 -1
  44. data/lib/rui/links/secondary.rb +3 -1
  45. data/lib/rui/links.rb +3 -0
  46. data/lib/rui/markdown/generator.rb +2 -1
  47. data/lib/rui/markdown/safe.rb +3 -1
  48. data/lib/rui/markdown/safe_renderer.rb +3 -1
  49. data/lib/rui/markdown/unsafe.rb +3 -1
  50. data/lib/rui/markdown/unsafe_renderer.rb +9 -1
  51. data/lib/rui/markdown.rb +3 -0
  52. data/lib/rui/navigation/menu_button.rb +7 -0
  53. data/lib/rui/navigation/sidebar.rb +43 -0
  54. data/lib/rui/navigation/top.rb +19 -0
  55. data/lib/rui/navigation.rb +2 -50
  56. data/lib/rui/slideout.rb +9 -9
  57. data/lib/rui/table.rb +54 -0
  58. data/lib/rui/text.rb +5 -3
  59. metadata +70 -3
  60. data/dist/relay_ui/relay_ui.css +0 -595
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Links::Outline < RUI::Links::Base
2
4
  private
3
5
 
4
- def variant_classes = "rui:border rui:rounded rui:border-zinc-700 rui:hover:border-zinc-900 rui:text-zinc-700 rui:hover:text-zinc-900 rui:hover:bg-zinc-100"
6
+ def variant_classes = "border rounded border-zinc-300 hover:border-zinc-700 text-zinc-700"
5
7
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Links::Primary < RUI::Links::Base
2
4
  private
3
5
 
4
- def variant_classes = "rui:bg-blue-700 rui:hover:bg-blue-900 rui:text-white"
6
+ def variant_classes = "bg-blue-700 hover:bg-blue-900 text-white border border-blue-700 hover:border-blue-900"
5
7
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Links::Secondary < RUI::Links::Base
2
4
  private
3
5
 
4
- def variant_classes = "rui:bg-zinc-700 rui:hover:bg-zinc-900 rui:text-white"
6
+ def variant_classes = "bg-zinc-700 hover:bg-zinc-900 text-white border border-zinc-700 hover:border-zinc-900"
5
7
  end
data/lib/rui/links.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RUI::Links; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "redcarpet"
2
4
 
3
5
  class RUI::Markdown::Generator
@@ -7,7 +9,6 @@ class RUI::Markdown::Generator
7
9
  options = {
8
10
  filter_html: true,
9
11
  hard_wrap: true,
10
- link_attributes: { rel: "nofollow", target: "_blank" },
11
12
  escape_html: true
12
13
  }
13
14
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Markdown::Safe < RUI::Base
2
4
  def view_template(&block)
3
- article(class: "rui:markdown") do
5
+ article(class: "prose") do
4
6
  RUI::Markdown::Generator.instance.get_safe(capture(&block))
5
7
  end
6
8
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rouge"
2
4
  require "rouge/plugins/redcarpet"
3
5
  require "redcarpet"
4
6
 
5
- class RUI::Markdown::SafeRenderer < Redcarpet::Render::XHTML
7
+ class RUI::Markdown::SafeRenderer < Redcarpet::Render::HTML
6
8
  include Rouge::Plugins::Redcarpet
7
9
 
8
10
  private
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Markdown::Unsafe < RUI::Base
2
4
  def view_template(&block)
3
- article(class: "rui:markdown") do
5
+ article(class: "prose") do
4
6
  RUI::Markdown::Generator.instance.get_unsafe(capture(&block))
5
7
  end
6
8
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rouge"
2
4
  require "rouge/plugins/redcarpet"
3
5
  require "redcarpet"
4
6
 
5
- class RUI::Markdown::UnsafeRenderer < Redcarpet::Render::XHTML
7
+ class RUI::Markdown::UnsafeRenderer < Redcarpet::Render::HTML
6
8
  include Rouge::Plugins::Redcarpet
7
9
 
8
10
  def block_code(code, lang)
@@ -26,6 +28,12 @@ class RUI::Markdown::UnsafeRenderer < Redcarpet::Render::XHTML
26
28
  formatter.format(lexer.lex(unescaped))
27
29
  end
28
30
 
31
+ def codespan(code)
32
+ unescaped = CGI.unescapeHTML(code)
33
+
34
+ "<code>#{unescaped}</code>"
35
+ end
36
+
29
37
  private
30
38
 
31
39
  def rouge_formatter(lexer)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RUI::Markdown; end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RUI::Navigation::MenuButton < RUI::Base
4
+ def view_template
5
+ render RUI::Buttons::Outline.new(icon: "menu", data: { action: "navigation#toggle", class: "lg:hidden" })
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RUI::Navigation::Sidebar < RUI::Base
4
+ def view_template
5
+ div(class: "p-10 pb-36 hidden lg:flex flex-col bg-white z-50 lg:z-auto fixed lg:relative w-screen md:w-auto h-screen lg:h-auto overflow-auto", data: { "navigation-target": "sidebar" }) do
6
+ yield
7
+ end
8
+ button(class: "lg:hidden hidden bg-black/75 fixed w-screen h-screen", data: { navigation_target: "curtain", action: "navigation#toggle" })
9
+ end
10
+
11
+ def section_heading
12
+ p(class: "pt-8 pb-4 mt-6 text-base md:text-sm font-semibold uppercase text-zinc-400") do
13
+ yield
14
+ end
15
+ end
16
+
17
+ def icon_link(icon:, href:, selected: false)
18
+ if selected
19
+ state_classes = "border-blue-700 text-zinc-700 **:[svg]:stroke-blue-700 font-semibold"
20
+ else
21
+ state_classes = "border-transparent text-zinc-500 hover:border-zinc-200 hover:text-zinc-700 **:[svg]:stroke-zinc-400 hover:**:[svg]:stroke-zinc-700"
22
+ end
23
+
24
+ a(href:, class: "inline-flex items-center gap-2 py-1 #{state_classes}") do
25
+ div(class: "size-5 md:size-4") do
26
+ render RUI::Icon.new(icon)
27
+ end
28
+ span(class: "text-lg md:text-base") { yield }
29
+ end
30
+ end
31
+
32
+ def text_link(href:, selected: false)
33
+ if selected
34
+ state_classes = "border-blue-700 text-zinc-700 font-semibold"
35
+ else
36
+ state_classes = "border-transparent text-zinc-400 hover:border-zinc-200 hover:text-zinc-700"
37
+ end
38
+
39
+ a(href:, class: "text-zinc-400 px-5 py-1 border-l-3 #{state_classes}") do
40
+ span(class: "text-lg md:text-base") { yield }
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RUI::Navigation::Top < RUI::Base
4
+ def view_template(&)
5
+ div(class: "fixed top-0 left-0 right-0 bg-white flex flex-col z-50") do
6
+ section(class: "flex flex-row items-center justify-between gap-3 border-b border-zinc-300 p-3 lg:px-10", &)
7
+ section(class: "lg:hidden p-3 border-b border-zinc-300") do
8
+ render RUI::Buttons::Ghost.new(
9
+ icon: "menu",
10
+ data: { action: "navigation#toggle" }
11
+ )
12
+ end
13
+ end
14
+ end
15
+
16
+ def group(&)
17
+ section(class: "flex flex-row items-center gap-3", &)
18
+ end
19
+ end
@@ -1,51 +1,3 @@
1
- class RUI::Navigation < RUI::Base
2
- register_value_helper :request
1
+ # frozen_string_literal: true
3
2
 
4
- def view_template
5
- div(class: "rui:flex rui:flex-col rui:sticky rui:top-0 rui:max-h-screen rui:overflow-y-auto rui:mx-10 rui:py-10") do
6
- yield
7
- end
8
- end
9
-
10
- def section_heading
11
- p(class: "rui:pt-8 rui:pb-4 rui:mt-6 rui:text-sm rui:font-semibold rui:uppercase rui:text-zinc-400 rui:border-t rui:border-zinc-200") do
12
- yield
13
- end
14
- end
15
-
16
- def icon_link(href:, icon:)
17
- if request.path == href
18
- state_classes = "rui:border-blue-700 rui:text-zinc-700 rui:**:[svg]:stroke-blue-700"
19
- else
20
- state_classes = "rui:border-transparent rui:text-zinc-400 rui:hover:border-zinc-200 rui:hover:text-zinc-700 rui:**:[svg]:stroke-zinc-300 rui:hover:**:[svg]:stroke-zinc-700"
21
- end
22
-
23
- a(href:, class: "rui:inline-flex rui:items-center rui:gap-2 rui:py-1 #{state_classes}") do
24
- div(class: "rui:size-4") do
25
- render RUI::Icon.new(icon)
26
- end
27
- span { yield }
28
- end
29
- end
30
-
31
- def text_link(href)
32
- if request.path == href
33
- state_classes = "rui:border-blue-700 rui:text-zinc-700"
34
- else
35
- state_classes = "rui:border-transparent rui:text-zinc-400 rui:hover:border-zinc-200 rui:hover:text-zinc-700"
36
- end
37
-
38
- a(href:, class: "rui:text-zinc-400 rui:px-5 rui:py-1 rui:border-l-3 #{state_classes}") do
39
- span { yield }
40
- end
41
- end
42
-
43
- def coming_soon
44
- div(class: "rui:flex rui:flex-row rui:items-center") do
45
- span(class: "rui:text-zinc-400 rui:px-5 rui:py-1 rui:border-l-3 rui:border-transparent") do
46
- yield
47
- end
48
- render RUI::Badges::Gray.new { "Coming Soon" }
49
- end
50
- end
51
- end
3
+ module RUI::Navigation; end
data/lib/rui/slideout.rb CHANGED
@@ -1,17 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class RUI::Slideout < RUI::Base
2
4
  include Phlex::Rails::Helpers::TurboFrameTag
3
5
 
4
- def view_template
6
+ def view_template(&)
5
7
  turbo_frame_tag "slideout" do
6
- div(class: "rui:absolute rui:inset-0 rui:z-50", data: { controller: "slideout" }) do
7
- a(href: "#", class: "rui:cursor-default", data: { action: "slideout#hide" }) do
8
- div(id: "modal-curtain", class: "rui:w-screen rui:h-screen rui:bg-black rui:transition-opacity rui:opacity-75", data: { slideout_target: "curtain" })
8
+ div(class: "absolute inset-0 z-50", data: { controller: "slideout" }) do
9
+ a(href: "#", class: "cursor-default", data: { action: "slideout#hide" }) do
10
+ div(id: "modal-curtain", class: "w-screen h-screen bg-black transition-opacity opacity-75", data: { slideout_target: "curtain" })
9
11
  end
10
- div(class: "rui:right-0 rui:fixed rui:inset-y-0 rui:flex rui:max-w-1/2 rui:pointer-events-none") do
11
- div(class: "rui:w-screen rui:pointer-events-auto", data: { slideout_target: "slideout" }) do
12
- div(class: "rui:w-full rui:h-full rui:bg-white rui:shadow") do
13
- yield
14
- end
12
+ div(class: "right-0 fixed inset-y-0 flex max-w-1/2 pointer-events-none") do
13
+ div(class: "w-screen pointer-events-auto", data: { slideout_target: "slideout" }) do
14
+ div(class: "w-full h-full bg-white shadow", &)
15
15
  end
16
16
  end
17
17
  end
data/lib/rui/table.rb ADDED
@@ -0,0 +1,54 @@
1
+ class RUI::Table < RUI::Base
2
+ def initialize(rows)
3
+ @rows = rows
4
+ @columns = []
5
+ end
6
+
7
+ def view_template(&)
8
+ vanish(&)
9
+
10
+ table(class: "bg-white w-full table-auto border-collapse") do
11
+ thead(class: "bg-blue-50") do
12
+ @columns.each do |column|
13
+ th(class: "border border-zinc-300 py-2 px-2 #{align(column[:align])}") do
14
+ column[:header]
15
+ end
16
+ end
17
+ th(class: "border border-zinc-300 px-2 text-center") { "" }
18
+ end
19
+
20
+ tbody do
21
+ @rows.each do |row|
22
+ tr(class: "hover:bg-zinc-50") do
23
+ @columns.each do |column|
24
+ td(class: "border border-zinc-300 py-1 px-2 #{align(column[:align])}") do
25
+ column[:content].call(row)
26
+ end
27
+ end
28
+ td(class: "border border-zinc-300 py-1 px-2 text-center") do
29
+ div(class: "flex flex-row justify-center gap-3") do
30
+ render RUI::Buttons::Ghost.new(icon: "edit")
31
+ render RUI::Buttons::Ghost.new(icon: "archive")
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ def column(header, align = :left, &content)
41
+ @columns << { header:, align:, content: }
42
+ end
43
+
44
+ def align(align)
45
+ case align
46
+ when :right
47
+ "text-right"
48
+ when :center
49
+ "text-center"
50
+ else
51
+ "text-left"
52
+ end
53
+ end
54
+ end
data/lib/rui/text.rb CHANGED
@@ -1,19 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RUI::Text
2
4
  class Large < RUI::Base
3
5
  def view_template
4
- p(class: "rui:text-lg rui:text-zinc-700 rui:mb-4") { yield }
6
+ p(class: "text-lg text-zinc-700 mb-4", **@attrs) { yield }
5
7
  end
6
8
  end
7
9
 
8
10
  class Medium < RUI::Base
9
11
  def view_template
10
- p(class: "rui:text-base rui:text-zinc-700 rui:mb-4") { yield }
12
+ p(class: "text-base text-zinc-700 mb-4", **@attrs) { yield }
11
13
  end
12
14
  end
13
15
 
14
16
  class Small < RUI::Base
15
17
  def view_template
16
- p(class: "rui:text-sm rui:text-zinc-700 rui:mb-4") { yield }
18
+ p(class: "text-sm text-zinc-700 mb-4", **@attrs) { yield }
17
19
  end
18
20
  end
19
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relay_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - logicrelay
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 2025-03-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: phlex
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '4.5'
68
+ - !ruby/object:Gem::Dependency
69
+ name: nokogiri
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.18'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.18'
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: rake
70
84
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +107,34 @@ dependencies:
93
107
  - - ">="
94
108
  - !ruby/object:Gem::Version
95
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: guard-rspec
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
96
138
  - !ruby/object:Gem::Dependency
97
139
  name: guard-livereload
98
140
  requirement: !ruby/object:Gem::Requirement
@@ -148,10 +190,10 @@ extra_rdoc_files: []
148
190
  files:
149
191
  - LICENSE.txt
150
192
  - README.md
151
- - dist/relay_ui/relay_ui.css
152
193
  - lib/relay_ui.rb
153
194
  - lib/relay_ui/engine.rb
154
195
  - lib/relay_ui/version.rb
196
+ - lib/rui/badges.rb
155
197
  - lib/rui/badges/base.rb
156
198
  - lib/rui/badges/blue.rb
157
199
  - lib/rui/badges/gray.rb
@@ -160,26 +202,51 @@ files:
160
202
  - lib/rui/badges/red.rb
161
203
  - lib/rui/badges/yellow.rb
162
204
  - lib/rui/base.rb
205
+ - lib/rui/buttons.rb
163
206
  - lib/rui/buttons/base.rb
164
207
  - lib/rui/buttons/destructive.rb
165
208
  - lib/rui/buttons/ghost.rb
166
209
  - lib/rui/buttons/outline.rb
167
210
  - lib/rui/buttons/primary.rb
168
211
  - lib/rui/buttons/secondary.rb
212
+ - lib/rui/card.rb
213
+ - lib/rui/flash.rb
214
+ - lib/rui/forms.rb
215
+ - lib/rui/forms/checkbox.rb
216
+ - lib/rui/forms/email.rb
217
+ - lib/rui/forms/field_group.rb
218
+ - lib/rui/forms/label.rb
219
+ - lib/rui/forms/password.rb
220
+ - lib/rui/forms/phone.rb
221
+ - lib/rui/forms/radio.rb
222
+ - lib/rui/forms/select.rb
223
+ - lib/rui/forms/text.rb
224
+ - lib/rui/forms/textarea.rb
225
+ - lib/rui/helpers.rb
169
226
  - lib/rui/icon.rb
227
+ - lib/rui/layout.rb
228
+ - lib/rui/layout/body.rb
229
+ - lib/rui/layout/main.rb
230
+ - lib/rui/layout/page.rb
231
+ - lib/rui/links.rb
170
232
  - lib/rui/links/base.rb
171
233
  - lib/rui/links/destructive.rb
172
234
  - lib/rui/links/ghost.rb
173
235
  - lib/rui/links/outline.rb
174
236
  - lib/rui/links/primary.rb
175
237
  - lib/rui/links/secondary.rb
238
+ - lib/rui/markdown.rb
176
239
  - lib/rui/markdown/generator.rb
177
240
  - lib/rui/markdown/safe.rb
178
241
  - lib/rui/markdown/safe_renderer.rb
179
242
  - lib/rui/markdown/unsafe.rb
180
243
  - lib/rui/markdown/unsafe_renderer.rb
181
244
  - lib/rui/navigation.rb
245
+ - lib/rui/navigation/menu_button.rb
246
+ - lib/rui/navigation/sidebar.rb
247
+ - lib/rui/navigation/top.rb
182
248
  - lib/rui/slideout.rb
249
+ - lib/rui/table.rb
183
250
  - lib/rui/text.rb
184
251
  homepage: https://www.relayui.com
185
252
  licenses: