Thanks, I think that answers that question.
It looks like the :root
variable is defined in view/layout/layout.phtml, where it pulls the themeSetting('primary_color')
and first calls it $primaryColor
before declaring the :root{}
variables that are referenced in the CSS and declared as $color__primary
in the SASS.
So let’s say I add this to the freedom/config/theme.ini:
; /// General settings ///
element_groups.general = "General Settings"
elements.primary_color.name = "primary_color"
elements.primary_color.type = "Laminas\Form\Element\Color"
elements.primary_color.options.label = "Theme's Color Scheme #1"
elements.primary_color.options.info = "First of the theme's color scheme. The default is hex #025442 or rgb(2, 84, 66)."
elements.primary_color.attributes.value = "#025442"
elements.primary_color.options.element_group = "general"
elements.second_color.name = "second_color"
elements.second_color.type = "Laminas\Form\Element\Color"
elements.second_color.options.label = "Theme's Color Scheme #2"
elements.second_color.options.info = "Second of the theme's color scheme. The default is hex #035dab or rgb(3, 93, 171)."
elements.second_color.attributes.value = "#035dab"
elements.second_color.options.element_group = "general"
elements.third_color.name = "third_color"
elements.third_color.type = "Laminas\Form\Element\Color"
elements.third_color.options.label = "Theme's Color Scheme #3"
elements.third_color.options.info = "Third of the theme's color scheme. The default is hex #05aff2 or rgb(5, 175, 242)."
elements.third_color.attributes.value = "#05aff2"
elements.third_color.options.element_group = "general"
elements.fourth_color.name = "fourth_color"
elements.fourth_color.type = "Laminas\Form\Element\Color"
elements.fourth_color.options.label = "Theme's Color Scheme #4"
elements.fourth_color.options.info = "Fourth of the theme's color scheme. The default is hex #04e0a6 or rgb(4, 224, 166)."
elements.fourth_color.attributes.value = "#04e0a6"
elements.fourth_color.options.element_group = "general"
elements.fifth_color.name = "fifth_color"
elements.fifth_color.type = "Laminas\Form\Element\Color"
elements.fifth_color.options.label = "Theme's Color Scheme #5"
elements.fifth_color.options.info = "Fifth of the theme's color scheme. The default is hex #fff4b1 or rgb(255, 244, 177)."
elements.fifth_color.attributes.value = "#fff4b1"
elements.fifth_color.options.element_group = "general"
*is it reading the name from the elements.name.element_group
or the ="name"
?
Now I would need to go make sure that each new color was represented in the files that we discussed above:
freedom/view/layout/layout.phtml
$primaryColor = $this->themeSettings('primary_color') ?? '#025442';
$secondColor = $this->themeSettings('second_color') ?? '#035dab';
$thirdColor = $this->themeSettings('third_color') ?? '#05aff2';
$fourthColor = $this->themeSettings('fourth_color') ?? '#04e0a6';
$fifthColor = $this->themeSettings('fifth_color') ?? '#fff4b1';
...
<style type="text/css" media="screen">
:root {
--primary: <?php echo $primaryColor; ?>;
--primary-light: <?php echo $this->ShadeColor($primaryColor, 10); ?>;
--primary-dark: <?php echo $this->ShadeColor($primaryColor, -10); ?>;
--second: <?php echo $secondColor; ?>;
--second-light: <?php echo $this->ShadeColor($secondColor, 10); ?>;
--second-dark: <?php echo $this->ShadeColor($secondColor, -10); ?>;
--third: <?php echo $thirdColor; ?>;
--third-light: <?php echo $this->ShadeColor($thirdColor, 10); ?>;
--third-dark: <?php echo $this->ShadeColor($thirdColor, -10); ?>;
--fourth: <?php echo $fourthColor; ?>;
--fourth-light: <?php echo $this->ShadeColor($fourthColor, 10); ?>;
--fourth-dark: <?php echo $this->ShadeColor($fourthColor, -10); ?>;
--fifth: <?php echo $fifthColor; ?>;
--fifth-light: <?php echo $this->ShadeColor($fifthColor, 10); ?>;
--fifth-dark: <?php echo $this->ShadeColor($fifthColor, -10); ?>;
}
...
freedom/asset/sass/abstracts/variables/_colors.scss
$color__primary: var(--primary);
$color__primary-light: var(--primary-light);
$color__primary-dark: var(--primary-dark);
$color__secondary: var(--second);
$color__secondary-light: var(--second-light);
$color__secondary-dark: var(--second-dark);
$color__third: var(--third);
$color__third-light: var(--third-light);
$color__third-dark: var(--third-dark);
$color__fourth: var(--fourth);
$color__fourth-light: var(--fourth-light);
$color__fourth-dark: var(--fourth-dark);
$color__fifth: var(--fifth);
$color__fifth-light: var(--fifth-light);
$color__fifth-dark: var(--fifth-dark);
and making adjustments as needed in any of the SASS or CSS that I want changed (github says there are 15 files that include “$color__primary” and 12 for “$color__secondary”).
If I didn’t want to go through the original SASS and CSS, I should be able to use the newly defined root variables in the CSSEditor, right?
Did I miss anything?