Skip to content

palette option#477

Merged
rultor merged 8 commits intozerocracy:masterfrom
codeninja-ru:31-palette-option
Dec 26, 2025
Merged

palette option#477
rultor merged 8 commits intozerocracy:masterfrom
codeninja-ru:31-palette-option

Conversation

@codeninja-ru
Copy link
Contributor

@codeninja-ru codeninja-ru commented Dec 2, 2025

Close #31

Changes:

  • palette option was added. Possible values: classic, dark, mild.
  • classic palette is default.
  • palette can be changed by adding css class to <html> tag.
    For example:<html class="palette-dark"> will use dark palette.
  • Added roughly made palettes dark and mild they have to be adjusted and improved taking into account Integrate palette.css and remove redundant styles #461 Puzzles were added about this.

dark and mild palettes:
dark
mild

Summary by CodeRabbit

  • New Features

    • Added a palette configuration to customize the vitals HTML theme with choices: classic, dark, mild (default: classic).
    • Theme selection now applies a palette-specific class to the generated HTML.
  • Documentation

    • README updated to document the new palette option.
  • Tests

    • Added automated checks to validate output for each palette variant.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

Adds a configurable palette option that flows from the GitHub Action input through the entry script into the XSL transformation, producing HTML with a palette-specific root class and new Sass styles for classic, dark, and mild themes. (Documentation, scripts, XSL, and styles updated.)

Changes

Cohort / File(s) Summary
Docs & Action config
README.md, action.yml
Added palette input (default: classic) and documented available values (classic, dark, mild).
Action runtime script
entry.sh
Read INPUT_PALETTE into palette (default classic), echo selection, and pass palette=${palette} to Saxon XSLT invocations.
XSL output
xsl/vitals.xsl
Declared public parameter palette (xs:string) and applied class="palette-{palette}" on the root HTML element.
Styling
sass/main.scss
Added .palette-dark and .palette-mild theme blocks (colors for body, headings, header span, warning, footer) and stylelint controls/comments.
Tests / CI entries
entries/vitals-has-palette-option.sh
New test script exercising palette variants (dark, mild, classic, and default) and validating generated HTML contains corresponding palette classes.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
actor User
participant GitHubAction as Action (inputs)
participant Entry as entry.sh
participant Saxon as Saxon/XSLT
participant HTML as Generated HTML
participant CSS as Sass/CSS
User->>GitHubAction: supply inputs (including palette)
GitHubAction->>Entry: set INPUT_PALETTE env
Entry->>Entry: palette=${INPUT_PALETTE:-classic}
Entry->>Saxon: invoke XSLT with palette=${palette}
Saxon->>HTML: render ...
CSS->>HTML: .palette-{palette} rules applied at render time

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay special attention to:
    • entry.sh: correct defaulting, quoting, and that all Saxon call sites include the new parameter.
    • xsl/vitals.xsl: XSL parameter declaration and proper attribute value construction for the class.
    • sass/main.scss: selector specificity and potential clashes with existing styles.
    • entries/vitals-has-palette-option.sh: test robustness (temp files, bundle invocation, log handling, grep assertions).

Poem

🐇 I nudged the palette, now pages gleam,
classic, dark, or mild — a designer's dream.
From script to XSL, the classes leap,
styles tuck in, the visuals keep.
Hop, click, and watch the colors stream! 🎨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'palette option' is vague and generic, using non-descriptive phrasing that doesn't clearly convey the specific change being made. Use a more specific title like 'Add palette configuration option for dark, mild, and classic themes' to better summarize the main change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #31: adds a palette input parameter, implements classic/dark/mild palette options, applies palette class to HTML element, and integrates it throughout the action workflow.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the palette option feature as specified in issue #31; no unrelated or out-of-scope modifications were detected in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
xsl/vitals.xsl (1)

13-13: Palette parameter plumbing into the root HTML class looks correct; consider adding an XSL default.

The new palette param and class="palette-..." wiring are consistent with the rest of the PR. To make the transform more robust when run outside entry.sh, you could give the parameter an XSL-level default:

-  <xsl:param name="palette" as="xs:string"/>
+  <xsl:param name="palette" as="xs:string" select="'classic'"/>

This keeps current behavior but avoids an empty class="palette-" if the param isn’t provided.

Also applies to: 119-121

entry.sh (1)

173-177: Palette defaulting and Saxon parameter wiring look good.

Reading INPUT_PALETTE, falling back to "classic", and passing palette=${palette} into Saxon is consistent with the action input and XSLT parameter. I don’t see any functional issues here.

If you want slightly clearer logs, you could also echo the explicitly set palette (not only the default case), but that’s purely optional.

Also applies to: 225-225

sass/main.scss (1)

2-2: Palette-specific styles are wired correctly; consider contrast tweaks for the mild theme.

The .palette-dark / .palette-mild blocks line up with the class="palette-{palette}" on <html>, and the stylelint disable/enable around them is scoped cleanly.

One thing to revisit: in .palette-mild you set background-color: #777 with text #333 on body, which is a relatively low contrast combination. It may be worth lightening the background or darkening the text there (and checking headings) to keep the “mild” look while staying comfortably readable.

Also applies to: 83-144

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 846c479 and 5b46281.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • action.yml (1 hunks)
  • entry.sh (2 hunks)
  • sass/main.scss (2 hunks)
  • xsl/vitals.xsl (2 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~39-~39: Ensure spelling is correct
Context: ...HTML page; * palette (optional) color polette of the vitals HTML page; (default: clas...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: make

@codeninja-ru codeninja-ru marked this pull request as draft December 2, 2025 19:33
@codeninja-ru codeninja-ru marked this pull request as ready for review December 4, 2025 12:14
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
entries/vitals-has-palette-option.sh (2)

13-24: Consider improving log file handling and reducing code duplication.

The test script contains four nearly identical test blocks. While the repetition is clear and explicit, it could be refactored into a helper function to reduce maintenance burden and make future changes easier.

Additionally, each call to tee log.txt overwrites the log file, losing the output of previous test runs. If one of the later tests fails, you can only see the log from that final failed run, not the successful intermediate tests. Consider appending logs or using a timestamp-based naming scheme.

Example refactoring (helper function):

run_palette_test() {
  local palette_name=$1
  env "GITHUB_WORKSPACE=$(pwd)" \
    'GITHUB_REPOSITORY=foo/bar' \
    'GITHUB_REPOSITORY_OWNER=foo' \
    'INPUT_FACTBASE=test.fb' \
    'INPUT_OUTPUT=output' \
    'INPUT_VERBOSE=false' \
    "INPUT_PALETTE=${palette_name}" \
    'INPUT_ADLESS=false' \
    'INPUT_GITHUB-TOKEN=THETOKEN' \
    "${SELF}/entry.sh" 2>&1 | tee "log-${palette_name}.txt"
  
  grep "<html class=\"palette-${palette_name}\">" 'output/test-vitals.html'
}

# Test explicit palette values
run_palette_test "dark"
run_palette_test "mild"
run_palette_test "classic"

# Test default (no explicit INPUT_PALETTE)
env "GITHUB_WORKSPACE=$(pwd)" \
  'GITHUB_REPOSITORY=foo/bar' \
  'GITHUB_REPOSITORY_OWNER=foo' \
  'INPUT_FACTBASE=test.fb' \
  'INPUT_OUTPUT=output' \
  'INPUT_VERBOSE=false' \
  'INPUT_ADLESS=false' \
  'INPUT_GITHUB-TOKEN=THETOKEN' \
  "${SELF}/entry.sh" 2>&1 | tee log-default.txt

grep '<html class="palette-classic">' 'output/test-vitals.html'

This consolidation maintains the same test logic while making it easier to add new palettes and preserving logs from all test runs.

Also applies to: 26-37, 39-50, 52-62


24-24: Grep patterns could be more flexible.

The current grep patterns match the exact HTML format: <html class="palette-dark">. This works but is brittle—if attribute order changes or whitespace differs, the pattern breaks even if the feature works correctly.

Consider a more flexible grep pattern:

# Instead of:
grep '<html class="palette-dark">' 'output/test-vitals.html'

# Use:
grep -o 'class="palette-dark"' 'output/test-vitals.html' > /dev/null

or with regex to be more explicit:

grep 'class="palette-dark"' 'output/test-vitals.html' > /dev/null

This allows for variations in attribute order or spacing while still validating the core requirement (the palette class is present).

Also applies to: 37-37, 50-50, 62-62

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b46281 and 62159b4.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • action.yml (1 hunks)
  • entries/vitals-has-palette-option.sh (1 hunks)
  • entry.sh (2 hunks)
  • sass/main.scss (2 hunks)
  • xsl/vitals.xsl (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • xsl/vitals.xsl
  • sass/main.scss
  • README.md
  • entry.sh
🔇 Additional comments (2)
action.yml (1)

26-28: Palette input is well-documented.

The description correctly lists all three supported palettes (classic, dark, mild), addressing the prior feedback. The default value and format are appropriate.

entries/vitals-has-palette-option.sh (1)

1-5: Shell script error handling is correct.

The use of set -e -o pipefail ensures the test fails fast if any command fails, which is appropriate for test scripts.

@codeninja-ru
Copy link
Contributor Author

@yegor256 review please

@yegor256
Copy link
Member

@rultor merge

@rultor
Copy link
Contributor

rultor commented Dec 26, 2025

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here.

@rultor rultor merged commit cee6719 into zerocracy:master Dec 26, 2025
15 checks passed
@rultor
Copy link
Contributor

rultor commented Dec 26, 2025

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 8min).

@codeninja-ru codeninja-ru deleted the 31-palette-option branch December 26, 2025 10:11
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.

the palette option

3 participants