Search

Modular Research Themes Refactoring

This document describes the modular structure for research themes on the home page.

Overview

The research themes section has been refactored from inline HTML to a modular, data-driven structure.

Structure

Before (Inline HTML - 180 lines)

<div class="theme-block" data-theme="superconducting">
    <div class="theme-icon">
        <svg viewBox="0 0 100 100">
            <!-- 100+ lines of SVG code -->
        </svg>
    </div>
    <h3>Title</h3>
    <p>Description</p>
    <!-- Repeated for each theme -->
</div>

After (Modular - 25 lines)

{% for theme in site.data.research_themes %}
<div class="theme-block" data-theme="{{ theme.id }}">
    <div class="theme-icon">
        {% include components/theme-block.html theme=theme %}
    </div>
    <h3>{{ theme.title }}</h3>
    <p>{{ theme.description }}</p>
</div>
{% endfor %}

File Organization

/_data/
  └── research_themes.yml          # Theme configuration data
  └── README.md                     # Documentation

/assets/icons/themes/
  ├── superconducting.svg          # Individual SVG icons
  ├── qec.svg
  ├── tensor.svg
  ├── neural.svg
  └── README.md                     # Icon guidelines

/assets/js/
  └── home.js                       # Project data (unchanged)

/assets/css/
  └── home.css                      # Styling (unchanged)

/index.md                           # Simplified theme rendering

Benefits

1. Maintainability

2. Reusability

3. Scalability

4. Version Control

5. Developer Experience

Adding a New Theme

Step 1: Create Icon SVG

Create /assets/icons/themes/your-theme.svg:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
    <!-- Your icon design using currentColor -->
</svg>

Step 2: Add to Data File

Edit /_data/research_themes.yml:

- id: your-theme
  title: Your Theme Title
  description: Your theme description
  icon: /assets/icons/themes/your-theme.svg
  stats:
    completed: 0
    ongoing: 1
    potential: 0

Step 3: Add Projects (Optional)

Edit /assets/js/home.js to add project data for the theme.

Step 4: Add Custom Styling (Optional)

Edit /assets/css/home.css to add theme-specific hover colors.

Editing Existing Themes

Change Title/Description

Edit /_data/research_themes.yml - changes apply immediately on next build.

Change Icon

Edit the corresponding SVG file in /assets/icons/themes/.

Change Stats

Update the stats section in research_themes.yml.

Code Reduction

Conclusion

This refactoring makes the codebase more maintainable, scalable, and easier to understand while preserving all existing functionality.