Class: EasyAdmin::SettingsSidebarComponent

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
app/components/easy_admin/settings_sidebar_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(feature_toggles: [], expanded: false) ⇒ SettingsSidebarComponent

Returns a new instance of SettingsSidebarComponent.



5
6
7
8
# File 'app/components/easy_admin/settings_sidebar_component.rb', line 5

def initialize(feature_toggles: [], expanded: false)
  @feature_toggles = feature_toggles
  @expanded = expanded
end

Instance Method Details

#view_template ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
82
83
84
85
86
87
88
89
# File 'app/components/easy_admin/settings_sidebar_component.rb', line 10

def view_template
  div(
    id: "settings-sidebar",
    class: "fixed inset-y-0 right-0 z-50 w-96 bg-white shadow-2xl transform transition-all duration-500 ease-out #{@expanded ? 'translate-x-0' : 'translate-x-full'} backdrop-blur-sm",
    style: "background: rgba(255, 255, 255, 0.95);",
    data: { 
      controller: "settings-sidebar",
      settings_sidebar_target: "container"
    }
  ) do
    # Header

    div(class: "relative px-6 py-6 bg-gradient-to-br from-blue-50 via-white to-purple-50 border-b border-gray-100") do
      div(class: "text-center") do
        div(class: "inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full mb-3 shadow-lg") do
          unsafe_raw "            <svg class=\"w-6 h-6 text-white\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n              <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z\"/>\n              <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M15 12a3 3 0 11-6 0 3 3 0 016 0z\"/>\n            </svg>\n          SVG\n        end\n        h2(class: \"text-xl font-bold bg-gradient-to-r from-gray-800 to-gray-600 bg-clip-text text-transparent\") { \"Settings\" }\n      end\n      \n      # Close button - iOS style\n      button(\n        class: \"absolute top-4 right-4 w-8 h-8 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-all duration-200 transform hover:scale-105\",\n        data: { action: \"click->settings-sidebar#close\" },\n        title: \"Close\"\n      ) do\n        unsafe_raw <<~SVG\n          <svg class=\"w-4 h-4 text-gray-600\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n            <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2.5\" d=\"M6 18L18 6M6 6l12 12\"></path>\n          </svg>\n        SVG\n      end\n    end\n\n    # Content\n    div(class: \"flex-1 overflow-y-auto px-6 py-8 bg-gradient-to-b from-gray-50/30 to-white\") do\n      turbo_frame(\n        id: \"settings-form\",\n        class: \"space-y-8\"\n      ) do\n        form(\n          action: route_helper.settings_path,\n          method: \"patch\",\n          class: \"space-y-8\"\n        ) do\n        # Feature Toggles Section\n        div do\n          h3(class: \"text-md font-medium text-gray-900 mb-4\") { \"Feature Toggles\" }\n          \n          div(class: \"space-y-4\") do\n            @feature_toggles.each do |feature|\n              render_feature_toggle(feature)\n            end\n          end\n        end\n\n        # Save button\n        div(class: \"pt-6 border-t border-gray-200\") do\n          button(\n            type: \"submit\",\n            class: \"w-full inline-flex items-center justify-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors\"\n          ) do\n            unsafe_raw <<~SVG\n              <svg class=\"w-4 h-4 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n                <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path>\n              </svg>\n            SVG\n            span { \"Save Settings\" }\n          end\n        end\n        end\n      end\n    end\n\n  end\nend\n"