-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from mortendk/component-form-options
form options for radio, checkbox and dropdown / select
- Loading branch information
Showing
8 changed files
with
111 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/themes/grunn/includes/components/form/field/options.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{%- if env.mode != 'prod' %}<!-- 👋 field/options.njk --> file{%- endif -%} | ||
<div class="flex flex-col"> | ||
|
||
<label | ||
for="form-item-{{ item.title | slugify }}" | ||
class="font-bold text-lg hover:text-slate-800 hover:cursor-pointer"> | ||
{{ item.title }} | ||
{% if item.required %} * {% endif %} | ||
</label> | ||
|
||
{# Dropdown #} | ||
{% if item.inputtype == "Dropdown" %} | ||
<select name="select"> | ||
|
||
{% for option in item.option %} | ||
<option label="{{ option.title | slugify }}" {% if option.checked %} selected {% endif %}> | ||
{{ option.title }} | ||
</option> | ||
{% endfor %} | ||
|
||
</select> | ||
{# /Dropdown #} | ||
|
||
{% elif item.inputtype == "Radio" %} | ||
{# Radio #} | ||
{% for option in item.option %} | ||
<div class="py-4"> | ||
<input type="radio" id="{{ option.title | slugify }}" name="{{item.title | slugify }}" {% if option.checked %}checked{% endif %}> | ||
<label for="{{ option.title | slugify }}"> {{ option.title }} </label> | ||
</div> | ||
{% endfor %} | ||
{# /Radio #} | ||
|
||
{% elif item.inputtype == "Checkbox" %} | ||
{# Checkbox #} | ||
{% for option in item.option %} | ||
<div class="py-4"> | ||
<input type="checkbox" id="{{ option.title | slugify }}" {% if option.checked %}checked{% endif %}> | ||
<label for="{{ option.title | slugify }}"> {{ option.title }} </label> | ||
</div> | ||
{% endfor %} | ||
|
||
{% endif %} | ||
{#/ Checkbox #} | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.