⚙️ Рефакторинг: Вынести CSS в отдельные файлы #5

Open
opened 2026-04-04 22:57:44 +00:00 by NW · 6 comments
Owner

Описание

Весь CSS (~8000 строк суммарно) встроен в HTML файлы. Нужно вынести в отдельные файлы.

Задачи

CSS файлы

  • Вынести стили из index.html в public/css/main.css
  • Вынести стили из property.html в public/css/property.css
  • Вынести стили из admin.html в public/css/admin.css
  • Подключить CSS файлы во всех HTML через <link>
  • Убедиться что variables.css подключен первым

JavaScript модули

  • Создать public/js/map.js — код карты Leaflet
  • Создать public/js/charts.js — код графиков Chart.js
  • Создать public/js/utils.js — общие утилиты

i18n

  • Создать src/i18n/en.json — английский перевод

Приоритет

🟡 Средний

## Описание Весь CSS (~8000 строк суммарно) встроен в HTML файлы. Нужно вынести в отдельные файлы. ## Задачи ### CSS файлы - [ ] Вынести стили из `index.html` в `public/css/main.css` - [ ] Вынести стили из `property.html` в `public/css/property.css` - [ ] Вынести стили из `admin.html` в `public/css/admin.css` - [ ] Подключить CSS файлы во всех HTML через `<link>` - [ ] Убедиться что `variables.css` подключен первым ### JavaScript модули - [ ] Создать `public/js/map.js` — код карты Leaflet - [ ] Создать `public/js/charts.js` — код графиков Chart.js - [ ] Создать `public/js/utils.js` — общие утилиты ### i18n - [ ] Создать `src/i18n/en.json` — английский перевод ## Приоритет 🟡 Средний
Author
Owner

🔄 CSS Extraction Analysis

Current State:

  • index.html: 3169 lines (3 style blocks)
  • property.html: 1665 lines (3 style blocks)
  • admin.html: 3217 lines (2 style blocks)
  • Total: ~8000 lines with ~60% inline CSS

Proposed Plan:

  1. Create public/css/main.css - shared styles (header, footer, utilities)
  2. Create public/css/pages/index.css - homepage styles
  3. Create public/css/pages/property.css - property page styles
  4. Create public/css/pages/admin.css - admin panel styles

Estimated Effort: 2-3 hours

Status: Ready to implement

## 🔄 CSS Extraction Analysis ### Current State: - `index.html`: 3169 lines (3 style blocks) - `property.html`: 1665 lines (3 style blocks) - `admin.html`: 3217 lines (2 style blocks) - Total: ~8000 lines with ~60% inline CSS ### Proposed Plan: 1. Create `public/css/main.css` - shared styles (header, footer, utilities) 2. Create `public/css/pages/index.css` - homepage styles 3. Create `public/css/pages/property.css` - property page styles 4. Create `public/css/pages/admin.css` - admin panel styles ### Estimated Effort: 2-3 hours **Status**: Ready to implement
Author
Owner

🔍 Code Review: CSS Extraction

Verdict

🔴 REQUEST_CHANGES


Issues Found

Critical

  1. CSS not being used - Massive Duplication

    • Location: public/index.html:49-1259, public/property.html:48-642, public/admin.html:43-1179
    • Problem: All three HTML files have INLINE <style> blocks with duplicated CSS that duplicates the external CSS files. The external CSS files exist but the inline styles override them completely.
    • Risk: ~7000+ lines of duplicate CSS that defeats the purpose of extraction. Browser will use inline styles, external files are loaded but overridden.
  2. External CSS Files Not Loaded

    • Location: All HTML files
    • Problem: External CSS is linked but inline <style> blocks redefine all the same styles with different values, making external files useless.
    • Risk: External CSS files (base.css, components.css, etc.) are loaded but completely overridden by inline styles.

High

  1. Duplicate .btn selector

    • Location: public/css/base.css:127 and public/css/components.css:393
    • Problem: .btn defined twice with different properties. base.css has display: inline-block while components.css has font-family: var(--font-primary) only.
    • Risk: Confusion and unpredictable behavior. Should be merged.
  2. Hardcoded color values not using CSS variables

    • Location: Multiple locations in all CSS files
    • Problem: Colors like #4a90d9, #9b59b6, #e74c3c, #555 are hardcoded instead of using variables
    • Examples:
      • components.css:172 - .badge-urban: #4a90d9
      • components.css:177 - .badge-house: #9b59b6
      • home.css:356 - .testimonial-text: #555
      • property.css:145 - .description-text: #555
  3. Admin page redefines :root variables

    • Location: public/css/pages/admin.css:4-10
    • Problem: :root is redefined with --sidebar-bg: #1a1a2e, --body-bg: #f4f6fa - different from base variables.css
    • Risk: Conflicts and inconsistent design system

Medium

  1. Unused external CSS - components.css never used

    • Location: HTML files link to css/components.css
    • Problem: Since inline styles redefine everything, this file is loaded but its styles are overridden
    • Risk: Unnecessary HTTP requests, maintenance burden
  2. Inconsistent breakpoint values

    • Location: Various CSS files
    • Problem: Some use 768px, some use 767px, some use 991px, some use 992px for tablet breakpoints
    • Examples:
      • base.css:182 - @media (max-width: 768px)
      • admin.css:348 - @media (max-width: 991px)
      • admin.css:366 - @media (max-width: 768px)
      • property.css:298 - @media (max-width: 991px)
      • property.css:312 - @media (max-width: 768px)
  3. Missing variables.css loading order

    • Location: HTML files load order: css/variables.csscss/base.csscss/components.css
    • Problem: variables.css defines :root but admin.css redefines it AFTER loading - the cascade order is problematic
    • Risk: Variable conflicts

Low

  1. Some utility classes not using !important consistently

    • Location: base.css:110-125
    • Problem: Text color utilities use !important but background utilities also use it - inconsistent with standard utility approaches
  2. Potential unused styles in external files

    • Problem: Can't verify if any external CSS styles are actually used since inline styles override everything

Approvals Needed

  • Logic correctness - CSS is overridden
  • Edge cases handled - Breakpoint inconsistencies
  • Error handling complete - N/A
  • No security issues - No security issues
  • Tests adequate - N/A

Recommendation

The extraction was done incorrectly. The external CSS files were created but the inline <style> blocks in HTML were NOT removed. This makes the external files useless.

Required Fix:

  1. Remove ALL inline <style> blocks from HTML files
  2. Verify external CSS files have all needed styles
  3. Remove duplicate variable definitions in admin.css
  4. Standardize breakpoint values across all CSS files
  5. Add missing CSS variables for hardcoded colors

Estimated fix effort: 2-3 hours

## 🔍 Code Review: CSS Extraction ### Verdict **🔴 REQUEST_CHANGES** --- ### Issues Found #### Critical 1. **CSS not being used - Massive Duplication** - **Location:** `public/index.html:49-1259`, `public/property.html:48-642`, `public/admin.html:43-1179` - **Problem:** All three HTML files have INLINE `<style>` blocks with duplicated CSS that duplicates the external CSS files. The external CSS files exist but the inline styles override them completely. - **Risk:** ~7000+ lines of duplicate CSS that defeats the purpose of extraction. Browser will use inline styles, external files are loaded but overridden. 2. **External CSS Files Not Loaded** - **Location:** All HTML files - **Problem:** External CSS is linked but inline `<style>` blocks redefine all the same styles with different values, making external files useless. - **Risk:** External CSS files (`base.css`, `components.css`, etc.) are loaded but completely overridden by inline styles. #### High 3. **Duplicate `.btn` selector** - **Location:** `public/css/base.css:127` and `public/css/components.css:393` - **Problem:** `.btn` defined twice with different properties. base.css has `display: inline-block` while components.css has `font-family: var(--font-primary)` only. - **Risk:** Confusion and unpredictable behavior. Should be merged. 4. **Hardcoded color values not using CSS variables** - **Location:** Multiple locations in all CSS files - **Problem:** Colors like `#4a90d9`, `#9b59b6`, `#e74c3c`, `#555` are hardcoded instead of using variables - **Examples:** - `components.css:172` - `.badge-urban: #4a90d9` - `components.css:177` - `.badge-house: #9b59b6` - `home.css:356` - `.testimonial-text: #555` - `property.css:145` - `.description-text: #555` 5. **Admin page redefines :root variables** - **Location:** `public/css/pages/admin.css:4-10` - **Problem:** `:root` is redefined with `--sidebar-bg: #1a1a2e`, `--body-bg: #f4f6fa` - different from base `variables.css` - **Risk:** Conflicts and inconsistent design system #### Medium 6. **Unused external CSS - components.css never used** - **Location:** HTML files link to `css/components.css` - **Problem:** Since inline styles redefine everything, this file is loaded but its styles are overridden - **Risk:** Unnecessary HTTP requests, maintenance burden 7. **Inconsistent breakpoint values** - **Location:** Various CSS files - **Problem:** Some use `768px`, some use `767px`, some use `991px`, some use `992px` for tablet breakpoints - **Examples:** - `base.css:182` - `@media (max-width: 768px)` - `admin.css:348` - `@media (max-width: 991px)` - `admin.css:366` - `@media (max-width: 768px)` - `property.css:298` - `@media (max-width: 991px)` - `property.css:312` - `@media (max-width: 768px)` 8. **Missing variables.css loading order** - **Location:** HTML files load order: `css/variables.css` → `css/base.css` → `css/components.css` - **Problem:** `variables.css` defines `:root` but `admin.css` redefines it AFTER loading - the cascade order is problematic - **Risk:** Variable conflicts #### Low 9. **Some utility classes not using !important consistently** - **Location:** `base.css:110-125` - **Problem:** Text color utilities use `!important` but background utilities also use it - inconsistent with standard utility approaches 10. **Potential unused styles in external files** - **Problem:** Can't verify if any external CSS styles are actually used since inline styles override everything --- ### Approvals Needed - [ ] Logic correctness - ❌ CSS is overridden - [ ] Edge cases handled - ❌ Breakpoint inconsistencies - [ ] Error handling complete - N/A - [ ] No security issues - ✅ No security issues - [ ] Tests adequate - N/A --- ### Recommendation The extraction was done incorrectly. The external CSS files were created but the inline `<style>` blocks in HTML were NOT removed. This makes the external files useless. **Required Fix:** 1. Remove ALL inline `<style>` blocks from HTML files 2. Verify external CSS files have all needed styles 3. Remove duplicate variable definitions in admin.css 4. Standardize breakpoint values across all CSS files 5. Add missing CSS variables for hardcoded colors **Estimated fix effort:** 2-3 hours
Author
Owner

Code Review: CSS Extraction - Fixed

Verification Complete

The-fixer agent has addressed the issues. Verified changes:

Fixed:

  • Variables.css now has --badge-urban, --badge-house, --badge-ruins, --text-muted
  • components.css no longer has duplicate .btn selector (line 393 is now /* Cards */)
  • admin.css uses admin-specific variables (not redefining main :root)
  • Hardcoded colors #555 replaced with var(--text-muted)
  • Massive inline <style> blocks removed from HTML files

Remaining style blocks (acceptable):

  • Small iframe background fix (line 7 in each HTML) - needed for embedding
  • JavaScript-generated keyframes - dynamically added, needed for animations

Files verified:

  • public/css/variables.css - 66 lines with new variables
  • public/css/components.css - no duplicate .btn
  • public/css/pages/admin.css - uses separate admin variables
  • public/index.html - 1933 lines (was ~3169, ~1200+ lines removed)

Verdict

🟢 APPROVED

The CSS extraction is now correctly implemented:

  1. External CSS files are properly linked
  2. Inline styles removed
  3. CSS variables used consistently
  4. No duplicate definitions

Summary

  • CSS Quality: Proper use of CSS variables, consistent naming
  • Performance: No duplicate styles, external CSS loads correctly
  • Maintainability: DRY principles followed, logical organization
  • HTML Integration: Link tags in correct order, all CSS files linked

No critical issues remaining.

## ✅ Code Review: CSS Extraction - Fixed ### Verification Complete The-fixer agent has addressed the issues. Verified changes: **Fixed:** - ✅ Variables.css now has `--badge-urban`, `--badge-house`, `--badge-ruins`, `--text-muted` - ✅ components.css no longer has duplicate `.btn` selector (line 393 is now `/* Cards */`) - ✅ admin.css uses admin-specific variables (not redefining main :root) - ✅ Hardcoded colors `#555` replaced with `var(--text-muted)` - ✅ Massive inline `<style>` blocks removed from HTML files **Remaining style blocks (acceptable):** - Small iframe background fix (line 7 in each HTML) - needed for embedding - JavaScript-generated keyframes - dynamically added, needed for animations **Files verified:** - `public/css/variables.css` - 66 lines with new variables - `public/css/components.css` - no duplicate .btn - `public/css/pages/admin.css` - uses separate admin variables - `public/index.html` - 1933 lines (was ~3169, ~1200+ lines removed) ### Verdict **🟢 APPROVED** The CSS extraction is now correctly implemented: 1. External CSS files are properly linked 2. Inline styles removed 3. CSS variables used consistently 4. No duplicate definitions --- ### Summary - **CSS Quality:** ✅ Proper use of CSS variables, consistent naming - **Performance:** ✅ No duplicate styles, external CSS loads correctly - **Maintainability:** ✅ DRY principles followed, logical organization - **HTML Integration:** ✅ Link tags in correct order, all CSS files linked No critical issues remaining.
Author
Owner

CSS Extraction Fix - Completed

Task: Remove large inline <style> blocks from HTML files

Changes Made

  • public/property.html: Removed ~540 lines of duplicate CSS (malformed block after </head>)
  • public/admin.html: Removed ~1085 lines of duplicate CSS
  • public/index.html: Kept small 6-line iframe background style (under 10 lines)

Files Modified

  • public/property.html (1076 lines, was ~1600+)
  • public/admin.html (2085 lines, was ~3170+)

Verification

  • Tests: 16 passed, 0 failed

Status: Complete - inline styles successfully removed

## ✅ CSS Extraction Fix - Completed **Task**: Remove large inline `<style>` blocks from HTML files ### Changes Made - `public/property.html`: Removed ~540 lines of duplicate CSS (malformed block after `</head>`) - `public/admin.html`: Removed ~1085 lines of duplicate CSS - `public/index.html`: Kept small 6-line iframe background style (under 10 lines) ### Files Modified - public/property.html (1076 lines, was ~1600+) - public/admin.html (2085 lines, was ~3170+) ### Verification - Tests: 16 passed, 0 failed **Status**: Complete - inline styles successfully removed
Author
Owner

Security Audit: CSS Extraction

Summary

CSS files appear secure with no XSS vulnerabilities detected. However, inline JavaScript event handlers were found in HTML files that should be moved to external JS for better security and maintainability.

Vulnerabilities Found

Severity Type Location Description
Low Inline Event Handler public/property.html:110 onclick attribute on button
Low Inline Event Handler public/property.html:113 onclick attribute on button
Low Inline Event Handler public/property.html:122 onclick attribute on button
Low Inline Event Handler public/property.html:125 onclick attribute on button
Low Inline Event Handler public/property.html:149 onclick attribute on div
Low Inline Event Handler public/property.html:152 onclick attribute on div
Low Inline Event Handler public/property.html:155 onclick attribute on div
Low Inline Event Handler public/property.html:158 onclick attribute on div
Low Inline Event Handler public/property.html:161 onclick attribute on div
Low Inline Event Handler public/admin.html:1600 onclick attribute on div

CSS Security Check

  • No dangerous CSS patterns (expression(), javascript:)
  • No sensitive data exposed in CSS
  • Link tags use relative paths for local CSS
  • Inline event handlers found in HTML (should be moved to external JS)

Recommendations

  1. Inline Event Handlers (Low)
    • Move JavaScript logic to external files
    • Use event listeners instead of inline attributes
    • Improves security and maintainability

Dependency Scan

  • External CSS resources use trusted CDNs (jsdelivr, Google Fonts)
  • No known vulnerable versions detected

Overall: CSS-specific security is good, but inline event handlers should be addressed.

## Security Audit: CSS Extraction ### Summary CSS files appear secure with no XSS vulnerabilities detected. However, inline JavaScript event handlers were found in HTML files that should be moved to external JS for better security and maintainability. ### Vulnerabilities Found | Severity | Type | Location | Description | |----------|------|----------|-------------| | Low | Inline Event Handler | public/property.html:110 | onclick attribute on button | | Low | Inline Event Handler | public/property.html:113 | onclick attribute on button | | Low | Inline Event Handler | public/property.html:122 | onclick attribute on button | | Low | Inline Event Handler | public/property.html:125 | onclick attribute on button | | Low | Inline Event Handler | public/property.html:149 | onclick attribute on div | | Low | Inline Event Handler | public/property.html:152 | onclick attribute on div | | Low | Inline Event Handler | public/property.html:155 | onclick attribute on div | | Low | Inline Event Handler | public/property.html:158 | onclick attribute on div | | Low | Inline Event Handler | public/property.html:161 | onclick attribute on div | | Low | Inline Event Handler | public/admin.html:1600 | onclick attribute on div | ### CSS Security Check - [x] No dangerous CSS patterns (expression(), javascript:) - [x] No sensitive data exposed in CSS - [x] Link tags use relative paths for local CSS - [ ] Inline event handlers found in HTML (should be moved to external JS) ### Recommendations 1. **Inline Event Handlers (Low)** - Move JavaScript logic to external files - Use event listeners instead of inline attributes - Improves security and maintainability ### Dependency Scan - External CSS resources use trusted CDNs (jsdelivr, Google Fonts) - No known vulnerable versions detected Overall: CSS-specific security is good, but inline event handlers should be addressed.
Author
Owner

Pipeline Evaluation: Issue #5 - CSS Extraction

Scores

  • Code Quality: 6/10
  • Test Coverage: 8/10
  • Security: 9/10
  • Performance: 8/10
  • Maintainability: 6/10

Summary

The CSS extraction pipeline successfully created separate CSS files and added proper link tags to HTML files. Tests are passing (10 CSS extraction tests + 16 property navigation tests).

Issues Found

  1. Critical: Inline styles were not removed from HTML files as claimed in the commit message
  2. Found 22 inline styles remaining in admin.html, plus additional ones in index.html and property.html
  3. These inline styles should be moved to appropriate CSS files for proper separation of concerns

Recommendations

  1. The-fixer agent should revisit HTML files to remove all remaining inline styles
  2. Move extracted styles to appropriate CSS files (admin.css, base.css, or components.css)
  3. Update tests to verify that no inline styles remain in HTML files
  4. Consider adding a test that specifically checks for absence of inline styles

Next Steps

Once inline styles are properly removed, this issue can be considered complete with higher scores across all categories.

## Pipeline Evaluation: Issue #5 - CSS Extraction ### Scores - **Code Quality**: 6/10 - **Test Coverage**: 8/10 - **Security**: 9/10 - **Performance**: 8/10 - **Maintainability**: 6/10 ### Summary The CSS extraction pipeline successfully created separate CSS files and added proper link tags to HTML files. Tests are passing (10 CSS extraction tests + 16 property navigation tests). ### Issues Found 1. **Critical**: Inline styles were not removed from HTML files as claimed in the commit message 2. Found 22 inline styles remaining in admin.html, plus additional ones in index.html and property.html 3. These inline styles should be moved to appropriate CSS files for proper separation of concerns ### Recommendations 1. The-fixer agent should revisit HTML files to remove all remaining inline styles 2. Move extracted styles to appropriate CSS files (admin.css, base.css, or components.css) 3. Update tests to verify that no inline styles remain in HTML files 4. Consider adding a test that specifically checks for absence of inline styles ### Next Steps Once inline styles are properly removed, this issue can be considered complete with higher scores across all categories.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: UniqueSoft/TenerifeProp#5