Module: Karafka::Web::Ui::Helpers::TailwindHelper

Included in:
Base
Defined in:
lib/karafka/web/ui/helpers/tailwind_helper.rb

Overview

Helper for generating tailwind rendering components with Ruby Simplifies many places in the UI

Constant Summary collapse

TYPES =

style types of components we support

%i[
  info
  error
  warning
  success
  primary
  secondary
].freeze

Instance Method Summary collapse

Instance Method Details

#badge(content, classes: '') ⇒ String

Renders a plain badge

Parameters:

  • content (String)

    badge content

  • classes (String) (defaults to: '')

    extra css classes

Returns:

  • (String)

    badge html



29
30
31
# File 'lib/karafka/web/ui/helpers/tailwind_helper.rb', line 29

def badge(content, classes: '')
  %(<span class="badge #{classes}">#{content}</span>)
end

Renders a link to with button styling

Parameters:

  • name (String)

    button name

  • path (String)

    path to where to go

  • classes (String) (defaults to: '')

    extra css classes

  • title (String, nil) (defaults to: nil)

    title (if any)

Returns:

  • (String)

    button link html



39
40
41
# File 'lib/karafka/web/ui/helpers/tailwind_helper.rb', line 39

def link_button(name, path, classes: '', title: nil)
  %(<a href="#{path}" class="btn #{classes}" title="#{title}">#{name}</a>)
end

#tailwind_typesArray<Symbol>

Returns style types of components we support.

Returns:

  • (Array<Symbol>)

    style types of components we support



21
22
23
# File 'lib/karafka/web/ui/helpers/tailwind_helper.rb', line 21

def tailwind_types
  TYPES
end