solrengine-ui 0.1.0 → 0.1.1

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: e2bc2bd3aeb36e1145142d929300a08d854a330cd65c71d68dfece9c1767e018
4
- data.tar.gz: 80de3bf17e3233c33a9fded9bbc729862e04d0df498c7c4f112b7f2cc27e92de
3
+ metadata.gz: 197b6db92ceb99c4cc092b2d7696a5017c4d25d2550c66eb7194288ca5bfb4d9
4
+ data.tar.gz: 44240c5b4f42f3ca739fd7710da5e62e9344a1482cb36a59aadd709db8e55034
5
5
  SHA512:
6
- metadata.gz: b2ff1de5ef92fcb51ff9f6fdaffb62c1537acb5d93807c6474fce68555213d0adab10559469477b11515a0cc65c27c41aec72f6ffe5b6b6986160630451bf469
7
- data.tar.gz: 2961bafc62c4c0174dfa678f579de14276805a97d4607da9906caa343d6ff271bbc88c6c292ef91ce027c21f7edfc182dd32d9323c85b22ffc7c29fc62259d67
6
+ metadata.gz: 627316c5de0fdad3ecd9df1238d0382d8190455bffa8fac3b4a6a7b3d1e0fcc3a167d25defe1f2c8e40f740c9f64c7a365f97fdf45de1e9272352997a96948dd
7
+ data.tar.gz: 1fe9f7f7678ef3d99fd1efc9a2e3965f8b7a015dfb6b13f196ad4c56b20fd5b59c041ebb248d02419f65af51944cd9d723502147cc92bf631000b7448a91d8d1
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 %>
@@ -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>
@@ -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,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def add_tailwind_source
9
+ css_file = "app/assets/stylesheets/application.tailwind.css"
10
+ return unless File.exist?(css_file)
11
+
12
+ content = File.read(css_file)
13
+ return if content.include?("solrengine-ui")
14
+
15
+ gem_path = Gem.loaded_specs["solrengine-ui"]&.full_gem_path
16
+ return unless gem_path
17
+
18
+ append_to_file css_file, "\n/* SolRengine UI components */\n@source \"#{gem_path}/app\";\n"
19
+ end
20
+
21
+ def add_lookbook_route
22
+ route_file = "config/routes.rb"
23
+ content = File.read(route_file)
24
+ return if content.include?("Lookbook")
25
+
26
+ inject_into_file route_file, after: "Rails.application.routes.draw do\n" do
27
+ " mount Lookbook::Engine, at: \"/lookbook\" if Rails.env.development?\n\n"
28
+ end
29
+ end
30
+
31
+ def add_lookbook_preview_path
32
+ app_file = "config/application.rb"
33
+ content = File.read(app_file)
34
+ return if content.include?("lookbook.preview_paths")
35
+
36
+ inject_into_file app_file, before: /^ end/ do
37
+ <<~RUBY
38
+
39
+ # SolRengine UI Lookbook previews
40
+ config.lookbook.preview_paths << File.join(Gem.loaded_specs["solrengine-ui"].full_gem_path, "previews") if defined?(Lookbook)
41
+ RUBY
42
+ end
43
+ end
44
+
45
+ def show_post_install
46
+ say "\n SolRengine UI installed!", :green
47
+ say ""
48
+ say " Next steps:"
49
+ say " 1. Add gem 'lookbook' to your Gemfile (development group) if not already added"
50
+ say " 2. yarn add @solrengine/ui (for Stimulus controllers)"
51
+ say " 3. bin/dev and visit /lookbook to see all components"
52
+ say ""
53
+ end
54
+ end
55
+ end
56
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Solrengine
4
4
  module Ui
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class AddressComponentPreview < Lookbook::Preview
6
+ # @label Default (copyable)
7
+ def default
8
+ render Solrengine::Ui::AddressComponent.new(
9
+ address: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
10
+ )
11
+ end
12
+
13
+ # @label With explorer link
14
+ def with_explorer
15
+ render Solrengine::Ui::AddressComponent.new(
16
+ address: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
17
+ explorer: true,
18
+ network: "mainnet-beta"
19
+ )
20
+ end
21
+
22
+ # @label Not copyable (devnet)
23
+ def not_copyable_devnet
24
+ render Solrengine::Ui::AddressComponent.new(
25
+ address: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
26
+ copyable: false,
27
+ explorer: true,
28
+ network: "devnet"
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class AppBarComponentPreview < Lookbook::Preview
6
+ # @label Default (with logo and wallet)
7
+ def default
8
+ render Solrengine::Ui::AppBarComponent.new do |bar|
9
+ bar.with_logo do
10
+ tag.span("SolRengine", class: "text-lg font-bold text-gray-900 dark:text-white")
11
+ end
12
+ bar.with_wallet_button do
13
+ render Solrengine::Ui::WalletButtonComponent.new
14
+ end
15
+ end
16
+ end
17
+
18
+ # @label With network badge
19
+ def with_network_badge
20
+ render Solrengine::Ui::AppBarComponent.new do |bar|
21
+ bar.with_logo do
22
+ tag.span("SolRengine", class: "text-lg font-bold text-gray-900 dark:text-white")
23
+ end
24
+ bar.with_network_badge do
25
+ render Solrengine::Ui::NetworkBadgeComponent.new(network: "devnet")
26
+ end
27
+ bar.with_wallet_button do
28
+ render Solrengine::Ui::WalletButtonComponent.new
29
+ end
30
+ end
31
+ end
32
+
33
+ # @label With nav links
34
+ def with_nav_links
35
+ user = OpenStruct.new(wallet_address: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU")
36
+ render Solrengine::Ui::AppBarComponent.new do |bar|
37
+ bar.with_logo do
38
+ tag.span("SolRengine", class: "text-lg font-bold text-gray-900 dark:text-white")
39
+ end
40
+ bar.with_nav_link do
41
+ tag.a("Dashboard", href: "/dashboard", class: "text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors")
42
+ end
43
+ bar.with_nav_link do
44
+ tag.a("History", href: "/history", class: "text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors")
45
+ end
46
+ bar.with_network_badge do
47
+ render Solrengine::Ui::NetworkBadgeComponent.new(network: "mainnet-beta")
48
+ end
49
+ bar.with_wallet_button do
50
+ render Solrengine::Ui::WalletButtonComponent.new(current_user: user)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class BadgeComponentPreview < Lookbook::Preview
6
+ # @label Success
7
+ def success
8
+ render Solrengine::Ui::BadgeComponent.new(text: "Confirmed", variant: :success)
9
+ end
10
+
11
+ # @label Warning
12
+ def warning
13
+ render Solrengine::Ui::BadgeComponent.new(text: "Pending", variant: :warning)
14
+ end
15
+
16
+ # @label Error
17
+ def error
18
+ render Solrengine::Ui::BadgeComponent.new(text: "Failed", variant: :error)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class BalanceComponentPreview < Lookbook::Preview
6
+ # @label From SOL amount (medium)
7
+ def from_sol
8
+ render Solrengine::Ui::BalanceComponent.new(sol: 1.5)
9
+ end
10
+
11
+ # @label From lamports (small)
12
+ def from_lamports
13
+ render Solrengine::Ui::BalanceComponent.new(lamports: 500_000_000, size: :sm)
14
+ end
15
+
16
+ # @label Large without symbol
17
+ def large_no_symbol
18
+ render Solrengine::Ui::BalanceComponent.new(sol: 42.123456789, size: :lg, show_symbol: false)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class ExplorerLinkComponentPreview < Lookbook::Preview
6
+ # @label Address link (mainnet)
7
+ def address_mainnet
8
+ render Solrengine::Ui::ExplorerLinkComponent.new(
9
+ value: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
10
+ )
11
+ end
12
+
13
+ # @label Transaction link (mainnet)
14
+ def transaction_mainnet
15
+ render Solrengine::Ui::ExplorerLinkComponent.new(
16
+ value: "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQU",
17
+ type: :tx
18
+ )
19
+ end
20
+
21
+ # @label Devnet address (not truncated)
22
+ def devnet_full
23
+ render Solrengine::Ui::ExplorerLinkComponent.new(
24
+ value: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
25
+ network: "devnet",
26
+ truncate: false
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class NetworkBadgeComponentPreview < Lookbook::Preview
6
+ # @label Mainnet
7
+ def mainnet
8
+ render Solrengine::Ui::NetworkBadgeComponent.new(network: "mainnet-beta")
9
+ end
10
+
11
+ # @label Devnet
12
+ def devnet
13
+ render Solrengine::Ui::NetworkBadgeComponent.new(network: "devnet")
14
+ end
15
+
16
+ # @label Testnet
17
+ def testnet
18
+ render Solrengine::Ui::NetworkBadgeComponent.new(network: "testnet")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class NotificationComponentPreview < Lookbook::Preview
6
+ # @label Success
7
+ def success
8
+ render Solrengine::Ui::NotificationComponent.new(
9
+ message: "Transaction confirmed successfully!",
10
+ type: :success,
11
+ explorer_url: "https://solscan.io/tx/abc123"
12
+ )
13
+ end
14
+
15
+ # @label Error
16
+ def error
17
+ render Solrengine::Ui::NotificationComponent.new(
18
+ message: "Transaction failed. Please try again.",
19
+ type: :error
20
+ )
21
+ end
22
+
23
+ # @label Info (non-dismissible)
24
+ def info_non_dismissible
25
+ render Solrengine::Ui::NotificationComponent.new(
26
+ message: "Your wallet is connected to Devnet.",
27
+ type: :info,
28
+ dismissible: false
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class ThemeToggleComponentPreview < Lookbook::Preview
6
+ # @label Default
7
+ def default
8
+ render Solrengine::Ui::ThemeToggleComponent.new
9
+ end
10
+
11
+ # @label In a flex container
12
+ def in_flex_container
13
+ render_with_template(
14
+ template: "solrengine/ui/theme_toggle_component_preview/in_flex_container"
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solrengine
4
+ module Ui
5
+ class WalletButtonComponentPreview < Lookbook::Preview
6
+ # @label Disconnected
7
+ def disconnected
8
+ render Solrengine::Ui::WalletButtonComponent.new
9
+ end
10
+
11
+ # @label Connected
12
+ def connected
13
+ user = OpenStruct.new(wallet_address: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU")
14
+ render Solrengine::Ui::WalletButtonComponent.new(current_user: user)
15
+ end
16
+
17
+ # @label Connected (custom paths)
18
+ def connected_custom_paths
19
+ user = OpenStruct.new(wallet_address: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin")
20
+ render Solrengine::Ui::WalletButtonComponent.new(
21
+ current_user: user,
22
+ login_path: "/login",
23
+ logout_path: "/logout"
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrengine-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Ferrer
@@ -81,9 +81,19 @@ files:
81
81
  - app/components/solrengine/ui/theme_toggle_component.rb
82
82
  - app/components/solrengine/ui/wallet_button_component.html.erb
83
83
  - app/components/solrengine/ui/wallet_button_component.rb
84
+ - lib/generators/solrengine/ui/install_generator.rb
84
85
  - lib/solrengine/ui.rb
85
86
  - lib/solrengine/ui/engine.rb
86
87
  - lib/solrengine/ui/version.rb
88
+ - previews/solrengine/ui/address_component_preview.rb
89
+ - previews/solrengine/ui/app_bar_component_preview.rb
90
+ - previews/solrengine/ui/badge_component_preview.rb
91
+ - previews/solrengine/ui/balance_component_preview.rb
92
+ - previews/solrengine/ui/explorer_link_component_preview.rb
93
+ - previews/solrengine/ui/network_badge_component_preview.rb
94
+ - previews/solrengine/ui/notification_component_preview.rb
95
+ - previews/solrengine/ui/theme_toggle_component_preview.rb
96
+ - previews/solrengine/ui/wallet_button_component_preview.rb
87
97
  homepage: https://github.com/solrengine/ui
88
98
  licenses:
89
99
  - MIT