colorpicker.html 1.1 KB

12345678910111213141516171819202122232425262728
  1. {% assign id = include.id | default: 'default' %}
  2. {% assign alpha = include.alpha | default: false %}
  3. {% assign format = include.format | default: false %}
  4. <input type="text" class="form-control d-block{% if include.class %} {{ include.class }}{% endif %}" id="colorpicker-{{ id }}" value="{{ include.value }}" />
  5. {% capture_script %}
  6. <script>
  7. document.addEventListener("DOMContentLoaded", function () {
  8. {% if environment == 'development' %}
  9. window.tabler_colorpicker = window.tabler_colorpicker || {};
  10. {% endif %}
  11. window.Coloris && ({% if environment == 'development' %}window.tabler_colorpicker["colorpicker-{{ id }}"] = {% endif %}Coloris({
  12. el: "#colorpicker-{{ id }}",
  13. selectInput: false,
  14. alpha: {% if alpha %}true{% else %}false{% endif %},
  15. {% if format %}format: "{{ format }}",{% endif %}
  16. {% if include['swatches-only'] %}swatchesOnly: true,{% endif %}
  17. swatches: [
  18. {% for color in site.colors %}
  19. window.getComputedStyle(document.body).getPropertyValue('{{ color[1].prop }}'),
  20. {% endfor %}
  21. ],
  22. }))
  23. })
  24. </script>
  25. {% endcapture_script %}