View Source SaladUI.Patcher (SaladUI v0.13.0)

Provides functionality to patch various configuration and source files in Phoenix projects.

This module is intended to be used by the CLI during the installation of SaladUI in a project. It handles patching of config files, Tailwind CSS configuration, CSS files, and JavaScript files.

Summary

Functions

Patches the Elixir project configuration file.

Patches a CSS file by adding all variables needed for a color scheme. Also adds optional tweaks to the CSS file.

Patches a JavaScript file by adding JS code snippet to handle events from the server.

Patches the Tailwind CSS configuration in a Phoenix project.

Functions

Link to this function

patch_config(config_path, configs)

View Source

Patches the Elixir project configuration file.

Adds new configuration to the existing config file without modifying or removing previous content.

Parameters

  • config_path: The path to the project's config.exs file
  • configs: A list of configurations to add to the config file. Each configuration must be a tuple with the name of the configuration and a map with the description and values to add. If you want to insert Elixir code, suchs as modules or an expression, use a string with the code you want to insert.
Link to this function

patch_css_file(css_file_path, color_scheme_file_path)

View Source

Patches a CSS file by adding all variables needed for a color scheme. Also adds optional tweaks to the CSS file.

Parameters

  • css_file_path: Path to the CSS file
  • color_scheme_file_path: Path to the file containing the color scheme CSS code
Link to this function

patch_js_file(js_file_path, code_to_add_file_path)

View Source

Patches a JavaScript file by adding JS code snippet to handle events from the server.

Parameters

  • js_file_path: Path to the JavaScript file
  • code_to_add_file_path: Path to the file containing the JS code to be added
Link to this function

patch_tailwind_config(tailwind_config_path, opts \\ [])

View Source

Patches the Tailwind CSS configuration in a Phoenix project.

Adds required plugins to the Tailwind configuration and extends the theme configuration to use a JSON file that enables theming via CSS variables, without modifying existing user configuration.

Parameters

  • tailwind_config_path: Path to the Tailwind configuration file