OpenFn / OpenFn/lightning

Choose between `select_field` and `select`; document and implement across app

Open
#201 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

cc @elias-ba , @stuartc - there are two different implementations for a select component in Form.

  • choose the better one, delete the other
  • add inline documentation to the better one (@doc)
  • move all existing implementations of the losing function to use the new function

the functions below:

  def select_field(assigns) do
    select_classes = ~w[
      block
      w-full
      rounded-md
      border-secondary-300
      shadow-sm
      focus:border-primary-300
      focus:ring
      focus:ring-primary-200
      focus:ring-opacity-50
    ]

    opts =
      assigns_to_attributes(assigns, [:form, :name, :values]) ++
        [class: select_classes]

    ~H"""
    <%= select(@form, @name, @values, opts) %>
    """
  end

  def select(assigns) do
    select_classes = ~w[
      block
      w-full
      rounded-md
      border-secondary-300
      sm:text-sm
      shadow-sm
      focus:border-primary-300
      focus:ring
      focus:ring-primary-200
      focus:ring-opacity-50
    ]

    opts = assigns_to_attributes(assigns) ++ [class: select_classes]

    assigns = assigns |> assign(opts: opts)

    ~H"""
    <select {@opts}>
      <%= render_slot(@inner_block) %>
    </select>
    """
  end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Form component where select_field/1 and select/1 are defined, and search the application for usages of both functions. Compare their existing behavior, choose one, then verify that the losing function has no remaining callers and that the retained function has inline @doc documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.