Source code for betty.project.extension.cotton_candy.config
"""
Provide configuration for the Cotton Candy extension.
"""
from __future__ import annotations
import re
from typing import Sequence, TYPE_CHECKING
from typing_extensions import override
from betty.assertion import (
assert_str,
assert_record,
OptionalField,
)
from betty.assertion.error import AssertionFailed
from betty.config import Configuration
from betty.locale.localizable import _
from betty.project.config import EntityReference, EntityReferenceSequence
if TYPE_CHECKING:
from betty.serde.dump import Dump, DumpMapping
from betty.model import UserFacingEntity, Entity
[docs]
class ColorConfiguration(Configuration):
"""
Configure a color.
"""
_HEX_PATTERN = re.compile(r"^#[a-zA-Z0-9]{6}$")
@property
def featured_entities(self) -> EntityReferenceSequence[UserFacingEntity & Entity]:
"""
The entities featured on the front page.
"""
return self._featured_entities
@property
def primary_inactive_color(self) -> ColorConfiguration:
"""
The color for inactive primary/CTA elements.
"""
return self._primary_inactive_color
@property
def primary_active_color(self) -> ColorConfiguration:
"""
The color for active primary/CTA elements.
"""
return self._primary_active_color
@property
def link_inactive_color(self) -> ColorConfiguration:
"""
The color for inactive hyperlinks.
"""
return self._link_inactive_color
@property
def link_active_color(self) -> ColorConfiguration:
"""
The color for active hyperlinks.
"""
return self._link_active_color