Skip to content

Extract shared CSS into separate style block with validation - #9

Merged
namingbe merged 5 commits into
masterfrom
claude/css-coherence-check-u43wd9
Sep 6, 2026
Merged

Extract shared CSS into separate style block with validation#9
namingbe merged 5 commits into
masterfrom
claude/css-coherence-check-u43wd9

Conversation

@namingbe

@namingbe namingbe commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a mechanism to maintain consistent shared CSS across multiple HTML files by extracting common styles into a dedicated <style data-shared> block and adding automated validation via GitHub Actions.

Key Changes

  • Added GitHub Actions workflow (check-shared-css.yml): Automatically verifies that all HTML files with <style data-shared> blocks contain identical CSS, preventing style drift across the codebase
  • Refactored CSS in index.html and playground.html:
    • Moved common CSS variables and universal reset rules (*, body base styles) into a shared <style data-shared> block
    • Separated page-specific CSS variables (--add, --del, --drop-active) into a separate <style> block to maintain file-specific customizations
    • Preserved all existing styles and functionality

Implementation Details

  • The shared CSS block includes foundational styles: CSS custom properties (colors, fonts), universal selector reset, and base body styling
  • Page-specific variables remain in separate style blocks, allowing each page to customize behavior while maintaining a consistent visual foundation
  • The validation workflow uses xmllint to extract and compare data-shared style blocks, ensuring consistency is maintained as the codebase evolves
  • The workflow requires at least 2 files with shared CSS blocks to be present, preventing accidental removal of the feature

https://claude.ai/code/session_01S3ETpFXfDZUnDPky8Vs6Gw

Both pages keep their CSS fully inlined (no external stylesheet),
preserving single-file portability. A CI workflow verifies the
<style data-shared> blocks are byte-identical across all HTML files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3ETpFXfDZUnDPky8Vs6Gw
Drop HTMLParser class in favor of string splitting.
Expand header rules back to multi-line to match original style.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3ETpFXfDZUnDPky8Vs6Gw
Splits :root tokens and reset into <style data-shared> in both pages.
CI uses xmllint XPath to extract and compare the shared blocks.
No selectors reorganized; page-specific CSS untouched.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3ETpFXfDZUnDPky8Vs6Gw
@namingbe
namingbe merged commit b43e476 into master Sep 6, 2026
1 check passed
@namingbe
namingbe deleted the claude/css-coherence-check-u43wd9 branch September 6, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants