calendar.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. {% assign day-names = "Sun,Mon,Tue,Wed,Thu,Fri,Sat" | split: "," %}
  2. {% assign start-day = include.start-day | default: -2 %}
  3. {% assign today = include.today | default: 8 %}
  4. {% assign days = include.days | default: 30 %}
  5. {% assign all-days = days | minus: start-day | plus: 1 | divide: 7.0 | ceil | times: 7 %}
  6. {% assign end-day = all-days | plus: start-day | minus: 1 %}
  7. {% assign range-start = include.range-start | default: 14 %}
  8. {% assign range-end = include.range-end | default: 21 %}
  9. <div class="calendar{% if include.class %} {{ include.class }}{% endif %}">
  10. <div class="calendar-nav">
  11. <button class="btn btn-action btn-link btn-lg">
  12. {% include ui/icon.html icon="chevron-left" %}
  13. </button>
  14. <div class="calendar-title">{{ include.title | default: 'March 2017' }}</div>
  15. <button class="btn btn-action btn-link btn-lg">
  16. {% include ui/icon.html icon="chevron-right" %}
  17. </button>
  18. </div>
  19. <div class="calendar-container">
  20. <div class="calendar-header">
  21. {% for col in (1..7) %}
  22. <div class="calendar-date">{{ day-names[forloop.index0] }}</div>
  23. {% endfor %}
  24. </div>
  25. <div class="calendar-body">
  26. {% for day in (start-day..end-day) %}
  27. {% if day <= 0 %}
  28. {% assign d = 31 | plus: day %}
  29. {% elsif day > days %}
  30. {% assign d = day | minus: days %}
  31. {% else %}
  32. {% assign d = day %}
  33. {% endif %}
  34. <div class="calendar-date{% if day <= 0 %} prev-month{% elsif day > days %} next-month{% endif %}{% if range-start and day >= range-start and range-end and day <= range-end %} calendar-range{% if day == range-start %} range-start{% endif %}{% if day == range-end %} range-end{% endif %}{% endif %}">
  35. <a href="#" class="date-item{% if day == today %} date-today{% endif %}">{{ d }}</a>
  36. </div>
  37. {% endfor %}
  38. </div>
  39. </div>
  40. </div>