chore: init commit
in worker.../repo/GITFOLDER.zip is the .git folder.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module ButtonHelper
|
||||
def render_button(label = "", text: nil, variant: :default, as: :button, href: nil, data: {}, **options, &block)
|
||||
base_classes = base_class_styling
|
||||
variant_classes = case variant.to_sym
|
||||
when :default
|
||||
" bg-primary text-primary-foreground hover:bg-primary/90 "
|
||||
when :secondary
|
||||
" bg-secondary text-secondary-foreground hover:bg-secondary/80 "
|
||||
when :error, :danger, :alert, :destructive
|
||||
" bg-destructive text-destructive-foreground hover:bg-destructive/90 "
|
||||
when :outline
|
||||
" border border-input bg-background hover:bg-accent hover:text-accent-foreground"
|
||||
when :ghost
|
||||
" hover:bg-accent hover:text-accent-foreground "
|
||||
end
|
||||
button_classes = "#{base_classes} #{variant_classes} #{options[:class]}"
|
||||
button_classes = tw(button_classes)
|
||||
text = label if label.present?
|
||||
text = capture(&block) if block
|
||||
render "components/ui/button", text:, button_classes:, as:, href:, data:, **options
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def base_class_styling
|
||||
" inline-flex items-center justify-center rounded-md text-sm font-medium " \
|
||||
"ring-offset-background transition-colors focus-visible:outline-hidden " \
|
||||
"focus-visible:ring-2 focus-visible:ring-3 focus-visible:ring-offset-2 " \
|
||||
"disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 "
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module CheckboxHelper
|
||||
def render_checkbox(label:, name:, **options)
|
||||
render "components/ui/checkbox", name: name, label: label, options: options
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module FormsHelper
|
||||
def render_form_with(**, &)
|
||||
form_with(**, builder: Shadcn::FormBuilder, &)
|
||||
end
|
||||
|
||||
def render_form_for(obj, **opts, &)
|
||||
form_for(obj, **opts, builder: Shadcn::FormBuilder, html: opts, &)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,55 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module InputHelper
|
||||
def render_input(name:, label: false, id: nil, type: :text, value: nil, **options)
|
||||
options[:class] = border_styling(options[:class])
|
||||
|
||||
options[:class] << case options[:variant]
|
||||
when :borderless
|
||||
borderless_variant_styling
|
||||
else
|
||||
border_variant_default_styling
|
||||
end
|
||||
options[:class] = tw(options[:class])
|
||||
|
||||
options.reverse_merge!(
|
||||
label: options[:lable] || false,
|
||||
required: options[:required] || false,
|
||||
disabled: options[:disabled] || false,
|
||||
readonly: options[:readonly] || false,
|
||||
placeholder: options[:placeholder] || "",
|
||||
autocomplete: options[:autocomplete] || "",
|
||||
autocapitalize: options[:autocapitalize] || nil,
|
||||
autocorrect: options[:autocorrect] || nil
|
||||
)
|
||||
render partial: "components/ui/input", locals: {
|
||||
type:,
|
||||
label:,
|
||||
name:,
|
||||
value:,
|
||||
id:,
|
||||
options: options
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def border_styling(options_class)
|
||||
"flex h-10 w-full rounded-md border border-input bg-background px-3 " \
|
||||
"py-2 text-sm transition-colors 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} "
|
||||
end
|
||||
|
||||
def borderless_variant_styling
|
||||
" border-0 focus-visible:outline-hidden focus-visible:shadow-none focus-visible:ring-transparent"
|
||||
end
|
||||
|
||||
def border_variant_default_styling
|
||||
"shadow-xs focus-visible:outline-hidden focus-visible:ring-2a " \
|
||||
"focus-visible:ring-3 focus-visible:ring-offset-2 focus-visible:border-muted"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module LabelHelper
|
||||
def render_label(name:, label:, **options)
|
||||
render "components/ui/label", name: name, label: label, options: options
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Components
|
||||
module TextareaHelper
|
||||
def render_textarea(name:, label: false, id: nil, value: nil, **options)
|
||||
options.reverse_merge!(
|
||||
rows: 3, required: false, disabled: false,
|
||||
readonly: false, class: "", label: false, placeholder: "Type here..."
|
||||
)
|
||||
render partial: "components/ui/textarea", locals: {
|
||||
label:,
|
||||
name:,
|
||||
value:,
|
||||
id:,
|
||||
options: options
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user