1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-21 17:34:25 +04:00

added optgroup form examples (#1108)

* added optgroup form examples

* added missing ts-dropdown class
This commit is contained in:
Kevin Papst
2022-06-01 14:07:12 +02:00
committed by GitHub
parent f12a41a872
commit cf77c7f6f3
4 changed files with 53 additions and 2 deletions

View File

@@ -69,3 +69,25 @@ labels:
people: people:
value: 4 value: 4
data: people data: people
optgroups:
value: Optgroups
data: optgroup
options:
-
title: Tags
options:
- HTML
- JavaScript
- CSS
- jQuery
- Bootstrap
- Ruby
- Python
-
title: People
options:
- Chuck Tesla
- Elon Musk
- Paweł Kuna
- Nikola Tesla

View File

@@ -29,6 +29,21 @@
<div {% if horizontal %}class="col"{% endif %}> <div {% if horizontal %}class="col"{% endif %}>
<select class="form-select"> <select class="form-select">
<option>Option 1</option> <option>Option 1</option>
<optgroup label="Optgroup 1">
<option>Option 1</option>
<option>Option 2</option>
</optgroup>
<option>Option 2</option>
<optgroup label="Optgroup 2">
<option>Option 1</option>
<option>Option 2</option>
</optgroup>
<optgroup label="Optgroup 3">
<option>Option 1</option>
<option>Option 2</option>
</optgroup>
<option>Option 3</option>
<option>Option 4</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -46,6 +46,11 @@
{% include ui/select.html key="users" %} {% include ui/select.html key="users" %}
</div> </div>
<div class="mb-3">
<label class="form-label">Advanced select with optgroup</label>
{% include ui/select.html key="optgroups" %}
</div>
<div class="mb-3"> <div class="mb-3">
<label class="form-label">Select with avatars</label> <label class="form-label">Select with avatars</label>
{% include ui/select.html key="people" indicator="avatar" %} {% include ui/select.html key="people" indicator="avatar" %}
@@ -65,4 +70,4 @@
<label class="form-label">Advanced select with validation state</label> <label class="form-label">Advanced select with validation state</label>
{% include ui/select.html id="countries-valid" key="countries" state="valid" class="mb-3" %} {% include ui/select.html id="countries-valid" key="countries" state="valid" class="mb-3" %}
{% include ui/select.html id="countries-invalid" key="countries" state="invalid" %} {% include ui/select.html id="countries-invalid" key="countries" state="invalid" %}
</div> </div>

View File

@@ -20,6 +20,15 @@
<option value="{{ person.id }}"{% if include.indicator == 'avatar' %} data-custom-properties="{% capture indicator %}{% include ui/avatar.html size='xs' person=person %}{% endcapture %}{{ indicator | strip | escape }}"{% endif %}>{{ person.full_name }}</option> <option value="{{ person.id }}"{% if include.indicator == 'avatar' %} data-custom-properties="{% capture indicator %}{% include ui/avatar.html size='xs' person=person %}{% endcapture %}{{ indicator | strip | escape }}"{% endif %}>{{ person.full_name }}</option>
{% endfor %} {% endfor %}
{% elsif data.data == 'optgroup' %}
{% for group in options %}
<optgroup label="{{ group.title }}">
{% for option in group.options %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
</optgroup>
{% endfor %}
{% else %} {% else %}
{% for option in options %} {% for option in options %}
{% if option.first %} {% if option.first %}
@@ -56,7 +65,7 @@
var el; var el;
window.TomSelect && ({% if jekyll.environment == 'development' %}window.tabler_select["select-{{ id }}"] = {% endif %}new TomSelect(el = document.getElementById('select-{{ id }}'), { window.TomSelect && ({% if jekyll.environment == 'development' %}window.tabler_select["select-{{ id }}"] = {% endif %}new TomSelect(el = document.getElementById('select-{{ id }}'), {
copyClassesToDropdown: false, copyClassesToDropdown: false,
dropdownClass: 'dropdown-menu', dropdownClass: 'dropdown-menu ts-dropdown',
optionClass:'dropdown-item', optionClass:'dropdown-item',
{% unless include.show-search %} {% unless include.show-search %}