Sha256: 3101fb26b918d845814af6019b0eba8d8677b1d26336e5806cdfb16ad866cc1c

Contents?: true

Size: 1.3 KB

Versions: 140

Compression:

Stored size: 1.3 KB

Contents

<em>
  <p class="color-fg-accent">This select list controls which field is visible.</p>
</em>

<%= render(Primer::Alpha::Select.new(name: :dietary_pref, label: "Dietary preference")) do |c| %>
  <% c.option(label: "Meatatarian", value: "meatatarian") %>
  <% c.option(label: "Vegetarian", value: "vegetarian") %>
<% end %>

<hr>

<em>
  <p class="color-fg-accent">This is the multi input.</p>
</em>

<%= render(Primer::Alpha::MultiInput.new(name: :dish, **system_arguments)) do |c| %>
  <% c.select_list(name: :meatatarian) do |list| %>
    <% list.option(label: "Steak", value: "steak") %>
    <% list.option(label: "Salmon", value: "salmon") %>
  <% end %>
  <% c.select_list(name: :vegetarian, hidden: true) do |list| %>
    <% list.option(label: "Portobello mushroom", value: "portobello") %>
    <% list.option(label: "Tofu curry", value: "tofu") %>
  <% end %>
<% end %>

<script type="text/javascript" data-eval="true">
  const dietaryPrefList = document.querySelector("[name=dietary_pref]");
  const dishMulti = document.querySelector("[data-name=dish]");

  dietaryPrefList.onchange = (evt) => {
    switch (evt.target.value) {
      case 'meatatarian':
        dishMulti.activateField('meatatarian');
        break;
      case 'vegetarian':
        dishMulti.activateField('vegetarian');
        break;
    }
  };
</script>

Version data entries

140 entries across 140 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.52.2 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.36.4 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.52.1 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.52.0 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.36.3 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.51.0 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.36.2 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.50.1 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.50.0 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.36.1 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.36.0 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.49.2 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.35.2 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.49.1 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.49.0 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.35.1 previews/primer/alpha/multi_input_preview/playground.html.erb
primer_view_components-0.35.0 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.48.2 previews/primer/alpha/multi_input_preview/playground.html.erb
openproject-primer_view_components-0.48.1 previews/primer/alpha/multi_input_preview/playground.html.erb