Fix Scss: injetar cores hex como cor SCSS, não string com aspas

ValueConverter::fromPhp('#0b0e1a') gera SassString com aspas, e
'background-color:"#0b0e1a"' é CSS inválido (browser ignora — fundo
cinza). Bug latente desde os temas legados (afetava qualquer uso direto
de $var injetada, ex. cor do botão); ficou visível quando os fundos
passaram a usar $page-background-color. Hex agora entra via parseValue()
como cor de verdade — também habilita funções de cor sobre as variáveis.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-07-03 20:58:09 -03:00
parent d36e14c767
commit fade913fa9

View file

@ -19,7 +19,13 @@ class Scss {
if (!empty($variables)) {
$convertedVariables = [];
foreach ($variables as $key => $value) {
$convertedVariables[$key] = \ScssPhp\ScssPhp\ValueConverter::fromPhp($value);
if (is_string($value) && preg_match('/^#[0-9a-fA-F]{3,8}$/', $value)) {
// Cores hex precisam entrar como cor SCSS de verdade: fromPhp()
// gera string com aspas ("#0b0e1a"), que é CSS inválido
$convertedVariables[$key] = \ScssPhp\ScssPhp\ValueConverter::parseValue($value);
} else {
$convertedVariables[$key] = \ScssPhp\ScssPhp\ValueConverter::fromPhp($value);
}
}
$scss->addVariables($convertedVariables);
}