From a08ede294af272e16a0d1a14311dfbab861e8c85 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 24 Mar 2021 12:11:30 +0100 Subject: [PATCH] Add english documentation for customize components --- docs/SUMMARY.md | 1 + docs/en/customization/components.md | 25 +++++++++++++++++++++++++ docs/en/customization/customization.md | 1 + 3 files changed, 27 insertions(+) create mode 100644 docs/en/customization/components.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 98cc13d7a..0ab17c0e7 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -34,6 +34,7 @@ * [Views & Styles](en/customization/views_and_styles.md) * [Javascript](en/customization/javascript.md) * [Models](en/customization/models.md) + * [Components](en/customization/components.md) * [Gems](en/customization/gems.md) * [Overwritting Application](en/customization/overwritting.md) diff --git a/docs/en/customization/components.md b/docs/en/customization/components.md new file mode 100644 index 000000000..dae1276f4 --- /dev/null +++ b/docs/en/customization/components.md @@ -0,0 +1,25 @@ +# Components + +For components, customization can be used to change both the logic (included in a `.rb` file) and the view (included in a `.erb` file). If you only want to customize the logic for, let's say, the `Admin::TableActionsComponent`, create a file named `app/components/custom/admin/table_actions_component.rb` with the following content: + +```ruby +require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s + +class Admin::TableActionsComponent + # Your custom logic here +end +``` + +If, on the other hand, you also want to customize the view, you need a small modification. Instead of the previous code, use: + +```ruby +class Admin::TableActionsComponent < ApplicationComponent; end + +require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s + +class Admin::TableActionsComponent + # Your custom logic here +end +``` + +This will make the component use the view in `app/components/custom/admin/table_actions_component.html.erb`. You can create this file and customize it to your needs. diff --git a/docs/en/customization/customization.md b/docs/en/customization/customization.md index edc85bebd..75cfaa9a0 100644 --- a/docs/en/customization/customization.md +++ b/docs/en/customization/customization.md @@ -6,5 +6,6 @@ * [Views & Styles](views_and_styles.md) * [Javascript](javascript.md) * [Models](models.md) +* [Components](components.md) * [Gems](gems.md) * [Overwritting Application](overwritting.md)