Module: SuperSettings::Helper
- Included in:
- Application
- Defined in:
- lib/super_settings/application/helper.rb
Overview
Helper functions used for rendering the Super Settings HTML application. These methods are mixed in to the Application class so they are accessible from the ERB templates.
Constant Summary collapse
- ICON_SVG =
Dir.glob(File.join(__dir__, "images", "*.svg")).each_with_object({}) do |file, cache| svg = File.read(file).chomp cache[File.basename(file, ".svg")] = svg end.freeze
- GEAR_SVG =
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>'- ICON_BUTTON_STYLE =
{ cursor: "pointer", width: "1.35rem", height: "1.35rem", "min-width": "20px", "min-height": "20px", "margin-top": "0.25rem", "margin-right": "0.5rem" }.freeze
- DEFAULT_ICON_STYLE =
{ width: "1rem", height: "1rem", display: "inline-block" }.freeze
Class Method Summary collapse
-
.application_header(locale: nil) ⇒ String
Render the header HTML for the web pages using values set in the configuration.
Instance Method Summary collapse
-
#add_to_head ⇒ String
Additional HTML code that should go into the
element on the page. -
#api_base_url ⇒ String
The base URL for the REST API.
-
#application_header ⇒ String
Render the header for the web pages using values set in the configuration.
-
#application_name ⇒ Object
Return the application name set by the configuration or a default value.
-
#color_scheme ⇒ Boolean?
Whether to use dark mode for the application UI.
-
#content_tag(tag, body, options) ⇒ Object
Render an HTML tag with body content.
-
#dark_mode_selector ⇒ String?
A CSS selector that sets dark mode when it matches an element in the page.
-
#html_attributes(options) ⇒ Object
Format a hash into HTML attributes.
-
#html_escape(text) ⇒ String
Escape text for use in HTML.
-
#icon_button(icon, title:, color:, js_class:, url: nil, disabled: false, style: {}, link_style: nil) ⇒ String
Render an icon image as a link tag.
-
#icon_image(name, options = {}) ⇒ String
Render an image tag for one of the SVG images in the images directory.
-
#javascript_tag ⇒ Object
Render the scripts.js file as an inline