Module: ViewPrimitives::Generators::Components
- Defined in:
- lib/generators/view_primitives/components.rb
Constant Summary collapse
- TEMPLATE_ROOT =
File.("add/templates", __dir__)
- EXTRA_STIMULUS =
Stimulus controllers not colocated with the component template directory.
{ "alert_dialog" => {source: "dialog/dialog_controller.js", name: "dialog"}, "sheet" => {source: "dialog/dialog_controller.js", name: "dialog"}, "drawer" => {source: "dialog/dialog_controller.js", name: "dialog"} }.freeze
- OPTIONAL_THEMES =
%w[rose].freeze
- SETUP_NOTES =
Post-install instructions for components that require external dependencies.
{ "chart" => <<~TEXT, "wysiwyg" => <<~TEXT WYSIWYG defaults to Trix (adapter: :trix). To use Trix, install ActionText: bundle add actiontext rails action_text:install To use Quill (adapter: :quill), add it to your importmap: # config/importmap.rb pin "quill", to: "https://esm.sh/quill@2" Also add Quill's stylesheet to your CSS entry point: @import url("https://esm.sh/quill@2/dist/quill.snow.css"); Usage: ui :wysiwyg, name: "body" ui :wysiwyg, name: "body", adapter: :quill, placeholder: "Write something..." TEXT }.freeze
Class Method Summary collapse
- .installed(root) ⇒ Object
- .installed?(component, root) ⇒ Boolean
- .optional_theme_imports ⇒ Object
- .primary_path(component) ⇒ Object
- .supported ⇒ Object
Class Method Details
.installed(root) ⇒ Object
67 68 69 |
# File 'lib/generators/view_primitives/components.rb', line 67 def self.installed(root) supported.select { |name| installed?(name, root) } end |
.installed?(component, root) ⇒ Boolean
63 64 65 |
# File 'lib/generators/view_primitives/components.rb', line 63 def self.installed?(component, root) File.exist?(File.join(root, primary_path(component))) end |
.optional_theme_imports ⇒ Object
71 72 73 |
# File 'lib/generators/view_primitives/components.rb', line 71 def self.optional_theme_imports OPTIONAL_THEMES end |
.primary_path(component) ⇒ Object
59 60 61 |
# File 'lib/generators/view_primitives/components.rb', line 59 def self.primary_path(component) "app/components/ui/#{component}_component.rb" end |
.supported ⇒ Object
53 54 55 56 57 |
# File 'lib/generators/view_primitives/components.rb', line 53 def self.supported @supported ||= Dir.children(TEMPLATE_ROOT) .select { |e| File.directory?(File.join(TEMPLATE_ROOT, e)) } .sort.freeze end |