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

Add info text and tooltip above the field #153

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
51 changes: 28 additions & 23 deletions content-elements/form/checkbox/prototype/template.twig
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
{% macro render(elementId = null, elementPartId = null, formTextPartId = null, errorRequiredPartId = null, labelText = null, infoText = null, errorRequiredText = null) %}{% apply spaceless %}
{% deprecated 'The usage of "element.render(...)" is deprecated, use "include ... with {...}" instead. For detailed information, visit: https://github.com/bsi-software/bsi-cx-design-master-template-web/blob/main/MIGRATION_GUIDE.md"' %}
{% include './template.twig' %}
{% endapply %}{% endmacro %}
{% macro render(elementId = null, elementPartId = null, formTextPartId = null, errorRequiredPartId = null, labelText = null, infoText = null, errorRequiredText = null) %}
{% apply spaceless %}
{% deprecated 'The usage of "element.render(...)" is deprecated, use "include ... with {...}" instead. For detailed information, visit: https://github.com/bsi-software/bsi-cx-design-master-template-web/blob/main/MIGRATION_GUIDE.md"' %}
{% include './template.twig' %}
{% endapply %}
{% endmacro %}

{% apply spaceless %}
{% set checkboxElementId = elementId ?: 'checkbox-24CNSe' %}
{% set checkboxElementPartId = elementPartId ?: 'checkbox-part-Nls88s' %}
{% set checkboxFormTextPartId = formTextPartId ?: 'checkbox-part-text-6ycJm4' %}
{% set checkboxErrorRequiredPartId = errorRequiredPartId ?: 'checkbox-part-error-required-iYG8Ss' %}
{% set checkboxLabelText = (labelText ?: properties.checkboxLabelText) ?: bsi_cx_lorem(3) %}
{% set checkboxInfoText = (infoText ?: properties.checkboxInfoText) ?: "" %}
{% set checkboxErrorRequiredText = (errorRequiredText ?: properties.errorRequiredText) ?: 'Bitte füllen Sie dieses Feld aus.' %} {# TODO: make translatable #}
{% set checkboxElementId = elementId ?: 'checkbox-24CNSe' %}
{% set checkboxElementPartId = elementPartId ?: 'checkbox-part-Nls88s' %}
{% set checkboxFormTextPartId = formTextPartId ?: 'checkbox-part-text-6ycJm4' %}
{% set checkboxErrorRequiredPartId = errorRequiredPartId ?: 'checkbox-part-error-required-iYG8Ss' %}
{% set checkboxLabelText = (labelText ?: properties.checkboxLabelText) ?: bsi_cx_lorem(3) %}
{% set checkboxInfoText = (infoText ?: properties.checkboxInfoText) ?: "" %}
{% set checkboxErrorRequiredText = (errorRequiredText ?: properties.errorRequiredText) ?: 'Bitte füllen Sie dieses Feld aus.' %}
{# TODO: make translatable #}

<div x-data="checkbox" data-bsi-element="{{ checkboxElementId }}" class="{{ 'bsi-element-' ~ checkboxElementId }} bsi-form-checkbox-element mb-4 bsi-form-element form-check bsi-form-flex-label bsi-checkbox-spacing-visible bsi-form-switch-hide" data-bsi-element-part="{{ checkboxElementPartId }}">
<div class="bsi-form-input-element">
<input x-on:change="validateInput" class="form-check-input form-checkbox-input" type="checkbox" id="switch">
<div class="checkbox-label-and-tooltip">
<label class="form-check-label" for="switch">{{ checkboxLabelText }}</label>
<i class="bi bi-info-circle" data-bs-toggle="tooltip" data-bs-custom-class="bsi-tooltip" role="tooltip" aria-label="{{ checkboxInfoText }}"></i>
</div>
<div data-bsi-element-part="{{ checkboxFormTextPartId }}" class="form-text">{{ checkboxInfoText }}</div>
<div data-bsi-element-part="{{ checkboxErrorRequiredPartId }}" class="invalid-feedback"> {{ checkboxErrorRequiredText }} </div>
</div>
</div>
{% endapply %}
<div x-data="checkbox" data-bsi-element="{{ checkboxElementId }}" class="{{ 'bsi-element-' ~ checkboxElementId }} bsi-form-checkbox-element mb-4 bsi-form-element form-check bsi-form-flex-label bsi-checkbox-spacing-visible bsi-form-switch-hide" data-bsi-element-part="{{ checkboxElementPartId }}">
<div class="bsi-form-input-element">
<div class="checkbox-label-and-tooltip">
<div tabindex = "0" data-bsi-element-part="{{ checkboxFormTextPartId }}" class="form-text">{{ checkboxInfoText }}</div>
<i tabindex = "0" class="bi bi-info-circle" data-bs-toggle="tooltip" data-bs-custom-class="bsi-tooltip" role="tooltip" aria-label="{{ checkboxInfoText }}"></i>
</div>
<input tabindex = "0" x-on:change="validateInput" class="form-check-input form-checkbox-input" type="checkbox" id="switch">
<label tabindex = "0" class="form-check-label" for="switch">{{ checkboxLabelText }}</label>
<div tabindex = "0" data-bsi-element-part="{{ checkboxErrorRequiredPartId }}" class="invalid-feedback">
{{ checkboxErrorRequiredText }}
</div>
</div>
</div>
{% endapply %}