Sha256: f37ec316c7031b29b7ac75a8c19f63c7e003db6ce44eb6d9ad9e9fd6599db50a

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

module Components::InputHelper
  def render_input(name:, label: false, id: nil, type: :text, value: nil, **options)
    options[:class] = "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 #{options[:class]} "
    options[:class] << case options[:style]
    when :borderless
      " border-0 focus-visible:outline-none focus-visible:shadow-none focus-visible:ring-transparent"
    else
      " focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:border-muted"
    end
    options.reverse_merge!(required: false, disabled: false,
      readonly: false, label: false, placeholder: "Type here...")
    render partial: "components/ui/input", locals: {
      type:,
      label:,
      name:,
      value:,
      id:,
      options: options
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shadcn-ui-0.0.3 app/helpers/components/input_helper.rb
shadcn-ui-0.0.2 app/helpers/components/input_helper.rb