Commit 05d2acc9 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Scheme settings

2 merge requests!291WIP: Minds Pro (stable branch),!281WIP: (feat): Minds Pro (development branch)
Pipeline #75238812 passed with stages
in 11 minutes and 17 seconds
......@@ -239,6 +239,13 @@ class Manager
->setTagList(array_values($tagList));
}
if (isset($values['scheme'])) {
// TODO: Validate!
$settings
->setScheme($values['scheme']);
}
return $this->repository->update($settings);
}
}
......@@ -96,7 +96,9 @@ class Repository
->setLogoGuid($data['logo_guid'] ?? '')
->setFooterText($data['footer_text'] ?? '')
->setFooterLinks($data['footer_links'] ?? [])
->setTagList($data['tag_list'] ?? []);
->setTagList($data['tag_list'] ?? [])
->setScheme($data['scheme'] ?? '')
;
$response[] = $settings;
}
......@@ -140,6 +142,7 @@ class Repository
'footer_text' => $settings->getFooterText(),
'footer_links' => $settings->getFooterLinks(),
'tag_list' => $settings->getTagList(),
'scheme' => $settings->getScheme(),
]),
];
......
......@@ -34,6 +34,8 @@ use Minds\Traits\MagicAttributes;
* @method Settings setFooterLinks(array $footerLinks)
* @method array getTagList()
* @method Settings setTagList(array $footerLinks)
* @method string getScheme()
* @method Settings setScheme(string $scheme)
* @method string getBackgroundImage()
* @method Settings setBackgroundImage(string $backgroundImage)
* @method string getLogoImage()
......@@ -88,31 +90,48 @@ class Settings implements JsonSerializable
/** @var array */
protected $tagList = [];
/** @var string */
protected $scheme;
/**
* @return array
*/
public function export()
{
$textColor = $this->textColor ?: static::DEFAULT_TEXT_COLOR;
$primaryColor = $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR;
$plainBackgroundColor = $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR;
return [
'user_guid' => (string) $this->userGuid,
'domain' => $this->domain,
'title' => $this->title,
'headline' => $this->headline,
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'text_color' => $textColor,
'primary_color' => $primaryColor,
'plain_background_color' => $plainBackgroundColor,
'footer_text' => $this->footerText,
'footer_links' => $this->footerLinks,
'tag_list' => $this->tagList,
'logo_guid' => (string) $this->logoGuid,
'background_image' => $this->backgroundImage,
'logo_image' => $this->logoImage,
'styles' => [
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'transparent_background_color' => sprintf("%sa0", $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR),
],
'scheme' => $this->scheme,
'styles' => $this->buildStyles(),
];
}
public function buildStyles()
{
$textColor = $this->textColor ?: static::DEFAULT_TEXT_COLOR;
$primaryColor = $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR;
$plainBackgroundColor = $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR;
return [
'text_color' => $textColor,
'primary_color' => $primaryColor,
'plain_background_color' => $plainBackgroundColor,
'transparent_background_color' => sprintf("%sa0", $plainBackgroundColor),
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment