Class: StyleGuideController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- StyleGuideController
- Includes:
- NeonSakura::IconHelper, NeonSakura::ThemeHelper, Pagy::Backend, Pagy::Method
- Defined in:
- app/controllers/style_guide_controller.rb
Overview
Controller for the style guide - development/test only Displays all UI components, icons, themes, and code examples
Instance Method Summary collapse
Methods included from NeonSakura::ThemeHelper
#available_themes_json, #current_theme, #render_theme_icon, #theme_count, #theme_data_attributes, #theme_switcher_mode
Methods included from NeonSakura::IconHelper
#available_icons, #icon_exists?, #render_icon, #render_icon_list, #render_login_logo
Instance Method Details
#index ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/style_guide_controller.rb', line 31 def index @page_title = "Neon Sakura Style Guide" # Collect all icons dynamically @icons = available_icons # Collect all images dynamically @images = available_images # Set up Pagy pagination examples if enabled @pagy_enabled = NeonSakura.configuration.style_guide_pagy_examples @pagy_available = false @pagy_error = nil if @pagy_enabled # Generate dummy data for Pagy pagination examples @pagy_items = generate_pagy_dummy_data # Try to set up Pagy if available if defined?(Pagy) begin # Pagy 43+ uses pagy(:offset, collection, **options) # Older Pagy versions use pagy_array(collection, **options) if defined?(Pagy::Method) # Pagy 43+ API @pagy, @page_items = pagy(:offset, @pagy_items, limit: 10) elsif respond_to?(:pagy_array) # Older Pagy API with array extra @pagy, @page_items = pagy_array(@pagy_items, limit: 10) else raise NoMethodError, "No compatible Pagy pagination method found" end @pagy_available = true rescue StandardError => e # Pagy initialization failed - provide helpful error message @pagy_error = "Pagy pagination examples failed to initialize. " \ "Error: #{e.}. " \ "To disable these examples, set config.style_guide_pagy_examples = false in your " \ "NeonSakura configuration." end else # Pagy not installed @pagy_error = "Pagy gem is not installed. Add 'gem \"pagy\"' to your Gemfile, " \ "or disable Pagy examples by setting config.style_guide_pagy_examples = false" end end # Theme information @available_themes = NeonSakura.config.available_themes @current_theme = current_theme end |