feat: learn_theme — add analyze_styles, DEFAULTS, most_common_value, derive_darkmode integration
Excludes dominant text color from accent candidates; blockquote-first quote_bg heuristic avoids picking up decorative divider colors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e457b4463b
commit
95ba69fd5a
1 changed files with 3 additions and 0 deletions
|
|
@ -290,6 +290,7 @@ def analyze_styles(grouped: dict) -> dict:
|
||||||
# --- primary (accent color) ------------------------------------------------
|
# --- primary (accent color) ------------------------------------------------
|
||||||
# Collect non-gray colors from strong/section/h1-h3/span; boost colors from
|
# Collect non-gray colors from strong/section/h1-h3/span; boost colors from
|
||||||
# elements whose font-size is ≥ 20 px (weight × 5).
|
# elements whose font-size is ≥ 20 px (weight × 5).
|
||||||
|
# Exclude the dominant text color so near-black body text never wins.
|
||||||
accent_tags = {"strong", "section", "h1", "h2", "h3", "span"}
|
accent_tags = {"strong", "section", "h1", "h2", "h3", "span"}
|
||||||
accent_counter: Counter = Counter()
|
accent_counter: Counter = Counter()
|
||||||
for tag in accent_tags:
|
for tag in accent_tags:
|
||||||
|
|
@ -300,6 +301,8 @@ def analyze_styles(grouped: dict) -> dict:
|
||||||
hex_c = rgb_to_hex(color_val)
|
hex_c = rgb_to_hex(color_val)
|
||||||
if is_gray(hex_c):
|
if is_gray(hex_c):
|
||||||
continue
|
continue
|
||||||
|
if hex_c == result["text"]:
|
||||||
|
continue
|
||||||
# Check font-size for boost
|
# Check font-size for boost
|
||||||
fs = d.get("font-size")
|
fs = d.get("font-size")
|
||||||
fs_px = _parse_px(fs) if fs else None
|
fs_px = _parse_px(fs) if fs else None
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue