Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radio button version of image check #1298

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pages/_docs/form-image-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Add an image check to your form and give users visually attractive options to ch
{% endcapture %}
{% include example.html code=code max-width="25rem" %}

{% capture code %}
{% include parts/form/input-image-radio.html offset=10 %}
{% endcapture %}
{% include example.html code=code max-width="25rem" %}


{% capture code %}
{% include parts/form/input-image-people.html %}
Expand Down
1 change: 1 addition & 0 deletions src/pages/_includes/forms/form-elements-3.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% include parts/form/input-image.html %}
{% include parts/form/input-image-radio.html offset=10 %}
{% include parts/form/input-color.html %}
{% include parts/form/input-color.html name="color-rounded" rounded=true %}
{% include parts/form/input-colorpicker.html %}
Expand Down
19 changes: 19 additions & 0 deletions src/pages/_includes/parts/form/input-image-radio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% assign limit = include.limit | default: 6 %}
{% assign offset = include.offset | default: 0 %}
<div class="mb-3">
<label class="form-label">Image Check Radio</label>
<div class="row g-2">
{% assign photos = site.data.photos | where: 'horizontal', true %}

{% for photo in photos limit: limit offset: offset %}
<div class="{{ include.row-class | default: 'col-6 col-sm-4' }}">
<label class="form-imagecheck mb-2">
<input name="form-imagecheck-radio" type="radio" value="{{ forloop.index }}" class="form-imagecheck-input" {% if forloop.index == 2 or forloop.index == 4 or forloop.index == 7 %} checked{% endif %}/>
<span class="form-imagecheck-figure">
<img src="{{ site.base }}/static/photos/{{ photo.file }}" alt="{{ photo.title }}" class="form-imagecheck-image">
</span>
</label>
</div>
{% endfor %}
</div>
</div>
5 changes: 3 additions & 2 deletions src/pages/_includes/parts/form/input-image.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% assign limit = include.limit | default: 9 %}
{% assign limit = include.limit | default: 6 %}
{% assign offset = include.offset | default: 0 %}
<div class="mb-3">
<label class="form-label">Image Check</label>
<div class="row g-2">
{% assign photos = site.data.photos | where: 'horizontal', true %}

{% for photo in photos limit: limit %}
{% for photo in photos limit: limit offset: offset %}
<div class="{{ include.row-class | default: 'col-6 col-sm-4' }}">
<label class="form-imagecheck mb-2">
<input name="form-imagecheck" type="checkbox" value="{{ forloop.index }}" class="form-imagecheck-input" {% if forloop.index == 2 or forloop.index == 4 or forloop.index == 7 %} checked{% endif %}/>
Expand Down
7 changes: 6 additions & 1 deletion src/scss/ui/forms/_form-imagecheck.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Image check
user-select: none;
background: $form-check-input-bg;
border: var(--#{$prefix}border-width) solid var(--#{$prefix}border-color);
border-radius: 3px;
border-radius: $form-check-input-border-radius;
@include transition(opacity $transition-time);

.form-imagecheck-input:checked ~ & {
Expand All @@ -55,6 +55,11 @@ Image check
background-size: $form-check-input-checked-bg-size;
border-color: $form-check-input-checked-border-color;
}

.form-imagecheck-input[type="radio"] ~ & {
border-radius: $form-check-radio-border-radius;
background-image: escape-svg($form-check-radio-checked-bg-image);
}
}
}

Expand Down