solrengine-ui 0.1.0 → 0.2.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +181 -16
  3. data/app/components/solrengine/ui/address_component.html.erb +1 -1
  4. data/app/components/solrengine/ui/airdrop_button_component.html.erb +14 -0
  5. data/app/components/solrengine/ui/airdrop_button_component.rb +19 -0
  6. data/app/components/solrengine/ui/card_component.html.erb +17 -0
  7. data/app/components/solrengine/ui/card_component.rb +17 -0
  8. data/app/components/solrengine/ui/collapse_component.html.erb +8 -0
  9. data/app/components/solrengine/ui/collapse_component.rb +16 -0
  10. data/app/components/solrengine/ui/dropdown_component.html.erb +10 -0
  11. data/app/components/solrengine/ui/dropdown_component.rb +20 -0
  12. data/app/components/solrengine/ui/footer_component.html.erb +16 -0
  13. data/app/components/solrengine/ui/footer_component.rb +10 -0
  14. data/app/components/solrengine/ui/modal_component.html.erb +27 -0
  15. data/app/components/solrengine/ui/modal_component.rb +28 -0
  16. data/app/components/solrengine/ui/notification_component.html.erb +2 -2
  17. data/app/components/solrengine/ui/send_transaction_form_component.html.erb +27 -0
  18. data/app/components/solrengine/ui/send_transaction_form_component.rb +19 -0
  19. data/app/components/solrengine/ui/theme_toggle_component.html.erb +1 -1
  20. data/app/components/solrengine/ui/token_icon_component.html.erb +7 -0
  21. data/app/components/solrengine/ui/token_icon_component.rb +29 -0
  22. data/app/components/solrengine/ui/token_list_component.html.erb +11 -0
  23. data/app/components/solrengine/ui/token_list_component.rb +14 -0
  24. data/app/components/solrengine/ui/token_row_component.html.erb +17 -0
  25. data/app/components/solrengine/ui/token_row_component.rb +34 -0
  26. data/app/components/solrengine/ui/transaction_status_component.html.erb +9 -0
  27. data/app/components/solrengine/ui/transaction_status_component.rb +35 -0
  28. data/lib/generators/solrengine/ui/install_generator.rb +56 -0
  29. data/lib/solrengine/ui/version.rb +1 -1
  30. data/previews/solrengine/ui/address_component_preview.rb +33 -0
  31. data/previews/solrengine/ui/airdrop_button_component_preview.rb +19 -0
  32. data/previews/solrengine/ui/app_bar_component_preview.rb +56 -0
  33. data/previews/solrengine/ui/badge_component_preview.rb +22 -0
  34. data/previews/solrengine/ui/balance_component_preview.rb +22 -0
  35. data/previews/solrengine/ui/card_component_preview.rb +26 -0
  36. data/previews/solrengine/ui/collapse_component_preview.rb +19 -0
  37. data/previews/solrengine/ui/dropdown_component_preview.rb +22 -0
  38. data/previews/solrengine/ui/explorer_link_component_preview.rb +31 -0
  39. data/previews/solrengine/ui/footer_component_preview.rb +13 -0
  40. data/previews/solrengine/ui/modal_component_preview.rb +18 -0
  41. data/previews/solrengine/ui/network_badge_component_preview.rb +22 -0
  42. data/previews/solrengine/ui/notification_component_preview.rb +33 -0
  43. data/previews/solrengine/ui/send_transaction_form_component_preview.rb +16 -0
  44. data/previews/solrengine/ui/theme_toggle_component_preview.rb +19 -0
  45. data/previews/solrengine/ui/token_icon_component_preview/sizes.html.erb +5 -0
  46. data/previews/solrengine/ui/token_icon_component_preview.rb +21 -0
  47. data/previews/solrengine/ui/token_list_component_preview.rb +19 -0
  48. data/previews/solrengine/ui/token_row_component_preview.rb +17 -0
  49. data/previews/solrengine/ui/transaction_status_component_preview.rb +26 -0
  50. data/previews/solrengine/ui/wallet_button_component_preview.rb +28 -0
  51. metadata +46 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2bc2bd3aeb36e1145142d929300a08d854a330cd65c71d68dfece9c1767e018
4
- data.tar.gz: 80de3bf17e3233c33a9fded9bbc729862e04d0df498c7c4f112b7f2cc27e92de
3
+ metadata.gz: 917bd58960b2d08fd11f97503c709abd8a292f51b3950b7eadfabdbd9f1b0a9e
4
+ data.tar.gz: 20458d17c03fda602eca17f7d5461d930b444e89463a8e736742200a4b8a9212
5
5
  SHA512:
6
- metadata.gz: b2ff1de5ef92fcb51ff9f6fdaffb62c1537acb5d93807c6474fce68555213d0adab10559469477b11515a0cc65c27c41aec72f6ffe5b6b6986160630451bf469
7
- data.tar.gz: 2961bafc62c4c0174dfa678f579de14276805a97d4607da9906caa343d6ff271bbc88c6c292ef91ce027c21f7edfc182dd32d9323c85b22ffc7c29fc62259d67
6
+ metadata.gz: 3e9c5fe51239d9aeba8c3cfdb5b943d880e47d6e1d1e9e6072614a67b4f3f43ade1a3b3c1aceaf84123f933b272ef763fba04c067a06d5862f55c804bee4c824
7
+ data.tar.gz: 95cb035aa44e7060cbeda754d9bfee8c8c1167148122dd986763849918e261679c765905b09fee63d97f85b720482a64c7f4d1e8a728b8f0bfd073ef9c6ea963
data/README.md CHANGED
@@ -1,35 +1,200 @@
1
- # Solrengine::Ui
1
+ # SolRengine UI
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/solrengine/ui`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A ViewComponent library for Solana dApps built with Ruby on Rails and [SolRengine](https://github.com/solrengine). Ships 9 ready-to-use components styled with Tailwind CSS, with built-in dark/light mode support and Lookbook previews for every component.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
7
+ Add the gem to your Gemfile:
8
+
9
+ ```ruby
10
+ gem "solrengine-ui", github: "solrengine/ui"
11
+
12
+ group :development do
13
+ gem "lookbook", ">= 2.0"
14
+ end
15
+ ```
10
16
 
11
- Install the gem and add to the application's Gemfile by executing:
17
+ Run the install generator:
12
18
 
13
19
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
20
+ bundle install
21
+ bin/rails generate solrengine:ui:install
15
22
  ```
16
23
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
24
+ Install the JavaScript package for Stimulus controllers:
18
25
 
19
26
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
27
+ yarn add @solrengine/ui
28
+ ```
29
+
30
+ ## Quick Example
31
+
32
+ ```erb
33
+ <%= render Solrengine::Ui::AppBarComponent.new do |bar| %>
34
+ <% bar.with_logo do %>
35
+ <span class="text-xl font-bold">My dApp</span>
36
+ <% end %>
37
+ <% bar.with_network_badge do %>
38
+ <%= render Solrengine::Ui::NetworkBadgeComponent.new(network: "devnet") %>
39
+ <% end %>
40
+ <% bar.with_wallet_button do %>
41
+ <%= render Solrengine::Ui::WalletButtonComponent.new(current_user: current_user) %>
42
+ <% end %>
43
+ <% end %>
44
+
45
+ <%= render Solrengine::Ui::BalanceComponent.new(lamports: 1_500_000_000, size: :lg) %>
46
+
47
+ <%= render Solrengine::Ui::AddressComponent.new(address: "So1R...xYz9", copyable: true) %>
48
+ ```
49
+
50
+ ## Component Reference
51
+
52
+ | Component | Props | Description |
53
+ |-----------|-------|-------------|
54
+ | `AddressComponent` | `address:`, `copyable: true`, `explorer: false`, `network: "mainnet-beta"` | Truncated wallet address with copy and explorer link |
55
+ | `AppBarComponent` | slots: `logo`, `wallet_button`, `network_badge`, `nav_links` | Top navigation bar with slots for logo, wallet, and nav |
56
+ | `BadgeComponent` | `text:`, `variant: :info` | Colored label badge (`:success`, `:warning`, `:error`, `:info`, `:purple`) |
57
+ | `BalanceComponent` | `lamports: nil`, `sol: nil`, `show_symbol: true`, `size: :md` | SOL balance display with auto-conversion from lamports |
58
+ | `ExplorerLinkComponent` | `value:`, `type: :address`, `network: "mainnet-beta"`, `truncate: true` | Link to Solscan/Solana Explorer for addresses or transactions |
59
+ | `NetworkBadgeComponent` | `network:` | Colored dot + label for mainnet-beta, devnet, or testnet |
60
+ | `NotificationComponent` | `message:`, `type: :info`, `dismissible: true`, `explorer_url: nil` | Flash-style notification with icon and optional explorer link |
61
+ | `ThemeToggleComponent` | _(none)_ | Dark/light mode toggle button |
62
+ | `WalletButtonComponent` | `current_user: nil`, `login_path: "/auth/login"`, `logout_path: "/auth/logout"` | Connect/disconnect wallet button with truncated address |
63
+
64
+ ## Usage Examples
65
+
66
+ ### AddressComponent
67
+
68
+ ```erb
69
+ <%= render Solrengine::Ui::AddressComponent.new(
70
+ address: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
71
+ copyable: true,
72
+ explorer: true,
73
+ network: "devnet"
74
+ ) %>
75
+ ```
76
+
77
+ ### AppBarComponent
78
+
79
+ ```erb
80
+ <%= render Solrengine::Ui::AppBarComponent.new do |bar| %>
81
+ <% bar.with_logo do %>
82
+ <span class="font-bold">My dApp</span>
83
+ <% end %>
84
+ <% bar.with_nav_link do %>
85
+ <%= link_to "Dashboard", dashboard_path %>
86
+ <% end %>
87
+ <% bar.with_nav_link do %>
88
+ <%= link_to "Transactions", transactions_path %>
89
+ <% end %>
90
+ <% bar.with_network_badge do %>
91
+ <%= render Solrengine::Ui::NetworkBadgeComponent.new(network: "devnet") %>
92
+ <% end %>
93
+ <% bar.with_wallet_button do %>
94
+ <%= render Solrengine::Ui::WalletButtonComponent.new(current_user: current_user) %>
95
+ <% end %>
96
+ <% end %>
21
97
  ```
22
98
 
23
- ## Usage
99
+ ### BadgeComponent
100
+
101
+ ```erb
102
+ <%= render Solrengine::Ui::BadgeComponent.new(text: "Confirmed", variant: :success) %>
103
+ <%= render Solrengine::Ui::BadgeComponent.new(text: "Pending", variant: :warning) %>
104
+ ```
105
+
106
+ ### BalanceComponent
107
+
108
+ ```erb
109
+ <%# From lamports %>
110
+ <%= render Solrengine::Ui::BalanceComponent.new(lamports: 2_500_000_000, size: :lg) %>
111
+
112
+ <%# From SOL %>
113
+ <%= render Solrengine::Ui::BalanceComponent.new(sol: 1.5, show_symbol: false, size: :sm) %>
114
+ ```
24
115
 
25
- TODO: Write usage instructions here
116
+ ### ExplorerLinkComponent
26
117
 
27
- ## Development
118
+ ```erb
119
+ <%# Address link %>
120
+ <%= render Solrengine::Ui::ExplorerLinkComponent.new(
121
+ value: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
122
+ type: :address
123
+ ) %>
124
+
125
+ <%# Transaction link %>
126
+ <%= render Solrengine::Ui::ExplorerLinkComponent.new(
127
+ value: "5UfDuX...",
128
+ type: :tx,
129
+ network: "devnet"
130
+ ) %>
131
+ ```
132
+
133
+ ### NetworkBadgeComponent
134
+
135
+ ```erb
136
+ <%= render Solrengine::Ui::NetworkBadgeComponent.new(network: "mainnet-beta") %>
137
+ <%= render Solrengine::Ui::NetworkBadgeComponent.new(network: "devnet") %>
138
+ ```
139
+
140
+ ### NotificationComponent
141
+
142
+ ```erb
143
+ <%= render Solrengine::Ui::NotificationComponent.new(
144
+ message: "Transaction confirmed!",
145
+ type: :success,
146
+ explorer_url: "https://solscan.io/tx/5UfDuX..."
147
+ ) %>
148
+
149
+ <%= render Solrengine::Ui::NotificationComponent.new(
150
+ message: "Insufficient balance",
151
+ type: :error,
152
+ dismissible: false
153
+ ) %>
154
+ ```
155
+
156
+ ### ThemeToggleComponent
157
+
158
+ ```erb
159
+ <%= render Solrengine::Ui::ThemeToggleComponent.new %>
160
+ ```
161
+
162
+ ### WalletButtonComponent
163
+
164
+ ```erb
165
+ <%= render Solrengine::Ui::WalletButtonComponent.new(
166
+ current_user: current_user,
167
+ login_path: "/auth/login",
168
+ logout_path: "/auth/logout"
169
+ ) %>
170
+ ```
171
+
172
+ ## Dark / Light Mode
173
+
174
+ All components include `dark:` Tailwind variants out of the box. Add the `dark` class to your `<html>` element to activate dark mode, or use the `ThemeToggleComponent` to let users switch. No extra configuration needed.
175
+
176
+ ## Lookbook
177
+
178
+ After running the install generator, visit `/lookbook` in development to browse every component with live previews. The gem ships Lookbook preview classes for all 9 components.
179
+
180
+ To add Lookbook manually (without the generator):
181
+
182
+ ```ruby
183
+ # config/routes.rb
184
+ mount Lookbook::Engine, at: "/lookbook" if Rails.env.development?
185
+
186
+ # config/application.rb
187
+ config.lookbook.preview_paths << File.join(
188
+ Gem.loaded_specs["solrengine-ui"].full_gem_path, "previews"
189
+ ) if defined?(Lookbook)
190
+ ```
28
191
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
192
+ ## Links
30
193
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
194
+ - [SolRengine](https://github.com/solrengine) -- the framework for building Solana dApps with Ruby on Rails
195
+ - [Source](https://github.com/solrengine/ui)
196
+ - [Changelog](https://github.com/solrengine/ui/blob/main/CHANGELOG.md)
32
197
 
33
- ## Contributing
198
+ ## License
34
199
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/solrengine-ui.
200
+ MIT
@@ -1,6 +1,6 @@
1
1
  <span class="inline-flex items-center gap-1.5">
2
2
  <% if copyable %>
3
- <button data-controller="clipboard" data-clipboard-text-value="<%= address %>" class="text-gray-400 dark:text-gray-400 text-xs font-mono bg-gray-100 dark:bg-gray-800 px-2.5 py-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors cursor-pointer">
3
+ <button data-controller="sui-clipboard" data-sui-clipboard-text-value="<%= address %>" class="text-gray-400 dark:text-gray-400 text-xs font-mono bg-gray-100 dark:bg-gray-800 px-2.5 py-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors cursor-pointer">
4
4
  <%= truncated_address %>
5
5
  </button>
6
6
  <% else %>
@@ -0,0 +1,14 @@
1
+ <% if devnet? %>
2
+ <form action="<%= action_url %>" method="post" class="inline">
3
+ <input type="hidden" name="address" value="<%= address %>" />
4
+ <input type="hidden" name="network" value="<%= network %>" />
5
+ <button type="submit" class="inline-flex items-center gap-2 px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-white font-medium rounded-lg text-sm transition-colors cursor-pointer">
6
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
7
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" />
8
+ </svg>
9
+ Airdrop 1 SOL
10
+ </button>
11
+ </form>
12
+ <% else %>
13
+ <span class="text-xs text-gray-400 dark:text-gray-500">Airdrop available on devnet/testnet only</span>
14
+ <% end %>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class AirdropButtonComponent < ViewComponent::Base
6
+ attr_reader :address, :network, :action_url
7
+
8
+ def initialize(address:, network: "devnet", action_url: "/airdrop")
9
+ @address = address
10
+ @network = network
11
+ @action_url = action_url
12
+ end
13
+
14
+ def devnet?
15
+ network == "devnet" || network == "testnet"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ <div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden">
2
+ <% if header? %>
3
+ <div class="px-5 py-4 border-b border-gray-200 dark:border-gray-800">
4
+ <%= header %>
5
+ </div>
6
+ <% end %>
7
+ <% if body? %>
8
+ <div class="<%= 'px-5 py-4' if padding %>">
9
+ <%= body %>
10
+ </div>
11
+ <% end %>
12
+ <% if footer? %>
13
+ <div class="px-5 py-3 border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-950">
14
+ <%= footer %>
15
+ </div>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class CardComponent < ViewComponent::Base
6
+ renders_one :header
7
+ renders_one :body
8
+ renders_one :footer
9
+
10
+ attr_reader :padding
11
+
12
+ def initialize(padding: true)
13
+ @padding = padding
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ <div data-controller="sui-collapse" data-sui-collapse-expanded-value="<%= expanded %>">
2
+ <button data-action="click->sui-collapse#toggle" class="w-full cursor-pointer">
3
+ <%= trigger %>
4
+ </button>
5
+ <div data-sui-collapse-target="content" class="<%= 'hidden' unless expanded %> overflow-hidden">
6
+ <%= content %>
7
+ </div>
8
+ </div>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class CollapseComponent < ViewComponent::Base
6
+ renders_one :trigger
7
+ renders_one :content
8
+
9
+ attr_reader :expanded
10
+
11
+ def initialize(expanded: false)
12
+ @expanded = expanded
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ <div data-controller="sui-dropdown" class="relative inline-block">
2
+ <div data-action="click->sui-dropdown#toggle">
3
+ <%= trigger %>
4
+ </div>
5
+ <div data-sui-dropdown-target="menu" class="hidden absolute z-40 <%= align_class %> mt-2 w-48 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-lg shadow-lg py-1">
6
+ <% items.each do |item| %>
7
+ <%= item %>
8
+ <% end %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class DropdownComponent < ViewComponent::Base
6
+ renders_one :trigger
7
+ renders_many :items
8
+
9
+ attr_reader :align
10
+
11
+ def initialize(align: :right)
12
+ @align = align
13
+ end
14
+
15
+ def align_class
16
+ align == :left ? "left-0" : "right-0"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ <footer class="border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-950 px-6 py-8">
2
+ <div class="max-w-7xl mx-auto">
3
+ <% if links.any? %>
4
+ <div class="flex flex-wrap gap-6 justify-center mb-4">
5
+ <% links.each do |link| %>
6
+ <%= link %>
7
+ <% end %>
8
+ </div>
9
+ <% end %>
10
+ <% if powered_by? %>
11
+ <div class="text-center text-sm text-gray-500 dark:text-gray-400">
12
+ <%= powered_by %>
13
+ </div>
14
+ <% end %>
15
+ </div>
16
+ </footer>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class FooterComponent < ViewComponent::Base
6
+ renders_one :powered_by
7
+ renders_many :links
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ <div data-controller="sui-modal" class="hidden fixed inset-0 z-50">
2
+ <div data-sui-modal-target="backdrop" data-action="click->sui-modal#backdropClick" class="absolute inset-0 bg-black/50 backdrop-blur-sm"></div>
3
+ <div class="relative flex items-center justify-center min-h-screen p-4">
4
+ <div data-sui-modal-target="panel" class="relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl shadow-xl w-full <%= size_class %>">
5
+ <% if title %>
6
+ <div class="flex items-center justify-between px-5 py-4 border-b border-gray-200 dark:border-gray-800">
7
+ <h3 class="text-lg font-semibold text-gray-900 dark:text-white"><%= title %></h3>
8
+ <button data-action="click->sui-modal#close" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer">
9
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
10
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
11
+ </svg>
12
+ </button>
13
+ </div>
14
+ <% end %>
15
+ <% if body? %>
16
+ <div class="px-5 py-4">
17
+ <%= body %>
18
+ </div>
19
+ <% end %>
20
+ <% if actions? %>
21
+ <div class="px-5 py-3 border-t border-gray-200 dark:border-gray-800 flex justify-end gap-2">
22
+ <%= actions %>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ </div>
27
+ </div>
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class ModalComponent < ViewComponent::Base
6
+ renders_one :body
7
+ renders_one :actions
8
+
9
+ attr_reader :title, :size
10
+
11
+ SIZES = {
12
+ sm: "max-w-sm",
13
+ md: "max-w-md",
14
+ lg: "max-w-lg",
15
+ xl: "max-w-xl"
16
+ }.freeze
17
+
18
+ def initialize(title: nil, size: :md)
19
+ @title = title
20
+ @size = size
21
+ end
22
+
23
+ def size_class
24
+ SIZES.fetch(size, SIZES[:md])
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,4 +1,4 @@
1
- <div data-controller="notification" class="p-4 rounded-xl border text-sm flex items-start gap-3 <%= variant_classes %>">
1
+ <div data-controller="sui-notification" class="p-4 rounded-xl border text-sm flex items-start gap-3 <%= variant_classes %>">
2
2
  <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0 mt-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
3
3
  <path stroke-linecap="round" stroke-linejoin="round" d="<%= icon_path %>" />
4
4
  </svg>
@@ -11,7 +11,7 @@
11
11
  <% end %>
12
12
  </div>
13
13
  <% if dismissible %>
14
- <button data-action="click->notification#dismiss" class="shrink-0 mt-0.5 hover:opacity-70 transition-opacity cursor-pointer">
14
+ <button data-action="click->sui-notification#dismiss" class="shrink-0 mt-0.5 hover:opacity-70 transition-opacity cursor-pointer">
15
15
  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
16
16
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
17
17
  </svg>
@@ -0,0 +1,27 @@
1
+ <div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-5">
2
+ <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Send SOL</h3>
3
+ <% if connected? %>
4
+ <form action="<%= action_url %>" method="post" class="space-y-4">
5
+ <div>
6
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">From</label>
7
+ <div class="text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 px-3 py-2 rounded-lg">
8
+ <%= wallet_address %>
9
+ </div>
10
+ </div>
11
+ <div>
12
+ <label for="sui-send-recipient" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Recipient</label>
13
+ <input type="text" name="recipient" id="sui-send-recipient" placeholder="Solana address" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" required />
14
+ </div>
15
+ <div>
16
+ <label for="sui-send-amount" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Amount (SOL)</label>
17
+ <input type="number" name="amount" id="sui-send-amount" step="0.000000001" min="0" placeholder="0.0" class="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" required />
18
+ </div>
19
+ <input type="hidden" name="network" value="<%= network %>" />
20
+ <button type="submit" class="w-full py-2.5 px-4 bg-purple-600 hover:bg-purple-700 text-white font-medium rounded-lg text-sm transition-colors cursor-pointer">
21
+ Send Transaction
22
+ </button>
23
+ </form>
24
+ <% else %>
25
+ <p class="text-sm text-gray-500 dark:text-gray-400 text-center py-4">Connect your wallet to send SOL</p>
26
+ <% end %>
27
+ </div>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class SendTransactionFormComponent < ViewComponent::Base
6
+ attr_reader :wallet_address, :network, :action_url
7
+
8
+ def initialize(wallet_address: nil, network: "devnet", action_url: "/transfers")
9
+ @wallet_address = wallet_address
10
+ @network = network
11
+ @action_url = action_url
12
+ end
13
+
14
+ def connected?
15
+ wallet_address.present?
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
- <button data-controller="theme" data-action="click->theme#toggle" class="p-2 rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
1
+ <button data-controller="sui-theme" data-action="click->sui-theme#toggle" class="p-2 rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
2
2
  <%# Sun icon — visible in dark mode %>
3
3
  <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 hidden dark:block" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
4
4
  <path stroke-linecap="round" stroke-linejoin="round" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
@@ -0,0 +1,7 @@
1
+ <% if uri %>
2
+ <img src="<%= uri %>" alt="<%= symbol %>" class="<%= size_class %> rounded-full" loading="lazy" />
3
+ <% else %>
4
+ <div class="<%= size_class %> rounded-full bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-400 flex items-center justify-center text-sm font-bold">
5
+ <%= fallback_letter %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class TokenIconComponent < ViewComponent::Base
6
+ SIZES = {
7
+ sm: "h-6 w-6",
8
+ md: "h-8 w-8",
9
+ lg: "h-10 w-10"
10
+ }.freeze
11
+
12
+ attr_reader :uri, :symbol, :size
13
+
14
+ def initialize(symbol:, uri: nil, size: :md)
15
+ @uri = uri
16
+ @symbol = symbol
17
+ @size = size
18
+ end
19
+
20
+ def size_class
21
+ SIZES.fetch(size, SIZES[:md])
22
+ end
23
+
24
+ def fallback_letter
25
+ symbol&.first&.upcase || "?"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ <div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden divide-y divide-gray-200 dark:divide-gray-800">
2
+ <% if tokens.empty? %>
3
+ <div class="px-4 py-8 text-center text-gray-500 dark:text-gray-400 text-sm">
4
+ No tokens found
5
+ </div>
6
+ <% else %>
7
+ <% tokens.each do |token| %>
8
+ <%= render Solrengine::Ui::TokenRowComponent.new(token: token) %>
9
+ <% end %>
10
+ <% end %>
11
+ </div>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class TokenListComponent < ViewComponent::Base
6
+ attr_reader :tokens
7
+
8
+ # tokens: array of { symbol:, name:, balance:, icon_uri:, usd_value: }
9
+ def initialize(tokens:)
10
+ @tokens = tokens
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ <div class="flex items-center justify-between py-3 px-4 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors">
2
+ <div class="flex items-center gap-3">
3
+ <%= render Solrengine::Ui::TokenIconComponent.new(symbol: symbol, uri: icon_uri, size: :md) %>
4
+ <div>
5
+ <div class="font-medium text-gray-900 dark:text-white text-sm"><%= symbol %></div>
6
+ <% if name %>
7
+ <div class="text-xs text-gray-500 dark:text-gray-400"><%= name %></div>
8
+ <% end %>
9
+ </div>
10
+ </div>
11
+ <div class="text-right">
12
+ <div class="font-medium text-gray-900 dark:text-white text-sm"><%= balance %></div>
13
+ <% if usd_value %>
14
+ <div class="text-xs text-gray-500 dark:text-gray-400">$<%= usd_value %></div>
15
+ <% end %>
16
+ </div>
17
+ </div>
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class TokenRowComponent < ViewComponent::Base
6
+ attr_reader :token
7
+
8
+ # token: { symbol:, name:, balance:, icon_uri:, usd_value: }
9
+ def initialize(token:)
10
+ @token = token
11
+ end
12
+
13
+ def symbol
14
+ token[:symbol]
15
+ end
16
+
17
+ def name
18
+ token[:name]
19
+ end
20
+
21
+ def balance
22
+ token[:balance]
23
+ end
24
+
25
+ def icon_uri
26
+ token[:icon_uri]
27
+ end
28
+
29
+ def usd_value
30
+ token[:usd_value]
31
+ end
32
+ end
33
+ end
34
+ end