Skip to content

Commit 0efa01c

Browse files
authored
Merge pull request #33 from comphy-lab/vs-branch-6
vs-branch-6
2 parents 03f6849 + 0563aa1 commit 0efa01c

14 files changed

+1383
-1477
lines changed

Diff for: .github/assets/js/shortcut-key.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
// Platform detection is now handled by platform-utils.js
3+
/**
4+
* Dynamically loads a stylesheet into the document's head.
5+
*
6+
* Creates a <link> element with the specified URL, sets attributes necessary for secure loading,
7+
* and appends it to the document's head. If the stylesheet fails to load, an error is logged
8+
* to the console.
9+
*
10+
* @param {string} href - The URL of the stylesheet to be loaded.
11+
* @returns {HTMLLinkElement} The created and appended link element.
12+
*/
13+
14+
function loadStylesheet(href) {
15+
const link = document.createElement('link');
16+
link.rel = 'stylesheet';
17+
link.href = href;
18+
link.crossOrigin = 'anonymous';
19+
link.onerror = () => console.error(`Failed to load stylesheet: ${href}`);
20+
document.head.appendChild(link);
21+
return link;
22+
}
23+
24+
const FA_VERSION = '6.7.2'; // Extract version to a constant for easier updates
25+
26+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/solid.css`);
27+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/brands.css`);
28+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/fontawesome.css`);
29+
});

Diff for: News.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a href="https://ammodo-science.webflow.io/researches/vatsal-sanjay" style="display: flex; align-items: center; text-decoration: none; color: #cf4900; font-size: 1em; font-weight: 500;"><i class="fa-solid fa-arrow-up-right-from-square" style="margin-right: 8px; font-size: 1.2em;"></i>Read More</a>
1414
</div>
1515
</div>
16-
<div style="font-size: 0.75em; color: #666; margin-top: 5px; font-style: italic;">
16+
<div style="font-size: 0.75em; color: var(--color-text); opacity: 0.7; margin-top: 5px; font-style: italic;">
1717
Image credit: J. Heitman, B. J. Howlett, P. W. Crous, E. H. Stukenbrock, T. Y. James & N. A. R. Gow, The fungal kingdom, John Wiley & Sons (2020)
1818
</div>
1919
</div>

Diff for: README.md

+65-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ A static website for the Computational Multiphase Physics Laboratory, built with
3333
│ │ ├── research.css # Research page styles with dark mode support
3434
│ │ ├── teaching.css # Teaching page styles with dark mode support
3535
│ │ ├── team.css # Team page styles with dark mode support
36-
│ │ ├── styles.css # Global styles with light/dark theme variables
36+
│ │ ├── styles.css # Global styles with light/dark theme variables (optimized)
3737
│ │ └── command-palette.css # Command palette styles (⌘K)
3838
│ ├── js # JavaScript files
3939
│ │ ├── main.js # Main JavaScript
4040
│ │ ├── command-data.js # Command palette data and functionality
41-
│ │ ├── shortcut-key.js # Platform detection for shortcuts
41+
│ │ ├── platform-utils.js # Platform detection and UI utilities
42+
│ │ ├── shortcut-key.js # Keyboard shortcut handling
4243
│ │ └── search_db.json # Generated search database (used by command palette)
4344
│ ├── favicon # Favicon files
4445
│ └── img # Image assets
@@ -467,4 +468,65 @@ To submit a PR:
467468
3. Test changes locally
468469
4. Create a PR using the template
469470
5. Link any related issues
470-
6. Wait for review
471+
6. Wait for review
472+
473+
### Code Style
474+
475+
#### General
476+
- Use 2-space indentation across all files
477+
- Follow DRY principles: reuse components, variables, and styles
478+
- Add comments for complex logic, but keep code self-documenting
479+
480+
#### HTML/Markdown
481+
- Use semantic HTML elements
482+
- Follow BEM naming convention for CSS classes (e.g., `s-header__nav-list`)
483+
- Keep content files in markdown format where possible
484+
485+
#### CSS
486+
- Use CSS variables for colors and typography (defined in `:root`)
487+
- Use responsive breakpoints at 1700px, 1300px, 900px, 768px, 500px
488+
- Use `rem` units for font sizes and spacing
489+
- Follow mobile-first approach for media queries
490+
- Leverage CSS custom properties for theme switching
491+
- Organize media queries by breakpoint for better maintainability
492+
- Use standardized variable naming for consistent styling
493+
494+
#### JavaScript
495+
- Use ES6+ features (arrow functions, const/let, template literals)
496+
- Always include 'use strict' mode
497+
- Use async/await for asynchronous operations
498+
- Implement error handling with try/catch blocks
499+
- Use camelCase for variable and function names
500+
- Prefer event delegation for multiple similar elements
501+
502+
#### Images
503+
- Optimize images for web (compress to reduce file size)
504+
- Follow naming convention: `[name]-[descriptor].[extension]`
505+
- Include alt text for all images
506+
507+
### CSS Architecture
508+
509+
The website's CSS has been optimized for better performance and maintainability:
510+
511+
1. **Variable System**
512+
- Color variables for both light and dark themes
513+
- Typography variables for consistent font sizing
514+
- Spacing variables for layout consistency
515+
- Shadow and transition presets for unified effects
516+
517+
2. **Consolidated Media Queries**
518+
- Queries organized by breakpoint rather than by component
519+
- Shared breakpoints at 1700px, 1300px, 1200px, 900px, 768px, and 500px
520+
- Mobile-first approach throughout
521+
522+
3. **Optimized Dark Theme Support**
523+
- CSS variables for seamless theme switching
524+
- Fallback values for older browsers
525+
- Theme-specific accent colors and contrasts
526+
- Consistent text and background colors across components
527+
528+
4. **Performance Improvements**
529+
- Reduced redundant selectors
530+
- Consolidated duplicate styles
531+
- Optimized transitions and animations
532+
- Simplified box shadows for better rendering

Diff for: _layouts/default.html

+17-18
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@
9292
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
9393
<script defer src="/assets/js/main.js"></script>
9494
<script defer src="/assets/js/command-data.js"></script>
95+
<script defer src="/assets/js/platform-utils.js"></script>
96+
<script defer src="/assets/js/shortcut-key.js"></script>
9597

9698
<script>
9799
document.documentElement.classList.remove('no-js');
@@ -135,25 +137,22 @@
135137
<script>
136138
// Check if we're on localhost
137139
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
138-
// Load only specific Font Awesome icons for local development
139-
var icons = ['github', 'search', 'arrow-up-right-from-square', 'bluesky', 'youtube', 'arrow-up'];
140-
var link = document.createElement('link');
141-
link.rel = 'stylesheet';
142-
link.href = 'https://use.fontawesome.com/releases/v6.7.2/css/solid.css';
143-
link.crossOrigin = 'anonymous';
144-
document.head.appendChild(link);
145-
146-
var link2 = document.createElement('link');
147-
link2.rel = 'stylesheet';
148-
link2.href = 'https://use.fontawesome.com/releases/v6.7.2/css/brands.css';
149-
link2.crossOrigin = 'anonymous';
150-
document.head.appendChild(link2);
140+
// Load Font Awesome stylesheets with improved error handling and version extraction
141+
function loadStylesheet(href) {
142+
const link = document.createElement('link');
143+
link.rel = 'stylesheet';
144+
link.href = href;
145+
link.crossOrigin = 'anonymous';
146+
link.onerror = () => console.error(`Failed to load stylesheet: ${href}`);
147+
document.head.appendChild(link);
148+
return link;
149+
}
150+
151+
const FA_VERSION = '6.7.2'; // Extract version to a constant for easier updates
151152

152-
var link3 = document.createElement('link');
153-
link3.rel = 'stylesheet';
154-
link3.href = 'https://use.fontawesome.com/releases/v6.7.2/css/fontawesome.css';
155-
link3.crossOrigin = 'anonymous';
156-
document.head.appendChild(link3);
153+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/solid.css`);
154+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/brands.css`);
155+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/fontawesome.css`);
157156
} else {
158157
// Use Kit for production with defer
159158
var script = document.createElement('script');

Diff for: _layouts/research.html

+39-21
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,27 @@
6161
cursor: pointer;
6262
transition: background-color 0.2s ease;
6363
text-decoration: none;
64-
color: inherit;
64+
color: #333333;
65+
}
66+
[data-theme="dark"] tags span, [data-theme="dark"] tags a.tag-link {
67+
background-color: #2a2a30;
68+
color: #ffffff;
69+
border: 1px solid rgba(111, 161, 255, 0.3);
6570
}
6671
tags span:hover, tags a.tag-link:hover {
6772
background-color: #e0e0e0;
6873
}
74+
[data-theme="dark"] tags span:hover, [data-theme="dark"] tags a.tag-link:hover {
75+
background-color: #3a3a40;
76+
}
6977
tags span.active, tags a.tag-link.active {
7078
background-color: #007bff;
7179
color: white;
7280
}
81+
[data-theme="dark"] tags span.active, [data-theme="dark"] tags a.tag-link.active {
82+
background-color: #4d8dff;
83+
color: white;
84+
}
7385
/* Style for filter notification */
7486
.filter-note {
7587
margin: 1rem 0;
@@ -152,6 +164,7 @@
152164
<script defer src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
153165
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
154166
<script defer src="/assets/js/main.js"></script>
167+
<script defer src="/assets/js/platform-utils.js"></script>
155168
<script defer src="/assets/js/command-data.js"></script>
156169
<script>
157170
document.documentElement.classList.remove('no-js');
@@ -195,25 +208,22 @@
195208
<script>
196209
// Check if we're on localhost
197210
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
198-
// Load only specific Font Awesome icons for local development
199-
var icons = ['github', 'search', 'arrow-up-right-from-square', 'bluesky', 'youtube', 'arrow-up'];
200-
var link = document.createElement('link');
201-
link.rel = 'stylesheet';
202-
link.href = 'https://use.fontawesome.com/releases/v6.7.2/css/solid.css';
203-
link.crossOrigin = 'anonymous';
204-
document.head.appendChild(link);
205-
206-
var link2 = document.createElement('link');
207-
link2.rel = 'stylesheet';
208-
link2.href = 'https://use.fontawesome.com/releases/v6.7.2/css/brands.css';
209-
link2.crossOrigin = 'anonymous';
210-
document.head.appendChild(link2);
211+
// Load Font Awesome stylesheets with improved error handling and version extraction
212+
function loadStylesheet(href) {
213+
const link = document.createElement('link');
214+
link.rel = 'stylesheet';
215+
link.href = href;
216+
link.crossOrigin = 'anonymous';
217+
link.onerror = () => console.error(`Failed to load stylesheet: ${href}`);
218+
document.head.appendChild(link);
219+
return link;
220+
}
221+
222+
const FA_VERSION = '6.7.2'; // Extract version to a constant for easier updates
211223

212-
var link3 = document.createElement('link');
213-
link3.rel = 'stylesheet';
214-
link3.href = 'https://use.fontawesome.com/releases/v6.7.2/css/fontawesome.css';
215-
link3.crossOrigin = 'anonymous';
216-
document.head.appendChild(link3);
224+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/solid.css`);
225+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/brands.css`);
226+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/fontawesome.css`);
217227
} else {
218228
// Use Kit for production with defer
219229
var script = document.createElement('script');
@@ -516,7 +526,12 @@ <h3>Contents</h3>
516526
const updateMatchingTags = (tagText, shouldHighlight) => {
517527
document.querySelectorAll('tags span').forEach(tag => {
518528
if (tag.textContent === tagText) {
519-
tag.classList.toggle('active', shouldHighlight);
529+
// First remove any active class
530+
tag.classList.remove('active');
531+
// Then add it back if needed
532+
if (shouldHighlight) {
533+
tag.classList.add('active');
534+
}
520535
}
521536
});
522537
};
@@ -529,7 +544,8 @@ <h3>Contents</h3>
529544
// If clicking the active tag, deactivate it
530545
if (activeTag === tagText) {
531546
activeTag = null;
532-
updateMatchingTags(tagText, false);
547+
// Remove active class from all tags
548+
allTags.forEach(t => t.classList.remove('active'));
533549
paperContainers.forEach(container => {
534550
container.classList.remove('hidden');
535551
});
@@ -539,7 +555,9 @@ <h3>Contents</h3>
539555

540556
// Update active tag
541557
activeTag = tagText;
558+
// Remove active class from all tags
542559
allTags.forEach(t => t.classList.remove('active'));
560+
// Add active class to matching tags
543561
updateMatchingTags(tagText, true);
544562

545563
// Update URL

Diff for: _layouts/teaching-course.html

+16-18
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<script defer src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
8282
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
8383
<script defer src="/assets/js/main.js"></script>
84+
<script defer src="/assets/js/platform-utils.js"></script>
8485
<script defer src="/assets/js/command-data.js"></script>
8586

8687
<!-- Theme toggle functionality -->
@@ -137,25 +138,22 @@
137138
<script>
138139
// Check if we're on localhost
139140
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
140-
// Load only specific Font Awesome icons for local development
141-
var icons = ['github', 'search', 'arrow-up-right-from-square', 'bluesky', 'youtube', 'arrow-up', 'calendar-days', 'location-dot', 'clock'];
142-
var link = document.createElement('link');
143-
link.rel = 'stylesheet';
144-
link.href = 'https://use.fontawesome.com/releases/v6.7.2/css/solid.css';
145-
link.crossOrigin = 'anonymous';
146-
document.head.appendChild(link);
147-
148-
var link2 = document.createElement('link');
149-
link2.rel = 'stylesheet';
150-
link2.href = 'https://use.fontawesome.com/releases/v6.7.2/css/brands.css';
151-
link2.crossOrigin = 'anonymous';
152-
document.head.appendChild(link2);
141+
// Load Font Awesome stylesheets with improved error handling and version extraction
142+
function loadStylesheet(href) {
143+
const link = document.createElement('link');
144+
link.rel = 'stylesheet';
145+
link.href = href;
146+
link.crossOrigin = 'anonymous';
147+
link.onerror = () => console.error(`Failed to load stylesheet: ${href}`);
148+
document.head.appendChild(link);
149+
return link;
150+
}
151+
152+
const FA_VERSION = '6.7.2'; // Extract version to a constant for easier updates
153153

154-
var link3 = document.createElement('link');
155-
link3.rel = 'stylesheet';
156-
link3.href = 'https://use.fontawesome.com/releases/v6.7.2/css/fontawesome.css';
157-
link3.crossOrigin = 'anonymous';
158-
document.head.appendChild(link3);
154+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/solid.css`);
155+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/brands.css`);
156+
loadStylesheet(`https://use.fontawesome.com/releases/v${FA_VERSION}/css/fontawesome.css`);
159157
} else {
160158
// Use Kit for production with defer
161159
var script = document.createElement('script');

0 commit comments

Comments
 (0)