Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Re organize lookbook previews #296

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::DateComponent < InputFieldComponent
class Input::DateComponent < InputFieldComponent
def initialize(label: '', name:, value: Date.today, placeholder: '', error_message: '', helper_text: '')
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::FileInputComponent < ViewComponent::Base
class Input::FileInputComponent < ViewComponent::Base
def initialize(name:, html_options: '')
@name = name
@html_options = html_options
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::SelectComponent < InputFieldComponent
class Input::SelectComponent < InputFieldComponent

def initialize(id: nil, label: '', name:, value: [], selected: '', placeholder: '', error_message: '', helper_text: '', multiple: false, open_to_add_values: false)
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::TextAreaComponent < InputFieldComponent
class Input::TextAreaComponent < InputFieldComponent
def initialize(label: '', name:, value: nil, placeholder: '', error_message: '', helper_text: '', rows: "5")
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text)
@rows = rows
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::TextInputComponent < InputFieldComponent
class Input::TextInputComponent < InputFieldComponent
def initialize(label: '', name:, value: nil, placeholder: '', error_message: '', helper_text: '')
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message, helper_text: helper_text)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/mappings/bulk_loader/_loader.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
= JSON.pretty_generate @example_code
= form_with url: '/mappings/loader', method: :post, multipart: true, data: { turbo: true} do
%div
= render Form::FileInputComponent.new(name: :file)
= render Input::FileInputComponent.new(name: :file)
%button.btn.btn-secondary.btn-block.mt-2{type:'submit'}
Save
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ChipButtonComponentPreview < ViewComponent::Preview
class Display::ChipButtonComponentPreview < ViewComponent::Preview

# @param url text
# @param text text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class DateTimeFieldComponentPreview < ViewComponent::Preview
class Display::DateTimeFieldComponentPreview < ViewComponent::Preview

# @param text text
# @param format select [year_month_day_concise, month_day_year, monthfull_day_year]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class FieldContainerComponentPreview < ViewComponent::Preview
class Display::FieldContainerComponentPreview < ViewComponent::Preview

# @param label text
# @param value text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class LanguageFieldComponentPreview < ViewComponent::Preview
class Display::LanguageFieldComponentPreview < ViewComponent::Preview

# @param value text
def default(value: 'fr')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class LicenseFieldComponentPreview < ViewComponent::Preview
class Display::LicenseFieldComponentPreview < ViewComponent::Preview

# @param value select [ CC-BY IGO 3.0, https://creativecommons.org/licenses/by/4.0/, http://www.gnu.org/licenses/gpl-3.0, https://opensource.org/licenses/MIT, http://www.apache.org/licenses/LICENSE-2.0 ]
def default(value: "https://creativecommons.org/licenses/by/4.0/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class LinkFieldComponentPreview < ViewComponent::Preview
class Display::LinkFieldComponentPreview < ViewComponent::Preview

# @param text text
def default(text: "https://agroportal.lirmm.fr/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TextAreaFieldComponentPreview < ViewComponent::Preview
class Display::TextAreaFieldComponentPreview < ViewComponent::Preview


# @param value textarea
Expand Down
9 changes: 0 additions & 9 deletions test/components/previews/form/file_input_component_preview.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ChipsComponentPreview < ViewComponent::Preview
class Input::ChipsComponentPreview < ViewComponent::Preview

# @param name text
# @param value text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::DateComponentPreview < ViewComponent::Preview
class Input::DateComponentPreview < ViewComponent::Preview
def default
# This is a date input field:
# - To use it without a label: don't give a value to the param label or leave it empty.
Expand All @@ -11,7 +11,7 @@ def default
# @param helper_text text

def default(label: "Label", placeholder: "", error_message: "", helper_text: "")
render Form::DateComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text)
render Input::DateComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Input::FileInputComponentPreview < ViewComponent::Preview


def default
render Input::FileInputComponent.new(name: "file")
end


end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class NestedFormInputComponentPreview < ViewComponent::Preview
class Input::NestedFormInputComponentPreview < ViewComponent::Preview

include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

class Form::SelectComponentPreview < ViewComponent::Preview
class Input::SelectComponentPreview < ViewComponent::Preview
def default(id: "", name: "", values: ["choices 1", "choices 2", "choices 3"], selected: "choices 2", multiple: false, open_to_add_values: false)
render Form::SelectComponent.new(id: id, name: name, values: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
render Input::SelectComponent.new(id: id, name: name, value: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
end

def multiple(id: "", name: "", values: ["choices 1", "choices 2", "choices 3"], selected: "choices 2", multiple: true, open_to_add_values: false)
render Form::SelectComponent.new(id: id, name: name, values: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
render Input::SelectComponent.new(id: id, name: name, value: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
end

def open_to_add(id: "", name: "", values: ["choices 1", "choices 2", "choices 3"], selected: "choices 2", multiple: true , open_to_add_values: true)
render Form::SelectComponent.new(id: id, name: name, values: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
render Input::SelectComponent.new(id: id, name: name, value: values, selected: selected, multiple: multiple, open_to_add_values: open_to_add_values)
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::TextAreaComponentPreview < ViewComponent::Preview
class Input::TextAreaComponentPreview < ViewComponent::Preview
# This is a textarea field:
# - To use it without a label: don't give a value to the param label or leave it empty.
# - To give it a hint (placeholder): define the param hint with the hind you want to be displayed.
Expand All @@ -14,6 +14,6 @@ class Form::TextAreaComponentPreview < ViewComponent::Preview
# @param rows number

def default(label: "Label", placeholder: "", error_message: "", helper_text: "", rows: 5)
render Form::TextAreaComponent.new(label: label, name: "name",value: '', placeholder: placeholder, error_message: error_message, helper_text: helper_text, rows: rows)
render Input::TextAreaComponent.new(label: label, name: "name",value: '', placeholder: placeholder, error_message: error_message, helper_text: helper_text, rows: rows)
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Form::TextInputComponentPreview < ViewComponent::Preview
class Input::TextInputComponentPreview < ViewComponent::Preview
# This is a text input field:
# - To use it without a label: don't give a value to the param label or leave it empty.
# - To give it a hint (placeholder): define the param hint with the hind you want to be displayed.
Expand All @@ -12,6 +12,6 @@ class Form::TextInputComponentPreview < ViewComponent::Preview
# @param helper_text text

def default(label: "Label", placeholder: "", error_message: "", helper_text: "")
render Form::TextInputComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text)
render Input::TextInputComponent.new(label: label, name: "name", placeholder: placeholder, error_message: error_message, helper_text: helper_text)
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CardMessageComponentPreview < ViewComponent::Preview
class Layout::CardMessageComponentPreview < ViewComponent::Preview

# @param message text
# @param button_text text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class DropdownContainerComponentPreview < ViewComponent::Preview
class Layout::DropdownContainerComponentPreview < ViewComponent::Preview
layout 'component_preview_not_centred'

# @param title text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SummarySectionComponentPreview < ViewComponent::Preview
class Layout::SummarySectionComponentPreview < ViewComponent::Preview
layout 'component_preview_not_centred'
# @param title text
# @param content textarea
Expand Down