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_templateObject



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
            <svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <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"/>
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
            </svg>
          SVG
        end
        h2(class: "text-xl font-bold bg-gradient-to-r from-gray-800 to-gray-600 bg-clip-text text-transparent") { "Settings" }
      end
      
      # Close button - iOS style
      button(
        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",
        data: { action: "click->settings-sidebar#close" },
        title: "Close"
      ) do
        unsafe_raw <<~SVG
          <svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M6 18L18 6M6 6l12 12"></path>
          </svg>
        SVG
      end
    end

    # Content
    div(class: "flex-1 overflow-y-auto px-6 py-8 bg-gradient-to-b from-gray-50/30 to-white") do
      turbo_frame(
        id: "settings-form",
        class: "space-y-8"
      ) do
        form(
          action: route_helper.settings_path,
          method: "patch",
          class: "space-y-8"
        ) do
        # Feature Toggles Section
        div do
          h3(class: "text-md font-medium text-gray-900 mb-4") { "Feature Toggles" }
          
          div(class: "space-y-4") do
            @feature_toggles.each do |feature|
              render_feature_toggle(feature)
            end
          end
        end

        # Save button
        div(class: "pt-6 border-t border-gray-200") do
          button(
            type: "submit",
            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"
          ) do
            unsafe_raw <<~SVG
              <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
              </svg>
            SVG
            span { "Save Settings" }
          end
        end
        end
      end
    end

  end
end