html-elements.mdc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. ---
  2. description: Tabler Project HTML Elements Guidelines
  3. globs: ["**/*.html", "**/*.liquid", "**/*.md"]
  4. alwaysApply: true
  5. ---
  6. ## HTML Elements Guidelines
  7. ### 1. Icons
  8. When you need to use an icon, always use the Tabler icon include syntax:
  9. ```html
  10. {% include "ui/icon.html" icon="ICON_NAME" %}
  11. ```
  12. **Examples:**
  13. - `{% include "ui/icon.html" icon="home" %}`
  14. - `{% include "ui/icon.html" icon="building-community" %}`
  15. - `{% include "ui/icon.html" icon="map-pin" %}`
  16. ### 2. Page Links
  17. When linking to other pages, always use the relative page syntax:
  18. ```html
  19. href="{{ page | relative }}/url.html"
  20. ```
  21. **Examples:**
  22. - `href="{{ page | relative }}/job-post.html"`
  23. - `href="{{ page | relative }}/job-listing.html"`
  24. - `href="{{ page | relative }}/marketing/index.html"`
  25. ### 3. Static Generation
  26. All pages are statically generated to HTML using Eleventy (11ty). Keep this in mind when:
  27. - Writing frontmatter (must be static YAML, no Liquid templating)
  28. - Creating dynamic content (use Liquid templating in the body, not frontmatter)
  29. - Linking between pages (use relative paths)
  30. ### 4. Additional Guidelines
  31. #### Frontmatter Rules
  32. - Frontmatter must be static YAML
  33. - Cannot use Liquid templating in frontmatter
  34. - Use static values for title, permalink, etc.
  35. #### Liquid Templating
  36. - Use Liquid templating only in the HTML body
  37. - Access data using `{{ variable }}` syntax
  38. - Use `{% for %}` loops for dynamic content
  39. - Use `{% if %}` conditions for conditional rendering
  40. #### File Structure
  41. - Pages go in `preview/pages/`
  42. - Includes go in `shared/includes/`
  43. - Data files go in `shared/data/`
  44. - Documentation goes in `docs/content/`
  45. #### CSS Classes
  46. - Use Bootstrap 5 classes
  47. - Use Tabler's custom CSS classes
  48. - Follow the pattern: `--#{$prefix}component-property`
  49. #### Accessibility
  50. - Include proper ARIA labels
  51. - Use semantic HTML elements
  52. - Ensure proper heading hierarchy
  53. - Add alt text for images
  54. ### 5. Component Usage
  55. #### Cards
  56. - Use `card` class for main containers
  57. - Use `card-body` for content areas
  58. - Use `card-header` for card headers
  59. - Use `card-title` for card title
  60. #### Buttons
  61. - Use `btn` class for all buttons
  62. - Use `btn-primary` for primary actions
  63. - Use `btn` for secondary actions, don't use `btn-outline-secondary`
  64. - Use `btn-sm` for smaller buttons
  65. - Use `w-100` for full-width buttons
  66. #### Forms
  67. - Use `form-control` for input fields
  68. - Use `form-label` for labels
  69. - Use `form-check` for checkboxes/radio buttons
  70. - Use `form-select` for dropdowns
  71. #### Layout
  72. - Use Bootstrap grid system (`row`, `col-*`)
  73. - Use `container-xl` for main containers
  74. - Use `page-wrapper` for page structure
  75. - Use `page-body` for main content area
  76. #### Badges
  77. - Use `badge` class for badges
  78. - Don't use `badge-outline` for badges, use `badge` class instead
  79. - Don't use `badge-primary` for badges, use `badge` class instead
  80. - Don't change the text color of badges
  81. #### Markdown
  82. - Use `markdown` class for markdown content
  83. - Apply to containers that render markdown content
  84. - Example: `<div class="markdown">...</div>`
  85. #### Rest of the rules
  86. - Read the rest of the rules in the `docs/content/ui/` folder
  87. ### 6. Data Integration
  88. #### Using JSON Data
  89. ```liquid
  90. {% for item in items %}
  91. <div>{{ item.name }}</div>
  92. {% endfor %}
  93. ```
  94. #### Conditional Rendering
  95. ```liquid
  96. {% if condition %}
  97. <div>Content</div>
  98. {% endif %}
  99. ```
  100. #### Including Components
  101. ```liquid
  102. {% include "ui/button.html" color="primary" text="Click me" %}
  103. ```
  104. ### 7. Best Practices
  105. #### Performance
  106. - Minimize nested loops
  107. - Use `limit` filters when iterating large datasets
  108. - Optimize images for web use
  109. #### Code Organization
  110. - Keep components modular and reusable
  111. - Use consistent naming conventions
  112. - Comment complex logic
  113. - Group related functionality together
  114. #### Error Handling
  115. - Always check if data exists before using it
  116. - Provide fallback content for missing data
  117. - Use `{% if %}` guards for optional content